Package com.compomics.util.protein
Class ModificationTemplate
java.lang.Object
com.compomics.util.protein.ModificationTemplate
public class ModificationTemplate extends 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
Fields Modifier and Type Field Description protected boolean
iArtifact
Boolean to indicate whether this modification is an artifact.protected String
iCode
The code for this modification (eg., Mox).protected HashMap
iMassDeltas
This HashMap will contain the following 'key-value' mappings: (key > value)
(residue > double[]{MONOISOTOPIC_DELTA, AVERAGE_DELTA})protected String
iTitle
The title for this modification (eg., Oxidation Met). -
Constructor Summary
Constructors Constructor Description ModificationTemplate()
Empty default constructorModificationTemplate(String aTitle, String aCode, HashMap aMassDeltas)
This constructor allows initialization of all the properties for the modification template.ModificationTemplate(String aTitle, String aCode, HashMap aMassDeltas, boolean aArtifact)
This constructor allows initialization of all the properties for the modification template. -
Method Summary
Modifier and Type Method Description Object
clone()
Override of the clone method.int
compareTo(Object o)
Compares this object with the specified object for order.boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.double
getAverageMassDelta(String aResidue)
This method returns a double with the average mass difference conferred on the sequence by this modification for the specified residue.String
getCode()
This method returns the short code for the modification, eg.protected double
getMassDelta(String aResidue, int aMonoOrAvg)
This method returns the mass delta for the specified residue, measured either monoisotopically or averaged.double
getMonoisotopicMassDelta(String aResidue)
This method returns a double with the monoisotopic mass difference conferred on the sequence by this modification for the specified residue.Collection
getResidues()
This method reports on all the residues that can be modified by this Modification.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.String
toString()
This method returns a String representation of the Modification.
-
Field Details
-
iMassDeltas
This HashMap will contain the following 'key-value' mappings: (key > value)
(residue > double[]{MONOISOTOPIC_DELTA, AVERAGE_DELTA}) -
iCode
The code for this modification (eg., Mox). -
iTitle
The title for this modification (eg., Oxidation Met). -
iArtifact
protected boolean iArtifactBoolean to indicate whether this modification is an artifact.
-
-
Constructor Details
-
ModificationTemplate
public ModificationTemplate()Empty default constructor -
ModificationTemplate
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
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 Details
-
getAverageMassDelta
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
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
This method returns the title of the modification, eg. 'Oxidation Met'.- Returns:
- String with the title for the modification.
-
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
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
Indicates whether some other object is "equal to" this one. For this class comparison is based on:- class identity
- title equality
- location equality
- Overrides:
equals
in classObject
- 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 byjava.util.Hashtable
.The general contract of
hashCode
is:- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals(Object)
method, then calling thehashCode
method on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
Object.equals(Object)
method, then calling thehashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
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 Java programming language.)- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this object.
- See Also:
Object.equals(Object)
,Hashtable
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
-
toString
This method returns a String representation of the Modification. -
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. -
compareTo
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:
ClassCastException
- if the specified object's type prevents it from being compared to this Object.
-
getMassDelta
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.
-