Class ModificationFactory
java.lang.Object
com.compomics.util.experiment.biology.modifications.ModificationFactory
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionbooleanSet to true if the default mods are sorted alphabetically.static final StringSuffix for the modification clone targeting a single amino acid instead of a pattern.booleanSet to true if the users mods are sorted alphabetically. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUserModification(Modification modification) Adds a new user modification.voidClears the factory getInstance() needs to be called afterwards.booleancontainsModification(String name) Returns a boolean indicating whether the Modification is loaded in the factory.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.intReturns the color used to code the given modification.static intgetDefaultColor(String modification) Returns a default color based on the modification name.Returns the names of the default modifications.Returns the alphabetically (case insensitive) ordered names of the default modifications.getExpectedVariableModifications(SearchParameters searchParameters) Returns the expected variable modifications given the search parameters.static ModificationFactoryStatic method to get the instance of the factory.getModification(String name) Returns the modification with the given name name.Returns the names of all imported Modifications.getModifications(ModificationCategory... modCategories) Returns the names of all modifications in the given categories.getModificationsForPsiAccession(String psiModAccession) Returns an array list of the utilities modification names mapping to the given PSI-MOD accession number.getSameMassNotFixedModifications(double modificationMass, SearchParameters searchParameters) Returns a list containing all not fixed modifications with the same mass.static StringReturns the folder where the factory is saved.static ModificationgetSingleAAModification(Modification modification) Returns a clone of the given Modification targeting a single amino acid instead of a pattern.getSingleAAModification(String modificationName) Returns a clone of the given Modification targeting a single amino acid instead of a pattern.Returns the names of the user defined modifications.Returns the alphabetically (case insensitive) ordered names of the user defined modifications.getUtilitiesModificationName(String modName) Tries to convert a modification name to a utilities modification name.booleanisUserDefined(String modificationName) Convenience method returning a boolean indicating whether a Modification is user defined or default.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 ModificationFactoryloadFromFile(File file) Loads an enzyme factory from a file.voidReloads the factory getInstance() needs to be called afterwards.voidremoveUserPtm(String modificationName) Removes a user Modification.voidSaves the factory in the user folder.static voidsaveToFile(ModificationFactory modificationFactory, File file) Saves a Modification factory to a file.voidSets a new color for the given expected modification.static voidsetSerializationFolder(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:
-
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 IOException Saves 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:ModificationProviderReturns the modification with the given name name. Null if none found.- Specified by:
getModificationin 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
-