com.compomics.util.protein
Class ModificationTemplate

java.lang.Object
  extended by com.compomics.util.protein.ModificationTemplate

public class ModificationTemplate
extends java.lang.Object

This class holds a template for a Modification, meaning that it contains all shared characteristics of a Modification, but not the instance-specific one. As such, instances can be treated as singletons and are obviously immutable by nature.

Author:
Lennart Martens

Field Summary
protected  boolean iArtifact
          Boolean to indicate whether this modification is an artifact.
protected  java.lang.String iCode
          The code for this modification (eg., Mox).
protected  java.util.HashMap iMassDeltas
          This HashMap will contain the following 'key-value' mappings: (key --> value)
(residue-->double[]{MONOISOTOPIC_DELTA, AVERAGE_DELTA})
protected  java.lang.String iTitle
          The title for this modification (eg., Oxidation Met).
 
Constructor Summary
ModificationTemplate(java.lang.String aTitle, java.lang.String aCode, java.util.HashMap aMassDeltas)
          This constructor allows initialization of all the properties for the modification template.
ModificationTemplate(java.lang.String aTitle, java.lang.String aCode, java.util.HashMap aMassDeltas, boolean aArtifact)
          This constructor allows initialization of all the properties for the modification template.
 
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.
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.
 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

iMassDeltas

protected java.util.HashMap iMassDeltas
This HashMap will contain the following 'key-value' mappings: (key --> value)
(residue-->double[]{MONOISOTOPIC_DELTA, AVERAGE_DELTA})


iCode

protected java.lang.String iCode
The code for this modification (eg., Mox).


iTitle

protected java.lang.String iTitle
The title for this modification (eg., Oxidation Met).


iArtifact

protected boolean iArtifact
Boolean to indicate whether this modification is an artifact.

Constructor Detail

ModificationTemplate

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

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.

ModificationTemplate

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

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 class is an artifact.
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.

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'.

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'.

Returns:
String with the title for the modification.

getResidues

public java.util.Collection getResidues()
This method reports on all the residues that can be modified by this Modification.
The Collection is a keySet of a HashMap.

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.

Parameters:
aResidue - String with the residue for which the mass delta needs to be calculated.
Returns:
double with the monoisotopic mass difference.

isArtifact

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

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.

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'.

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 © 2013. All Rights Reserved.