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 Details

    • SINGLE_AA_SUFFIX

      public static final String 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 defaultModsSorted
      Set to true if the default mods are sorted alphabetically.
    • usersModsSorted

      public boolean usersModsSorted
      Set to true if the users mods are sorted alphabetically.
  • Method Details

    • getInstance

      public static ModificationFactory getInstance()
      Static method to get the instance of the factory.
      Returns:
      the instance of the factory
    • loadFromFile

      public static ModificationFactory loadFromFile​(File file) throws IOException
      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 save
      file - 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

      public void saveFactory() throws IOException
      Saves the factory in the user folder.
      Throws:
      IOException - exception thrown whenever an error occurred while saving the modificationFactory
    • getSingleAAModification

      public static Modification getSingleAAModification​(Modification modification)
      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

      public Modification getSingleAAModification​(String modificationName)
      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

      public void addUserModification​(Modification modification)
      Adds a new user modification.
      Parameters:
      modification - the new modification to add
    • removeUserPtm

      public void removeUserPtm​(String modificationName)
      Removes a user Modification.
      Parameters:
      modificationName - the name of the Modification to remove
    • getModification

      public Modification getModification​(String name)
      Description copied from interface: ModificationProvider
      Returns the modification with the given name name. Null if none found.
      Specified by:
      getModification in interface ModificationProvider
      Parameters:
      name - The name of the modification of interest.
      Returns:
      The modification of interest
    • containsModification

      public boolean containsModification​(String name)
      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

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

      public ArrayList<String> getDefaultModificationsOrdered()
      Returns the alphabetically (case insensitive) ordered names of the default modifications.
      Returns:
      the alphabetically ordered 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
    • getUserModificationsOrdered

      public ArrayList<String> getUserModificationsOrdered()
      Returns the alphabetically (case insensitive) ordered names of the user defined modifications.
      Returns:
      the alphabetically ordered names of the user defined modifications
    • getModifications

      public ArrayList<String> getModifications()
      Returns the names of all imported Modifications.
      Returns:
      the names of all imported Modifications
    • isUserDefined

      public boolean isUserDefined​(String modificationName)
      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 load
      overwrite - if true, overwrite the modification
      Returns:
      returns a list of modifications already loaded which should be checked.
    • getColor

      public int 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, int 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 int 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, 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 name
      modProfile - the modification profile to add the Modifications to
      unknownPtms - the list of unknown ModificationS, updated during this method
      isFixed - 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

      public String getUtilitiesModificationName​(String modName)
      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

      public static String getSerializationFolder()
      Returns the folder where the factory is saved.
      Returns:
      the folder where the factory is saved
    • setSerializationFolder

      public static void setSerializationFolder​(String serializationFolder)
      Sets the folder where the factory is saved.
      Parameters:
      serializationFolder - the folder where the factory is saved
    • getModificationsForPsiAccession

      public ArrayList<String> getModificationsForPsiAccession​(String psiModAccession)
      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

      public ArrayList<String> getModifications​(ModificationCategory... modCategories)
      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 mass
      searchParameters - the search parameters
      Returns:
      a list of all not fixed modifications with the same mass
    • getExpectedVariableModifications

      public ArrayList<String> getExpectedVariableModifications​(SearchParameters searchParameters)
      Returns the expected variable modifications given the search parameters.
      Parameters:
      searchParameters - the search parameters
      Returns:
      expected variable modifications given the search parameters