X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=fce50fe01b7eed25210665beabad05992e760521;hb=153dd62dc91da13ae732600e6ea55ddbe15eab39;hp=1330cf6c604f1ca1ffb92adf852674e4b07754f9;hpb=aff93619ba53584f9b01970832558331951d9dbf;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 1330cf6..fce50fe 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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 file is part of Jalview. * - * 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. + * Jalview 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 3 of the License, or (at your option) any later version. * - * 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 + * Jalview 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 Jalview. If not, see . */ package jalview.appletgui; @@ -22,10 +21,14 @@ import java.io.*; import java.net.*; import java.util.*; +import java.applet.Applet; import java.awt.*; import java.awt.event.*; +import org.jmol.api.JmolViewer; + import jalview.analysis.*; +import jalview.api.SequenceStructureBinding; import jalview.bin.JalviewLite; import jalview.commands.*; import jalview.datamodel.*; @@ -86,6 +89,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { sortPairwiseMenuItem_actionPerformed(); } + else if (param.equalsIgnoreCase("Length")) + { + sortLengthMenuItem_actionPerformed(); + } } param = applet.getParameter("wrap"); @@ -150,7 +157,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * DOCUMENT ME! * * @param String - * DOCUMENT ME! + * DOCUMENT ME! */ public void parseFeaturesFile(String file, String type) @@ -159,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(); @@ -176,7 +183,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } viewport.showSequenceFeatures = true; sequenceFeatures.setState(true); - if (viewport.featureSettings!=null) + if (viewport.featureSettings != null) { viewport.featureSettings.refreshTable(); } @@ -441,13 +448,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } alignPanel.paintAlignment(true); } + /** * called by key handler and the hide all/show all menu items + * * @param toggleSeqs * @param toggleCols */ - private void toggleHiddenRegions(boolean toggleSeqs, - boolean toggleCols) + private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols) { boolean hide = false; SequenceGroup sg = viewport.getSelectionGroup(); @@ -456,8 +464,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // Hide everything by the current selection - this is a hack - we do the // invert and then hide // first check that there will be visible columns after the invert. - if ((viewport.colSel != null - && viewport.colSel.getSelected() != null && viewport.colSel + if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel .getSelected().size() > 0) || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg .getEndRes())) @@ -508,6 +515,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } } } + public void keyReleased(KeyEvent evt) { } @@ -587,7 +595,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, else if (evt.getSource() == this.centreColumnLabelFlag) { centreColumnLabelFlag_stateChanged(); - } else if (evt.getSource() == this.followMouseOverFlag) + } + else if (evt.getSource() == this.followMouseOverFlag) { mouseOverFlag_stateChanged(); } @@ -598,7 +607,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, private void mouseOverFlag_stateChanged() { viewport.followHighlight = followMouseOverFlag.getState(); - // TODO: could kick the scrollTo mechanism to reset view for current searchresults. + // TODO: could kick the scrollTo mechanism to reset view for current + // searchresults. } private void centreColumnLabelFlag_stateChanged() @@ -761,18 +771,21 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, viewport.hideAllSelectedSeqs(); alignPanel.paintAlignment(true); } - else if (source == hideAllButSelection) { - toggleHiddenRegions(false,false); + else if (source == hideAllButSelection) + { + toggleHiddenRegions(false, false); alignPanel.paintAlignment(true); } - else if (source == hideAllSelection) { + else if (source == hideAllSelection) + { SequenceGroup sg = viewport.getSelectionGroup(); viewport.expandColSelection(sg, false); viewport.hideAllSelectedSeqs(); viewport.hideSelectedColumns(); alignPanel.paintAlignment(true); } - else if (source == showAllHidden) { + else if (source == showAllHidden) + { viewport.showAllHiddenColumns(); viewport.showAllHiddenSeqs(); alignPanel.paintAlignment(true); @@ -833,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) { @@ -900,6 +914,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { sortIDMenuItem_actionPerformed(); } + else if (source == sortLengthMenuItem) + { + sortLengthMenuItem_actionPerformed(); + } else if (source == sortGroupMenuItem) { sortGroupMenuItem_actionPerformed(); @@ -956,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)); } @@ -996,14 +1014,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, private Hashtable getDisplayedFeatureCols() { - if (alignPanel.getFeatureRenderer()!=null) { + if (alignPanel.getFeatureRenderer() != null) + { FeatureRenderer fr = alignPanel.getFeatureRenderer(); Hashtable fcols = new Hashtable(); Enumeration en = viewport.featuresDisplayed.keys(); while (en.hasMoreElements()) { Object col = en.nextElement(); - fcols.put(col,fr.featureColours.get(col)); + fcols.put(col, fr.featureColours.get(col)); } return fcols; } @@ -1015,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) @@ -1053,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) @@ -1191,7 +1210,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void undoMenuItem_actionPerformed() { @@ -1216,7 +1235,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void redoMenuItem_actionPerformed() { @@ -1594,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()); } @@ -1653,13 +1672,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, this.setVisible(false); } } + protected void makeGrpsFromSelection_actionPerformed() { 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; @@ -1668,10 +1689,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, for (int g = 0; g < gps.length; g++) { // gps[g].setShowunconserved(viewport.getShowUnconserved()); - gps[g].setIncludeAllConsSymbols(viewport.isIncludeAllConsensusSymbols()); + 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( @@ -1683,6 +1704,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, alignPanel.paintAlignment(true); } } + protected void deleteGroups_actionPerformed() { viewport.alignment.deleteAllGroups(); @@ -1731,6 +1753,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); } + public void invertColSel_actionPerformed() { viewport.invertColumnSelection(); @@ -1906,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]); } } } @@ -1917,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()); @@ -1976,7 +1997,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * get sequence feature groups that are hidden or shown * * @param visible - * true is visible + * true is visible * @return list */ public String[] getFeatureGroupsOfState(boolean visible) @@ -1994,9 +2015,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * Change the display state for the given feature groups * * @param groups - * list of group strings + * list of group strings * @param state - * visible or invisible + * visible or invisible */ public void setFeatureGroupState(String[] groups, boolean state) { @@ -2097,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); @@ -2133,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 { @@ -2153,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 { @@ -2165,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); @@ -2198,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(); } } @@ -2238,6 +2260,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, modifyPID_actionPerformed(); } + public void sortPairwiseMenuItem_actionPerformed() { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); @@ -2253,7 +2276,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByID(viewport.getAlignment()); - addHistoryItem(new OrderCommand("ID Sort", oldOrder, + addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment)); + alignPanel.paintAlignment(true); + } + + public void sortLengthMenuItem_actionPerformed() + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter.sortByLength(viewport.getAlignment()); + addHistoryItem(new OrderCommand("Length Sort", oldOrder, viewport.alignment)); alignPanel.paintAlignment(true); } @@ -2288,7 +2319,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public void PCAMenuItem_actionPerformed() { // are the sequences aligned? - if (!viewport.alignment.isAligned()) + if (!viewport.alignment.isAligned(false)) { SequenceI current; int Width = viewport.getAlignment().getWidth(); @@ -2345,7 +2376,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, void NewTreePanel(String type, String pwType, String title) { // are the sequences aligned? - if (!viewport.alignment.isAligned()) + if (!viewport.alignment.isAligned(false)) { SequenceI current; int Width = viewport.getAlignment().getWidth(); @@ -2392,28 +2423,36 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500); addTreeMenuItem(tp, treeFile); } + /** * sort the alignment using the given treePanel - * @param treePanel tree used to sort view - * @param title string used for undo event name + * + * @param treePanel + * tree used to sort view + * @param title + * string used for undo event name */ public void sortByTree(TreePanel treePanel, String title) { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel - .getTree()); + AlignmentSorter + .sortByTree(viewport.getAlignment(), treePanel.getTree()); // addHistoryItem(new HistoryItem("Sort", viewport.alignment, // HistoryItem.SORT)); - addHistoryItem(new OrderCommand("Order by "+title, oldOrder, + addHistoryItem(new OrderCommand("Order by " + title, oldOrder, viewport.alignment)); alignPanel.paintAlignment(true); } + /** - * Do any automatic reordering of the alignment and add the necessary bits to the menu structure for the new tree + * Do any automatic reordering of the alignment and add the necessary bits to + * the menu structure for the new tree + * * @param treePanel * @param title */ - protected void addTreeMenuItem(final TreePanel treePanel, final String title) + protected void addTreeMenuItem(final TreePanel treePanel, + final String title) { final MenuItem item = new MenuItem(title); sortByTreeMenu.add(item); @@ -2454,7 +2493,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, class AboutPanel extends Canvas { String version; + String builddate; + public AboutPanel(String version, String builddate) { this.version = version; @@ -2475,31 +2516,33 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, g.setFont(new Font("Helvetica", Font.BOLD, 14)); g.drawString("JalviewLite - Release " + version, x, y += fh); g.setFont(new Font("Helvetica", Font.BOLD, 12)); - g.drawString("Build date: "+builddate, x, y += fh); + 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("Bioinformatics doi: 10.1093/bioinformatics/btp033",x,y+=fh); + "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); } } Frame frame = new Frame(); - frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite.getBuildDate())); + frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite + .getBuildDate())); jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 220); } @@ -2514,22 +2557,38 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { try { - if (url.indexOf(":")==-1) + if (url.indexOf(":") == -1) { - // TODO: verify (Bas Vroling bug) prepend codebase or server URL to form valid URL - if (url.indexOf("/")==0) + // TODO: verify (Bas Vroling bug) prepend codebase or server URL to + // form valid URL + if (url.indexOf("/") == 0) { String codebase = viewport.applet.getCodeBase().toString(); - url = codebase.substring(0,codebase.length()-viewport.applet.getCodeBase().getFile().length())+url; - } else { - url = viewport.applet.getCodeBase()+url; + url = codebase.substring(0, codebase.length() + - viewport.applet.getCodeBase().getFile().length()) + + url; + } + else + { + url = viewport.applet.getCodeBase() + url; } System.out.println("Show url (prepended codebase): " + url); - } else { + } + else + { System.out.println("Show url: " + url); } - viewport.applet.getAppletContext().showDocument( - new java.net.URL(url), target); + 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); + } } catch (Exception ex) { ex.printStackTrace(); @@ -2586,6 +2645,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MenuItem sortIDMenuItem = new MenuItem(); + MenuItem sortLengthMenuItem = new MenuItem(); + MenuItem sortGroupMenuItem = new MenuItem(); MenuItem removeRedundancyMenuItem = new MenuItem(); @@ -2660,7 +2721,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MenuItem deleteGroups = new MenuItem(); - MenuItem grpsFromSelection= new MenuItem(); + MenuItem grpsFromSelection = new MenuItem(); MenuItem delete = new MenuItem(); @@ -2763,6 +2824,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, sortPairwiseMenuItem.addActionListener(this); sortIDMenuItem.setLabel("by ID"); sortIDMenuItem.addActionListener(this); + sortLengthMenuItem.setLabel("by Length"); + sortLengthMenuItem.addActionListener(this); sortGroupMenuItem.setLabel("by Group"); sortGroupMenuItem.addActionListener(this); removeRedundancyMenuItem.setLabel("Remove Redundancy..."); @@ -2812,7 +2875,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, annotationPanelMenuItem.addItemListener(this); colourTextMenuItem.setLabel("Colour Text"); colourTextMenuItem.addItemListener(this); - displayNonconservedMenuItem.setLabel("Show non-conserved"); + displayNonconservedMenuItem.setLabel("Show nonconserved"); displayNonconservedMenuItem.addItemListener(this); alProperties.addActionListener(this); overviewMenuItem.setLabel("Overview Window"); @@ -3006,6 +3069,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, pasteMenu.add(pasteNew); pasteMenu.add(pasteThis); sort.add(sortIDMenuItem); + sort.add(sortLengthMenuItem); sort.add(sortByTreeMenu); sort.add(sortGroupMenuItem); sort.add(sortPairwiseMenuItem); @@ -3042,7 +3106,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, selectMenu.add(invertColSel); selectMenu.add(grpsFromSelection); selectMenu.add(deleteGroups); - + } MenuItem featureSettings = new MenuItem(); @@ -3066,7 +3130,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MenuItem hideSequences = new MenuItem(); MenuItem hideAllButSelection = new MenuItem(); + MenuItem hideAllSelection = new MenuItem(); + MenuItem showAllHidden = new MenuItem(); Menu formatMenu = new Menu(); @@ -3081,8 +3147,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * platform independent manner to avoid OSX/Mac menu appendage daftness. * * @param reallyEmbedded - * true to attach the view to the applet area on the page - * rather than in a new window + * true to attach the view to the applet area on the page rather than + * in a new window */ public void createAlignFrameWindow(boolean reallyEmbedded, String title) { @@ -3100,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(); } @@ -3124,4 +3190,207 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, DEFAULT_HEIGHT); } } + + /** + * create a new binding between structures in an existing jmol viewer instance + * and an alignpanel with sequences that have existing PDBFile entries. Note, + * 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 sequenceIds + * - sequence Ids to search for associations + * This method doesn't work. See http://issues.jalview.org/browse/JAL-621 + * + public SequenceStructureBinding addStructureViewInstance(Object jmolviewer, String[] sequenceIds) + { + org.jmol.api.JmolViewer viewer=null; + try { + viewer = (org.jmol.api.JmolViewer) jmolviewer; + } + catch (ClassCastException ex) { + System.err.println("Unsupported viewer object :"+jmolviewer.getClass()); + } + if (viewer==null) + { + System.err.println("Can't use this object as a structure viewer:"+jmolviewer.getClass()); + return null; + } + SequenceI[] seqs=null; + if (sequenceIds==null || sequenceIds.length==0) + { + seqs = viewport.getAlignment().getSequencesArray(); + } else { + Vector sqi=new Vector(); + AlignmentI al = viewport.getAlignment(); + for (int sid=0;sid0) { + seqs = new SequenceI[sqi.size()]; + for (int sid=0,sSize=sqi.size();sid 0) + { + for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++) + { + pdbentry = (PDBEntry) pdbe.elementAt(pe); + if (!pdbentry.getId().equals(pdbEntryString) + && !pdbentry.getFile().equals(pdbFile)) + { + pdbentry = null; + } + else + { + continue; + } + } + } + if (pdbentry == null) + { + pdbentry = new PDBEntry(); + pdbentry.setId(pdbEntryString); + pdbentry.setFile(pdbFile); + needtoadd = true; // add this new entry to sequence. + } + // resolve data source + // TODO: this code should be a refactored to an io package + String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB"); + if (protocol == null) + { + return false; + } + if (needtoadd) + { + // make a note of the access mode and add + if (pdbentry.getProperty()==null) + {pdbentry.setProperty(new Hashtable());} + pdbentry.getProperty().put("protocol", protocol); + toaddpdb.addPDBId(pdbentry); + } + } + return true; + } + private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains) + { + if (seqs != null) + { + Vector sequences = new Vector(); + for (int i = 0; i < seqs.length; i++) + { + if (seqs[i] != null) + { + sequences.addElement(new Object[] { seqs[i], (chains!=null) ? chains[i] : null}); + } + } + seqs = new SequenceI[sequences.size()]; + chains = new String[sequences.size()]; + for (int i = 0, isize = sequences.size(); i < isize; i++) + { + Object[] oj = (Object[]) sequences.elementAt(i); + + seqs[i] = (SequenceI) oj[0]; + chains[i] = (String) oj[1]; + } + } + return new Object[] { seqs, chains}; + + } + public void newStructureView(JalviewLite applet, PDBEntry pdb, + SequenceI[] seqs, String[] chains, String protocol) + { + // Scrub any null sequences from the array + Object[] sqch = cleanSeqChainArrays(seqs, chains); + seqs = (SequenceI[]) sqch[0]; + chains = (String[]) sqch[1]; + if (seqs == null || seqs.length == 0) + { + System.err + .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); + } + if (protocol == null || protocol.trim().length() == 0 + || protocol.equals("null")) + { + protocol = (String) pdb.getProperty().get("protocol"); + if (protocol == null) + { + System.err.println("Couldn't work out protocol to open structure: " + + pdb.getId()); + return; + } + } + if (applet.isAlignPdbStructures() && applet.jmolAvailable) + { + // can only do alignments with Jmol + // find the last jmol window assigned to this alignment + jalview.appletgui.AppletJmol ajm = null, tajm; + Vector jmols = applet + .getAppletWindow(jalview.appletgui.AppletJmol.class); + for (int i = 0, iSize = jmols.size(); i < iSize; i++) + { + tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i); + if (tajm.ap.alignFrame == this) + { + ajm = tajm; + break; + } + } + if (ajm!=null) + { + System.err.println("Incremental adding and aligning structure to existing Jmol view not yet implemented."); + // try and add the pdb structure + // ajm.addS + ajm = null; + } + } + // otherwise, create a new window + if (applet.jmolAvailable) + { + new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel, + protocol); + applet.lastFrameX += 40; + applet.lastFrameY += 40; + } + else + { + new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol); + } + + } + + public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb, + SequenceI[][] seqs, String[][] chains, String[] protocols) + { + // TODO Auto-generated method stub + System.err.println("Aligned Structure View: Not yet implemented."); + } }