JAL-553 JAL-1557 always send selections after triggering the PaintRefreser for a...
[jalview.git] / src / jalview / analysis / AlignmentUtils.java
index fa135f8..fba023f 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;
@@ -38,6 +40,7 @@ import jalview.schemes.ResidueProperties;
 import jalview.util.Comparison;
 import jalview.util.MapList;
 import jalview.util.MappingUtils;
+import jalview.util.StringUtils;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
@@ -69,7 +72,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
@@ -1926,11 +1928,16 @@ public class AlignmentUtils
                     .codonTranslate(codon));
     if (trans != null && !trans.equals(residue))
     {
-      String desc = residue + "->" + trans;
-      // set score to 0f so 'graduated colour' option is offered!
+      String residue3Char = StringUtils
+              .toSentenceCase(ResidueProperties.aa2Triplet.get(residue));
+      String trans3Char = StringUtils
+              .toSentenceCase(ResidueProperties.aa2Triplet.get(trans));
+      String desc = "p." + residue3Char + peptidePos + trans3Char;
+      // set score to 0f so 'graduated colour' option is offered! JAL-2060
       SequenceFeature sf = new SequenceFeature(
               SequenceOntologyI.SEQUENCE_VARIANT, desc, peptidePos,
-              peptidePos, 0f, null);
+              peptidePos, 0f, "Jalview");
+      StringBuilder attributes = new StringBuilder(32);
       String id = (String) var.variant.getValue(ID);
       if (id != null)
       {
@@ -1939,6 +1946,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 +1965,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;