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 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.
 ArrayList<String> getDefaultModifications()
          Returns the names of the default modifications.
 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
 ArrayList<String> getExpectedPTMs(ModificationProfile modificationProfile, Peptide peptide, String searchedPTMName)
          Returns the names of the possibly expected variable modification based on the name of the searched variable modification
static PTMFactory getInstance()
          Static method to get the instance of the factory.
 Integer getOMSSAIndex(String modificationName)
          Returns the index of the desired modification.
 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(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.
 ArrayList<String> getUserModifications()
          Returns the names of the user defined modifications.
 void importModifications(File modificationsFile, boolean userMod)
          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 setDefaultNeutralLosses()
          Sets the default neutral losses of PTMs when not implemented.
 void setDefaultReporterIons()
          Sets the default reporter ions of PTMs when not implemented.
 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(int index)
Get a PTM according to its omssa index.

Parameters:
index - the PTM index
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

getOMSSAIndex

public Integer getOMSSAIndex(String modificationName)
Returns the index of the desired modification.

Parameters:
modificationName - the desired modification name to lower case
Returns:
the corresponding index

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

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

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 ArrayList<String> getExpectedPTMs(ModificationProfile modificationProfile,
                                         Peptide peptide,
                                         double modificationMass,
                                         double massTolerance)
                                  throws IOException,
                                         IllegalArgumentException,
                                         InterruptedException
Returns the expected modifications based on the modification profile, the peptide found and the modification details

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 list 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

getExpectedPTMs

public ArrayList<String> getExpectedPTMs(ModificationProfile modificationProfile,
                                         Peptide peptide,
                                         String searchedPTMName)
                                  throws IOException,
                                         IllegalArgumentException,
                                         InterruptedException
Returns the names of the possibly expected variable modification based on the name of the searched variable modification

Parameters:
modificationProfile - the modification profile used for the search (available in the search parameters)
searchedPTMName - 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

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.



Copyright © 2012. All Rights Reserved.