use OOMwarning to warn user when out of Memory occurs
[jalview.git] / src / MCview / PDBChain.java
index 8441a2d..8dea416 100755 (executable)
@@ -1,17 +1,17 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- *
+ * 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
+ * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
@@ -25,6 +25,7 @@ import java.awt.*;
 import jalview.analysis.*;
 import jalview.datamodel.*;
 import jalview.schemes.*;
+import jalview.structure.StructureMapping;
 
 public class PDBChain
 {
@@ -94,7 +95,6 @@ public class PDBChain
       }
     }
   }
-
   /**
    * copy over the RESNUM seqfeatures from the internal chain sequence to the mapped sequence
    * @param seq
@@ -126,7 +126,7 @@ public class PDBChain
     SequenceFeature[] features = sequence.getSequenceFeatures();
     for (int i = 0; i < features.length; i++)
     {
-      if (features[i].getFeatureGroup().equals(PDBChain.PDBFILEFEATURE))
+      if (features[i].getFeatureGroup().equals(pdbid))
       {
         SequenceFeature tx = new SequenceFeature(features[i]);
         tx.setBegin(1 +
@@ -235,9 +235,11 @@ public class PDBChain
                               tmpat.resName + ":" + tmpat.resNumIns + " " +
                               pdbid + id,
                               "", offset + count, offset + count,
-                              MCview.PDBChain.PDBFILEFEATURE);
+                              pdbid);
+
+      //MCview.PDBChain.PDBFILEFEATURE);
       resFeatures.addElement(sf);
-      resAnnotation.addElement(new Annotation("","",'\0',tmpat.tfactor));
+      resAnnotation.addElement(new Annotation(tmpat.tfactor));
       // Keep totting up the sequence
       if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null)
       {
@@ -277,7 +279,7 @@ public class PDBChain
         max = annots[i].value;
       resAnnotation.setElementAt(null, i);
     }
-    AlignmentAnnotation tfactorann = new AlignmentAnnotation("PDB.CATempFactor","CA Temperature Factor", 
+    AlignmentAnnotation tfactorann = new AlignmentAnnotation("PDB.CATempFactor","CA Temperature Factor for "+sequence.getName(),
             annots, 0, max, AlignmentAnnotation.LINE_GRAPH);
     tfactorann.setSequenceRef(sequence);
     sequence.addAlignmentAnnotation(tfactorann);
@@ -375,4 +377,51 @@ public class PDBChain
       tmp.endCol = col;
     }
   }
+
+  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
+   */
+  public void transferResidueAnnotation(StructureMapping mapping)
+  {
+    SequenceI sq = mapping.getSequence();
+    if (sq!=null)
+    {
+      if (sequence!=null && sequence.getAnnotation()!=null)
+      {
+
+      }
+      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++)
+      {
+        int prn = mapping.getPDBResNum(k+1);
+
+        an[k] = new Annotation((float)prn);
+        if (min==-1)
+        {
+          min=k;
+          max=k;
+        } else {
+          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, (float)min,(float)max, AlignmentAnnotation.LINE_GRAPH));
+    }
+  }
 }