JAL-3691 patch toUpper/toLower to use Locale.ROOT for 2.11.2 src
[jalview.git] / src / mc_view / PDBChain.java
index a3c8bee..97514e9 100755 (executable)
@@ -35,6 +35,7 @@ import jalview.util.Comparison;
 
 import java.awt.Color;
 import java.util.List;
+import java.util.Locale;
 import java.util.Vector;
 
 public class PDBChain
@@ -78,10 +79,27 @@ public class PDBChain
 
   public String pdbid = "";
 
-  public PDBChain(String thePdbid, String theId)
+  String tfacName = "Temperature Factor";
+
+
+  public PDBChain(String thePdbid, String theId, String tempFactorColumnName)
   {
-    this.pdbid = thePdbid == null ? thePdbid : thePdbid.toLowerCase();
+    this.pdbid = thePdbid == null ? thePdbid : thePdbid.toLowerCase(Locale.ROOT);
     this.id = theId;
+    if (tempFactorColumnName!=null && tempFactorColumnName.length()>0)
+    {
+      tfacName = tempFactorColumnName;
+    }
+  }
+
+  /**
+   * import chain data assuming Temperature Factor is in the Temperature Factor column
+   * @param thePdbid
+   * @param theId
+   */
+  public PDBChain(String thePdbid, String theId)
+  {
+    this(thePdbid,theId, null);
   }
 
   /**
@@ -212,10 +230,16 @@ public class PDBChain
    * @param seq
    * @param status
    *          The Status of the transferred annotation
+   * 
+   * @param altPDBID the group id for the features on the destination sequence (e.g. the official accession ID)
    */
   public void transferRESNUMFeatures(SequenceI seq,
-          String status)
+          String status, String altPDBID)
   {
+    if (altPDBID==null)
+    {
+      altPDBID = pdbid;
+    }
     SequenceI sq = seq;
     while (sq != null && sq.getDatasetSequence() != null)
     {
@@ -248,7 +272,7 @@ public class PDBChain
         int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms
                 .elementAt(0).alignmentMapping;
         SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd,
-                feature.getFeatureGroup(), feature.getScore());
+                altPDBID, feature.getScore());
         tx.setStatus(status
                 + ((tx.getStatus() == null || tx.getStatus().length() == 0)
                         ? ""
@@ -490,15 +514,18 @@ public class PDBChain
         min = Math.min(min, annots[i].value);
         resAnnotation.setElementAt(null, i);
       }
-
       AlignmentAnnotation tfactorann = new AlignmentAnnotation(
-              "Temperature Factor", "Temperature Factor for " + pdbid + id,
+              tfacName, tfacName + " for " + pdbid + id,
               annots, min, max, AlignmentAnnotation.LINE_GRAPH);
+      
+      tfactorann.setCalcId(getClass().getName());
+
       tfactorann.setSequenceRef(sequence);
       sequence.addAlignmentAnnotation(tfactorann);
     }
   }
 
+
   /**
    * Colour start/end of bonds by charge
    * <ul>
@@ -615,8 +642,10 @@ public class PDBChain
 
         for (AlignmentAnnotation ana : shadow.getAnnotation())
         {
-          List<AlignmentAnnotation> transfer = sq
-                  .getAlignmentAnnotations(ana.getCalcId(), ana.label);
+          // match on calcId, label and description so annotations from
+          // different structures are preserved
+          List<AlignmentAnnotation> transfer = sq.getAlignmentAnnotations(
+                  ana.getCalcId(), ana.label, ana.description);
           if (transfer == null || transfer.size() == 0)
           {
             ana = new AlignmentAnnotation(ana);
@@ -636,8 +665,11 @@ public class PDBChain
         {
           for (AlignmentAnnotation ana : sequence.getAnnotation())
           {
+            // match on calcId, label and description so annotations from
+            // different structures are preserved
             List<AlignmentAnnotation> transfer = dsq
-                    .getAlignmentAnnotations(ana.getCalcId(), ana.label);
+                    .getAlignmentAnnotations(ana.getCalcId(), ana.label,
+                            ana.description);
             if (transfer == null || transfer.size() == 0)
             {
               ana = new AlignmentAnnotation(ana);