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. Created by IntelliJ IDEA. User: Marc Date: Jun 22, 2010 Time: 8:26:09 PM

See Also:
Serialized Form

Field Summary
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
static PTMFactory getInstance()
          Static method to get the instance of the factory
 ArrayList<Integer> getOMSSAIndexes(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)
          getter for a ptm according to its measured characteristics /!
 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
 ArrayList<String> getUserModifications()
          Returns the names of the user defined modifications
 void importModifications(File modificationsFile, boolean userMod)
          Import modifications from a modification file
 void reloadFactory()
          Reloads the factory getInstance() needs to be called afterwards
 void removeUserPtm(String ptmName)
          Removes a user ptm
 void replacePTM(String oldName, PTM newPTM)
          replaces an old ptm by a new
 void saveFactory()
          Saves the factory in the user folder
 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

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

replacePTM

public void replacePTM(String oldName,
                       PTM newPTM)
replaces an old ptm by a new

Parameters:
oldName - the name of the old ptm
newPTM - the new ptm

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

getOMSSAIndexes

public ArrayList<Integer> getOMSSAIndexes(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)
getter for a ptm according to its measured characteristics /!\ This method can generate inconsistent results in case a measurement matches to various PTMs.

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

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


Copyright © 2012. All Rights Reserved.