com.compomics.util.protein
Class ModificationImplementation

java.lang.Object
  extended by com.compomics.util.protein.ModificationImplementation
All Implemented Interfaces:
Modification, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class ModificationImplementation
extends java.lang.Object
implements Modification, java.lang.Cloneable, java.io.Serializable

This class implements a specific Modification.

Author:
Lennart Martens
See Also:
Serialized Form

Field Summary
protected  int iLocation
          The location for the modification in the parent sequence.
protected  ModificationTemplate iTemplate
          The ModificationTemplate which holds all the shared information for a modification.
 
Fields inherited from interface com.compomics.util.interfaces.Modification
AVERAGE, CTERMINUS, MONOISOTOPIC, NTERMINUS
 
Constructor Summary
ModificationImplementation(ModificationTemplate aTemplate, int aLocation)
          This constructor allows initialization of all the properties for the modification.
ModificationImplementation(java.lang.String aTitle, java.lang.String aCode, java.util.HashMap aMassDeltas, boolean aArtifact, int aLocation)
          This constructor allows initialization of all the properties for the modification.
ModificationImplementation(java.lang.String aTitle, java.lang.String aCode, java.util.HashMap aMassDeltas, int aLocation)
          This constructor allows initialization of all the properties for the modification.
 
Method Summary
 java.lang.Object clone()
          Override of the clone method.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 double getAverageMassDelta(java.lang.String aResidue)
          This method returns a double with the average mass difference conferred on the sequence by this modification for the specified residue.
 java.lang.String getCode()
          This method returns the short code for the modification, eg.
 int getLocation()
          This method returns the location of the modification in the sequence.
protected  double getMassDelta(java.lang.String aResidue, int aMonoOrAvg)
          This method returns the mass delta for the specified residue, measured either monoisotopically or averaged.
 double getMonoisotopicMassDelta(java.lang.String aResidue)
          This method returns a double with the monoisotopic mass difference conferred on the sequence by this modification for the specified residue.
 java.util.Collection getResidues()
          This method reports on all the residues that can be modified by this Modification.
 java.lang.String getTitle()
          This method returns the title of the modification, eg.
 int hashCode()
          Returns a hash code value for the object.
 boolean isArtifact()
          This method indicates whether this modification is considered an artifact.
 void setLocation(int aLocation)
          This method allows the setting of the location for this modification.
 java.lang.String toString()
          This method returns a String representation of the Modification.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

iTemplate

protected ModificationTemplate iTemplate
The ModificationTemplate which holds all the shared information for a modification. It is to be considered a singleton and it is immutable.


iLocation

protected int iLocation
The location for the modification in the parent sequence.

Constructor Detail

ModificationImplementation

public ModificationImplementation(ModificationTemplate aTemplate,
                                  int aLocation)
This constructor allows initialization of all the properties for the modification.

Parameters:
aTemplate - ModificationTemplate with the shared information for this modification
aLocation - int with the location of this modification in the parent sequence.

ModificationImplementation

public ModificationImplementation(java.lang.String aTitle,
                                  java.lang.String aCode,
                                  java.util.HashMap aMassDeltas,
                                  int aLocation)
This constructor allows initialization of all the properties for the modification.

Parameters:
aTitle - String with the title for the modification (eg., Oxidation Met).
aCode - String with the code for the modification (eg., Mox). The code can be used when annotating a sequence String (eg., NH2-MGTEFSM<Mox>R-COOH).
aMassDeltas - HashMap with the following 'key-value' mappings: (key --> value)
(residue-->double[]{MONOISOTOPIC_DELTA, AVERAGE_DELTA}
Note that the residues for the N-terminus and C-terminus are represented by the NTERMINUS and CTERMINUS constants, respectively.
aLocation - int with the location for this modification.

ModificationImplementation

public ModificationImplementation(java.lang.String aTitle,
                                  java.lang.String aCode,
                                  java.util.HashMap aMassDeltas,
                                  boolean aArtifact,
                                  int aLocation)
This constructor allows initialization of all the properties for the modification.

Parameters:
aTitle - String with the title for the modification (eg., Oxidation Met).
aCode - String with the code for the modification (eg., Mox). The code can be used when annotating a sequence String (eg., NH2-MGTEFSM<Mox>R-COOH).
aMassDeltas - HashMap with the following 'key-value' mappings: (key --> value)
(residue-->double[]{MONOISOTOPIC_DELTA, AVERAGE_DELTA}
Note that the residues for the N-terminus and C-terminus are represented by the NTERMINUS and CTERMINUS constants, respectively.
aArtifact - boolean to indicate whether this modification is an artifact.
aLocation - int with the location for this modification.
Method Detail

getAverageMassDelta

public double getAverageMassDelta(java.lang.String aResidue)
This method returns a double with the average mass difference conferred on the sequence by this modification for the specified residue. This mass delta can be negative! When a residue was specified that is not affected by this modification, '0.0' is returned.

Specified by:
getAverageMassDelta in interface Modification
Parameters:
aResidue - String with the residue for which the mass delta needs to be calculated.
Returns:
double with the average mass difference.

getCode

public java.lang.String getCode()
This method returns the short code for the modification, eg. 'Mox'.

Specified by:
getCode in interface Modification
Returns:
String with the short code for the modification. Can be used to annotate a sequence.

getTitle

public java.lang.String getTitle()
This method returns the title of the modification, eg. 'Oxidation Met'.

Specified by:
getTitle in interface Modification
Returns:
String with the title for the modification.

getLocation

public int getLocation()
This method returns the location of the modification in the sequence. Note that the N-terminus is 0, and the C-terminus is (sequence_length)+1.

Specified by:
getLocation in interface Modification
Returns:
int with the location for the modification.

getResidues

public java.util.Collection getResidues()
This method reports on all the residues that can be modified by this Modification.

Specified by:
getResidues in interface Modification
Returns:
Collection with the residues that can be modified by this modification.

getMonoisotopicMassDelta

public double getMonoisotopicMassDelta(java.lang.String aResidue)
This method returns a double with the monoisotopic mass difference conferred on the sequence by this modification for the specified residue. This mass delta can be negative! When a residue was specified that is not affected by this modification, '0.0' is returned.

Specified by:
getMonoisotopicMassDelta in interface Modification
Parameters:
aResidue - String with the residue for which the mass delta needs to be calculated.
Returns:
double with the monoisotopic mass difference.

setLocation

public void setLocation(int aLocation)
This method allows the setting of the location for this modification. The specified integer should be calculated from the start of the parent sequence, where the N-terminus is 0, and the C-terminus is (sequence_length)+1.

Specified by:
setLocation in interface Modification
Parameters:
aLocation - int with the location for this modification within the parent sequence.

isArtifact

public boolean isArtifact()
This method indicates whether this modification is considered an artifact.

Specified by:
isArtifact in interface Modification
Returns:
boolean that indicates whether this modification is an artifact.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. For this class comparison is based on:

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
hashCode(), Hashtable

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.equals(Object), Hashtable

toString

public java.lang.String toString()
This method returns a String representation of the Modification.

Specified by:
toString in interface Modification
Overrides:
toString in class java.lang.Object
Returns:
String with a String Representation of the Modification.

clone

public java.lang.Object clone()
Override of the clone method. It doesn't do anything except making the method public and catching the 'CloneNotSupportedException'. The method now returns a 'null' when cloning was not possible.

Overrides:
clone in class java.lang.Object
Returns:
Object with a clone of this class, or 'null' when the CloneNotSupportedException was thrown.

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

In this implementation, ordering is first done on location, and only if this is identical, the title is compared. Therefore, since equals uses title and location as well, two equals instances will compare to '0'.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this Object.

getMassDelta

protected double getMassDelta(java.lang.String aResidue,
                              int aMonoOrAvg)
This method returns the mass delta for the specified residue, measured either monoisotopically or averaged.

Parameters:
aResidue - String with the residue for which the modification applies (value for the N-terminus is the NTERMINUS constant and for the C-terminus the CTERMINUS constant).
aMonoOrAvg - int which should be either MONOISOTOPIC or AVERAGE
Returns:
double with the mass delta (can be negative, of course!) or '0.0' if this modification does not apply to the specified residue.


Copyright © 2011. All Rights Reserved.