Package com.compomics.util.protein
Class ModificationImplementation
java.lang.Object
com.compomics.util.protein.ModificationImplementation
- All Implemented Interfaces:
Modification,Cloneable,Comparable
This class implements a specific Modification.
- Author:
- Lennart Martens
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe location for the modification in the parent sequence.protected ModificationTemplateThe 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
ConstructorsConstructorDescriptionEmpty 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 TypeMethodDescriptionclone()Override of the clone method.intCompares this object with the specified object for order.booleanIndicates whether some other object is "equal to" this one.doublegetAverageMassDelta(String aResidue) This method returns a double with the average mass difference conferred on the sequence by this modification for the specified residue.getCode()This method returns the short code for the modification, eg.intThis method returns the location of the modification in the sequence.protected doublegetMassDelta(String aResidue, int aMonoOrAvg) This method returns the mass delta for the specified residue, measured either monoisotopically or averaged.doublegetMonoisotopicMassDelta(String aResidue) This method returns a double with the monoisotopic mass difference conferred on the sequence by this modification for the specified residue.This method reports on all the residues that can be modified by this Modification.getTitle()This method returns the title of the modification, eg.inthashCode()Returns a hash code value for the object.booleanThis method indicates whether this modification is considered an artifact.voidsetLocation(int aLocation) This method allows the setting of the location for this modification.toString()This method returns a String representation of the Modification.
-
Field Details
-
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 iLocationThe location for the modification in the parent sequence.
-
-
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:
getAverageMassDeltain 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:
getCodein 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:
getTitlein 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:
getLocationin 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:
getResiduesin 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:
getMonoisotopicMassDeltain 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:
setLocationin 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:
isArtifactin 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
-
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
hashCodeis:- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons 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 thehashCodemethod 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 thehashCodemethod 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
Objectdoes 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.) - 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:
toStringin interfaceModification- Overrides:
toStringin 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:
compareToin 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.
-