JAL-1191 stub class for a SequenceOntology wrapper
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 22 Dec 2015 09:28:04 +0000 (09:28 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 22 Dec 2015 09:28:04 +0000 (09:28 +0000)
src/jalview/io/gff/SequenceOntology.java [new file with mode: 0644]

diff --git a/src/jalview/io/gff/SequenceOntology.java b/src/jalview/io/gff/SequenceOntology.java
new file mode 100644 (file)
index 0000000..c437f86
--- /dev/null
@@ -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);
+  }
+}