Class EnzymeFactory

java.lang.Object
com.compomics.util.experiment.biology.enzymes.EnzymeFactory

public class EnzymeFactory
extends Object
This factory will load enzymes from a JSON file and provide them on demand as a standard class.
Author:
Marc Vaudel, Harald Barsnes
  • Method Details

    • getInstance

      public static EnzymeFactory getInstance()
      Static method to get an instance of the factory. Attempts to load the factory from the file set in the path preferences. If any exception occurs it is ignored silently and defaults are used.
      Returns:
      the factory instance
    • 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
    • setDefaultEnzymes

      public static void setDefaultEnzymes()
      Sets the instance to only contain the default enzymes.
    • loadFromFile

      public static EnzymeFactory 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​(EnzymeFactory enzymeFactory, File file) throws IOException
      Saves en enzyme factory to a file.
      Parameters:
      enzymeFactory - the enzyme factory to save
      file - the file where to save
      Throws:
      IOException - exception thrown whenever an error occurred while saving the file
    • getSerializationFolder

      public static String getSerializationFolder()
      Returns the folder where to save the factory.
      Returns:
      the folder where to save the factory
    • setSerializationFolder

      public static void setSerializationFolder​(String serializationFilePath)
      Sets the folder where to save the factory. Warning: this overwrites SERIALIZATION_FILE_FOLDER.
      Parameters:
      serializationFilePath - the folder where to save the factory
    • getEnzymes

      public ArrayList<Enzyme> getEnzymes()
      Get the imported enzymes.
      Returns:
      The enzymes as ArrayList
    • getSortedEnzymeNames

      public ArrayList<String> getSortedEnzymeNames()
      Get the sorted list of enzyme names.
      Returns:
      the enzyme names as a sorted ArrayList
    • getEnzyme

      public Enzyme getEnzyme​(String enzymeName)
      Returns the enzyme corresponding to the given name. Null if not found.
      Parameters:
      enzymeName - the name of the desired enzyme
      Returns:
      the corresponding enzyme
    • addEnzyme

      public void addEnzyme​(Enzyme enzyme)
      Adds an enzyme in the factory.
      Parameters:
      enzyme - the new enzyme to add
    • removeEnzyme

      public void removeEnzyme​(String enzymeName)
      Removes an enzyme from the mapping.
      Parameters:
      enzymeName - the name of the enzyme to remove.
    • enzymeLoaded

      public boolean enzymeLoaded​(String enzyme)
      Indicates whether an enzyme is loaded in the factory.
      Parameters:
      enzyme - the name of the enzyme
      Returns:
      a boolean indicating whether an enzyme is loaded in the factory
    • getUtilitiesEnzyme

      public Enzyme getUtilitiesEnzyme​(String cvTermAccession)
      Returns the enzyme associated to the given cvTerm. Null if not found.
      Parameters:
      cvTermAccession - the accession of the cv term
      Returns:
      the associated enzyme.