refactored from PopupMenu (for JAL-860)
authorjprocter <jprocter@compbio.dundee.ac.uk>
Sat, 9 Jul 2011 11:12:47 +0000 (12:12 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Sat, 9 Jul 2011 11:12:47 +0000 (12:12 +0100)
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java

index e9b0873..b658ffb 100755 (executable)
@@ -4517,10 +4517,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             int l = 0, c = pdbfn.indexOf(".");
             while (mtch == null && c != -1)
             {
-              while ((c = pdbfn.indexOf(".", l)) > l)
+              do 
               {
                 l = c;
-              }
+              } while ((c = pdbfn.indexOf(".", l)) > l);
               if (l > -1)
               {
                 pdbfn = pdbfn.substring(0, l);
index af3ab95..26fb890 100644 (file)
@@ -2248,4 +2248,38 @@ public class AlignViewport implements SelectionSource, VamsasSource
   {
     return StructureSelectionManager.getStructureSelectionManager(Desktop.instance);
   }
+
+  /**
+   * 
+   * @param pdbEntries
+   * @return a series of SequenceI arrays, one for each PDBEntry, listing which sequence in the alignment holds a reference to it
+   */
+  public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
+  {
+    ArrayList<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
+    for (PDBEntry pdb: pdbEntries) {
+    ArrayList<SequenceI> seqs = new ArrayList<SequenceI>();
+    for (int i = 0; i < alignment.getHeight(); i++)
+    {
+      Vector pdbs = alignment.getSequenceAt(i)
+              .getDatasetSequence().getPDBId();
+      if (pdbs == null)
+        continue;
+      SequenceI sq;
+      for (int p = 0; p < pdbs.size(); p++)
+      {
+        PDBEntry p1 = (PDBEntry) pdbs.elementAt(p);
+        if (p1.getId().equals(pdb.getId()))
+        {
+          if (!seqs.contains(sq=alignment.getSequenceAt(i)))
+            seqs.add(sq);
+
+          continue;
+        }
+      }
+    }
+    seqvectors.add(seqs.toArray(new SequenceI[seqs.size()]));
+    }
+    return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
+  }
 }