JAL-2041 add ID,clinical_significance to feature attributes (for export)
[jalview.git] / src / jalview / analysis / AlignmentUtils.java
index fa135f8..42a1201 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.analysis;
 
+import static jalview.io.gff.GffConstants.CLINICAL_SIGNIFICANCE;
+
 import jalview.datamodel.AlignedCodon;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.Alignment;
@@ -69,7 +71,6 @@ public class AlignmentUtils
 
   private static final String SEQUENCE_VARIANT = "sequence_variant:";
   private static final String ID = "ID";
-  private static final String CLINICAL_SIGNIFICANCE = "clinical_significance";
 
   /**
    * A data model to hold the 'normal' base value at a position, and an optional
@@ -1927,10 +1928,11 @@ public class AlignmentUtils
     if (trans != null && !trans.equals(residue))
     {
       String desc = residue + "->" + trans;
-      // set score to 0f so 'graduated colour' option is offered!
+      // set score to 0f so 'graduated colour' option is offered! JAL-2060
       SequenceFeature sf = new SequenceFeature(
               SequenceOntologyI.SEQUENCE_VARIANT, desc, peptidePos,
               peptidePos, 0f, null);
+      StringBuilder attributes = new StringBuilder(32);
       String id = (String) var.variant.getValue(ID);
       if (id != null)
       {
@@ -1939,6 +1941,7 @@ public class AlignmentUtils
           id = id.substring(SEQUENCE_VARIANT.length());
         }
         sf.setValue(ID, id);
+        attributes.append(ID).append("=").append(id);
         // TODO handle other species variants
         StringBuilder link = new StringBuilder(32);
         try
@@ -1957,8 +1960,14 @@ public class AlignmentUtils
       if (clinSig != null)
       {
         sf.setValue(CLINICAL_SIGNIFICANCE, clinSig);
+        attributes.append(";").append(CLINICAL_SIGNIFICANCE).append("=")
+                .append(clinSig);
       }
       peptide.addSequenceFeature(sf);
+      if (attributes.length() > 0)
+      {
+        sf.setAttributes(attributes.toString());
+      }
       return true;
     }
     return false;