From 05c04b298565cdc668027027e13d0ac6f8bc8517 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 31 Aug 2010 16:18:55 +0000 Subject: [PATCH] notes re JAL-623 and JAL-583, new api methods for adding several structure/seq mappings at once --- src/jalview/appletgui/AlignFrame.java | 258 ++++++++++++++++++++------------- src/jalview/appletgui/AppletJmol.java | 24 ++- src/jalview/bin/JalviewLite.java | 72 ++++++++- 3 files changed, 243 insertions(+), 111 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index adb0da5..c5f37fd 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -166,10 +166,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, boolean featuresFile = false; try { - featuresFile = new jalview.io.FeaturesFile(file, type).parse( - viewport.alignment, alignPanel.seqPanel.seqCanvas - .getFeatureRenderer().featureColours, featureLinks, - true); + featuresFile = new jalview.io.FeaturesFile(file, type) + .parse(viewport.alignment, + alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours, + featureLinks, true); } catch (Exception ex) { ex.printStackTrace(); @@ -846,8 +846,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, else if (source == clustalColour) { abovePIDThreshold.setState(false); - changeColour(new ClustalxColourScheme(viewport.alignment - .getSequences(), viewport.alignment.getWidth())); + changeColour(new ClustalxColourScheme( + viewport.alignment.getSequences(), + viewport.alignment.getWidth())); } else if (source == zappoColour) { @@ -973,10 +974,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "Alignment output - " - + e.getActionCommand(), 600, 500); - cap.setText(new AppletFormatAdapter().formatSequences(e - .getActionCommand(), viewport.getAlignment(), + jalview.bin.JalviewLite.addFrame(frame, + "Alignment output - " + e.getActionCommand(), 600, 500); + cap.setText(new AppletFormatAdapter().formatSequences( + e.getActionCommand(), viewport.getAlignment(), viewport.showJVSuffix)); } @@ -1033,13 +1034,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, String features; if (format.equalsIgnoreCase("Jalview")) { - features = new FeaturesFile().printJalviewFormat(viewport.alignment - .getSequencesArray(), getDisplayedFeatureCols()); + features = new FeaturesFile().printJalviewFormat( + viewport.alignment.getSequencesArray(), + getDisplayedFeatureCols()); } else { - features = new FeaturesFile().printGFFFormat(viewport.alignment - .getSequencesArray(), getDisplayedFeatureCols()); + features = new FeaturesFile().printGFFFormat( + viewport.alignment.getSequencesArray(), + getDisplayedFeatureCols()); } if (displayTextbox) @@ -1071,9 +1074,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.applet.getParameter("annotations") != null) { url.append("&annotations="); - url - .append(appendProtocol(viewport.applet - .getParameter("annotations"))); + url.append(appendProtocol(viewport.applet.getParameter("annotations"))); } if (viewport.applet.getParameter("jnetfile") != null) @@ -1612,8 +1613,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.setEndSeq(viewport.alignment.getHeight()); viewport.alignment.getWidth(); - viewport.firePropertyChange("alignment", null, viewport.alignment - .getSequences()); + viewport.firePropertyChange("alignment", null, + viewport.alignment.getSequences()); } @@ -1677,8 +1678,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.getSelectionGroup() != null) { SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom( - viewport.getSequenceSelection(), viewport.getAlignmentView( - true).getSequenceStrings(viewport.getGapCharacter()), + viewport.getSequenceSelection(), + viewport.getAlignmentView(true).getSequenceStrings( + viewport.getGapCharacter()), viewport.alignment.getGroups()); viewport.alignment.deleteAllGroups(); viewport.sequenceColours = null; @@ -1689,8 +1691,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // gps[g].setShowunconserved(viewport.getShowUnconserved()); gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo()); viewport.alignment.addGroup(gps[g]); - Color col = new Color((int) (Math.random() * 255), (int) (Math - .random() * 255), (int) (Math.random() * 255)); + Color col = new Color((int) (Math.random() * 255), + (int) (Math.random() * 255), (int) (Math.random() * 255)); col = col.brighter(); for (Enumeration sq = gps[g].getSequences(null).elements(); sq .hasMoreElements(); viewport.setSequenceColour( @@ -1927,9 +1929,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated) { - newal - .addAnnotation(viewport.alignment - .getAlignmentAnnotation()[i]); + newal.addAnnotation(viewport.alignment.getAlignmentAnnotation()[i]); } } } @@ -1938,8 +1938,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId(); PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId()); - PaintRefresher.Register(newaf.alignPanel, newaf.alignPanel.av - .getSequenceSetId()); + PaintRefresher.Register(newaf.alignPanel, + newaf.alignPanel.av.getSequenceSetId()); PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas, newaf.alignPanel.av.getSequenceSetId()); @@ -2118,8 +2118,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, Alignment al = (Alignment) viewport.alignment; Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, al.getSequences(), 0, al - .getWidth() - 1); + ResidueProperties.propHash, 3, al.getSequences(), 0, + al.getWidth() - 1); c.calculate(); c.verdict(false, viewport.ConsPercGaps); @@ -2154,8 +2154,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } if (cs instanceof ClustalxColourScheme) { - sg.cs = new ClustalxColourScheme(sg - .getSequences(viewport.hiddenRepSequences), sg.getWidth()); + sg.cs = new ClustalxColourScheme( + sg.getSequences(viewport.hiddenRepSequences), + sg.getWidth()); } else { @@ -2174,9 +2175,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, || cs instanceof Blosum62ColourScheme) { sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus()); - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(viewport.hiddenRepSequences), 0, sg - .getWidth())); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(viewport.hiddenRepSequences), 0, + sg.getWidth())); } else { @@ -2186,8 +2187,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.getConservationSelected()) { Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, sg - .getSequences(viewport.hiddenRepSequences), 0, + ResidueProperties.propHash, 3, + sg.getSequences(viewport.hiddenRepSequences), 0, viewport.alignment.getWidth() - 1); c.calculate(); c.verdict(false, viewport.ConsPercGaps); @@ -2219,8 +2220,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme != null) { - SliderPanel.setPIDSliderSource(alignPanel, viewport - .getGlobalColourScheme(), "Background"); + SliderPanel.setPIDSliderSource(alignPanel, + viewport.getGlobalColourScheme(), "Background"); SliderPanel.showPIDSlider(); } } @@ -2283,7 +2284,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByLength(viewport.getAlignment()); - addHistoryItem(new OrderCommand("Length Sort", oldOrder, viewport.alignment)); + addHistoryItem(new OrderCommand("Length Sort", oldOrder, + viewport.alignment)); alignPanel.paintAlignment(true); } @@ -2516,28 +2518,23 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, g.setFont(new Font("Helvetica", Font.BOLD, 12)); g.drawString("Build date: " + builddate, x, y += fh); g.setFont(new Font("Helvetica", Font.PLAIN, 12)); - g - .drawString( - "Authors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,", - x, y += fh * 1.5); + g.drawString( + "Authors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,", + x, y += fh * 1.5); g.drawString("David Martin & Geoff Barton.", x + 50, y += fh); - g - .drawString( - "Development managed by The Barton Group, University of Dundee, Scotland, UK.", - x, y += fh); - g - .drawString( - "For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list", - x, y += fh); + g.drawString( + "Development managed by The Barton Group, University of Dundee, Scotland, UK.", + x, y += fh); + g.drawString( + "For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list", + x, y += fh); g.drawString("If you use Jalview, please cite:", x, y += fh + 8); - g - .drawString( - "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)", - x, y += fh); - g - .drawString( - "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench", - x, y += fh); + g.drawString( + "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)", + x, y += fh); + g.drawString( + "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench", + x, y += fh); g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", x, y += fh); } @@ -2581,13 +2578,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { System.out.println("Show url: " + url); } - if (url.indexOf("javascript:")==0) + if (url.indexOf("javascript:") == 0) { // no target for the javascript context - viewport.applet.getAppletContext().showDocument(new java.net.URL(url)); - } else{ viewport.applet.getAppletContext().showDocument( - new java.net.URL(url), target); + new java.net.URL(url)); + } + else + { + viewport.applet.getAppletContext().showDocument( + new java.net.URL(url), target); } } catch (Exception ex) { @@ -3166,9 +3166,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.applet.setLayout(new BorderLayout()); viewport.applet.add(embeddedMenu, BorderLayout.NORTH); viewport.applet.add(statusBar, BorderLayout.SOUTH); - alignPanel.setSize(viewport.applet.getSize().width, viewport.applet - .getSize().height - - embeddedMenu.HEIGHT - statusBar.HEIGHT); + alignPanel.setSize(viewport.applet.getSize().width, + viewport.applet.getSize().height - embeddedMenu.HEIGHT + - statusBar.HEIGHT); viewport.applet.add(alignPanel, BorderLayout.CENTER); viewport.applet.validate(); } @@ -3197,7 +3197,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * this does not open a new Jmol window, or modify the display of the * structures in the original jmol window. Note * - * @param viewer JmolViewer instance + * @param viewer + * JmolViewer instance * @param sequenceIds * - sequence Ids to search for associations * This method doesn't work. See http://issues.jalview.org/browse/JAL-621 @@ -3248,37 +3249,38 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, return jmv; } - **/ + **/ public boolean addPdbFile(String sequenceId, String pdbEntryString, String pdbFile) { SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId); - boolean needtoadd=false; - if (toaddpdb!=null) + boolean needtoadd = false; + if (toaddpdb != null) { Vector pdbe = toaddpdb.getPDBId(); PDBEntry pdbentry = null; - if (pdbe!=null && pdbe.size()>0) + if (pdbe != null && pdbe.size() > 0) { - for (int pe=0,peSize=pdbe.size(); pe + * Undocumented for 2.6 - related to JAL-434 + */ + applet.setAlignPdbStructures(getDefaultParameter("alignpdbfiles",false)); /* * @@ -905,8 +913,10 @@ public class JalviewLite extends Applet * * */ - + int pdbFileCount = 0; + // Accumulate pdbs here if they are heading for the same view (if alignPdbStructures is true) + Vector pdbs=new Vector(); do { if (pdbFileCount > 0) @@ -998,16 +1008,35 @@ public class JalviewLite extends Applet } } } - - newAlignFrame.newStructureView(applet, pdb, seqs, chains, + + if (!alignPdbStructures) { + newAlignFrame.newStructureView(applet, pdb, seqs, chains, protocol); - + } else { + pdbs.add(new Object[] { pdb, seqs, chains, new String(protocol)}); + } } } pdbFileCount++; } while (pdbFileCount < 10); - + if (pdbs.size()>0) + { + SequenceI[][] seqs = new SequenceI[pdbs.size()][]; + PDBEntry[] pdb = new PDBEntry[pdbs.size()]; + String[][] chains = new String[pdbs.size()][]; + String[] protocols = new String[pdbs.size()]; + for (int pdbsi=0,pdbsiSize=pdbs.size(); pdbsi