From: gmungoc Date: Tue, 22 Dec 2015 09:28:04 +0000 (+0000) Subject: JAL-1191 stub class for a SequenceOntology wrapper X-Git-Tag: Release_2_10_0~296^2~98 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e5770a4f8047fc5356c7bbd55fb37747e948e5cf;p=jalview.git JAL-1191 stub class for a SequenceOntology wrapper --- diff --git a/src/jalview/io/gff/SequenceOntology.java b/src/jalview/io/gff/SequenceOntology.java new file mode 100644 index 0000000..c437f86 --- /dev/null +++ b/src/jalview/io/gff/SequenceOntology.java @@ -0,0 +1,67 @@ +package jalview.io.gff; + +/** + * A wrapper class that parses the Sequence Ontology and exposes useful access + * methods + */ +public class SequenceOntology +{ + private static SequenceOntology instance = new SequenceOntology(); + + public static SequenceOntology getInstance() + { + return instance; + } + + /** + * Private constructor to enforce use of singleton. + */ + private SequenceOntology() + { + // TODO: parse and cache so.obo data file e.g. using BioJava + } + + /** + * Test whether the given Sequence Ontology term is nucleotide_match (either + * directly or via is_a relationship) + * + * @param soTerm + * @return + */ + public boolean isNucleotideMatch(String soTerm) + { + // temporary until OBO parser is in place! + // (which should also match SO ids e.g. "SO:0000347") + String[] nucMatch = { "nucleotide_match", "primer_match", + "cross_genome_match", "expressed_sequence_match", + "translated_nucleotide_match", "UST_match", "RSF_match", + "cDNA_match", "EST_match" }; + for (int i = 0; i < nucMatch.length; i++) + { + if (nucMatch[i].equals(soTerm)) + { + return true; + } + } + return false; + } + + /** + * Test whether the given Sequence Ontology term is protein_match (either + * directly or via is_a relationship) + * + * @param soTerm + * @return + */ + public boolean isProteinMatch(String soTerm) + { + // temporary until OBO parser is in place! + return "protein_match".equals(soTerm) + || "protein_hmm_match".equals(soTerm); + } + + public boolean isPolypeptide(String soTerm) + { + return "polypeptide".equals(soTerm); + } +}