com.compomics.util.experiment.identification
Class Identification

java.lang.Object
  extended by com.compomics.util.experiment.personalization.ExperimentObject
      extended by com.compomics.util.experiment.identification.Identification
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
Ms2Identification

public abstract class Identification
extends ExperimentObject

This class contains identification results.

Author:
Marc Vaudel
See Also:
Serialized Form

Field Summary
protected  boolean automatedMemoryManagement
          boolean indicating whether the memory management should be done automatically.
protected  int cacheSize
          The cache size in number of matches. 20000 by default: should be enough to contain a velos file.
static String EXTENTION
          Extention for a serialized hit. cuh for Compomics Utilities Hit.
protected  boolean inMemory
          boolean indicating whether the identification should be stored in memory or not.
protected  ArrayList<String> loadedMatches
          List of the loaded matches with the most used matches in the end
protected  HashMap<String,Object> loadedMatchesMap
          Map of the loaded matches
protected  ArrayList<String> longKeys
          Map of long keys which will be referenced by their index for file creation
protected  int methodUsed
          The method used.
protected  HashMap<String,Boolean> modifiedMatches
          Map indicating whether a match is modified.
protected  ArrayList<String> peptideIdentification
          List of the keys of all imported peptides
protected  ArrayList<String> proteinIdentification
          List of the keys of all imported proteins
protected  HashMap<String,ArrayList<String>> proteinMap
          a map linking protein accessions to all their protein matches keys
protected  String serializationDirectory
          the directory where matches will be serialized
protected  ArrayList<String> spectrumIdentification
          List of the keys of all imported psms
protected  HashMap<String,HashMap<String,UrParameter>> urParameters
          Map of the user's parameters.
 
Constructor Summary
Identification()
           
 
Method Summary
 void addMatchParameter(String key, UrParameter urParameter)
          Adds a parameter with a corresponding match key which will be loaded in the memory.
 void addSpectrumMatch(Set<SpectrumMatch> spectrumMatches)
          Add a set of spectrumMatches to the model
 void addSpectrumMatch(SpectrumMatch newMatch)
          Add a spectrum match to the spectrum matches map.
 void buildPeptidesAndProteins(JProgressBar progressBar)
          Creates the peptides and protein instances based on the spectrum matches.
 void buildPeptidesAndProteins(String spectrumMatchKey)
          Creates the peptides and protein instances based on the given spectrum match.
 void emptyCache(ProgressDialogX progressDialog)
          Empties the cache and serializes everything in the specified serialization folder
 int getCacheSize()
          Returns the cache size in number of matches
 String getFileName(String key)
          Returns the name of the file to use for serialization/deserialization
 UrParameter getMatchParameter(String matchKey, UrParameter urParameter)
          Returns the personalization parameter of the given match
 int getMethodUsed()
          Getter for the identification method used
 ArrayList<String> getPeptideIdentification()
          Returns a list of the keys of all encountered peptides.
 PeptideMatch getPeptideMatch(String peptideKey)
          Returns a peptide match
 ArrayList<String> getProteinIdentification()
          Returns a list of the keys of all encountered proteins.
 HashMap<String,ArrayList<String>> getProteinMap()
          Returns a map of all the protein matches which can be ascribed to a protein indexed by its accession.
 ProteinMatch getProteinMatch(String proteinKey)
          Returns a protein match.
 String getSerializationDirectory()
          Returns the serialization directory
 ArrayList<String> getSpectrumIdentification()
          Returns a list of the keys of all encountered psms.
 SpectrumMatch getSpectrumMatch(String spectrumKey)
          Returns a spectrum match
 boolean isAutomatedMemoryManagement()
          Returns whether the memory management is automated.
 boolean isInMemory()
          Indicates whether matches will be stored in memory
 boolean matchExists(String matchKey)
          Indicates whether a match indexed by the given key exists
 boolean memoryCheck()
          Indicates whether the memory used by the application is lower than 99% of the heap size.
 void reduceMemoryConsumtion(JProgressBar progressBar)
          Reduces the amount of identification saved in memory by 20%.
 void removeMatch(String matchKey)
          Removes a match from the model
 void save(File newFolder, ProgressDialogX progressDialog)
          Saves the identification matches in the desired folder
 void setAutomatedMemoryManagement(boolean automatedMemoryManagement)
          Sets whether the memory management should be automated
 void setCacheSize(int cacheSize)
          Sets the cache size
 void setInMemory(boolean inMemory)
          Sets whether matches shall be stored in memory
 void setMatchChanged(IdentificationMatch match)
          Indicates that a match was changed, it will thus be serialized again if needed.
 void setSerializationDirectory(String serializationDirectory)
          sets the serialization directory
 void updateCache()
          Updates the cache according to the memory settings.
 
Methods inherited from class com.compomics.util.experiment.personalization.ExperimentObject
addUrParam, getParameterKey, getUrParam
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENTION

public static final String EXTENTION
Extention for a serialized hit. cuh for Compomics Utilities Hit.

See Also:
Constant Field Values

proteinIdentification

protected ArrayList<String> proteinIdentification
List of the keys of all imported proteins


peptideIdentification

protected ArrayList<String> peptideIdentification
List of the keys of all imported peptides


spectrumIdentification

protected ArrayList<String> spectrumIdentification
List of the keys of all imported psms


proteinMap

protected HashMap<String,ArrayList<String>> proteinMap
a map linking protein accessions to all their protein matches keys


methodUsed

protected int methodUsed
The method used.


cacheSize

protected int cacheSize
The cache size in number of matches. 20000 by default: should be enough to contain a velos file.


serializationDirectory

protected String serializationDirectory
the directory where matches will be serialized


inMemory

protected boolean inMemory
boolean indicating whether the identification should be stored in memory or not. True by default, the serialization directory should be set otherwise!


automatedMemoryManagement

protected boolean automatedMemoryManagement
boolean indicating whether the memory management should be done automatically. If true, the cache size will be extended to reach 90% of the available heap size when inMemory is wrong. True by default.


loadedMatchesMap

protected HashMap<String,Object> loadedMatchesMap
Map of the loaded matches


loadedMatches

protected ArrayList<String> loadedMatches
List of the loaded matches with the most used matches in the end


modifiedMatches

protected HashMap<String,Boolean> modifiedMatches
Map indicating whether a match is modified. Only modified matches will be serialized.


urParameters

protected HashMap<String,HashMap<String,UrParameter>> urParameters
Map of the user's parameters.


longKeys

protected ArrayList<String> longKeys
Map of long keys which will be referenced by their index for file creation

Constructor Detail

Identification

public Identification()
Method Detail

addMatchParameter

public void addMatchParameter(String key,
                              UrParameter urParameter)
Adds a parameter with a corresponding match key which will be loaded in the memory. Use this method only for frequently used parameters, otherwise attach the parameters to the matches.

Parameters:
key - the key of the parameter
urParameter - the additional parameter

getMatchParameter

public UrParameter getMatchParameter(String matchKey,
                                     UrParameter urParameter)
Returns the personalization parameter of the given match

Parameters:
matchKey - the match key
urParameter - example of parameter to retrieve
Returns:
the personalization parameter

isAutomatedMemoryManagement

public boolean isAutomatedMemoryManagement()
Returns whether the memory management is automated.

Returns:
whether the memory management is automated.

setAutomatedMemoryManagement

public void setAutomatedMemoryManagement(boolean automatedMemoryManagement)
Sets whether the memory management should be automated

Parameters:
automatedMemoryManagement - a boolean indicating whether the memory management should be automated

getCacheSize

public int getCacheSize()
Returns the cache size in number of matches

Returns:
the cache size in number of matches

setCacheSize

public void setCacheSize(int cacheSize)
Sets the cache size

Parameters:
cacheSize - number of matches to allow in the cache size

isInMemory

public boolean isInMemory()
Indicates whether matches will be stored in memory

Returns:
a boolean indicating whether matches will be stored in memory

setInMemory

public void setInMemory(boolean inMemory)
Sets whether matches shall be stored in memory

Parameters:
inMemory - a boolean indicating whether matches shall be stored in memory

getSerializationDirectory

public String getSerializationDirectory()
Returns the serialization directory

Returns:
the serialization directory

setSerializationDirectory

public void setSerializationDirectory(String serializationDirectory)
sets the serialization directory

Parameters:
serializationDirectory - the path of the serialization directory

removeMatch

public void removeMatch(String matchKey)
Removes a match from the model

Parameters:
matchKey - the key of the match to remove

matchExists

public boolean matchExists(String matchKey)
Indicates whether a match indexed by the given key exists

Parameters:
matchKey - the key of the match looked for
Returns:
a boolean indicating whether a match indexed by the given key exists

getSpectrumMatch

public SpectrumMatch getSpectrumMatch(String spectrumKey)
                               throws IllegalArgumentException
Returns a spectrum match

Parameters:
spectrumKey - the key of the match
Returns:
the desired match
Throws:
IllegalArgumentException - exception thrown whenever an error occurred while retrieving the match

getPeptideMatch

public PeptideMatch getPeptideMatch(String peptideKey)
                             throws IllegalArgumentException
Returns a peptide match

Parameters:
peptideKey - the key of the match
Returns:
the desired match
Throws:
IllegalArgumentException - exception thrown whenever an error occurred while retrieving the match

getProteinMatch

public ProteinMatch getProteinMatch(String proteinKey)
                             throws IllegalArgumentException
Returns a protein match.

Parameters:
proteinKey - the key of the match
Returns:
the desired match
Throws:
IllegalArgumentException - exception thrown whenever an error occurred while retrieving the match

getProteinIdentification

public ArrayList<String> getProteinIdentification()
Returns a list of the keys of all encountered proteins.

Returns:
the corresponding identification results

getPeptideIdentification

public ArrayList<String> getPeptideIdentification()
Returns a list of the keys of all encountered peptides.

Returns:
the corresponding identification results

getSpectrumIdentification

public ArrayList<String> getSpectrumIdentification()
Returns a list of the keys of all encountered psms.

Returns:
the corresponding identification results

addSpectrumMatch

public void addSpectrumMatch(SpectrumMatch newMatch)
                      throws FileNotFoundException,
                             IOException
Add a spectrum match to the spectrum matches map.

Parameters:
newMatch - the new spectrum match
Throws:
FileNotFoundException
IOException

updateCache

public void updateCache()
                 throws FileNotFoundException,
                        IOException
Updates the cache according to the memory settings.

Throws:
FileNotFoundException - exception thrown whenever an error occurred while serializing a match
IOException - exception thrown whenever an error occurred while serializing a match

memoryCheck

public boolean memoryCheck()
Indicates whether the memory used by the application is lower than 99% of the heap size.

Returns:
a boolean indicating whether the memory used by the application is lower than 99% of the heap

reduceMemoryConsumtion

public void reduceMemoryConsumtion(JProgressBar progressBar)
                            throws FileNotFoundException,
                                   IOException
Reduces the amount of identification saved in memory by 20%.

Parameters:
progressBar - the progress bar
Throws:
FileNotFoundException - exception thrown whenever an error occurred while serializing a match
IOException - exception thrown whenever an error occurred while serializing a match

buildPeptidesAndProteins

public void buildPeptidesAndProteins(JProgressBar progressBar)
Creates the peptides and protein instances based on the spectrum matches. Note that the attribute bestAssumption should be set for every spectrum match at this point. This operation will be very slow if the cache is already full.

Parameters:
progressBar - the progress bar

buildPeptidesAndProteins

public void buildPeptidesAndProteins(String spectrumMatchKey)
Creates the peptides and protein instances based on the given spectrum match. Note that the attribute bestAssumption should be set for every spectrum match at this point. This operation will be very slow if the cache is already full.

Parameters:
spectrumMatchKey - The key of the spectrum match to add

emptyCache

public void emptyCache(ProgressDialogX progressDialog)
                throws FileNotFoundException,
                       IOException
Empties the cache and serializes everything in the specified serialization folder

Parameters:
progressDialog -
Throws:
FileNotFoundException - exception thrown whenever an error occurred while serializing a match
IOException - exception thrown whenever an error occurred while serializing a match

addSpectrumMatch

public void addSpectrumMatch(Set<SpectrumMatch> spectrumMatches)
                      throws FileNotFoundException,
                             IOException
Add a set of spectrumMatches to the model

Parameters:
spectrumMatches - The spectrum matches
Throws:
FileNotFoundException - exception thrown when one tries to assign more than one identification per advocate to the same spectrum
IOException - exception thrown when one tries to assign more than one identification per advocate to the same spectrum

getMethodUsed

public int getMethodUsed()
Getter for the identification method used

Returns:
the identification method used

getProteinMap

public HashMap<String,ArrayList<String>> 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.

setMatchChanged

public void setMatchChanged(IdentificationMatch match)
                     throws IllegalArgumentException
Indicates that a match was changed, it will thus be serialized again if needed.

Parameters:
match -
Throws:
IllegalArgumentException

save

public void save(File newFolder,
                 ProgressDialogX progressDialog)
          throws FileNotFoundException,
                 IOException
Saves the identification matches in the desired folder

Parameters:
newFolder - the new folder
progressDialog - a progress dialog to display the progress (can be null)
Throws:
FileNotFoundException - Exception thrown whenever a problem occurred during the serialization process
IOException - Exception thrown whenever a problem occurred during the serialization process

getFileName

public String getFileName(String key)
Returns the name of the file to use for serialization/deserialization

Parameters:
key - the key of the match
Returns:
the name of the corresponding file


Copyright © 2012. All Rights Reserved.