JAL-1191 use full SO in desktop application
[jalview.git] / src / jalview / io / gff / Gff3Helper.java
index d878f64..031900d 100644 (file)
@@ -69,12 +69,13 @@ public class Gff3Helper extends GffHelperBase
       String atts = gff[ATTRIBUTES_COL];
       Map<String, List<String>> attributes = parseNameValuePairs(atts);
 
-      if (SequenceOntology.getInstance().isProteinMatch(soTerm))
+      SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+      if (so.isA(soTerm, SequenceOntologyI.PROTEIN_MATCH))
       {
-        sf = processProteinMatch(attributes, seq, gff, align,
-                newseqs, relaxedIdMatching);
+        sf = processProteinMatch(attributes, seq, gff, align, newseqs,
+                relaxedIdMatching);
       }
-      else if (SequenceOntology.getInstance().isNucleotideMatch(soTerm))
+      else if (so.isA(soTerm, SequenceOntologyI.NUCLEOTIDE_MATCH))
       {
         sf = processNucleotideMatch(attributes, seq, gff, align,
                 newseqs, relaxedIdMatching);
@@ -371,7 +372,9 @@ public class Gff3Helper extends GffHelperBase
       desc = target.split(" ")[0];
     }
 
-    if (SequenceOntology.getInstance().isSequenceVariant(sf.getType()))
+    SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+    String type = sf.getType();
+    if (so.isA(type, SequenceOntologyI.SEQUENCE_VARIANT))
     {
       /*
        * Ensembl returns dna variants as 'alleles'
@@ -379,6 +382,26 @@ public class Gff3Helper extends GffHelperBase
       desc = StringUtils.listToDelimitedString(
               attributes.get("alleles"), ",");
     }
+
+    /*
+     * extract 'Name' for a transcript (to show gene name)
+     * or an exon (so 'colour by label' shows exon boundaries) 
+     */
+    if (SequenceOntologyI.NMD_TRANSCRIPT_VARIANT.equals(type)
+            || so.isA(type, SequenceOntologyI.TRANSCRIPT)
+            || so.isA(type, SequenceOntologyI.EXON))
+    {
+      desc = StringUtils.listToDelimitedString(attributes.get("Name"), ",");
+    }
+
+    /*
+     * if the above fails, try ID
+     */
+    if (desc == null)
+    {
+      desc = (String) sf.getValue(ID);
+    }
+
     return desc;
   }
 }