JAL-1620 version bump and release notes
[jalview.git] / src / MCview / PDBChain.java
index 5dd38a4..9cf7097 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
@@ -267,7 +267,7 @@ public class PDBChain
     bonds.addElement(new Bond(start, end, at1, at2));
   }
 
-  public void makeResidueList()
+  public void makeResidueList(boolean visibleChainAnnotation)
   {
     int count = 0;
     Object symbol;
@@ -377,23 +377,27 @@ public class PDBChain
               .elementAt(i));
       resFeatures.setElementAt(null, i);
     }
-    Annotation[] annots = new Annotation[resAnnotation.size()];
-    float max = 0;
-    for (i = 0, iSize = annots.length; i < iSize; i++)
+    if (visibleChainAnnotation)
     {
-      annots[i] = (Annotation) resAnnotation.elementAt(i);
-      if (annots[i].value > max)
+      Annotation[] annots = new Annotation[resAnnotation.size()];
+      float max = 0;
+      for (i = 0, iSize = annots.length; i < iSize; i++)
       {
-        max = annots[i].value;
+        annots[i] = (Annotation) resAnnotation.elementAt(i);
+        if (annots[i].value > max)
+        {
+          max = annots[i].value;
+        }
+        resAnnotation.setElementAt(null, i);
       }
-      resAnnotation.setElementAt(null, i);
+
+      AlignmentAnnotation tfactorann = new AlignmentAnnotation(
+              "Temperature Factor", "Temperature Factor for " + pdbid + id,
+              annots, 0, max,
+              AlignmentAnnotation.LINE_GRAPH);
+      tfactorann.setSequenceRef(sequence);
+      sequence.addAlignmentAnnotation(tfactorann);
     }
-    AlignmentAnnotation tfactorann = new AlignmentAnnotation(
-            "PDB.TempFactor", "Temperature Factor for "
-                    + sequence.getName(), annots, 0, max,
-            AlignmentAnnotation.LINE_GRAPH);
-    tfactorann.setSequenceRef(sequence);
-    sequence.addAlignmentAnnotation(tfactorann);
   }
 
   public void setChargeColours()
@@ -487,22 +491,17 @@ public class PDBChain
     }
   }
 
-  public AlignmentAnnotation[] transferResidueAnnotation(SequenceI seq,
-          String status)
-  {
-    AlignmentAnnotation[] transferred = null;
-
-    return transferred;
-
-  }
-
   /**
    * copy any sequence annotation onto the sequence mapped using the provided
    * StructureMapping
    * 
    * @param mapping
+   *          - positional mapping between destination sequence and pdb resnum
+   * @param sqmpping
+   *          - mapping between destination sequence and local chain
    */
-  public void transferResidueAnnotation(StructureMapping mapping)
+  public void transferResidueAnnotation(
+          StructureMapping mapping, jalview.datamodel.Mapping sqmpping)
   {
     SequenceI sq = mapping.getSequence();
     SequenceI dsq = sq;
@@ -523,8 +522,10 @@ public class PDBChain
                   ana.getCalcId(), ana.label);
           if (transfer == null || transfer.size() == 0)
           {
+            ana = new AlignmentAnnotation(ana);
             ana.liftOver(sequence, shadowMap);
-            mapping.transfer(ana);
+            ana.liftOver(dsq, sqmpping);
+            dsq.addAlignmentAnnotation(ana);
           }
           else
           {
@@ -534,51 +535,56 @@ public class PDBChain
       }
       else
       {
-      if (sequence != null && sequence.getAnnotation() != null)
-      {
-        for (AlignmentAnnotation ana : sequence.getAnnotation())
+        if (sequence != null && sequence.getAnnotation() != null)
         {
-          List<AlignmentAnnotation> transfer = sq.getAlignmentAnnotations(
-                  ana.getCalcId(), ana.label);
-          if (transfer == null || transfer.size() == 0)
+          for (AlignmentAnnotation ana : sequence.getAnnotation())
           {
-            mapping.transfer(ana);
-          }
-          else
-          {
-            continue;
+            List<AlignmentAnnotation> transfer = sq
+                    .getAlignmentAnnotations(ana.getCalcId(), ana.label);
+            if (transfer == null || transfer.size() == 0)
+            {
+              ana = new AlignmentAnnotation(ana);
+              ana.liftOver(dsq, sqmpping);
+              // mapping.transfer(ana);
+            }
+            else
+            {
+              continue;
+            }
           }
         }
       }
-      }
-      float min = -1, max = 0;
-      Annotation[] an = new Annotation[sq.getEnd() - sq.getStart() + 1];
-      for (int i = sq.getStart(), j = sq.getEnd(), k = 0; i <= j; i++, k++)
+      if (false)
       {
-        int prn = mapping.getPDBResNum(k + 1);
-
-        an[k] = new Annotation(prn);
-        if (min == -1)
+        // Useful for debugging mappings - adds annotation for mapped position
+        float min = -1, max = 0;
+        Annotation[] an = new Annotation[sq.getEnd() - sq.getStart() + 1];
+        for (int i = sq.getStart(), j = sq.getEnd(), k = 0; i <= j; i++, k++)
         {
-          min = k;
-          max = k;
-        }
-        else
-        {
-          if (min > k)
+          int prn = mapping.getPDBResNum(k + 1);
+
+          an[k] = new Annotation(prn);
+          if (min == -1)
           {
             min = k;
+            max = k;
           }
-          else if (max < k)
+          else
           {
-            max = k;
+            if (min > k)
+            {
+              min = k;
+            }
+            else if (max < k)
+            {
+              max = k;
+            }
           }
         }
+        sq.addAlignmentAnnotation(new AlignmentAnnotation("PDB.RESNUM",
+                "PDB Residue Numbering for " + this.pdbid + ":" + this.id,
+                an, min, max, AlignmentAnnotation.LINE_GRAPH));
       }
-      sq.addAlignmentAnnotation(new AlignmentAnnotation("PDB.RESNUM",
-              "PDB Residue Numbering for " + this.pdbid + ":" + this.id,
-              an, min, max, AlignmentAnnotation.LINE_GRAPH));
-
     }
   }
 }