com.compomics.util.preferences
Class GenePreferences

java.lang.Object
  extended by com.compomics.util.preferences.GenePreferences
All Implemented Interfaces:
Serializable

public class GenePreferences
extends Object
implements Serializable

Contains methods for downloading gene and GO mappings.

Author:
Harald Barsnes
See Also:
Serialized Form

Field Summary
static String GENE_MAPPING_FILE_SUFFIX
          The suffix to use for files containing gene mappings.
static String GENE_MAPPING_FOLDER
          The folder where gene mapping related info is stored.
static String GO_MAPPING_FILE_SUFFIX
          The suffix to use for files containing GO mappings.
 
Constructor Summary
GenePreferences()
          Create a new GenePreferences object.
GenePreferences(GenePreferences genePreferences)
          Creates new gene preferences based on a GenePreferences object.
 
Method Summary
 void createDefaultGeneMappingFiles(File aEnsemblVersionsFile, File aGoDomainsFile, File aSpeciesFile, File aDefaultSpeciesGoMappingsFile, File aDefaultSpeciesGeneMappingFile)
          Insert the default gene mappings files.
 void downloadGeneMappings(String ensemblType, String ensemblSchemaName, String selectedSpecies, String ensemblVersion, WaitingHandler waitingHandler)
          Download the gene mappings.
 boolean downloadGoMappings(String ensemblType, String ensemblSchemaName, String selectedSpecies, WaitingHandler waitingHandler)
          Download the GO mappings.
 HashMap<String,ArrayList<String>> getAllSpecies()
          Return the species lists.
 HashMap<String,HashMap<String,String>> getAllSpeciesMap()
          Returns the species map.
 String getCurrentSpecies()
          Returns the current species.
 String getCurrentSpeciesType()
          Returns the current species type.
 String getEnsemblDatabaseName(String speciesName)
          Deprecated. use the one with the Ensembl type parameter instead
 String getEnsemblDatabaseName(String ensemblType, String speciesName)
          Returns the Ensembl database name corresponding to a species name according to the speciesMap.
 String getEnsemblSpeciesVersion(String speciesName)
          Deprecated. use getEnsemblSpeciesVersion(String ensemblType, String speciesName) instead
 String getEnsemblSpeciesVersion(String ensemblType, String speciesName)
          Returns the Ensembl version for the given species name.
 String getEnsemblVersion(String ensemblDatabase)
          Returns the Ensembl version corresponding to the given Ensembl database according to the ensemblVersionsMap.
 HashMap<String,String> getEnsemblVersionsMap()
          Returns the Ensembl versions map.
 File getGeneMappingFolder()
          Returns the path to the folder containing the gene mapping files.
 HashMap<String,String> getGoDomainMap()
          Returns the GO domain map, e.g., key: GO term: GO:0007568, element: biological_process.
static String getProteinEvidencAsString(Integer type)
          Return the protein evidence type as text.
 ArrayList<String> getSpecies()
          Deprecated. use getAllSpecies instead
 HashMap<String,String> getSpeciesMap()
          Deprecated. use getAllSpeciesMap instead
 void loadEnsemblSpeciesVersions(File ensemblVersionsFile)
          Loads the given Ensembl species file.
 boolean loadGeneMappings(String jarFilePath, WaitingHandler waitingHandler)
          Imports the gene mappings.
 void loadSpeciesAndGoDomains()
          Load the mapping files.
 void setCurrentSpecies(String currentSpecies)
          Set the current species.
 void setCurrentSpeciesType(String currentSpeciesType)
          Set the current species type.
 void updateEnsemblVersion(String selectedSpecies, String ensemblVersion)
          Update the Ensembl version for the given species.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENE_MAPPING_FOLDER

public static final String GENE_MAPPING_FOLDER
The folder where gene mapping related info is stored.


GENE_MAPPING_FILE_SUFFIX

public static final String GENE_MAPPING_FILE_SUFFIX
The suffix to use for files containing gene mappings.

See Also:
Constant Field Values

GO_MAPPING_FILE_SUFFIX

public static final String GO_MAPPING_FILE_SUFFIX
The suffix to use for files containing GO mappings.

See Also:
Constant Field Values
Constructor Detail

GenePreferences

public GenePreferences()
Create a new GenePreferences object.


GenePreferences

public GenePreferences(GenePreferences genePreferences)
Creates new gene preferences based on a GenePreferences object.

Parameters:
genePreferences -
Method Detail

getProteinEvidencAsString

public static String getProteinEvidencAsString(Integer type)
Return the protein evidence type as text.

Parameters:
type - the type of evidence
Returns:
the protein evidence type as text

downloadGoMappings

public boolean downloadGoMappings(String ensemblType,
                                  String ensemblSchemaName,
                                  String selectedSpecies,
                                  WaitingHandler waitingHandler)
                           throws MalformedURLException,
                                  IOException
Download the GO mappings.

Parameters:
ensemblType - the Ensembl type, e.g., default or plants
ensemblSchemaName - the Ensembl schema name, e.g., default or plants_mart_18
selectedSpecies -
waitingHandler -
Returns:
true of the downloading was OK
Throws:
MalformedURLException
IOException

downloadGeneMappings

public void downloadGeneMappings(String ensemblType,
                                 String ensemblSchemaName,
                                 String selectedSpecies,
                                 String ensemblVersion,
                                 WaitingHandler waitingHandler)
                          throws MalformedURLException,
                                 IOException,
                                 IllegalArgumentException
Download the gene mappings.

Parameters:
ensemblType - the Ensembl type, e.g., default or plants
ensemblSchemaName - the Ensembl schema name, e.g., default or plants_mart_18
selectedSpecies -
ensemblVersion -
waitingHandler -
Throws:
MalformedURLException
IOException
IllegalArgumentException

getGeneMappingFolder

public File getGeneMappingFolder()
Returns the path to the folder containing the gene mapping files.

Returns:
the gene mapping folder

getCurrentSpecies

public String getCurrentSpecies()
Returns the current species.

Returns:
the currentSpecies

setCurrentSpecies

public void setCurrentSpecies(String currentSpecies)
Set the current species.

Parameters:
currentSpecies - the currentSpecies to set

getCurrentSpeciesType

public String getCurrentSpeciesType()
Returns the current species type.

Returns:
the currentSpeciesType

setCurrentSpeciesType

public void setCurrentSpeciesType(String currentSpeciesType)
Set the current species type.

Parameters:
currentSpeciesType - the currentSpeciesType to set

createDefaultGeneMappingFiles

public void createDefaultGeneMappingFiles(File aEnsemblVersionsFile,
                                          File aGoDomainsFile,
                                          File aSpeciesFile,
                                          File aDefaultSpeciesGoMappingsFile,
                                          File aDefaultSpeciesGeneMappingFile)
Insert the default gene mappings files. If newer versions of the mapping exists they will not be overwritten.

Parameters:
aEnsemblVersionsFile -
aGoDomainsFile -
aSpeciesFile -
aDefaultSpeciesGoMappingsFile -
aDefaultSpeciesGeneMappingFile -

loadSpeciesAndGoDomains

public void loadSpeciesAndGoDomains()
                             throws IOException,
                                    IllegalArgumentException
Load the mapping files.

Throws:
IOException
IllegalArgumentException

getGoDomainMap

public HashMap<String,String> getGoDomainMap()
Returns the GO domain map, e.g., key: GO term: GO:0007568, element: biological_process.

Returns:
the goDomainMap

getSpeciesMap

public HashMap<String,String> getSpeciesMap()
Deprecated. use getAllSpeciesMap instead

Returns the species map. Key: latin name, element: Ensembl database name, e.g., key: Homo sapiens, element: hsapiens.

Returns:
the speciesMap

getAllSpeciesMap

public HashMap<String,HashMap<String,String>> getAllSpeciesMap()
Returns the species map. Main key: Ensembl type, e.g., Vertebrates or Plants. Next level: key: latin name, element: ensembl database name, e.g., key: Homo sapiens, element: hsapiens_gene_ensembl.

Returns:
the speciesMap

getEnsemblDatabaseName

public String getEnsemblDatabaseName(String speciesName)
Deprecated. use the one with the Ensembl type parameter instead

Returns the Ensembl database name corresponding to a species name according to the speciesMap. Null if not found.

Parameters:
speciesName - the species name as available in the species list
Returns:
the Ensembl database name

getEnsemblDatabaseName

public String getEnsemblDatabaseName(String ensemblType,
                                     String speciesName)
Returns the Ensembl database name corresponding to a species name according to the speciesMap. Null if not found.

Parameters:
ensemblType - the Ensembl type, e.g., Vertebrates or Plants
speciesName - the species name as available in the species list
Returns:
the Ensembl database name

getEnsemblVersionsMap

public HashMap<String,String> getEnsemblVersionsMap()
Returns the Ensembl versions map.

Returns:
the ensemblVersionsMap

getEnsemblVersion

public String getEnsemblVersion(String ensemblDatabase)
Returns the Ensembl version corresponding to the given Ensembl database according to the ensemblVersionsMap. Null if not found.

Parameters:
ensemblDatabase - the Ensembl database
Returns:
the Ensembl version

getEnsemblSpeciesVersion

public String getEnsemblSpeciesVersion(String speciesName)
Deprecated. use getEnsemblSpeciesVersion(String ensemblType, String speciesName) instead

Returns the Ensembl version for the given species name. Null if not found.

Parameters:
speciesName - the species name as available in the species list
Returns:
the Ensembl version

getEnsemblSpeciesVersion

public String getEnsemblSpeciesVersion(String ensemblType,
                                       String speciesName)
Returns the Ensembl version for the given species name. Null if not found.

Parameters:
ensemblType - the Ensembl type, e.g., Vertebrates or Plants
speciesName - the species name as available in the species list
Returns:
the Ensembl version

getSpecies

public ArrayList<String> getSpecies()
Deprecated. use getAllSpecies instead

Return the species list. NB: also contains species separators.

Returns:
the species

getAllSpecies

public HashMap<String,ArrayList<String>> getAllSpecies()
Return the species lists.

Returns:
the species

updateEnsemblVersion

public void updateEnsemblVersion(String selectedSpecies,
                                 String ensemblVersion)
                          throws IOException
Update the Ensembl version for the given species.

Parameters:
selectedSpecies - the database name of the species to update, e.g., hsapiens_gene_ensembl
ensemblVersion - the new Ensembl version
Throws:
IOException

loadEnsemblSpeciesVersions

public void loadEnsemblSpeciesVersions(File ensemblVersionsFile)
                                throws FileNotFoundException,
                                       IOException
Loads the given Ensembl species file.

Parameters:
ensemblVersionsFile - the Ensembl species file to load
Throws:
FileNotFoundException
IOException

loadGeneMappings

public boolean loadGeneMappings(String jarFilePath,
                                WaitingHandler waitingHandler)
Imports the gene mappings.

Parameters:
jarFilePath - the jar file path
waitingHandler - the waiting handler
Returns:
a boolean indicating whether the loading was successful


Copyright © 2013. All Rights Reserved.