peakml
Class PeakData<gPeak extends Peak>

java.lang.Object
  extended by peakml.PeakData<gPeak>
Type Parameters:
gPeak - The Peak type associated to this container.
All Implemented Interfaces:
java.lang.Iterable<gPeak>

public class PeakData<gPeak extends Peak>
extends java.lang.Object
implements java.lang.Iterable<gPeak>

Implementation of a container for peak-data. This central container keeps track of peak data in arrays of basic data-types in order to reduce the memory footprint and load-times of applications using large amounts of data.


Nested Class Summary
static interface PeakData.PeakFactory<gPeak extends Peak>
          Interface describing a factory for the creation of instances of the generic gPeak type.
 
Field Summary
static int INDEX_INDEXTABLE
           
static int INDEX_REAL
           
 
Constructor Summary
PeakData(PeakData.PeakFactory<gPeak> factory, int size)
          Creates a new PeakData instance associated to the given PeakData.PeakFactory and of the given size.
PeakData(PeakData.PeakFactory<gPeak> factory, int size, int[] scanids, int[] patternids, int[] measurementids, double[] masses, double[] intensities, double[] retentiontimes)
          Creates a new PeakData instance associated to the given PeakData.PeakFactory and of the given size.
PeakData(PeakData<gPeak> peakdata)
          Highly optimized copy constructor, which makes a deep-copy of the data stored in the given PeakData instance.
 
Method Summary
 PeakData.PeakFactory<gPeak> getFactory()
          Returns the factory for the Peak type associated to this container.
 int[] getIndexOfMass(double mass)
          ...
 double[] getIndexTableAscendingIntensity()
           
 double[] getIndexTableAscendingMass()
           
 int[][] getIndicesInMassRange(double minmass, double maxmass)
           
 double[] getIntensities()
          Returns all the intensities stored in this container.
 double getIntensity(int index)
          Returns the intensity stored at the given index.
 double getMass(int index)
          Returns the mass stored at the given index.
 double[] getMasses()
          Returns all the masses stored in this container.
 int getMeasurementID(int index)
          Returns the measurement-id stored at the given index.
 int[] getMeasurementIDs()
          Returns all the measurement-id's stored in this container.
 int getPatternID(int index)
          Returns the pattern-id stored at the given index.
 int[] getPatternIDs()
          Returns all the pattern-id's stored in this container.
 gPeak getPeak(int index)
          Returns a Peak instance using the data stored at the given index in this container.
 java.util.Vector<gPeak> getPeaks()
          Returns a vector with Peak instances covering all the data stored in this container.
 double getRetentionTime(int index)
          Returns the retention-time stored at the given index.
 double[] getRetentionTimes()
          Returns all the retention-times stored in this container.
 int getScanID(int index)
          Returns the scan-id stored at the given index.
 int[] getScanIDs()
          Returns all the scan-id's stored in this container.
 int indexOfMaxIntensity()
           
 java.util.Iterator<gPeak> iterator()
           
 void set(int index, gPeak peak)
           
 void set(int index, int scanid, double retentiontime, double mass, double intensity)
          Set all the properties of a peak at the given index at one go.
 void setIntensity(int index, double intensity)
          Sets the given intensity at the given index.
 void setMass(int index, double mass)
          Sets the given mass at the given index.
 void setMeasurementID(int index, int measurementid)
          Sets the given measurement-id at the given index.
 void setPatternID(int index, int patternid)
          Sets the given pattern-id at the given index.
 void setRetentionTime(int index, double retentiontime)
          Sets the given retention-time at the given index.
 void setScanID(int index, int scanid)
          Sets the given scan-id at the given index.
 int size()
          Returns the size of the container.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEX_REAL

public static final int INDEX_REAL
See Also:
Constant Field Values

INDEX_INDEXTABLE

public static final int INDEX_INDEXTABLE
See Also:
Constant Field Values
Constructor Detail

PeakData

public PeakData(PeakData.PeakFactory<gPeak> factory,
                int size)
Creates a new PeakData instance associated to the given PeakData.PeakFactory and of the given size. All the peak-data is initialized to -1.

Parameters:
factory - The factory for creating new instances of the generic gPeak type.
size - The number of peaks stored in this container.

PeakData

public PeakData(PeakData.PeakFactory<gPeak> factory,
                int size,
                int[] scanids,
                int[] patternids,
                int[] measurementids,
                double[] masses,
                double[] intensities,
                double[] retentiontimes)
Creates a new PeakData instance associated to the given PeakData.PeakFactory and of the given size. The container is initialized with the given arrays (the reference is copies, so do not remove).

Parameters:
factory - The factory for creating new instances of the generic gPeak type.
size - The number of peaks stored in this container.
scanids - Array containing all the scan-id's.
patternids - Array containing all the pattern-id's.
measurementids - Array containing all the measurement-id's.
masses - Array containing all the masses.
intensities - Array containing all the intensities.
relativeintensities - Array containing all the relative-intensities.
retentiontimes - Array containing all the retention-times.

PeakData

public PeakData(PeakData<gPeak> peakdata)
Highly optimized copy constructor, which makes a deep-copy of the data stored in the given PeakData instance.

Parameters:
peakdata - The PeakData instance to copy.
Method Detail

size

public int size()
Returns the size of the container.

Returns:
The size (number of the peaks) of the container.

set

public void set(int index,
                gPeak peak)

set

public void set(int index,
                int scanid,
                double retentiontime,
                double mass,
                double intensity)
Set all the properties of a peak at the given index at one go.

Parameters:
index - The index of the peakdata to set.
scanid - The scanid.
retentiontime - The retention time.
mass - The mass.
intensity - The intensity.

getPeak

public gPeak getPeak(int index)
Returns a Peak instance using the data stored at the given index in this container.

Parameters:
index - The index where the data is located.
Returns:
A Peak instance.

getPeaks

public java.util.Vector<gPeak> getPeaks()
Returns a vector with Peak instances covering all the data stored in this container.

Returns:
A vector with all the peaks associated with this container.

getFactory

public PeakData.PeakFactory<gPeak> getFactory()
Returns the factory for the Peak type associated to this container. The factory can be used to create new instances.

Returns:
The factory for creating instances of the associated type.

getIndexTableAscendingMass

public double[] getIndexTableAscendingMass()
Returns:

getIndexOfMass

public int[] getIndexOfMass(double mass)
...
  --------------------------------
 | 1  | 5  | 8  | 10  | 20  | 30  |
  --------------------------------
   ^--> ^--> ^--> ^---> ^---> ^--->
 


getIndicesInMassRange

public int[][] getIndicesInMassRange(double minmass,
                                     double maxmass)

getIndexTableAscendingIntensity

public double[] getIndexTableAscendingIntensity()
Returns:

getScanIDs

public int[] getScanIDs()
Returns all the scan-id's stored in this container.

Returns:
All the scan-id's stored in this container.

getScanID

public int getScanID(int index)
Returns the scan-id stored at the given index.

Parameters:
index - The index.
Returns:
The scan-id at the given index.

setScanID

public void setScanID(int index,
                      int scanid)
Sets the given scan-id at the given index.

Parameters:
index - The index.
scanid - The new scan-id.

getRetentionTimes

public double[] getRetentionTimes()
Returns all the retention-times stored in this container.

Returns:
All the retention-times stored in this container.

getRetentionTime

public double getRetentionTime(int index)
Returns the retention-time stored at the given index.

Parameters:
index - The index.
Returns:
The retention-time at the given index.

setRetentionTime

public void setRetentionTime(int index,
                             double retentiontime)
Sets the given retention-time at the given index.

Parameters:
index - The index.
retentiontime - The new retention-time.

getMasses

public double[] getMasses()
Returns all the masses stored in this container.

Returns:
All the masses stored in this container.

getMass

public double getMass(int index)
Returns the mass stored at the given index.

Parameters:
index - The index.
Returns:
The mass at the given index.

setMass

public void setMass(int index,
                    double mass)
Sets the given mass at the given index.

Parameters:
index - The index.
mass - The new mass.

indexOfMaxIntensity

public int indexOfMaxIntensity()

getIntensities

public double[] getIntensities()
Returns all the intensities stored in this container.

Returns:
All the intensities stored in this container.

getIntensity

public double getIntensity(int index)
Returns the intensity stored at the given index.

Parameters:
index - The index.
Returns:
The intensity at the given index.

setIntensity

public void setIntensity(int index,
                         double intensity)
Sets the given intensity at the given index.

Parameters:
index - The index.
intensity - The new intensity.

getPatternIDs

public int[] getPatternIDs()
Returns all the pattern-id's stored in this container.

Returns:
All the pattern-id's stored in this container.

getPatternID

public int getPatternID(int index)
Returns the pattern-id stored at the given index.

Parameters:
index - The index.
Returns:
The pattern-id at the given index.

setPatternID

public void setPatternID(int index,
                         int patternid)
Sets the given pattern-id at the given index.

Parameters:
index - The index.
patternid - The new scan-id.

getMeasurementIDs

public int[] getMeasurementIDs()
Returns all the measurement-id's stored in this container.

Returns:
All the measurement-id's stored in this container.

getMeasurementID

public int getMeasurementID(int index)
Returns the measurement-id stored at the given index.

Parameters:
index - The index.
Returns:
The measurement-id at the given index.

setMeasurementID

public void setMeasurementID(int index,
                             int measurementid)
Sets the given measurement-id at the given index.

Parameters:
index - The index.
measurementid - The new measurement-id.

iterator

public java.util.Iterator<gPeak> iterator()
Specified by:
iterator in interface java.lang.Iterable<gPeak extends Peak>