Package com.compomics.util.protein
Class ModificationImplementation
java.lang.Object
com.compomics.util.protein.ModificationImplementation
- All Implemented Interfaces:
Modification
,Cloneable
,Comparable
public class ModificationImplementation extends Object implements Modification, Cloneable
This class implements a specific Modification.
- Author:
- Lennart Martens
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description ModificationImplementation()
Empty default constructorModificationImplementation(ModificationTemplate aTemplate, int aLocation)
This constructor allows initialization of all the properties for the modification.ModificationImplementation(String aTitle, String aCode, HashMap aMassDeltas, boolean aArtifact, int aLocation)
This constructor allows initialization of all the properties for the modification.ModificationImplementation(String aTitle, String aCode, HashMap aMassDeltas, int aLocation)
This constructor allows initialization of all the properties for the modification. -
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.int
getLocation()
This method returns the location of the modification in the sequence.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.void
setLocation(int aLocation)
This method allows the setting of the location for this modification.String
toString()
This method returns a String representation of the Modification.
-
Field Details
-
Constructor Details
-
ModificationImplementation
public ModificationImplementation()Empty default constructor -
ModificationImplementation
This constructor allows initialization of all the properties for the modification.- Parameters:
aTemplate
- ModificationTemplate with the shared information for this modificationaLocation
- int with the location of this modification in the parent sequence.
-
ModificationImplementation
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(String aTitle, String aCode, 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 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.- Specified by:
getAverageMassDelta
in interfaceModification
- 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'.- Specified by:
getCode
in interfaceModification
- 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'.- Specified by:
getTitle
in interfaceModification
- 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 interfaceModification
- Returns:
- int with the location for the modification.
-
getResidues
This method reports on all the residues that can be modified by this Modification.- Specified by:
getResidues
in interfaceModification
- 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.- Specified by:
getMonoisotopicMassDelta
in interfaceModification
- 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 interfaceModification
- 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 interfaceModification
- 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()
-
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)
- 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.- Specified by:
toString
in interfaceModification
- Overrides:
toString
in classObject
- Returns:
- String with 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'.
- Specified by:
compareTo
in interfaceComparable
- 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.
-