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
  • Constructor Details

    • Identification

      public Identification()
      Empty default constructor
    • Identification

      public Identification​(ObjectsDB objectsDB)
      Constructor.
      Parameters:
      objectsDB - The object database used to store the objects.
  • Method Details

    • getObjectsDB

      public ObjectsDB getObjectsDB()
      Returns the objects database used in this class.
      Returns:
      the objects database used in this class
    • getIdentificationKeys

      public IdentificationKeys getIdentificationKeys()
      Returns the identification keys.
      Returns:
      the identification keys
    • setIdentificationKeys

      public void setIdentificationKeys​(IdentificationKeys identificationKeys)
      Sets the identification keys.
      Parameters:
      identificationKeys - the identification keys
    • getSpectrumIdentification

      public HashMap<String,​HashSet<Long>> 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

      public HashSet<Long> 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

      public int getNumber​(Class className)
      Returns the number of objects of a given class
      Parameters:
      className - the class name of a given class
      Returns:
      the number of objects
    • getClassObjects

      public HashSet<Long> getClassObjects​(Class className)
      Returns the keys of the objects of the given class,
      Parameters:
      className - the class
      Returns:
      the keys of the objects
    • getClassObjects

      public HashSet<Long> getClassObjects​(Class className, String filters)
      Returns the keys of the objects of the given class,
      Parameters:
      className - the class
      filters - the filters
      Returns:
      the keys of the objects
    • loadObjects

      public void loadObjects​(Class className, WaitingHandler waitingHandler, boolean displayProgress) throws InterruptedException
      Loads all objects of the class in cache.
      Parameters:
      className - the class name
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - 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 InterruptedException
      Loads all objects of given keys in cache.
      Parameters:
      keyList - the list of keys of given objects
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - 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

      public Object retrieveObject​(long longKey)
      Returns an array of all objects of a given list of keys
      Parameters:
      longKey - the hash key
      Returns:
      the objects
    • getSpectrumMatch

      public SpectrumMatch getSpectrumMatch​(long key)
      Returns the spectrum match with the given key.
      Parameters:
      key - the key of the match
      Returns:
      the spectrum match with the given key
    • getPeptideMatch

      public PeptideMatch getPeptideMatch​(long key)
      Returns the peptide match with the given key.
      Parameters:
      key - the key of the match
      Returns:
      the peptide match with the given key
    • getProteinMatch

      public ProteinMatch getProteinMatch​(long key)
      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 list
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - 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 name
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - boolean indicating whether the progress of this method should be displayed on the waiting handler
      Returns:
      list of objects
    • addObject

      public void addObject​(long key, Object object)
      Adds an object into the database.
      Parameters:
      key - the key of the object
      object - 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 object
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - boolean indicating whether the progress of this method should be displayed on the waiting handler
    • updateObject

      public void updateObject​(long key, Object object)
      Updates an object in the database.
      Parameters:
      key - the key of the object
      object - 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 keys
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - boolean indicating whether the progress of this method should be displayed on the waiting handler
    • getDatabaseDirectory

      public String getDatabaseDirectory()
      Returns the database directory.
      Returns:
      the database directory
    • getProteinIdentification

      public HashSet<Long> getProteinIdentification()
      Returns a list of the keys of all encountered proteins.
      Returns:
      the corresponding identification results
    • getPeptideIdentification

      public HashSet<Long> getPeptideIdentification()
      Returns a list of the keys of all encountered peptides.
      Returns:
      the corresponding identification results
    • addPeptideMatch

      public void addPeptideMatch​(long key, PeptideMatch peptideMatch)
      Adds a peptide match. If an exception occurs when saving to the db it is thrown as runtime exception.
      Parameters:
      key - the peptide match key
      peptideMatch - the peptide match
    • addPeptideMatches

      public void addPeptideMatches​(HashMap<Long,​Object> peptideMatches)
      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 matches
      waitingHandler - the waiting handler allowing displaying progress and canceling the process
      displayProgress - boolean indicating whether the progress of this method should be displayed on the waiting handler
    • addProteinMatch

      public void addProteinMatch​(long key, ProteinMatch proteinMatch)
      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

      public void addProteinMatches​(HashMap<Long,​Object> proteinMatches)
      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

      public HashMap<String,​HashSet<Long>> 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

      public TreeSet<Long> getProteinMatches​(long peptideKey)
      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 iterate
      waitingHandler - the waiting handler
      Returns:
      a spectrum matches iterator
    • getSpectrumMatchesIterator

      public SpectrumMatchesIterator getSpectrumMatchesIterator​(WaitingHandler waitingHandler)
      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 handler
      filters - 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 iterate
      waitingHandler - the waiting handler
      Returns:
      a peptide matches iterator
    • getPeptideMatchesIterator

      public PeptideMatchesIterator getPeptideMatchesIterator​(WaitingHandler waitingHandler)
      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 iterate
      waitingHandler - the waiting handler
      Returns:
      a peptide matches iterator
    • getProteinMatchesIterator

      public ProteinMatchesIterator getProteinMatchesIterator​(WaitingHandler waitingHandler)
      Returns a protein matches iterator for all PeptideMatches.
      Parameters:
      waitingHandler - the waiting handler
      Returns:
      a peptide matches iterator
    • addFraction

      public void addFraction​(String fraction)
      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

      public ArrayList<String> getFractions()
      Returns the fractions.
      Returns:
      the fractions
    • setFractions

      public void setFractions​(ArrayList<String> fractions)
      Sets the fractions.
      Parameters:
      fractions - the fractions