public class NCBI2OWL extends NCBIConverter
The National Center for Biotechnology Information provides a Taxonomy Database with a large number of terms for classifying organisms. This tool converts that data to a Web Ontology Language (OWL) representation.
The latest NCBI Taxonomy data can be downloaded from
ftp://ftp.ebi.ac.uk/pub/databases/taxonomy/taxonomy.dat
(file size is more than 200MB).
The data format is line-based. Blocks are separated by "//",
and each line within the block provides the pair of a field name and a field
value separated by a colon. See the src/test/resources/sample.dat
file for an example.
This tool uses OWLAPI to create and manipulate the ontology, and depends on OBOFormat for the IRIs and labels of several annotation properties.
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
logger
Create a logger.
|
protected static String |
usage
Command line usage information.
|
Constructor and Description |
---|
NCBI2OWL() |
Modifier and Type | Method and Description |
---|---|
static void |
checkAxioms(String inputPath,
String outputPath)
Load an ontology from a file and then print a list of its axioms.
|
static org.semanticweb.owlapi.model.OWLOntology |
convertToOWL(String inputPath,
Map<String,String> uniqueNames)
Read a data file and create an OWL representation.
|
static org.semanticweb.owlapi.model.OWLOntology |
convertToOWL(String inputPath,
String outputPath,
InputStream mergeInfo,
InputStream citationInfo,
Map<String,String> uniqueNames)
Read a data file, create an OWL representation, and save an OWL file.
|
static org.semanticweb.owlapi.model.OWLOntology |
convertToOWL(String inputPath,
String outputPath,
Map<String,String> uniqueNames)
Read a data file, create an OWL representation, and save an OWL file.
|
static void |
error(String msg) |
protected static org.semanticweb.owlapi.model.OWLClass |
handleLine(org.semanticweb.owlapi.model.OWLOntology ontology,
Map<String,List<org.semanticweb.owlapi.model.OWLClass>> labels,
org.semanticweb.owlapi.model.OWLClass taxon,
String line,
int lineNumber)
Handle one line of the data file.
|
static void |
main(String[] args)
Handle command-line arguments when this class is used in an
executable Jar file.
|
static String[] |
parseLine(String line,
int lineNumber)
Parse a line of the data file into a pair of strings:
the field name and the field value.
|
static void |
printAxioms(org.semanticweb.owlapi.model.OWLOntology ontology,
String outputPath)
Print string representations of all the axioms in an ontology,
one axiom statement per line.
|
assertSubClass, checkTaxon, createNCBIIRI, createNCBIIRI, createTaxon, getTaxonID
annotate, annotate, annotate, annotate, annotate, annotate, assertSubAnnotationProperty, assertSubClass, createAnnotationProperty, createAnnotationProperty, createAnnotationProperty, declare, getFirstLiteral, getFirstLiteral, getFirstLiteral, initializeFormat, reformatName, synonym, synonym, updateAnnotation
protected static final org.apache.log4j.Logger logger
protected static String usage
public static void main(String[] args)
usage
.args
- one or more strings to provide options and pathspublic static void error(String msg)
public static org.semanticweb.owlapi.model.OWLOntology convertToOWL(String inputPath, Map<String,String> uniqueNames) throws IOException, org.semanticweb.owlapi.model.OWLOntologyCreationException, org.semanticweb.owlapi.model.OWLOntologyStorageException
inputPath
- the path to the input data file (e.g. taxonomy.dat)uniqueNames
- IOException
- if the paths do not resolveorg.semanticweb.owlapi.model.OWLOntologyCreationException
- if OWLAPI fails to create an
empty ontologyorg.semanticweb.owlapi.model.OWLOntologyStorageException
- if OWLAPI can't save the filepublic static org.semanticweb.owlapi.model.OWLOntology convertToOWL(String inputPath, String outputPath, Map<String,String> uniqueNames) throws IOException, org.semanticweb.owlapi.model.OWLOntologyCreationException, org.semanticweb.owlapi.model.OWLOntologyStorageException
inputPath
- the path to the input data file (e.g. taxonomy.dat)outputPath
- the path to the output OWL file
(e.g. ncbi_taxonomy.owl).uniqueNames
- IOException
- if the paths do not resolveorg.semanticweb.owlapi.model.OWLOntologyCreationException
- if OWLAPI fails to create an
empty ontologyorg.semanticweb.owlapi.model.OWLOntologyStorageException
- if OWLAPI can't save the filepublic static org.semanticweb.owlapi.model.OWLOntology convertToOWL(String inputPath, String outputPath, InputStream mergeInfo, InputStream citationInfo, Map<String,String> uniqueNames) throws IOException, org.semanticweb.owlapi.model.OWLOntologyCreationException, org.semanticweb.owlapi.model.OWLOntologyStorageException
inputPath
- the path to the input data file (e.g. taxonomy.dat)outputPath
- the path to the output OWL file
(e.g. ncbi_taxonomy.owl).mergeInfo
- the input stream of the merged informationcitationInfo
- the input stream of the citation informationuniqueNames
- IOException
- if the paths do not resolveorg.semanticweb.owlapi.model.OWLOntologyCreationException
- if OWLAPI fails to create an
empty ontologyorg.semanticweb.owlapi.model.OWLOntologyStorageException
- if OWLAPI can't save the fileprotected static org.semanticweb.owlapi.model.OWLClass handleLine(org.semanticweb.owlapi.model.OWLOntology ontology, Map<String,List<org.semanticweb.owlapi.model.OWLClass>> labels, org.semanticweb.owlapi.model.OWLClass taxon, String line, int lineNumber)
ontology
- the current ontologylabels
- a list to check that labels are uniquetaxon
- the current class or nullline
- the line to handlelineNumber
- for logging purposespublic static String[] parseLine(String line, int lineNumber)
line
- the line to be parsedlineNumber
- used for logging purposespublic static void checkAxioms(String inputPath, String outputPath) throws IOException, org.semanticweb.owlapi.model.OWLOntologyCreationException
inputPath
- the path for the input ontology fileoutputPath
- the path for the output fileIOException
- if it cannot write to the outputPathorg.semanticweb.owlapi.model.OWLOntologyCreationException
- if OWLAPI can't read the
ontology filepublic static void printAxioms(org.semanticweb.owlapi.model.OWLOntology ontology, String outputPath) throws IOException
ontology
- the ontology to printoutputPath
- the path for the output fileIOException
- if it cannot write to the outputPathCopyright © 2010–2015. All rights reserved.