Class Identification
java.lang.Object
com.compomics.util.experiment.personalization.ExperimentObject
com.compomics.util.experiment.identification.Identification
- All Implemented Interfaces:
Serializable
public class Identification extends ExperimentObject
This class interacts with the back-end database to manage identification
objects.
Interacting with the back-end database might cause InterruptedException.
These exceptions are passed as runtime exceptions for methods returning
identification objects.
- Author:
- Marc Vaudel, Dominik Kopczynski
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Identification()
Empty default constructorIdentification(ObjectsDB objectsDB)
Constructor. -
Method Summary
Modifier and Type Method Description void
addFraction(String fraction)
Adds a fraction, fractions correspond to the PSM files names.void
addObject(long key, Object object)
Adds an object into the database.void
addObjects(HashMap<Long,Object> objects, WaitingHandler waitingHandler, boolean displayProgress)
Adds a list of objects into the database.void
addPeptideMatch(long key, PeptideMatch peptideMatch)
Adds a peptide match.void
addPeptideMatches(HashMap<Long,Object> peptideMatches)
Adds a peptide match.void
addProteinMatch(long key, ProteinMatch proteinMatch)
Adds a protein match.void
addProteinMatches(HashMap<Long,Object> proteinMatches)
Adds a protein match.void
addSpectrumMatches(HashMap<Long,Object> spectrumMatches, WaitingHandler waitingHandler, boolean displayProgress)
Adds a spectrum matches into the database.void
close(boolean saveCache)
Closes the database connection.boolean
contains(long key)
Checks if database contains a certain object.HashSet<Long>
getClassObjects(Class className)
Returns the keys of the objects of the given class,HashSet<Long>
getClassObjects(Class className, String filters)
Returns the keys of the objects of the given class,String
getDatabaseDirectory()
Returns the database directory.ArrayList<String>
getFractions()
Returns the fractions.IdentificationKeys
getIdentificationKeys()
Returns the identification keys.int
getNumber(Class className)
Returns the number of objects of a given classObjectsDB
getObjectsDB()
Returns the objects database used in this class.HashSet<Long>
getPeptideIdentification()
Returns a list of the keys of all encountered peptides.PeptideMatch
getPeptideMatch(long key)
Returns the peptide match with the given key.PeptideMatchesIterator
getPeptideMatchesIterator(long[] peptideKeys, WaitingHandler waitingHandler)
Returns a peptide matches iterator for a given key list.PeptideMatchesIterator
getPeptideMatchesIterator(WaitingHandler waitingHandler)
Returns a peptide matches iterator for all PeptideMatches.HashSet<Long>
getProteinIdentification()
Returns a list of the keys of all encountered proteins.HashMap<String,HashSet<Long>>
getProteinMap()
Returns a map of all the protein matches which can be ascribed to a protein indexed by its accession.ProteinMatch
getProteinMatch(long key)
Returns the protein match with the given key.TreeSet<Long>
getProteinMatches(long peptideKey)
Returns the keys of the protein matches where a peptide can be found.ProteinMatchesIterator
getProteinMatchesIterator(long[] proteinKeys, WaitingHandler waitingHandler)
Returns a protein matches iterator for a given key list.ProteinMatchesIterator
getProteinMatchesIterator(WaitingHandler waitingHandler)
Returns a protein matches iterator for all PeptideMatches.HashMap<String,HashSet<Long>>
getSpectrumIdentification()
Returns a map of the spectrum matches keys indexed by spectrum file name.HashSet<Long>
getSpectrumIdentificationKeys()
Returns the keys of all the spectrum matches in the db.int
getSpectrumIdentificationSize()
Returns the number of spectrum identifications.SpectrumMatch
getSpectrumMatch(long key)
Returns the spectrum match with the given key.SpectrumMatchesIterator
getSpectrumMatchesIterator(long[] spectrumMatches, WaitingHandler waitingHandler)
Returns a spectrum matches iterator for a given key list.SpectrumMatchesIterator
getSpectrumMatchesIterator(WaitingHandler waitingHandler)
Returns a spectrum matches iterator for all SpectrumMatches.SpectrumMatchesIterator
getSpectrumMatchesIterator(WaitingHandler waitingHandler, String filters)
Returns a psm iterator for all SpectrumMatches.boolean
isConnectionActive()
Indicates whether the connection to the DB is active.void
loadObjects(Class className, WaitingHandler waitingHandler, boolean displayProgress)
Loads all objects of the class in cache.void
loadObjects(ArrayList<Long> keyList, WaitingHandler waitingHandler, boolean displayProgress)
Loads all objects of given keys in cache.void
removeObject(long key)
Removes an object from the database.void
removeObjects(ArrayList<Long> keys, WaitingHandler waitingHandler, boolean displayProgress)
Remove a list of objects from the database.Object
retrieveObject(long longKey)
Returns an array of all objects of a given list of keysArrayList<Object>
retrieveObjects(Class className, WaitingHandler waitingHandler, boolean displayProgress)
Returns an array of all objects of a given classArrayList<Object>
retrieveObjects(Collection<Long> keyList, WaitingHandler waitingHandler, boolean displayProgress)
Returns an array of all objects of a given list of keysvoid
setFractions(ArrayList<String> fractions)
Sets the fractions.void
setIdentificationKeys(IdentificationKeys identificationKeys)
Sets the identification keys.void
updateObject(long key, Object object)
Updates an object in the database.Methods inherited from class com.compomics.util.experiment.personalization.ExperimentObject
addUrParam, asLong, clearParametersMap, getId, getUrParam, getUrParams, removeUrParam, setId, setUrParams
-
Constructor Details
-
Identification
public Identification()Empty default constructor -
Identification
Constructor.- Parameters:
objectsDB
- The object database used to store the objects.
-
-
Method Details
-
getObjectsDB
Returns the objects database used in this class.- Returns:
- the objects database used in this class
-
getIdentificationKeys
Returns the identification keys.- Returns:
- the identification keys
-
setIdentificationKeys
Sets the identification keys.- Parameters:
identificationKeys
- the identification keys
-
getSpectrumIdentification
Returns a map of the spectrum matches keys indexed by spectrum file name.- Returns:
- a map of the spectrum matches keys indexed by spectrum file name
-
getSpectrumIdentificationKeys
Returns the keys of all the spectrum matches in the db.- Returns:
- the keys of all the spectrum matches in the db
-
getSpectrumIdentificationSize
public int getSpectrumIdentificationSize()Returns the number of spectrum identifications.- Returns:
- the number of spectrum identifications
-
getNumber
Returns the number of objects of a given class- Parameters:
className
- the class name of a given class- Returns:
- the number of objects
-
getClassObjects
Returns the keys of the objects of the given class,- Parameters:
className
- the class- Returns:
- the keys of the objects
-
getClassObjects
Returns the keys of the objects of the given class,- Parameters:
className
- the classfilters
- the filters- Returns:
- the keys of the objects
-
loadObjects
public void loadObjects(Class className, WaitingHandler waitingHandler, boolean displayProgress) throws InterruptedExceptionLoads all objects of the class in cache.- Parameters:
className
- the class namewaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler- Throws:
InterruptedException
- exception thrown if a threading error occurs while interacting with the database
-
loadObjects
public void loadObjects(ArrayList<Long> keyList, WaitingHandler waitingHandler, boolean displayProgress) throws InterruptedExceptionLoads all objects of given keys in cache.- Parameters:
keyList
- the list of keys of given objectswaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler- Throws:
InterruptedException
- exception thrown if a threading error occurs while interacting with the database
-
retrieveObject
Returns an array of all objects of a given list of keys- Parameters:
longKey
- the hash key- Returns:
- the objects
-
getSpectrumMatch
Returns the spectrum match with the given key.- Parameters:
key
- the key of the match- Returns:
- the spectrum match with the given key
-
getPeptideMatch
Returns the peptide match with the given key.- Parameters:
key
- the key of the match- Returns:
- the peptide match with the given key
-
getProteinMatch
Returns the protein match with the given key.- Parameters:
key
- the key of the match- Returns:
- the protein match with the given key
-
retrieveObjects
public ArrayList<Object> retrieveObjects(Collection<Long> keyList, WaitingHandler waitingHandler, boolean displayProgress)Returns an array of all objects of a given list of keys- Parameters:
keyList
- the key listwaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler- Returns:
- list of objects
-
retrieveObjects
public ArrayList<Object> retrieveObjects(Class className, WaitingHandler waitingHandler, boolean displayProgress)Returns an array of all objects of a given class- Parameters:
className
- the class namewaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler- Returns:
- list of objects
-
addObject
Adds an object into the database.- Parameters:
key
- the key of the objectobject
- the object
-
addObjects
public void addObjects(HashMap<Long,Object> objects, WaitingHandler waitingHandler, boolean displayProgress)Adds a list of objects into the database.- Parameters:
objects
- the objectwaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler
-
updateObject
Updates an object in the database.- Parameters:
key
- the key of the objectobject
- the object
-
removeObject
public void removeObject(long key)Removes an object from the database.- Parameters:
key
- the key of the object
-
contains
public boolean contains(long key)Checks if database contains a certain object.- Parameters:
key
- the key of the object- Returns:
- true if database contains a certain object otherwise false
-
removeObjects
public void removeObjects(ArrayList<Long> keys, WaitingHandler waitingHandler, boolean displayProgress)Remove a list of objects from the database.- Parameters:
keys
- the list of object keyswaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler
-
getDatabaseDirectory
Returns the database directory.- Returns:
- the database directory
-
getProteinIdentification
Returns a list of the keys of all encountered proteins.- Returns:
- the corresponding identification results
-
getPeptideIdentification
Returns a list of the keys of all encountered peptides.- Returns:
- the corresponding identification results
-
addPeptideMatch
Adds a peptide match. If an exception occurs when saving to the db it is thrown as runtime exception.- Parameters:
key
- the peptide match keypeptideMatch
- the peptide match
-
addPeptideMatches
Adds a peptide match. If an exception occurs when saving to the db it is thrown as runtime exception.- Parameters:
peptideMatches
- the peptide matches in a map
-
addSpectrumMatches
public void addSpectrumMatches(HashMap<Long,Object> spectrumMatches, WaitingHandler waitingHandler, boolean displayProgress)Adds a spectrum matches into the database.- Parameters:
spectrumMatches
- the spectrum matcheswaitingHandler
- the waiting handler allowing displaying progress and canceling the processdisplayProgress
- boolean indicating whether the progress of this method should be displayed on the waiting handler
-
addProteinMatch
Adds a protein match. If an exception occurs when saving to the db it is thrown as runtime exception.- Parameters:
key
- The match key.proteinMatch
- The protein match.
-
addProteinMatches
Adds a protein match. If an exception occurs when saving to the db it is thrown as runtime exception.- Parameters:
proteinMatches
- Map of the protein matches indexed by key.
-
getProteinMap
Returns a map of all the protein matches which can be ascribed to a protein indexed by its accession.- Returns:
- a map of all the protein matches which can be ascribed to a protein indexed by its accession.
-
close
public void close(boolean saveCache)Closes the database connection.- Parameters:
saveCache
- save the cache
-
isConnectionActive
public boolean isConnectionActive()Indicates whether the connection to the DB is active.- Returns:
- true if the connection to the DB is active
-
getProteinMatches
Returns the keys of the protein matches where a peptide can be found.- Parameters:
peptideKey
- the peptide key- Returns:
- the keys of the protein matches
-
getSpectrumMatchesIterator
public SpectrumMatchesIterator getSpectrumMatchesIterator(long[] spectrumMatches, WaitingHandler waitingHandler)Returns a spectrum matches iterator for a given key list.- Parameters:
spectrumMatches
- the keys of the spectra to iteratewaitingHandler
- the waiting handler- Returns:
- a spectrum matches iterator
-
getSpectrumMatchesIterator
Returns a spectrum matches iterator for all SpectrumMatches.- Parameters:
waitingHandler
- the waiting handler- Returns:
- a spectrum matches iterator
-
getSpectrumMatchesIterator
public SpectrumMatchesIterator getSpectrumMatchesIterator(WaitingHandler waitingHandler, String filters)Returns a psm iterator for all SpectrumMatches.- Parameters:
waitingHandler
- the waiting handlerfilters
- filters for the class- Returns:
- a peptide matches iterator
-
getPeptideMatchesIterator
public PeptideMatchesIterator getPeptideMatchesIterator(long[] peptideKeys, WaitingHandler waitingHandler)Returns a peptide matches iterator for a given key list.- Parameters:
peptideKeys
- the keys of the peptides to iteratewaitingHandler
- the waiting handler- Returns:
- a peptide matches iterator
-
getPeptideMatchesIterator
Returns a peptide matches iterator for all PeptideMatches.- Parameters:
waitingHandler
- the waiting handler- Returns:
- a peptide matches iterator
-
getProteinMatchesIterator
public ProteinMatchesIterator getProteinMatchesIterator(long[] proteinKeys, WaitingHandler waitingHandler)Returns a protein matches iterator for a given key list.- Parameters:
proteinKeys
- the keys of the peptides to iteratewaitingHandler
- the waiting handler- Returns:
- a peptide matches iterator
-
getProteinMatchesIterator
Returns a protein matches iterator for all PeptideMatches.- Parameters:
waitingHandler
- the waiting handler- Returns:
- a peptide matches iterator
-
addFraction
Adds a fraction, fractions correspond to the PSM files names. Fractions are ordered alphabetically upon adding of a new fraction.- Parameters:
fraction
- the fraction name
-
getFractions
Returns the fractions.- Returns:
- the fractions
-
setFractions
Sets the fractions.- Parameters:
fractions
- the fractions
-