peakml
Class Spectrum<gPeak extends Peak>

java.lang.Object
  extended by peakml.Annotatable
      extended by peakml.IPeak
          extended by peakml.Spectrum<gPeak>
Type Parameters:
gPeak - The type of peak stored in the spectrum, either Centroid or Profile.
All Implemented Interfaces:
java.lang.Iterable<gPeak>, Measurement

public class Spectrum<gPeak extends Peak>
extends IPeak
implements java.lang.Iterable<gPeak>, Measurement

Type-binding for a spectrum (a single measurement on a mass spectrometer). It's simply an extension of IPeakSet, which contains all the needed functionality already but has not been made specific. In the implementation of this class the only types that are allowed are those that inherit from Peak.


Nested Class Summary
static class Spectrum.DataFormat
          The format (centroid or profile) of the data
static class Spectrum.Type
          The type of data stored in the spectrum.
 
Nested classes/interfaces inherited from class peakml.IPeak
IPeak.AnnotationAscending, IPeak.AnnotationDescending, IPeak.MatchCompare<Type>, IPeak.RelationCompare<Type>
 
Field Summary
 
Fields inherited from class peakml.IPeak
relationid, sort_intensity_ascending, sort_intensity_descending, sort_mass_ascending, sort_mass_descending, sort_patternid_ascending, sort_patternid_descending, sort_profileid_ascending, sort_profileid_descending, sort_retentiontime_ascending, sort_retentiontime_descending, sort_scanid_ascending, sort_scanid_descending
 
Constructor Summary
Spectrum(PeakData<gPeak> peakdata)
          Calls the constructor Spectrum(PeakData, Type, Polarity, double) and assumes for type Spectrum.Type.MS1, for polarity Polarity.NEUTRAL and for precursormass -1.
Spectrum(PeakData<gPeak> peakdata, Polarity polarity)
          Calls the constructor Spectrum(PeakData, Type, Polarity, double) and assumes for type Spectrum.Type.MS1 and for precursormass -1.
Spectrum(PeakData<gPeak> peakdata, Spectrum.Type type, Polarity polarity)
          Calls the constructor Spectrum(PeakData, Type, Polarity, double) and assumes for precursor mass -1.
Spectrum(PeakData<gPeak> peakdata, Spectrum.Type type, Polarity polarity, double precursormass)
          Standard constructor for the spectrum.
 
Method Summary
 void addMSnSpectrum(Spectrum<gPeak> spectrum)
          Adds the given MSn spectrum to the list.
 double getIntensity()
          Retrieves the measured intensity for this peak.
 double getMass()
          Retrieves the mass of this peak.
 int getMeasurementID()
          Returns an optional measurement-id for this peak.
 Spectrum<gPeak> getMSnSpectrum(int index)
          Returns the MSn spectrum at the given index.
 int getNrMSnSpecra()
          Returns the number of MSn spectra associated with this spectrum.
 int getNrPeaks()
          Returns the number of peaks associated to this spectrum.
 int getPatternID()
          Returns an optional id for the peak.
 PeakData<gPeak> getPeakData()
          Returns the PeakData container associated to this spectrum.
 java.util.Vector<gPeak> getPeaks()
          Returns a vector with all the peaks.
 Polarity getPolarity()
          Returns the polarity of the data in the spectrum.
 double getRetentionTime()
          Retrieves the retention time for this peak.
 int getScanID()
          Retrieves the scan-id for this peak.
 Signal getSignal()
          Calculates the signal for this IPeak object.
 Spectrum.Type getType()
          Returns the type of the spectrum.
 java.util.Iterator<gPeak> iterator()
           
 void setIntensity(double intensity)
          Sets the intensity of this peak, for more information on mass see IPeak.getIntensity().
 void setMass(double mass)
          Sets the mass of this peak, for more information on mass see IPeak.getMass().
 void setMeasurementID(int id)
          Sets the profile-id of this peak, for more information on mass see IPeak.getMeasurementID().
 void setPatternID(int id)
          Sets the pattern-id of this peak, for more information on mass see IPeak.getPatternID().
 void setRetentionTime(double retentiontime)
          Sets the retention time for this peak, for more information on retention time see IPeak.setRetentionTime(double).
 void setScanID(int scan)
          Sets the scan-id for this peak, for more information on scan-id see IPeak.getScanID().
 
Methods inherited from class peakml.IPeak
findRelatedPeaks, getBestPeakOnMass, getBestPeakOnRT, match, match, peaksOfMeasurements, sha1, unpack
 
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
 

Constructor Detail

Spectrum

public Spectrum(PeakData<gPeak> peakdata)
Calls the constructor Spectrum(PeakData, Type, Polarity, double) and assumes for type Spectrum.Type.MS1, for polarity Polarity.NEUTRAL and for precursormass -1.

Parameters:
peakdata - The PeakData instance containing the data of this spectrum.

Spectrum

public Spectrum(PeakData<gPeak> peakdata,
                Polarity polarity)
Calls the constructor Spectrum(PeakData, Type, Polarity, double) and assumes for type Spectrum.Type.MS1 and for precursormass -1.

Parameters:
peakdata - The PeakData instance containing the data of this spectrum.
polarity - The polarity of the measurement (positive, negative, neutral).

Spectrum

public Spectrum(PeakData<gPeak> peakdata,
                Spectrum.Type type,
                Polarity polarity)
Calls the constructor Spectrum(PeakData, Type, Polarity, double) and assumes for precursor mass -1.

Parameters:
peakdata - The PeakData instance containing the data of this spectrum.
type - The type of spectrum (ms, msn, pda)
polarity - The polarity of the measurement (positive, negative, neutral).

Spectrum

public Spectrum(PeakData<gPeak> peakdata,
                Spectrum.Type type,
                Polarity polarity,
                double precursormass)
Standard constructor for the spectrum. The list of peaks forms the contents of the spectrum. As this class inherits from IPeakSet the list is passed to IPeakSet.IPeakSet(List). When the spectrum is made up of profile data, the peak selection must already have been performed and all the data-points making up a peak in the spectrum have been stored within the Profile class.

Parameters:
peakdata - The PeakData instance containing the data of this spectrum.
type - The type of spectrum (ms, msn, pda)
polarity - The polarity of the measurement (positive, negative, neutral).
precursormass - The precursor mass, only valid if type is Spectrum.Type.MSn.
Method Detail

getType

public Spectrum.Type getType()
Returns the type of the spectrum.

Returns:
The type of spectrum.

getPolarity

public Polarity getPolarity()
Returns the polarity of the data in the spectrum.

Returns:
The polarity of the data.

getNrPeaks

public int getNrPeaks()
Returns the number of peaks associated to this spectrum.

Returns:
The number of peaks in this spectrum.

getNrMSnSpecra

public int getNrMSnSpecra()
Returns the number of MSn spectra associated with this spectrum.

Returns:
The number of MSn spectra associated with this spectrum.

getMSnSpectrum

public Spectrum<gPeak> getMSnSpectrum(int index)
                                            throws java.lang.IndexOutOfBoundsException
Returns the MSn spectrum at the given index.

Returns:
The MSn spectrum at the given index.
Throws:
java.lang.IndexOutOfBoundsException - Thrown when the index is out of bounds.

addMSnSpectrum

public void addMSnSpectrum(Spectrum<gPeak> spectrum)
Adds the given MSn spectrum to the list.

Parameters:
spectrum - The MSn spectrum to be added.

getPeaks

public java.util.Vector<gPeak> getPeaks()
Returns a vector with all the peaks.

Returns:
A vector with all the peaks.

getPeakData

public PeakData<gPeak> getPeakData()
Returns the PeakData container associated to this spectrum.

Returns:
The peakdata container.

getRetentionTime

public double getRetentionTime()
Description copied from class: IPeak
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);
 

Specified by:
getRetentionTime in class IPeak
Returns:
The retention time at which the peak was measured.

setRetentionTime

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

Specified by:
setRetentionTime in class IPeak
Parameters:
retentiontime - The new retention time for this peak.

getScanID

public int getScanID()
Description copied from class: IPeak
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.

Specified by:
getScanID in class IPeak
Returns:
The scan at which the peak was measured.

setScanID

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

Specified by:
setScanID in class IPeak
Parameters:
scan - The new scan for this peak.

getIntensity

public double getIntensity()
Description copied from class: IPeak
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.

Specified by:
getIntensity in class IPeak
Returns:
The measured intensity of the peak.

setIntensity

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

Specified by:
setIntensity in class IPeak
Parameters:
intensity - The new intensity for this peak.

getMass

public double getMass()
Description copied from class: IPeak
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.

Specified by:
getMass in class IPeak
Returns:
The mass of the peak.

setMass

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

Specified by:
setMass in class IPeak
Parameters:
mass - The new mass for this peak.

getMeasurementID

public int getMeasurementID()
Description copied from class: IPeak
Returns an optional measurement-id for this peak. This is a convenience mechanism for locating the measurement-information for this peak in the Header.

Specified by:
getMeasurementID in class IPeak
Returns:
The profile-id of this peak.

setMeasurementID

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

Specified by:
setMeasurementID in class IPeak
Parameters:
id - The new profile-id for this peak.

getPatternID

public int getPatternID()
Description copied from class: IPeak
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.

Specified by:
getPatternID in class IPeak
Returns:
The id of this peak.

setPatternID

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

Specified by:
setPatternID in class IPeak
Parameters:
id - The new id for this peaks

getSignal

public Signal getSignal()
Description copied from class: IPeak
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.

Specified by:
getSignal in class IPeak
Returns:
The calculated signal.

iterator

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