Class ModificationFactory
java.lang.Object
com.compomics.util.experiment.biology.modifications.ModificationFactory
- All Implemented Interfaces:
ModificationProvider
public class ModificationFactory extends Object implements ModificationProvider
This factory will load Modification from an XML file and provide them on
demand as standard class.
- Author:
- Marc Vaudel, Harald Barsnes
-
Field Summary
Fields Modifier and Type Field Description boolean
defaultModsSorted
Set to true if the default mods are sorted alphabetically.static String
SINGLE_AA_SUFFIX
Suffix for the modification clone targeting a single amino acid instead of a pattern.boolean
usersModsSorted
Set to true if the users mods are sorted alphabetically. -
Method Summary
Modifier and Type Method Description void
addUserModification(Modification modification)
Adds a new user modification.void
clearFactory()
Clears the factory getInstance() needs to be called afterwards.boolean
containsModification(String name)
Returns a boolean indicating whether the Modification is loaded in the factory.String
convertPridePtm(String pridePtmName, ModificationParameters modProfile, ArrayList<String> unknownPtms, boolean isFixed)
Tries to convert a PRIDE Modification to utilities Modification name, and add it to the modification profile.int
getColor(String modification)
Returns the color used to code the given modification.static int
getDefaultColor(String modification)
Returns a default color based on the modification name.ArrayList<String>
getDefaultModifications()
Returns the names of the default modifications.ArrayList<String>
getDefaultModificationsOrdered()
Returns the alphabetically (case insensitive) ordered names of the default modifications.ArrayList<String>
getExpectedVariableModifications(SearchParameters searchParameters)
Returns the expected variable modifications given the search parameters.static ModificationFactory
getInstance()
Static method to get the instance of the factory.Modification
getModification(String name)
Returns the modification with the given name name.ArrayList<String>
getModifications()
Returns the names of all imported Modifications.ArrayList<String>
getModifications(ModificationCategory... modCategories)
Returns the names of all modifications in the given categories.ArrayList<String>
getModificationsForPsiAccession(String psiModAccession)
Returns an array list of the utilities modification names mapping to the given PSI-MOD accession number.ArrayList<String>
getSameMassNotFixedModifications(double modificationMass, SearchParameters searchParameters)
Returns a list containing all not fixed modifications with the same mass.static String
getSerializationFolder()
Returns the folder where the factory is saved.static Modification
getSingleAAModification(Modification modification)
Returns a clone of the given Modification targeting a single amino acid instead of a pattern.Modification
getSingleAAModification(String modificationName)
Returns a clone of the given Modification targeting a single amino acid instead of a pattern.ArrayList<String>
getUserModifications()
Returns the names of the user defined modifications.ArrayList<String>
getUserModificationsOrdered()
Returns the alphabetically (case insensitive) ordered names of the user defined modifications.String
getUtilitiesModificationName(String modName)
Tries to convert a modification name to a utilities modification name.boolean
isUserDefined(String modificationName)
Convenience method returning a boolean indicating whether a Modification 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.static ModificationFactory
loadFromFile(File file)
Loads an enzyme factory from a file.void
reloadFactory()
Reloads the factory getInstance() needs to be called afterwards.void
removeUserPtm(String modificationName)
Removes a user Modification.void
saveFactory()
Saves the factory in the user folder.static void
saveToFile(ModificationFactory modificationFactory, File file)
Saves a Modification factory to a file.void
setColor(String expectedModification, int color)
Sets a new color for the given expected modification.static void
setSerializationFolder(String serializationFolder)
Sets the folder where the factory is saved.
-
Field Details
-
SINGLE_AA_SUFFIX
Suffix for the modification clone targeting a single amino acid instead of a pattern.- See Also:
- Constant Field Values
-
defaultModsSorted
public boolean defaultModsSortedSet to true if the default mods are sorted alphabetically. -
usersModsSorted
public boolean usersModsSortedSet to true if the users mods are sorted alphabetically.
-
-
Method Details
-
getInstance
Static method to get the instance of the factory.- Returns:
- the instance of the factory
-
loadFromFile
Loads an enzyme factory from a file. The file must be an export of the factory in the json format.- Parameters:
file
- the file to load- Returns:
- the enzyme factory saved in file
- Throws:
IOException
- exception thrown whenever an error occurred while loading the file
-
saveToFile
public static void saveToFile(ModificationFactory modificationFactory, File file) throws IOExceptionSaves a Modification factory to a file.- Parameters:
modificationFactory
- the Modification factory to savefile
- the file where to save- Throws:
IOException
- exception thrown whenever an error occurred while saving the file
-
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
Saves the factory in the user folder.- Throws:
IOException
- exception thrown whenever an error occurred while saving the modificationFactory
-
getSingleAAModification
Returns a clone of the given Modification targeting a single amino acid instead of a pattern.- Parameters:
modification
- the modification of interest- Returns:
- a clone of the given Modification targeting a single amino acid instead of a pattern
-
getSingleAAModification
Returns a clone of the given Modification targeting a single amino acid instead of a pattern.- Parameters:
modificationName
- the name of the modification of interest- Returns:
- a clone of the given Modification targeting a single amino acid instead of a pattern
-
addUserModification
Adds a new user modification.- Parameters:
modification
- the new modification to add
-
removeUserPtm
Removes a user Modification.- Parameters:
modificationName
- the name of the Modification to remove
-
getModification
Description copied from interface:ModificationProvider
Returns the modification with the given name name. Null if none found.- Specified by:
getModification
in interfaceModificationProvider
- Parameters:
name
- The name of the modification of interest.- Returns:
- The modification of interest
-
containsModification
Returns a boolean indicating whether the Modification is loaded in the factory.- Parameters:
name
- the name of the Modification- Returns:
- a boolean indicating whether the Modification is loaded in the factory
-
getDefaultModifications
Returns the names of the default modifications.- Returns:
- the names of the default modifications
-
getDefaultModificationsOrdered
Returns the alphabetically (case insensitive) ordered names of the default modifications.- Returns:
- the alphabetically ordered names of the default modifications
-
getUserModifications
Returns the names of the user defined modifications.- Returns:
- the names of the user defined modifications
-
getUserModificationsOrdered
Returns the alphabetically (case insensitive) ordered names of the user defined modifications.- Returns:
- the alphabetically ordered names of the user defined modifications
-
getModifications
Returns the names of all imported Modifications.- Returns:
- the names of all imported Modifications
-
isUserDefined
Convenience method returning a boolean indicating whether a Modification is user defined or default.- Parameters:
modificationName
- the name of the Modification- Returns:
- boolean indicating whether a Modification 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 loadoverwrite
- if true, overwrite the modification- Returns:
- returns a list of modifications already loaded which should be checked.
-
getColor
Returns the color used to code the given modification.- Parameters:
modification
- the name of the given expected modification- Returns:
- the corresponding color
-
setColor
Sets a new color for the given expected modification.- Parameters:
expectedModification
- the name of the expected modificationcolor
- the new color
-
getDefaultColor
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, ModificationParameters modProfile, ArrayList<String> unknownPtms, boolean isFixed)Tries to convert a PRIDE Modification to utilities Modification name, and add it to the modification profile. Unknown Modifications are added to the unknown Modifications arraylist.- Parameters:
pridePtmName
- the PRIDE Modification namemodProfile
- the modification profile to add the Modifications tounknownPtms
- the list of unknown ModificationS, updated during this methodisFixed
- if true, the Modification will be added as a fixed modification- Returns:
- a pride parameters report as a string (for use in PRIDE Reshake)
-
getUtilitiesModificationName
Tries to convert a modification name to a utilities modification name. Null if no mapping is found.- Parameters:
modName
- the modification name to map- Returns:
- the utilities modification name, or null if there is no mapping
-
getSerializationFolder
Returns the folder where the factory is saved.- Returns:
- the folder where the factory is saved
-
setSerializationFolder
Sets the folder where the factory is saved.- Parameters:
serializationFolder
- the folder where the factory is saved
-
getModificationsForPsiAccession
Returns an array list of the utilities modification names mapping to the given PSI-MOD accession number. The accession number should be provided without the leading "MOD:" part.- Parameters:
psiModAccession
- the PSI-MOD accession number to look up (provided without the leading "MOD:" part)- Returns:
- an array list of the utilities modification names mapping to the given PSI-MOD accession number
-
getModifications
Returns the names of all modifications in the given categories.- Parameters:
modCategories
- the modification categories- Returns:
- the names of all modifications in the given categories
-
getSameMassNotFixedModifications
public ArrayList<String> getSameMassNotFixedModifications(double modificationMass, SearchParameters searchParameters)Returns a list containing all not fixed modifications with the same mass. Warning: all modifications of the profile must be loaded in the modification factory.- Parameters:
modificationMass
- the masssearchParameters
- the search parameters- Returns:
- a list of all not fixed modifications with the same mass
-
getExpectedVariableModifications
Returns the expected variable modifications given the search parameters.- Parameters:
searchParameters
- the search parameters- Returns:
- expected variable modifications given the search parameters
-