From 1b3b9ada9b959de9d66b1d477bb155a0c6668c8e Mon Sep 17 00:00:00 2001 From: jprocter Date: Sat, 9 Jul 2011 12:12:47 +0100 Subject: [PATCH] refactored from PopupMenu (for JAL-860) --- src/jalview/gui/AlignFrame.java | 4 ++-- src/jalview/gui/AlignViewport.java | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index e9b0873..b658ffb 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index af3ab95..26fb890 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -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 seqvectors = new ArrayList(); + for (PDBEntry pdb: pdbEntries) { + ArrayList seqs = new ArrayList(); + 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()][]); + } } -- 1.7.10.2