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 Summary
Modifier and Type Method Description void
addEnzyme(Enzyme enzyme)
Adds an enzyme in the factory.boolean
enzymeLoaded(String enzyme)
Indicates whether an enzyme is loaded in the factory.Enzyme
getEnzyme(String enzymeName)
Returns the enzyme corresponding to the given name.ArrayList<Enzyme>
getEnzymes()
Get the imported enzymes.static EnzymeFactory
getInstance()
Static method to get an instance of the factory.static String
getSerializationFolder()
Returns the folder where to save the factory.ArrayList<String>
getSortedEnzymeNames()
Get the sorted list of enzyme names.Enzyme
getUtilitiesEnzyme(String cvTermAccession)
Returns the enzyme associated to the given cvTerm.static EnzymeFactory
loadFromFile(File file)
Loads an enzyme factory from a file.void
removeEnzyme(String enzymeName)
Removes an enzyme from the mapping.void
saveFactory()
Saves the factory in the user folder.static void
saveToFile(EnzymeFactory enzymeFactory, File file)
Saves en enzyme factory to a file.static void
setDefaultEnzymes()
Sets the instance to only contain the default enzymes.static void
setSerializationFolder(String serializationFilePath)
Sets the folder where to save the factory.
-
Method Details
-
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
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
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
Saves en enzyme factory to a file.- Parameters:
enzymeFactory
- the enzyme factory to savefile
- the file where to save- Throws:
IOException
- exception thrown whenever an error occurred while saving the file
-
getSerializationFolder
Returns the folder where to save the factory.- Returns:
- the folder where to save the factory
-
setSerializationFolder
Sets the folder where to save the factory. Warning: this overwrites SERIALIZATION_FILE_FOLDER.- Parameters:
serializationFilePath
- the folder where to save the factory
-
getEnzymes
Get the imported enzymes.- Returns:
- The enzymes as ArrayList
-
getSortedEnzymeNames
Get the sorted list of enzyme names.- Returns:
- the enzyme names as a sorted ArrayList
-
getEnzyme
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
Adds an enzyme in the factory.- Parameters:
enzyme
- the new enzyme to add
-
removeEnzyme
Removes an enzyme from the mapping.- Parameters:
enzymeName
- the name of the enzyme to remove.
-
enzymeLoaded
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
Returns the enzyme associated to the given cvTerm. Null if not found.- Parameters:
cvTermAccession
- the accession of the cv term- Returns:
- the associated enzyme.
-