com.compomics.util.experiment.biology
Class PTMFactory

java.lang.Object
  extended by com.compomics.util.experiment.biology.PTMFactory
All Implemented Interfaces:
Serializable

public class PTMFactory
extends Object
implements Serializable

This factory will load PTM from an XML file and provide them on demand as standard class.

Author:
Marc Vaudel
See Also:
Serialized Form

Field Summary
static String SEARCH_SUFFIX
          Suffix for the modifications searched but not in the factory.
static PTM unknownPTM
          Unknown modification to be returned when the modification is not found.
 
Method Summary
 void addUserPTM(PTM ptm)
          Adds a new user modification.
 void checkFixedModifications(ModificationProfile modificationProfile, Peptide peptide)
          Removes the fixed modifications of the peptide and remaps the one searched for according to the ModificationProfile.
 void clearFactory()
          Clears the factory getInstance() needs to be called afterwards.
 boolean containsPTM(String name)
          Returns a boolean indicating whether the PTM is loaded in the factory.
 String convertPridePtm(String pridePtmName, ModificationProfile modProfile, ArrayList<String> unknownPtms, boolean isFixed)
          Tries to convert a PRIDE PTM to utilities PTM name, and add it to the modification profile.
 Color getColor(String modification)
          Returns the color used to code the given modification.
static Color getDefaultColor(String modification)
          Returns a default color based on the modification name.
 ArrayList<String> getDefaultModifications()
          Returns the names of the default modifications.
 Integer getDefaultOMSSAIndex(String modificationName)
          Returns the default OMSSA index of the modification.
static String getDefaultShortName(String modificationName)
          Returns a default short name for a given modification.
 HashMap<Integer,ArrayList<String>> getExpectedPTMs(ModificationProfile modificationProfile, Peptide peptide, double modificationMass, double massTolerance)
          Returns the expected modifications based on the modification profile, the peptide found and the modification details.
 HashMap<Integer,ArrayList<String>> getExpectedPTMs(ModificationProfile modificationProfile, Peptide peptide, String ptmName)
          Returns the names of the possibly expected modification based on the name of the expected modification in a map where the PTM names are indexed by their potential site on the sequence.
static PTMFactory getInstance()
          Static method to get the instance of the factory.
static HashMap<String,Integer> getOMSSAIndexes(File modificationsFile)
          Imports the OMSSA indexes from an XML file.
 String getOmssaUserModBloc(String ptmName, int cpt)
          Returns an MSModSpec bloc as present in the OMSSA user modification files for a given PTM.
 PTM getPTM(double mass, String location, String sequence)
          Deprecated. This method can generate inconsistent results in case a measurement matches to various PTMs.
 PTM getPTM(ModificationProfile modificationProfile, int index)
          Get a PTM according to its OMSSA index.
 PTM getPTM(String name)
          Returns the PTM indexed by its name.
 ArrayList<String> getPTMs()
          Returns the names of all imported PTMs.
 PTM getSearchedPTM(PTM modification)
          Returns the standard search compatible PTM corresponding to this pattern.
 PTM getSearchedPTM(String modificationName)
          Returns the standard search compatible PTM corresponding to this pattern, i.e., a pattern targeting a single amino-acid and not a complex pattern.
 String getShortName(String modification)
          Returns the user favorite short name, a default short name otherwise.
 ArrayList<String> getUserModifications()
          Returns the names of the user defined modifications.
 void importModifications(File modificationsFile, boolean userMod)
          Import modifications from a modification file.
 void importModifications(File modificationsFile, boolean userMod, boolean overwrite)
          Import modifications from a modification file.
 boolean isUserDefined(String ptmName)
          Convenience method returning a boolean indicating whether a PTM is user defined or default.
 ArrayList<String> loadBackedUpModifications(SearchParameters searchParameters, boolean overwrite)
          Verifies that the modifications backed-up in the search parameters are loaded and alerts the user in case conflicts are found.
 void reloadFactory()
          Reloads the factory getInstance() needs to be called afterwards.
 void removeUserPtm(String ptmName)
          Removes a user PTM.
 void saveFactory()
          Saves the factory in the user folder.
 void setColor(String expectedModification, Color color)
          Sets a new color for the given expected modification.
 void setDefaultNeutralLosses()
          Sets the default neutral losses of PTMs when not implemented.
 void setDefaultReporterIons()
          Sets the default reporter ions of PTMs when not implemented.
 void setSearchedOMSSAIndexes(ModificationProfile modificationProfile)
          Set the OMSSA indexes used for this search.
 void setShortName(String modification, String shortName)
          Sets the short name for a modification.
 void writeOmssaModificationsFiles(File aFolder, File utilitiesModFile, File utilitiesUserModFile)
          Write the OMSSA modification files to the given folder.
 void writeOmssaUserModificationFile(File file)
          Writes the OMSSA modification file corresponding to the PTMs loaded in the factory in the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unknownPTM

public static final PTM unknownPTM
Unknown modification to be returned when the modification is not found.


SEARCH_SUFFIX

public static final String SEARCH_SUFFIX
Suffix for the modifications searched but not in the factory.

See Also:
Constant Field Values
Method Detail

getInstance

public static PTMFactory getInstance()
Static method to get the instance of the factory.

Returns:
the instance of the factory

clearFactory

public void clearFactory()
Clears the factory getInstance() needs to be called afterwards.


reloadFactory

public void reloadFactory()
Reloads the factory getInstance() needs to be called afterwards.


saveFactory

public void saveFactory()
                 throws IOException
Saves the factory in the user folder.

Throws:
IOException - exception thrown whenever an error occurred while saving the ptmFactory

getPTM

public PTM getPTM(ModificationProfile modificationProfile,
                  int index)
Get a PTM according to its OMSSA index.

Parameters:
index - the PTM index
modificationProfile - the modification profile used for the search
Returns:
the selected PTM

getSearchedPTM

public PTM getSearchedPTM(PTM modification)
Returns the standard search compatible PTM corresponding to this pattern. i.e. a pattern targeting a single amino-acid and not a complex pattern.

Parameters:
modification - the modification of interest
Returns:
a search compatible modification

getSearchedPTM

public PTM getSearchedPTM(String modificationName)
Returns the standard search compatible PTM corresponding to this pattern, i.e., a pattern targeting a single amino-acid and not a complex pattern.

Parameters:
modificationName - the name of the modification of interest
Returns:
a search compatible modification

addUserPTM

public void addUserPTM(PTM ptm)
Adds a new user modification.

Parameters:
ptm - the new modification to add

removeUserPtm

public void removeUserPtm(String ptmName)
Removes a user PTM.

Parameters:
ptmName - the name of the PTM to remove

getPTM

public PTM getPTM(String name)
Returns the PTM indexed by its name.

Parameters:
name - the name of the desired PTM
Returns:
The desired PTM

containsPTM

public boolean containsPTM(String name)
Returns a boolean indicating whether the PTM is loaded in the factory.

Parameters:
name - the name of the PTM
Returns:
a boolean indicating whether the PTM is loaded in the factory

getPTM

public PTM getPTM(double mass,
                  String location,
                  String sequence)
Deprecated. This method can generate inconsistent results in case a measurement matches to various PTMs.

Getter for a PTM according to its measured characteristics.

Parameters:
mass - the measured mass induced by the modification
location - the modification location
sequence - the peptide sequence
Returns:
the candidate modification, null if none is found

importModifications

public void importModifications(File modificationsFile,
                                boolean userMod)
                         throws org.xmlpull.v1.XmlPullParserException,
                                IOException
Import modifications from a modification file.

Parameters:
modificationsFile - A file containing modifications
userMod - A boolean indicating whether the file comprises user designed modification
Throws:
org.xmlpull.v1.XmlPullParserException - exception thrown whenever an error is encountered while parsing
IOException - exception thrown whenever an error is encountered reading the file

importModifications

public void importModifications(File modificationsFile,
                                boolean userMod,
                                boolean overwrite)
                         throws org.xmlpull.v1.XmlPullParserException,
                                IOException
Import modifications from a modification file.

Parameters:
modificationsFile - A file containing modifications
userMod - A boolean indicating whether the file comprises user designed modification
overwrite - a boolean indicating whether modifications from the XML file should be overwritten
Throws:
org.xmlpull.v1.XmlPullParserException - exception thrown whenever an error is encountered while parsing
IOException - exception thrown whenever an error is encountered reading the file

getDefaultOMSSAIndex

public Integer getDefaultOMSSAIndex(String modificationName)
Returns the default OMSSA index of the modification. Null if not found.

Parameters:
modificationName - the name of the modification
Returns:
the default OMSSA index

getOMSSAIndexes

public static HashMap<String,Integer> getOMSSAIndexes(File modificationsFile)
                                               throws org.xmlpull.v1.XmlPullParserException,
                                                      FileNotFoundException,
                                                      IOException
Imports the OMSSA indexes from an XML file.

Parameters:
modificationsFile - the modification file
Returns:
a map of all indexes: modification name -> OMSSA index
Throws:
org.xmlpull.v1.XmlPullParserException
FileNotFoundException
IOException

writeOmssaModificationsFiles

public void writeOmssaModificationsFiles(File aFolder,
                                         File utilitiesModFile,
                                         File utilitiesUserModFile)
                                  throws IOException
Write the OMSSA modification files to the given folder.

Parameters:
aFolder - the folder to write the modification files to
utilitiesModFile - the utilities corresponding mod file
utilitiesUserModFile - the utilities corresponding usermod file
Throws:
IOException - an IOException is thrown in case an issue is encountered while reading or writing a file.

writeOmssaUserModificationFile

public void writeOmssaUserModificationFile(File file)
                                    throws IOException
Writes the OMSSA modification file corresponding to the PTMs loaded in the factory in the given file.

Parameters:
file - the file
Throws:
IOException - exception thrown whenever an error occurred while writing the file

getOmssaUserModBloc

public String getOmssaUserModBloc(String ptmName,
                                  int cpt)
Returns an MSModSpec bloc as present in the OMSSA user modification files for a given PTM. Only the amino acids targeted by the pattern of the PTM will be considered.

Parameters:
ptmName - the name of the PTM
cpt - the index of this PTM
Returns:
a string containing the XML bloc

getDefaultModifications

public ArrayList<String> getDefaultModifications()
Returns the names of the default modifications.

Returns:
the names of the default modifications

getUserModifications

public ArrayList<String> getUserModifications()
Returns the names of the user defined modifications.

Returns:
the names of the user defined modifications

getPTMs

public ArrayList<String> getPTMs()
Returns the names of all imported PTMs.

Returns:
the names of all imported PTMs

isUserDefined

public boolean isUserDefined(String ptmName)
Convenience method returning a boolean indicating whether a PTM is user defined or default.

Parameters:
ptmName -
Returns:
boolean indicating whether a PTM is user defined

loadBackedUpModifications

public ArrayList<String> loadBackedUpModifications(SearchParameters searchParameters,
                                                   boolean overwrite)
Verifies that the modifications backed-up in the search parameters are loaded and alerts the user in case conflicts are found.

Parameters:
searchParameters - the search parameters to load
overwrite - if true, overwrite the modification
Returns:
returns a list of modifications already loaded which should be checked.

getExpectedPTMs

public HashMap<Integer,ArrayList<String>> getExpectedPTMs(ModificationProfile modificationProfile,
                                                          Peptide peptide,
                                                          double modificationMass,
                                                          double massTolerance)
                                                   throws IOException,
                                                          IllegalArgumentException,
                                                          InterruptedException,
                                                          FileNotFoundException,
                                                          ClassNotFoundException,
                                                          FileNotFoundException
Returns the expected modifications based on the modification profile, the peptide found and the modification details. Returns the names in a map where the modification names are indexed by the index on the sequence. 1 is the first amino acid.

Parameters:
modificationProfile - the modification profile used for the search (available in the search parameters)
peptide - the peptide identified with the parent proteins (necessary for protein termini modifications)
modificationMass - the modification mass as found in the search results
massTolerance - the mass tolerance to use to match the modification mass
Returns:
a map of expected PTMs corresponding to the given characteristics. Empty if none found.
Throws:
IOException - exception thrown whenever an error occurred while reading a protein sequence
IllegalArgumentException - exception thrown whenever an error occurred while reading a protein sequence
InterruptedException - exception thrown whenever an error occurred while reading a protein sequence
FileNotFoundException
ClassNotFoundException

getExpectedPTMs

public HashMap<Integer,ArrayList<String>> getExpectedPTMs(ModificationProfile modificationProfile,
                                                          Peptide peptide,
                                                          String ptmName)
                                                   throws IOException,
                                                          IllegalArgumentException,
                                                          InterruptedException,
                                                          FileNotFoundException,
                                                          ClassNotFoundException
Returns the names of the possibly expected modification based on the name of the expected modification in a map where the PTM names are indexed by their potential site on the sequence. 1 is the first amino acid. Candidate PTMs are expected non fixed modifications with the same mass.

Parameters:
modificationProfile - the modification profile used for the search (available in the search parameters)
peptide - the peptide
ptmName - the name of the searched PTM
Returns:
the possible expected modification names. Empty if not found.
Throws:
IOException - exception thrown whenever an error occurred while reading a protein sequence
IllegalArgumentException - exception thrown whenever an error occurred while reading a protein sequence
InterruptedException - exception thrown whenever an error occurred while reading a protein sequence
FileNotFoundException
ClassNotFoundException

checkFixedModifications

public void checkFixedModifications(ModificationProfile modificationProfile,
                                    Peptide peptide)
                             throws IOException,
                                    IllegalArgumentException,
                                    InterruptedException,
                                    FileNotFoundException,
                                    ClassNotFoundException
Removes the fixed modifications of the peptide and remaps the one searched for according to the ModificationProfile. Note: for protein terminal modification the protein must be loaded in the sequence factory

Parameters:
modificationProfile -
peptide -
Throws:
IOException - exception thrown whenever an error occurred while reading a protein sequence
IllegalArgumentException - exception thrown whenever an error occurred while reading a protein sequence
InterruptedException - exception thrown whenever an error occurred while reading a protein sequence
FileNotFoundException
ClassNotFoundException

setSearchedOMSSAIndexes

public void setSearchedOMSSAIndexes(ModificationProfile modificationProfile)
Set the OMSSA indexes used for this search.

Parameters:
modificationProfile - the modification profile of this search

setDefaultNeutralLosses

public void setDefaultNeutralLosses()
Sets the default neutral losses of PTMs when not implemented.


setDefaultReporterIons

public void setDefaultReporterIons()
Sets the default reporter ions of PTMs when not implemented.


setShortName

public void setShortName(String modification,
                         String shortName)
Sets the short name for a modification.

Parameters:
modification - the modification name
shortName - the short name

getShortName

public String getShortName(String modification)
Returns the user favorite short name, a default short name otherwise.

Parameters:
modification - the name of the modification
Returns:
the corresponding short name

getDefaultShortName

public static String getDefaultShortName(String modificationName)
Returns a default short name for a given modification.

Parameters:
modificationName - the full name of the modification
Returns:
the default short name

getColor

public Color getColor(String modification)
Returns the color used to code the given modification.

Parameters:
modification - the name of the given expected modification
Returns:
the corresponding color

setColor

public void setColor(String expectedModification,
                     Color color)
Sets a new color for the given expected modification.

Parameters:
expectedModification - the name of the expected modification
color - the new color

getDefaultColor

public static Color getDefaultColor(String modification)
Returns a default color based on the modification name.

Parameters:
modification - the name of the modification
Returns:
a default color.

convertPridePtm

public String convertPridePtm(String pridePtmName,
                              ModificationProfile modProfile,
                              ArrayList<String> unknownPtms,
                              boolean isFixed)
Tries to convert a PRIDE PTM to utilities PTM name, and add it to the modification profile. Unknown PTMs are added to the unknown PTMs arraylist.

Parameters:
pridePtmName - the PRIDE PTM name
modProfile - the modification profile to add the PTMs to
unknownPtms - the list of unknown PTMS, updated during this method
isFixed - if true, the PTM will be added as a fixed modification
Returns:
a pride parameters report as a string (for use in PRIDE Reshake)


Copyright © 2013. All Rights Reserved.