peakml
Class IPeak

java.lang.Object
  extended by peakml.Annotatable
      extended by peakml.IPeak
Direct Known Subclasses:
BackgroundIon, IPeakSet, MassChromatogram, Peak, Spectrum

public abstract class IPeak
extends Annotatable

The base-class for all peak-types defined in the PeakML file format. This class defines the properties common to all the different types of peaks: mass, intensity, and optional scanid. The access methods to these properties have been defined as abstract and thus need to be overridden by the sub-classes.

It was chosen to make this an abstract class instead of an interface to allow for the central implementation of the annotation-scheme.


Nested Class Summary
static class IPeak.AnnotationAscending
          Comparator for sorting on a vector of peaks on an annotations.
static class IPeak.AnnotationDescending
          Comparator for sorting on a vector of peaks on an annotations.
static interface IPeak.MatchCompare<Type>
          This interface defines the setup for the comparison of peaks from two datasets, in order to determine whether they were caused by the same molecule.
static interface IPeak.RelationCompare<Type>
          This interface defines the setup for comparing the relatedness of two peaks.
 
Field Summary
static java.lang.String relationid
          This string is the label for the annotation of relation-id's used.
static peakml.IPeak.IntensityAscending sort_intensity_ascending
          Comparator sorting a set of IPeak on ascending intensity.
static peakml.IPeak.IntensityDescending sort_intensity_descending
          Comparator sorting a set of IPeak on descending intensity.
static peakml.IPeak.MassAscending sort_mass_ascending
          Comparator sorting a set of IPeak on ascending mass.
static peakml.IPeak.MassDescending sort_mass_descending
          Comparator sorting a set of IPeak on descending mass.
static peakml.IPeak.PatternIDAscending sort_patternid_ascending
          Comparator sorting a set of IPeak on ascending pattern-id.
static peakml.IPeak.PatternIDDescending sort_patternid_descending
          Comparator sorting a set of IPeak on descending pattern-id.
static peakml.IPeak.ProfileIDAscending sort_profileid_ascending
          Comparator sorting a set of IPeak on ascending profile-id.
static peakml.IPeak.ProfileIDDescending sort_profileid_descending
          Comparator sorting a set of IPeak on descending profile-id.
static peakml.IPeak.RetentionTimeAscending sort_retentiontime_ascending
          Comparator sorting a set of IPeak on ascending retention time.
static peakml.IPeak.RetentionTimeDescending sort_retentiontime_descending
          Comparator sorting a set of IPeak on descending retention time.
static peakml.IPeak.ScanIDAscending sort_scanid_ascending
          Comparator sorting a set of IPeak on ascending scan-id.
static peakml.IPeak.ScanIDDescending sort_scanid_descending
          Comparator sorting a set of IPeak on descending scan-id.
 
Method Summary
static java.util.Vector<IPeak> findRelatedPeaks(java.util.Vector<IPeak> peaks, double minrt, double rtwindow, IPeak.RelationCompare<IPeak> compare)
          This method attempts to find all the peaks that are related to each other.
static IPeak getBestPeakOnMass(java.util.Vector<IPeak> peaks, double mass)
          Locates the closest matching peak on the given mass from the list of peaks.
static IPeak getBestPeakOnRT(java.util.Vector<IPeak> peaks, double rt)
          Locates the closest matching peak on the given retention time from the list of peaks.
abstract  double getIntensity()
          Retrieves the measured intensity for this peak.
abstract  double getMass()
          Retrieves the mass of this peak.
abstract  int getMeasurementID()
          Returns an optional measurement-id for this peak.
abstract  int getPatternID()
          Returns an optional id for the peak.
abstract  double getRetentionTime()
          Retrieves the retention time for this peak.
abstract  int getScanID()
          Retrieves the scan-id for this peak.
abstract  Signal getSignal()
          Calculates the signal for this IPeak object.
static java.util.Vector<IPeakSet<IPeak>> match(java.util.Vector<IPeakSet<IPeak>> samples, double ppm)
          A ready to-go implementation of the match-function, which works on IPeak.
static java.util.Vector<IPeakSet<IPeak>> match(java.util.Vector<IPeakSet<IPeak>> samples, double ppm, IPeak.MatchCompare compare)
          General function for matching peaks together.
static java.util.Vector<IPeak> peaksOfMeasurements(java.util.Vector<IPeak> peaks, java.util.Vector<java.lang.Integer> measurementids)
          Returns the peaks with one of the given list of measurement id's
abstract  void setIntensity(double intensity)
          Sets the intensity of this peak, for more information on mass see getIntensity().
abstract  void setMass(double mass)
          Sets the mass of this peak, for more information on mass see getMass().
abstract  void setMeasurementID(int id)
          Sets the profile-id of this peak, for more information on mass see getMeasurementID().
abstract  void setPatternID(int id)
          Sets the pattern-id of this peak, for more information on mass see getPatternID().
abstract  void setRetentionTime(double retentiontime)
          Sets the retention time for this peak, for more information on retention time see setRetentionTime(double).
abstract  void setScanID(int scan)
          Sets the scan-id for this peak, for more information on scan-id see getScanID().
 java.lang.String sha1()
          Calculates the SHA-1 hash for this IPeak instance.
static java.util.Vector<IPeak> unpack(IPeak peak)
          Recursive function, which unpacks all the of the IPeakSet lists and returns a vector with all the non-list instances contained in the given peak.
 
Methods inherited from class peakml.Annotatable
addAnnotation, addAnnotation, addAnnotation, addAnnotation, addAnnotation, addAnnotations, getAnnotation, getAnnotations, removeAllAnnotations, removeAnnotation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relationid

public static final java.lang.String relationid
This string is the label for the annotation of relation-id's used.

See Also:
Constant Field Values

sort_mass_ascending

public static peakml.IPeak.MassAscending sort_mass_ascending
Comparator sorting a set of IPeak on ascending mass.


sort_mass_descending

public static peakml.IPeak.MassDescending sort_mass_descending
Comparator sorting a set of IPeak on descending mass.


sort_intensity_ascending

public static peakml.IPeak.IntensityAscending sort_intensity_ascending
Comparator sorting a set of IPeak on ascending intensity.


sort_intensity_descending

public static peakml.IPeak.IntensityDescending sort_intensity_descending
Comparator sorting a set of IPeak on descending intensity.


sort_scanid_ascending

public static peakml.IPeak.ScanIDAscending sort_scanid_ascending
Comparator sorting a set of IPeak on ascending scan-id.


sort_scanid_descending

public static peakml.IPeak.ScanIDDescending sort_scanid_descending
Comparator sorting a set of IPeak on descending scan-id.


sort_retentiontime_ascending

public static peakml.IPeak.RetentionTimeAscending sort_retentiontime_ascending
Comparator sorting a set of IPeak on ascending retention time.


sort_retentiontime_descending

public static peakml.IPeak.RetentionTimeDescending sort_retentiontime_descending
Comparator sorting a set of IPeak on descending retention time.


sort_profileid_ascending

public static peakml.IPeak.ProfileIDAscending sort_profileid_ascending
Comparator sorting a set of IPeak on ascending profile-id.


sort_profileid_descending

public static peakml.IPeak.ProfileIDDescending sort_profileid_descending
Comparator sorting a set of IPeak on descending profile-id.


sort_patternid_ascending

public static peakml.IPeak.PatternIDAscending sort_patternid_ascending
Comparator sorting a set of IPeak on ascending pattern-id.


sort_patternid_descending

public static peakml.IPeak.PatternIDDescending sort_patternid_descending
Comparator sorting a set of IPeak on descending pattern-id.

Method Detail

getMass

public abstract double getMass()
Retrieves the mass of this peak. For a single peak implementation this would be the real mass, but for a chromatographic peak for example this would consist of the mean of a cluster of peaks.

Returns:
The mass of the peak.

setMass

public abstract void setMass(double mass)
Sets the mass of this peak, for more information on mass see getMass(). It is possible that the class implementing this interface does not support this method.

Parameters:
mass - The new mass for this peak.

getIntensity

public abstract double getIntensity()
Retrieves the measured intensity for this peak. For a single peak implementation this would be the real measured intensity, but for a chromatographic peak for example this would consist of the mean measured intensity for a cluster of peaks.

Returns:
The measured intensity of the peak.

setIntensity

public abstract void setIntensity(double intensity)
Sets the intensity of this peak, for more information on mass see getIntensity(). It is possible that the class implementing this interface does not support this method.

Parameters:
intensity - The new intensity for this peak.

getScanID

public abstract int getScanID()
Retrieves the scan-id for this peak. For a single peak implementation this would be the scan at which it was measured, but for a chromatographic peak for example this would be the scan with the most intense peak.

Returns:
The scan at which the peak was measured.

setScanID

public abstract void setScanID(int scan)
Sets the scan-id for this peak, for more information on scan-id see getScanID(). It is possible that the class implementing this interface does not support this method.

Parameters:
scan - The new scan for this peak.

getRetentionTime

public abstract double getRetentionTime()
Retrieves the retention time for this peak. The retention time is closely linked to the scan-id, which is the index or order at which a particular measurement was made. The time is expressed in seconds (all parsers make sure the time-value stored in a file is converted to this convention) and can easily be converted into minutes and seconds with:
 double rt = peak.getRetentionTime();
 int minutes = (int) (rt / 60);
 int seconds = (int) (rt % 60);
 

Returns:
The retention time at which the peak was measured.

setRetentionTime

public abstract void setRetentionTime(double retentiontime)
Sets the retention time for this peak, for more information on retention time see setRetentionTime(double). It is possible that the class implementing this interface does not support this method.

Parameters:
retentiontime - The new retention time for this peak.

getMeasurementID

public abstract int getMeasurementID()
Returns an optional measurement-id for this peak. This is a convenience mechanism for locating the measurement-information for this peak in the Header.

Returns:
The profile-id of this peak.

setMeasurementID

public abstract void setMeasurementID(int id)
Sets the profile-id of this peak, for more information on mass see getMeasurementID(). It is possible that the class implementing this interface does not support this method.

Parameters:
id - The new profile-id for this peak.

getPatternID

public abstract int getPatternID()
Returns an optional id for the peak. This id can for example be used for peak sequence identification. Beware that this mechanism is highly volatile and can only be used in a single-threaded environment within a strictly controlled environment like a single function or a completely controlled application.

Returns:
The id of this peak.

setPatternID

public abstract void setPatternID(int id)
Sets the pattern-id of this peak, for more information on mass see getPatternID(). It is possible that the class implementing this interface does not support this method.

Parameters:
id - The new id for this peaks

getSignal

public abstract Signal getSignal()
Calculates the signal for this IPeak object. For a single data-point this will be a signal of one element. For a collection of IPeaks it will be a compounded version.

Returns:
The calculated signal.

sha1

public java.lang.String sha1()
Calculates the SHA-1 hash for this IPeak instance. The SHA-1 hash is used to verify that individual peaks have correctly been read from a storage point (e.g. a file). The SHA-1 hash is a string, which can be compared with String.equals(Object).

Returns:
The sha1-hash for this peak.

getBestPeakOnMass

public static IPeak getBestPeakOnMass(java.util.Vector<IPeak> peaks,
                                      double mass)
Locates the closest matching peak on the given mass from the list of peaks. This operation is performed often and this provides a convenient access point.

Parameters:
peaks - The list of peaks.
mass - The mass to optimize to.
Returns:
The best match (null if the list was empty).

getBestPeakOnRT

public static IPeak getBestPeakOnRT(java.util.Vector<IPeak> peaks,
                                    double rt)
Locates the closest matching peak on the given retention time from the list of peaks. This operation is performed often and this provides a convenient access point.

Parameters:
peaks - The list of peaks.
rt - The retention time to optimize to.
Returns:
The best match (null if the list was empty).

unpack

public static java.util.Vector<IPeak> unpack(IPeak peak)
Recursive function, which unpacks all the of the IPeakSet lists and returns a vector with all the non-list instances contained in the given peak.

Parameters:
peak - The peak to unpack.
Returns:
The list with all the non-list instances.

peaksOfMeasurements

public static java.util.Vector<IPeak> peaksOfMeasurements(java.util.Vector<IPeak> peaks,
                                                          java.util.Vector<java.lang.Integer> measurementids)
Returns the peaks with one of the given list of measurement id's

Parameters:
peaks - The list with the peaks
measurementids - The list with the measurementid's
Returns:
The filtered list

findRelatedPeaks

public static java.util.Vector<IPeak> findRelatedPeaks(java.util.Vector<IPeak> peaks,
                                                       double minrt,
                                                       double rtwindow,
                                                       IPeak.RelationCompare<IPeak> compare)
This method attempts to find all the peaks that are related to each other. Typical examples of this are isotopes, double charged, etc. and occur very frequently in mass spectrometry measurements. The process can be specialized with the parameters, of which the compare is the most important. The interface IPeak.MatchCompare allows the user to receive two IPeak instances and calculate the correlation of the two being related. As this is a correlation 1 is the maximum expected value, which indicates that the two peaks are closely related. When -1 is returned the two peaks are not considered for relation. The returned vector contains all the basepeaks.

The relationship is returned as an annotation in the peaks with label relationid. The most abundant one is marked as the base-peak and all related peaks follow it in the list and have the same id.

Parameters:
peaks - The vector with all the peaks.
minrt - The minimum RT before starting the matching (eg everything with a lower RT will be ignored).
mincorrelation - The minimal correlation to be achieved.
rtdelta - The maximum time two peaks can differ to be taken into acount.
compare - Instance of a class implementing the IPeak.MatchCompare interface.
Returns:
The base peaks.

match

public static java.util.Vector<IPeakSet<IPeak>> match(java.util.Vector<IPeakSet<IPeak>> samples,
                                                      double ppm)
A ready to-go implementation of the match-function, which works on IPeak. The match-compare function is set-up to optimize on the distance between retention time of potential matches. This is the most simple of cases and when more information is available should not be used. This function makes an anonymous implementation of match(Vector, double, peakml.IPeak.MatchCompare).

Parameters:
samples - Vector containing all the spectra to be matched
ppm - The ppm-value to make the match on
Returns:
Vector of IPeakSet's containing matched peaks

match

public static java.util.Vector<IPeakSet<IPeak>> match(java.util.Vector<IPeakSet<IPeak>> samples,
                                                      double ppm,
                                                      IPeak.MatchCompare compare)
General function for matching peaks together. The function works by minimizing the distance between two peaks as calculated by the pluggable MatchCompare instance. The peaks are passed as peaksets (i.e. the peaks of one set are collected in a single peakset). The vector contains all the datasets and will treated as such.

Keep track of where a peak came from with the measurementid found in each peak.

Parameters:
samples - The samples to compare.
ppm - The parts-per-milion the masses can differ at most.
compare - The comparator for comparing two peaks.
Returns:
A vector with all the matched peaks.