From 55e2e9b22b133db8b9ff0979b0338a33081fc8fd Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 6 Dec 2005 11:46:19 +0000 Subject: [PATCH] after merge --- src/jalview/appletgui/APopupMenu.java | 57 +- src/jalview/appletgui/AlignFrame.java | 744 +++++++++++++++++++- src/jalview/appletgui/AlignViewport.java | 12 +- src/jalview/appletgui/AlignmentPanel.java | 99 ++- src/jalview/appletgui/CutAndPasteTransfer.java | 93 ++- src/jalview/appletgui/FeatureRenderer.java | 289 ++++++-- src/jalview/appletgui/Finder.java | 80 ++- src/jalview/appletgui/FontChooser.java | 99 ++- src/jalview/appletgui/IdCanvas.java | 16 +- src/jalview/appletgui/IdPanel.java | 5 +- src/jalview/appletgui/OverviewPanel.java | 47 +- src/jalview/appletgui/PCAPanel.java | 102 ++- src/jalview/appletgui/PairwiseAlignPanel.java | 37 +- src/jalview/appletgui/RedundancyPanel.java | 6 +- src/jalview/appletgui/RotatableCanvas.java | 66 +- src/jalview/appletgui/SeqCanvas.java | 42 +- src/jalview/appletgui/SeqPanel.java | 26 +- src/jalview/appletgui/SequenceRenderer.java | 27 +- src/jalview/appletgui/SliderPanel.java | 81 ++- src/jalview/appletgui/TreeCanvas.java | 1 + src/jalview/appletgui/TreePanel.java | 97 ++- src/jalview/appletgui/UserDefinedColours.java | 141 +++- src/jalview/bin/Jalview.java | 7 +- src/jalview/bin/JalviewLite.java | 149 ++-- src/jalview/binding/Feature.java | 305 ++++++++ src/jalview/binding/FeatureSettings.java | 274 +++++++ src/jalview/binding/Features.java | 118 ++++ src/jalview/binding/JSeq.java | 304 ++++++++ src/jalview/binding/JalviewModelSequence.java | 26 + src/jalview/binding/JalviewModelSequence2.java | 319 --------- src/jalview/binding/JalviewModelSequence2Item.java | 206 ------ src/jalview/binding/Pdbentry.java | 326 +++++++++ src/jalview/binding/PdbentryItem.java | 197 ++++++ src/jalview/binding/Pdbids.java | 118 ++++ src/jalview/binding/Property.java | 173 +++++ src/jalview/binding/Setting.java | 253 +++++++ src/jalview/datamodel/Alignment.java | 102 +-- src/jalview/datamodel/AlignmentI.java | 14 +- src/jalview/datamodel/DBRefEntry.java | 23 + src/jalview/datamodel/PDBEntry.java | 36 + src/jalview/datamodel/Provenance.java | 26 + src/jalview/datamodel/ProvenanceEntry.java | 23 + src/jalview/datamodel/Sequence.java | 143 +++- src/jalview/datamodel/SequenceFeature.java | 104 ++- src/jalview/datamodel/SequenceI.java | 25 +- src/jalview/datamodel/UniprotEntry.java | 74 ++ src/jalview/datamodel/UniprotFile.java | 15 + src/jalview/datamodel/UniprotSequence.java | 24 + src/jalview/io/AlignFile.java | 42 ++ src/jalview/io/AppletFormatAdapter.java | 184 +++++ src/jalview/io/BLCFile.java | 80 +-- src/jalview/io/ClustalFile.java | 63 +- src/jalview/io/EBIFetchClient.java | 42 ++ src/jalview/io/FastaFile.java | 165 +---- src/jalview/io/FormatAdapter.java | 89 +-- src/jalview/io/HTMLOutput.java | 127 ++-- src/jalview/io/IdentifyFile.java | 2 +- src/jalview/io/MSFfile.java | 54 +- src/jalview/io/PIRFile.java | 67 +- src/jalview/io/PfamFile.java | 48 +- src/jalview/io/PileUpfile.java | 193 +---- src/jalview/io/SequenceFeatureFetcher.java | 730 +++++++------------ src/jalview/io/WSWUBlastClient.java | 207 ++++-- src/jalview/jbgui/GAlignFrame.java | 125 +++- src/jalview/jbgui/GDesktop.java | 39 +- src/jalview/jbgui/GPreferences.java | 152 ++-- src/jalview/jbgui/GTreePanel.java | 6 +- src/jalview/schemes/ResidueProperties.java | 21 +- src/jalview/util/Comparison.java | 383 +++++----- src/jalview/util/ImageMaker.java | 165 +++++ src/jalview/ws/JPredClient.java | 3 +- src/jalview/ws/MsaWSClient.java | 20 +- 72 files changed, 6035 insertions(+), 2523 deletions(-) create mode 100755 src/jalview/binding/Feature.java create mode 100755 src/jalview/binding/FeatureSettings.java create mode 100755 src/jalview/binding/Features.java delete mode 100755 src/jalview/binding/JalviewModelSequence2.java delete mode 100755 src/jalview/binding/JalviewModelSequence2Item.java create mode 100755 src/jalview/binding/Pdbentry.java create mode 100755 src/jalview/binding/PdbentryItem.java create mode 100755 src/jalview/binding/Pdbids.java create mode 100755 src/jalview/binding/Property.java create mode 100755 src/jalview/binding/Setting.java create mode 100755 src/jalview/datamodel/DBRefEntry.java create mode 100755 src/jalview/datamodel/PDBEntry.java create mode 100755 src/jalview/datamodel/Provenance.java create mode 100755 src/jalview/datamodel/ProvenanceEntry.java create mode 100755 src/jalview/datamodel/UniprotEntry.java create mode 100755 src/jalview/datamodel/UniprotFile.java create mode 100755 src/jalview/datamodel/UniprotSequence.java create mode 100755 src/jalview/io/AppletFormatAdapter.java create mode 100755 src/jalview/util/ImageMaker.java diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 272d653..8488dd8 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -46,7 +46,7 @@ public class APopupMenu MenuItem noColourmenuItem = new MenuItem(); protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); - AlignmentPanel ap; + final AlignmentPanel ap; MenuItem unGroupMenuItem = new MenuItem(); MenuItem nucleotideMenuItem = new MenuItem(); Menu colourMenu = new Menu(); @@ -54,7 +54,7 @@ public class APopupMenu CheckboxMenuItem showText = new CheckboxMenuItem(); CheckboxMenuItem showColourText = new CheckboxMenuItem(); - public APopupMenu(AlignmentPanel ap, Sequence seq, Vector links) + public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links) { /////////////////////////////////////////////////////////// // If this is activated from the sequence panel, the user may want to @@ -63,7 +63,7 @@ public class APopupMenu // If from the IDPanel, we must display the sequence menu ////////////////////////////////////////////////////////// - this.ap = ap; + this.ap = apanel; try { @@ -97,23 +97,50 @@ public class APopupMenu link = links.elementAt(i).toString(); final String target = link.substring(0, link.indexOf("|")); item = new MenuItem(target); + String id = seq.getName(); + if(id.indexOf("|")>-1) + id = id.substring(id.lastIndexOf("|")+1); + final String url = link.substring(link.indexOf("|")+1, link.indexOf("$SEQUENCE_ID$")) - + seq.getName() + + + id + link.substring(link.indexOf("$SEQUENCE_ID$") + 13); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { - jalview.bin.JalviewLite.showURL(url, target); + ap.alignFrame.showURL(url, target); } }); linkMenu.add(item); } add(linkMenu); + + item = new MenuItem("Show PDB Structure"); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + addPDB(seq); + } + }); + + add(item); + + } } + void addPDB(Sequence seq) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame.applet); + cap.setText("Paste your PDB file here."); + cap.setPDBImport(seq, ap.seqPanel.seqCanvas); + Frame frame = new Frame(); + frame.add(cap); + jalview.bin.JalviewLite.addFrame(frame, "Paste PDB file ", 400, 300); + } + private void jbInit() throws Exception { @@ -467,26 +494,6 @@ public class APopupMenu refresh(); } - protected void analyze_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame.applet); - Frame frame = new Frame(); - frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "Analyze this - ", 400, 300); - SequenceGroup sg = getGroup(); - StringBuffer sb = new StringBuffer(); - - for (int i = 0; i < sg.sequences.size(); i++) - { - Sequence tmp = (Sequence) sg.sequences.elementAt(i); - sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1)); - sb.append("\n"); - } - - sb.append("Something amazing will happen soon"); - cap.setText(sb.toString()); - - } SequenceGroup getGroup() { diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index e303500..cf4c40d 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -19,7 +19,6 @@ package jalview.appletgui; -import jalview.jbappletgui.GAlignFrame; import jalview.schemes.*; import jalview.datamodel.*; import jalview.analysis.*; @@ -29,12 +28,13 @@ import java.awt.event.*; import java.util.*; import java.io.InputStreamReader; import java.io.BufferedReader; +import java.net.URL; -public class AlignFrame - extends GAlignFrame + +public class AlignFrame extends Frame { final AlignmentPanel alignPanel; - final AlignViewport viewport; + public final AlignViewport viewport; int NEW_WINDOW_WIDTH = 700; int NEW_WINDOW_HEIGHT = 500; jalview.bin.JalviewLite applet; @@ -42,6 +42,12 @@ public class AlignFrame public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, String title) { + try{ + jbInit(); + }catch(Exception ex) + { + ex.printStackTrace(); + } this.applet = applet; viewport = new AlignViewport(al, applet); alignPanel = new AlignmentPanel(this, viewport); @@ -139,6 +145,99 @@ public class AlignFrame } + public AlignViewport getAlignViewport() + { + return viewport; + } + + public SeqCanvas getSeqcanvas() + { + return alignPanel.seqPanel.seqCanvas; + } + + + /** + * DOCUMENT ME! + * + * @param String DOCUMENT ME! + */ + + public void parseFeaturesFile(String file) + { + try + { + URL url = new URL(file); + + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + SequenceI seq = null; + String line, type, desc, token; + + int index, start, end; + StringTokenizer st; + SequenceFeature sf; + FeatureRenderer fr = alignPanel.seqPanel.seqCanvas.getFeatureRenderer(); + int lineNo = 0; + while ( (line = in.readLine()) != null) + { + lineNo++; + st = new StringTokenizer(line, "\t"); + if (st.countTokens() == 2) + { + type = st.nextToken(); + UserColourScheme ucs = new UserColourScheme(st.nextToken()); + fr.setColour(type, ucs.findColour("A")); + continue; + } + + while (st.hasMoreElements()) + { + desc = st.nextToken(); + token = st.nextToken(); + if (!token.equals("ID_NOT_SPECIFIED")) + { + index = viewport.alignment.findIndex(viewport.alignment.findName( + token)); + st.nextToken(); + } + else + { + index = Integer.parseInt(st.nextToken()); + } + + start = Integer.parseInt(st.nextToken()); + end = Integer.parseInt(st.nextToken()); + + seq = viewport.alignment.getSequenceAt(index); + start = seq.findIndex(start) - 1; + end = seq.findIndex(end) - 1; + + type = st.nextToken(); + + if(fr.getColour(type)==null) + { + // Probably the old style groups file + UserColourScheme ucs = new UserColourScheme(type); + fr.setColour(type, ucs.findColour("A")); + } + + sf = new SequenceFeature(type, desc, "", start, end); + + seq.addSequenceFeature(sf); + } + } + + viewport.showSequenceFeatures = true; + + alignPanel.repaint(); + + } + catch (Exception ex) + { + System.out.println("Error parsing groups file: " + ex); + } + } + + public void inputText_actionPerformed(ActionEvent e) { CutAndPasteTransfer cap = new CutAndPasteTransfer(true, applet); @@ -155,15 +254,14 @@ public class AlignFrame jalview.bin.JalviewLite.addFrame(frame, "Alignment output - " + e.getActionCommand(), 600, 500); - cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), - viewport.getAlignment(). - getSequences())); + cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(), + viewport.getAlignment().getSequences(), + viewport.showJVSuffix)); } public void closeMenuItem_actionPerformed(ActionEvent e) { PaintRefresher.components.remove(viewport.alignment); - dispose(); if(PaintRefresher.components.size()==0 && applet==null) System.exit(0); } @@ -550,6 +648,7 @@ public class AlignFrame viewport.setSelectionGroup(null); viewport.getColumnSelection().clear(); viewport.setSelectionGroup(null); + alignPanel.seqPanel.seqCanvas.highlightSearchResults(null); alignPanel.repaint(); PaintRefresher.Refresh(null, viewport.alignment); } @@ -778,13 +877,15 @@ public class AlignFrame new FontChooser(alignPanel); } - protected void fullSeqId_actionPerformed(ActionEvent e) + + public void seqLimits_itemStateChanged(ItemEvent e) { - viewport.setShowFullId(fullSeqId.getState()); + viewport.setShowJVSuffix(seqLimits.getState()); alignPanel.fontChanged(); alignPanel.repaint(); } + protected void colourTextMenuItem_actionPerformed(ActionEvent e) { viewport.setColourText(colourTextMenuItem.getState()); @@ -1275,7 +1376,7 @@ public class AlignFrame protected void documentation_actionPerformed(ActionEvent e) { - jalview.bin.JalviewLite.showURL("http://www.jalview.org/help.html"); + showURL("http://www.jalview.org/help.html"); } protected void about_actionPerformed(ActionEvent e) @@ -1342,4 +1443,625 @@ public class AlignFrame jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200); } + + /** + * Displays the given URL in a new browser window + * + * @param url URL to display in browser window. + *
New window will be named "HELP_WINDOW" + */ + public void showURL(String url) + { + showURL(url, "HELP"); + } + + public void showURL(String url, String target) + { + if (applet == null) + { + System.out.println("Not running as applet - no browser available."); + } + else + { + try + { + applet.getAppletContext().showDocument(new java.net.URL(url), + target); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + + + ////////////////////////////////////////////////////////////////////////////////// + //JBuilder Graphics here + + protected MenuBar alignFrameMenuBar = new MenuBar(); + protected Menu fileMenu = new Menu(); + protected MenuItem closeMenuItem = new MenuItem(); + protected Menu editMenu = new Menu(); + protected Menu viewMenu = new Menu(); + protected Menu colourMenu = new Menu(); + protected Menu calculateMenu = new Menu(); + protected MenuItem selectAllSequenceMenuItem = new MenuItem(); + protected MenuItem deselectAllSequenceMenuItem = new MenuItem(); + protected MenuItem invertSequenceMenuItem = new MenuItem(); + protected MenuItem remove2LeftMenuItem = new MenuItem(); + protected MenuItem remove2RightMenuItem = new MenuItem(); + protected MenuItem removeGappedColumnMenuItem = new MenuItem(); + protected MenuItem removeAllGapsMenuItem = new MenuItem(); + protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); + protected MenuItem sortPairwiseMenuItem = new MenuItem(); + protected MenuItem sortIDMenuItem = new MenuItem(); + protected MenuItem sortGroupMenuItem = new MenuItem(); + protected MenuItem removeRedundancyMenuItem = new MenuItem(); + protected MenuItem pairwiseAlignmentMenuItem = new MenuItem(); + protected MenuItem PCAMenuItem = new MenuItem(); + protected MenuItem averageDistanceTreeMenuItem = new MenuItem(); + protected MenuItem neighbourTreeMenuItem = new MenuItem(); + BorderLayout borderLayout1 = new BorderLayout(); + public Label statusBar = new Label(); + protected Menu outputTextboxMenu = new Menu(); + protected MenuItem clustalColour = new MenuItem(); + protected MenuItem zappoColour = new MenuItem(); + protected MenuItem taylorColour = new MenuItem(); + protected MenuItem hydrophobicityColour = new MenuItem(); + protected MenuItem helixColour = new MenuItem(); + protected MenuItem strandColour = new MenuItem(); + protected MenuItem turnColour = new MenuItem(); + protected MenuItem buriedColour = new MenuItem(); + protected MenuItem userDefinedColour = new MenuItem(); + protected MenuItem PIDColour = new MenuItem(); + protected MenuItem BLOSUM62Colour = new MenuItem(); + MenuItem njTreeBlosumMenuItem = new MenuItem(); + MenuItem avDistanceTreeBlosumMenuItem = new MenuItem(); + protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); + MenuItem overviewMenuItem = new MenuItem(); + protected MenuItem undoMenuItem = new MenuItem(); + protected MenuItem redoMenuItem = new MenuItem(); + protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); + MenuItem noColourmenuItem = new MenuItem(); + protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); + MenuItem findMenuItem = new MenuItem(); + Menu searchMenu = new Menu(); + protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem(); + protected MenuItem nucleotideColour = new MenuItem(); + MenuItem deleteGroups = new MenuItem(); + MenuItem delete = new MenuItem(); + MenuItem copy = new MenuItem(); + MenuItem cut = new MenuItem(); + Menu Menu1 = new Menu(); + MenuItem pasteNew = new MenuItem(); + MenuItem pasteThis = new MenuItem(); + protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); + protected MenuItem font = new MenuItem(); + protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleRight = new CheckboxMenuItem(); + MenuItem modifyPID = new MenuItem(); + MenuItem modifyConservation = new MenuItem(); + protected Menu sortByTreeMenu = new Menu(); + Menu sort = new Menu(); + Menu calculate = new Menu(); + MenuItem inputText = new MenuItem(); + Menu helpMenu = new Menu(); + MenuItem documentation = new MenuItem(); + MenuItem about = new MenuItem(); + protected CheckboxMenuItem seqLimits = new CheckboxMenuItem(); + + private void jbInit() throws Exception { + + setMenuBar(alignFrameMenuBar); + + MenuItem item; + + // dynamically fill save as menu with available formats + for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size(); i++) + { + + item = new MenuItem( (String) jalview.io.AppletFormatAdapter.formats. + elementAt( + i)); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + outputText_actionPerformed(e); + } + }); + + outputTextboxMenu.add(item); + } + + + fileMenu.setLabel("File"); + closeMenuItem.setLabel("Close"); + closeMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + closeMenuItem_actionPerformed(e); + } + }); + editMenu.setLabel("Edit"); + viewMenu.setLabel("View"); + colourMenu.setLabel("Colour"); + calculateMenu.setLabel("Calculate"); + selectAllSequenceMenuItem.setLabel("Select all"); + selectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + selectAllSequenceMenuItem_actionPerformed(e); + } + }); + deselectAllSequenceMenuItem.setLabel("Deselect All"); + deselectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + deselectAllSequenceMenuItem_actionPerformed(e); + } + }); + invertSequenceMenuItem.setLabel("Invert Selection"); + invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + invertSequenceMenuItem_actionPerformed(e); + } + }); + remove2LeftMenuItem.setLabel("Remove Left"); + remove2LeftMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + remove2LeftMenuItem_actionPerformed(e); + } + }); + remove2RightMenuItem.setLabel("Remove Right"); + remove2RightMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + remove2RightMenuItem_actionPerformed(e); + } + }); + removeGappedColumnMenuItem.setLabel("Remove Empty Columns"); + removeGappedColumnMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + removeGappedColumnMenuItem_actionPerformed(e); + } + }); + removeAllGapsMenuItem.setLabel("Remove All Gaps"); + removeAllGapsMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + removeAllGapsMenuItem_actionPerformed(e); + } + }); + viewBoxesMenuItem.setLabel("Boxes"); + viewBoxesMenuItem.setState(true); + viewBoxesMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + viewBoxesMenuItem_actionPerformed(null); + } + }); + viewTextMenuItem.setLabel("Text"); + viewTextMenuItem.setState(true); + viewTextMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + viewTextMenuItem_actionPerformed(null); + } + }); + sortPairwiseMenuItem.setLabel("by Pairwise Identity"); + sortPairwiseMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + sortPairwiseMenuItem_actionPerformed(e); + } + }); + sortIDMenuItem.setLabel("by ID"); + sortIDMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + sortIDMenuItem_actionPerformed(e); + } + }); + sortGroupMenuItem.setLabel("by Group"); + sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + sortGroupMenuItem_actionPerformed(e); + } + }); + removeRedundancyMenuItem.setLabel("Remove Redundancy..."); + removeRedundancyMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + removeRedundancyMenuItem_actionPerformed(e); + } + }); + pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments..."); + pairwiseAlignmentMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + pairwiseAlignmentMenuItem_actionPerformed(e); + } + }); + PCAMenuItem.setLabel("Principal Component Analysis"); + PCAMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + PCAMenuItem_actionPerformed(e); + } + }); + averageDistanceTreeMenuItem.setLabel( + "Average Distance Using % Identity"); + averageDistanceTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + averageDistanceTreeMenuItem_actionPerformed(e); + } + }); + neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity"); + neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + neighbourTreeMenuItem_actionPerformed(e); + } + }); + alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setBackground(Color.white); + statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setText("Status bar"); + outputTextboxMenu.setLabel("Output to Textbox"); + clustalColour.setLabel("Clustalx"); + + clustalColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + clustalColour_actionPerformed(e); + } + }); + zappoColour.setLabel("Zappo"); + zappoColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + zappoColour_actionPerformed(e); + } + }); + taylorColour.setLabel("Taylor"); + taylorColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + taylorColour_actionPerformed(e); + } + }); + hydrophobicityColour.setLabel("Hydrophobicity"); + hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + hydrophobicityColour_actionPerformed(e); + } + }); + helixColour.setLabel("Helix Propensity"); + helixColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + helixColour_actionPerformed(e); + } + }); + strandColour.setLabel("Strand Propensity"); + strandColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + strandColour_actionPerformed(e); + } + }); + turnColour.setLabel("Turn Propensity"); + turnColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + turnColour_actionPerformed(e); + } + }); + buriedColour.setLabel("Buried Index"); + buriedColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + buriedColour_actionPerformed(e); + } + }); + userDefinedColour.setLabel("User Defined..."); + userDefinedColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + userDefinedColour_actionPerformed(e); + } + }); + PIDColour.setLabel("Percentage Identity"); + PIDColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + PIDColour_actionPerformed(e); + } + }); + BLOSUM62Colour.setLabel("BLOSUM62 Score"); + BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + BLOSUM62Colour_actionPerformed(e); + } + }); + avDistanceTreeBlosumMenuItem.setLabel( + "Average Distance Using BLOSUM62"); + avDistanceTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + avTreeBlosumMenuItem_actionPerformed(e); + } + }); + njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62"); + njTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + njTreeBlosumMenuItem_actionPerformed(e); + } + }); + annotationPanelMenuItem.setActionCommand(""); + annotationPanelMenuItem.setState(true); + annotationPanelMenuItem.setLabel("Show Annotations"); + annotationPanelMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + annotationPanelMenuItem_actionPerformed(null); + } + }); + colourTextMenuItem.setLabel("Colour Text"); + colourTextMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + colourTextMenuItem_actionPerformed(null); + } + }); + overviewMenuItem.setLabel("Overview Window"); + overviewMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + overviewMenuItem_actionPerformed(e); + } + }); + undoMenuItem.setEnabled(false); + undoMenuItem.setLabel("Undo"); + undoMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + undoMenuItem_actionPerformed(e); + } + }); + redoMenuItem.setEnabled(false); + redoMenuItem.setLabel("Redo"); + redoMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + redoMenuItem_actionPerformed(e); + } + }); + conservationMenuItem.setLabel("by Conservation"); + conservationMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + conservationMenuItem_actionPerformed(null); + } + }); + noColourmenuItem.setLabel("None"); + noColourmenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + noColourmenuItem_actionPerformed(e); + } + }); + wrapMenuItem.setLabel("Wrap"); + wrapMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + wrapMenuItem_actionPerformed(null); + } + }); + renderGapsMenuItem.setLabel("Show Gaps"); + renderGapsMenuItem.setState(true); + renderGapsMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + renderGapsMenuItem_actionPerformed(null); + } + }); + findMenuItem.setLabel("Find..."); + findMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + findMenuItem_actionPerformed(e); + } + }); + searchMenu.setLabel("Search"); + + abovePIDThreshold.setLabel("Above Identity Threshold"); + abovePIDThreshold.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + abovePIDThreshold_actionPerformed(null); + } + }); + nucleotideColour.setLabel("Nucleotide"); + nucleotideColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + nucleotideColour_actionPerformed(e); + } + }); + deleteGroups.setLabel("Undefine Groups"); + deleteGroups.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + deleteGroups_actionPerformed(e); + } + }); + copy.setLabel("Copy"); + copy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + copy_actionPerformed(e); + } + }); + cut.setLabel("Cut"); + cut.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cut_actionPerformed(e); + } + }); + delete.setLabel("Delete"); + delete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + delete_actionPerformed(e); + } + }); + Menu1.setLabel("Paste"); + pasteNew.setLabel("To New Alignment"); + pasteNew.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + pasteNew_actionPerformed(e); + } + }); + pasteThis.setLabel("Add To This Alignment"); + pasteThis.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + pasteThis_actionPerformed(e); + } + }); + applyToAllGroups.setLabel("Apply Colour To All Groups"); + applyToAllGroups.setState(true); + applyToAllGroups.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + applyToAllGroups_actionPerformed(null); + } + }); + font.setLabel("Font..."); + font.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + font_actionPerformed(e); + } + }); + scaleAbove.setLabel("Scale Above"); + scaleAbove.setState(true); + scaleAbove.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + scaleAbove_actionPerformed(null); + } + }); + scaleLeft.setEnabled(false); + scaleLeft.setState(true); + scaleLeft.setLabel("Scale Left"); + scaleLeft.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + scaleLeft_actionPerformed(null); + } + }); + scaleRight.setEnabled(false); + scaleRight.setState(true); + scaleRight.setLabel("Scale Right"); + scaleRight.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + scaleRight_actionPerformed(null); + } + }); + modifyPID.setLabel("Modify Identity Threshold..."); + modifyPID.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + modifyPID_actionPerformed(e); + } + }); + modifyConservation.setLabel("Modify Conservation Threshold..."); + modifyConservation.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + modifyConservation_actionPerformed(e); + } + }); + sortByTreeMenu.setLabel("By Tree Order"); + sort.setLabel("Sort"); + calculate.setLabel("Calculate Tree"); + inputText.setLabel("Input from textbox"); + inputText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + inputText_actionPerformed(e); + } + }); + + helpMenu.setLabel("Help"); + documentation.setLabel("Documentation"); + documentation.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + documentation_actionPerformed(e); + } + }); + + about.setLabel("About..."); + about.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + about_actionPerformed(e); + } + }); + seqLimits.setState(true); + seqLimits.setLabel("Show Sequence Limits"); + seqLimits.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + seqLimits_itemStateChanged(e); + } + }); + + alignFrameMenuBar.add(fileMenu); + alignFrameMenuBar.add(editMenu); + alignFrameMenuBar.add(searchMenu); + alignFrameMenuBar.add(viewMenu); + alignFrameMenuBar.add(colourMenu); + alignFrameMenuBar.add(calculateMenu); + alignFrameMenuBar.add(helpMenu); + fileMenu.add(inputText); + fileMenu.add(outputTextboxMenu); + fileMenu.addSeparator(); + fileMenu.add(closeMenuItem); + editMenu.add(undoMenuItem); + editMenu.add(redoMenuItem); + editMenu.add(cut); + editMenu.add(copy); + editMenu.add(Menu1); + editMenu.add(delete); + editMenu.addSeparator(); + editMenu.add(selectAllSequenceMenuItem); + editMenu.add(deselectAllSequenceMenuItem); + editMenu.add(invertSequenceMenuItem); + editMenu.add(deleteGroups); + editMenu.addSeparator(); + editMenu.add(remove2LeftMenuItem); + editMenu.add(remove2RightMenuItem); + editMenu.add(removeGappedColumnMenuItem); + editMenu.add(removeAllGapsMenuItem); + editMenu.add(removeRedundancyMenuItem); + searchMenu.add(findMenuItem); + viewMenu.add(font); + viewMenu.addSeparator(); + viewMenu.add(seqLimits); + viewMenu.addSeparator(); + viewMenu.add(wrapMenuItem); + viewMenu.add(scaleAbove); + viewMenu.add(scaleLeft); + viewMenu.add(scaleRight); + viewMenu.addSeparator(); + viewMenu.add(viewBoxesMenuItem); + viewMenu.add(viewTextMenuItem); + viewMenu.add(colourTextMenuItem); + viewMenu.add(renderGapsMenuItem); + viewMenu.add(annotationPanelMenuItem); + viewMenu.addSeparator(); + viewMenu.add(overviewMenuItem); + colourMenu.add(applyToAllGroups); + colourMenu.addSeparator(); + colourMenu.add(noColourmenuItem); + colourMenu.add(clustalColour); + colourMenu.add(BLOSUM62Colour); + colourMenu.add(PIDColour); + colourMenu.add(zappoColour); + colourMenu.add(taylorColour); + colourMenu.add(hydrophobicityColour); + colourMenu.add(helixColour); + colourMenu.add(strandColour); + colourMenu.add(turnColour); + colourMenu.add(buriedColour); + colourMenu.add(nucleotideColour); + colourMenu.add(userDefinedColour); + colourMenu.addSeparator(); + colourMenu.add(conservationMenuItem); + colourMenu.add(modifyConservation); + colourMenu.add(abovePIDThreshold); + colourMenu.add(modifyPID); + calculateMenu.add(sort); + calculateMenu.add(calculate); + calculateMenu.addSeparator(); + calculateMenu.add(pairwiseAlignmentMenuItem); + calculateMenu.add(PCAMenuItem); + this.add(statusBar, BorderLayout.SOUTH); + Menu1.add(pasteNew); + Menu1.add(pasteThis); + sort.add(sortIDMenuItem); + sort.add(sortByTreeMenu); + sort.add(sortGroupMenuItem); + sort.add(sortPairwiseMenuItem); + calculate.add(averageDistanceTreeMenuItem); + calculate.add(neighbourTreeMenuItem); + calculate.add(avDistanceTreeBlosumMenuItem); + calculate.add(njTreeBlosumMenuItem); + helpMenu.add(documentation); + helpMenu.add(about); + } } + diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 209f939..2e0c1cb 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -36,7 +36,7 @@ public class AlignViewport int startSeq; int endSeq; - boolean showFullId = true; + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -98,7 +98,7 @@ public class AlignViewport String param = applet.getParameter("showFullId"); if (param != null) { - showFullId = Boolean.valueOf(param).booleanValue(); + showJVSuffix = Boolean.valueOf(param).booleanValue(); } param = applet.getParameter("showAnnotation"); @@ -596,14 +596,14 @@ public class AlignViewport return colourAppliesToAllGroups; } - public boolean getShowFullId() + public boolean getShowJVSuffix() { - return showFullId; + return showJVSuffix; } - public void setShowFullId(boolean b) + public void setShowJVSuffix(boolean b) { - showFullId = b; + showJVSuffix = b; } public boolean getShowAnnotation() diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 7332a1a..3771a57 100755 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -23,10 +23,8 @@ import java.awt.*; import java.awt.event.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; -public class AlignmentPanel - extends GAlignmentPanel implements AdjustmentListener +public class AlignmentPanel extends Panel implements AdjustmentListener { AlignViewport av; @@ -46,6 +44,15 @@ public class AlignmentPanel public AlignmentPanel(AlignFrame af, final AlignViewport av) { + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } + if(System.getProperty("os.name").startsWith("Mac")) MAC = true; @@ -204,14 +211,7 @@ public class AlignmentPanel while (i < al.getHeight() && al.getSequenceAt(i) != null) { SequenceI s = al.getSequenceAt(i); - if (av.getShowFullId()) - { - id = s.getDisplayId(); - } - else - { - id = s.getName(); - } + id = s.getDisplayId(av.getShowJVSuffix()); if (fm.stringWidth(id) > idWidth) { @@ -484,7 +484,7 @@ public class AlignmentPanel { int max = av.alignment.getWidth() / seqPanel.seqCanvas. - getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); + getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width) +1; vscroll.setMaximum(max); vscroll.setUnitIncrement(1); vscroll.setVisibleAmount(1); @@ -500,5 +500,80 @@ public class AlignmentPanel scalePanel.repaint(); annotationPanel.repaint(); + if (getBounds() == g.getClipBounds()) + { + if (overviewPanel != null) + overviewPanel.updateOverviewImage(); + } + + } + + protected Panel sequenceHolderPanel = new Panel(); + protected Scrollbar vscroll = new Scrollbar(); + protected Scrollbar hscroll = new Scrollbar(); + protected Panel seqPanelHolder = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + protected Panel scalePanelHolder = new Panel(); + protected Panel idPanelHolder = new Panel(); + BorderLayout borderLayout5 = new BorderLayout(); + protected Panel idSpaceFillerPanel1 = new Panel(); + public Panel annotationSpaceFillerHolder = new Panel(); + BorderLayout borderLayout6 = new BorderLayout(); + BorderLayout borderLayout7 = new BorderLayout(); + Panel hscrollHolder = new Panel(); + BorderLayout borderLayout10 = new BorderLayout(); + protected Panel hscrollFillerPanel = new Panel(); + BorderLayout borderLayout11 = new BorderLayout(); + public Panel annotationScroller = new Panel(); + BorderLayout borderLayout4 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + + private void jbInit() throws Exception { + // idPanelHolder.setPreferredSize(new Dimension(70, 10)); + this.setLayout(borderLayout7); + + // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); + sequenceHolderPanel.setLayout(borderLayout3); + seqPanelHolder.setLayout(borderLayout1); + scalePanelHolder.setBackground(Color.white); + + // scalePanelHolder.setPreferredSize(new Dimension(10, 30)); + scalePanelHolder.setLayout(borderLayout6); + idPanelHolder.setLayout(borderLayout5); + idSpaceFillerPanel1.setBackground(Color.white); + + // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); + idSpaceFillerPanel1.setLayout(borderLayout11); + annotationSpaceFillerHolder.setBackground(Color.white); + + // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); + annotationSpaceFillerHolder.setLayout(borderLayout4); + hscroll.setOrientation(Scrollbar.HORIZONTAL); + hscrollHolder.setLayout(borderLayout10); + hscrollFillerPanel.setBackground(Color.white); + + // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); + hscrollHolder.setBackground(Color.white); + + // annotationScroller.setPreferredSize(new Dimension(10, 80)); + // this.setPreferredSize(new Dimension(220, 166)); + seqPanelHolder.setBackground(Color.white); + idPanelHolder.setBackground(Color.white); + annotationScroller.setLayout(borderLayout2); + sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); + sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); + seqPanelHolder.add(vscroll, BorderLayout.EAST); + sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH); + + // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH); + this.add(idPanelHolder, BorderLayout.WEST); + idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH); + idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH); + this.add(hscrollHolder, BorderLayout.SOUTH); + hscrollHolder.add(hscroll, BorderLayout.CENTER); + hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST); + this.add(sequenceHolderPanel, BorderLayout.CENTER); } + } diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index 4c0d3de..ea9a8aa 100755 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -24,15 +24,23 @@ import java.awt.event.*; import jalview.datamodel.*; import jalview.io.*; -import jalview.jbappletgui.*; -public class CutAndPasteTransfer - extends GCutAndPasteTransfer +public class CutAndPasteTransfer extends Panel { jalview.bin.JalviewLite applet; + + boolean pdbImport = false; + Sequence seq; + SeqCanvas seqcanvas; + public CutAndPasteTransfer(boolean forImport, jalview.bin.JalviewLite mainApplet) { - super(); + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + applet = mainApplet; if (!forImport) @@ -41,6 +49,14 @@ public class CutAndPasteTransfer } } + public void setPDBImport(Sequence seq, SeqCanvas seqcanvas) + { + this.seq = seq; + this.seqcanvas = seqcanvas; + pdbImport = true; + } + + public String getText() { return textarea.getText(); @@ -68,29 +84,72 @@ public class CutAndPasteTransfer +warning); textarea.setCaretPosition(text.length()); - return; } - SequenceI[] sequences = null; + if(pdbImport) + { + new MCview.AppletPDBViewer(text, "Paste", seq, seqcanvas); + } + else + { + SequenceI[] sequences = null; - String format = IdentifyFile.Identify(text, "Paste"); - sequences = new FormatAdapter().readFile(text, "Paste", format); + String format = IdentifyFile.Identify(text, "Paste"); + sequences = new AppletFormatAdapter().readFile(text, "Paste", format); - if (sequences != null) - { - AlignFrame af = new AlignFrame(new Alignment(sequences), applet, - "Cut & Paste input - " + format); - af.statusBar.setText("Successfully pasted alignment file"); + if (sequences != null) + { + AlignFrame af = new AlignFrame(new Alignment(sequences), applet, + "Cut & Paste input - " + format); + af.statusBar.setText("Successfully pasted alignment file"); + } } - Frame frame = (Frame)this.getParent(); - frame.setVisible(false); + ((Frame)this.getParent()).setVisible(false); } protected void cancel_actionPerformed(ActionEvent e) { - Frame frame = (Frame)this.getParent(); - frame.setVisible(false); + ((Frame)this.getParent()).setVisible(false); + } + + protected TextArea textarea = new TextArea(); + Button ok = new Button(); + Button cancel = new Button(); + protected Panel buttonPanel = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + + + private void jbInit() throws Exception { + textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 10)); + textarea.setText("Paste your alignment file here"); + textarea.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(MouseEvent e) { + textarea_mousePressed(e); + } + }); + this.setLayout(borderLayout1); + ok.setLabel("OK"); + ok.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + ok_actionPerformed(e); + } + }); + cancel.setLabel("Cancel"); + cancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cancel_actionPerformed(e); + } + }); + this.add(buttonPanel, BorderLayout.SOUTH); + buttonPanel.add(ok, null); + buttonPanel.add(cancel, null); + this.add(textarea, java.awt.BorderLayout.CENTER); } + void textarea_mousePressed(MouseEvent e) { + if (textarea.getText().startsWith("Paste your")) { + textarea.setText(""); + } + } } diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 291ce5f..4a97e43 100755 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -16,94 +16,257 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; -import java.util.*; +import jalview.datamodel.*; import java.awt.*; -import jalview.datamodel.*; +import java.util.*; + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class FeatureRenderer { - AlignViewport av; - - SequenceGroup currentSequenceGroup = null; - SequenceGroup[] allGroups = null; - Color resBoxColour; - Graphics graphics; - - public FeatureRenderer(AlignViewport av) - { - this.av = av; - } - - public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, - int start, int end, int x1, int y1, int width, - int height) - { - Vector features = seq.getSequenceFeatures(); - Enumeration e = features.elements(); - while (e.hasMoreElements()) + AlignViewport av; + SequenceGroup currentSequenceGroup = null; + SequenceGroup[] allGroups = null; + Color resBoxColour; + Graphics graphics; + float transparency = .4f; + + // The following vector holds the features which are + // to be added, in the correct order or rendering + Vector featuresDisplayed; + + /** + * Creates a new FeatureRenderer object. + * + * @param av DOCUMENT ME! + */ + public FeatureRenderer(AlignViewport av) { - SequenceFeature sf = (SequenceFeature) e.nextElement(); - if (sf.getStart() > seq.getEnd()) - { - continue; - } + this.av = av; + initColours(); + String version = System.getProperty("java.version"); + if (version.indexOf("1.1") == 0) + highlightTransparent = false; - int fstart = seq.findIndex(sf.getStart()) - 1; - int fend = seq.findIndex(sf.getEnd()) - 1; + } - if ( (fstart <= end && fend >= start)) - { - if (fstart < 0) // fix for if the feature we have starts before the sequence start, +boolean highlightTransparent = true; + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param seq DOCUMENT ME! + * @param sg DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, + int start, int end, int x1, int y1, int width, int height) + { + + if(seq.getSequenceFeatures()==null) + return; + + Enumeration e = null, e2; + String type; + if(featuresDisplayed!=null) + e = featuresDisplayed.elements(); + else + e = seq.getSequenceFeatures().elements(); + + if(highlightTransparent) { - fstart = 0; // but the feature end is still valid!! + // MyGraphics.SetTransparency(g, transparency); } - if (fstart == fend) - { - g.setColor(Color.red); - g.fillRoundRect( (fstart - start) * width, y1, width, height, 4, 4); - g.setColor(Color.white); - - char s = seq.getSequence().charAt(fstart); - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + width * (fstart - start), - y1 + height - pady); - } - else + while (e.hasMoreElements()) { - for (int i = fstart; i <= fend; i++) - { - char s = seq.getSequence().charAt(i); - if (jalview.util.Comparison.isGap(s)) + SequenceFeature sf=null; + if(featuresDisplayed!=null) + { + e2 = seq.getSequenceFeatures().elements(); + type = e.nextElement().toString(); + while(e2.hasMoreElements()) + { + sf = (SequenceFeature) e2.nextElement(); + if(sf.getType().equals(type)) + break; + else + sf = null; + } + } + else { + sf = (SequenceFeature) e.nextElement(); + type = sf.getType(); + } + + if(sf==null) continue; + + + if (sf.getBegin() > seq.getEnd()) + { + continue; } - g.setColor(Color.blue); - g.fillRect( (i - start) * width, y1, width, height); + int fstart = seq.findIndex(sf.getBegin()) - 1; + int fend = seq.findIndex(sf.getEnd()) - 1; + + if (((fstart <= end) && (fend >= start))) + { + if (fstart < start) + { // fix for if the feature we have starts before the sequence start, + fstart = start; // but the feature end is still valid!! + } - g.setColor(Color.white); + if (fend >= end) + { + fend = end; + } - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + width * (i - start), - y1 + height - pady); + if (fstart == fend) + { + g.setColor(getColour(type)); + g.fillRoundRect((fstart - start) * width, y1, width, + height, 4, 4); + g.setColor(Color.white); + + char s = seq.getSequence().charAt(fstart); + FontMetrics fm = g.getFontMetrics(); + int charOffset = (width - fm.charWidth(s)) / 2; + int pady = height / 5; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (fstart - start)), + (y1 + height) - pady); + } + else + { + for (int i = fstart; i <= fend; i++) + { + char s = seq.getSequence().charAt(i); + + if (jalview.util.Comparison.isGap(s)) + { + continue; + } + + g.setColor(getColour(type)); + g.fillRect((i - start) * width, y1, width, height); + + g.setColor(Color.white); + + FontMetrics fm = g.getFontMetrics(); + int charOffset = (width - fm.charWidth(s)) / 2; + int pady = height / 5; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), + (y1 + height) - pady); + } + } + } } - } + + if (highlightTransparent) + { + // MyGraphics.SetTransparency(g, 1.0f); + } + } + + public Color getColour(String featureType) + { + return (Color)featureColours.get(featureType); + } + + public void setColour(String featureType, Color col) + { + featureColours.put(featureType, col); + } + + public void setTransparency(float value) + { + transparency = value; + } + + public float getTransparency() + { + return transparency; + } + + public void setFeaturePriority(Object [][] data) + { + // The feature table will display high priority + // features at the top, but theses are the ones + // we need to render last, so invert the data + featuresDisplayed = new Vector(); + for(int i=data.length-1; i>-1; i--) + { + String type = data[i][0].toString(); + setColour(type, (Color)data[i][1]); + if( ((Boolean)data[i][2]).booleanValue() ) + featuresDisplayed.addElement(type); } + } + Hashtable featureColours = new Hashtable(); + void initColours() + { + featureColours.put("active site", new Color(255, 75, 0)); + featureColours.put("binding site", new Color(245, 85, 0)); + featureColours.put("calcium-binding region", new Color(235, 95, 0)); + featureColours.put("chain", new Color(225, 105, 0)); + featureColours.put("coiled-coil region", new Color(215, 115, 0)); + featureColours.put("compositionally biased region", new Color(205, 125, 0)); + featureColours.put("cross-link", new Color(195, 135, 0)); + featureColours.put("disulfide bond", new Color(185, 145, 0)); + featureColours.put("DNA-binding region", new Color(175, 155, 0)); + featureColours.put("domain", new Color(165, 165, 0)); + featureColours.put("glycosylation site", new Color(155, 175, 0)); + featureColours.put("helix", new Color(145, 185, 0)); + featureColours.put("initiator methionine", new Color(135, 195, 5)); + featureColours.put("lipid moiety-binding region", new Color(125, 205, 15)); + featureColours.put("metal ion-binding site", new Color(115, 215, 25)); + featureColours.put("modified residue", new Color(105, 225, 35)); + featureColours.put("mutagenesis site", new Color(95, 235, 45)); + featureColours.put("non-consecutive residues", new Color(85, 245, 55)); + featureColours.put("non-terminal residue", new Color(75, 255, 65)); + featureColours.put("nucleotide phosphate-binding region", + new Color(65, 245, 75)); + featureColours.put("peptide", new Color(55, 235, 85)); + featureColours.put("propeptide", new Color(45, 225, 95)); + featureColours.put("region of interest", new Color(35, 215, 105)); + featureColours.put("repeat", new Color(25, 205, 115)); + featureColours.put("selenocysteine", new Color(15, 195, 125)); + featureColours.put("sequence conflict", new Color(5, 185, 135)); + featureColours.put("sequence variant", new Color(0, 175, 145)); + featureColours.put("short sequence motif", new Color(0, 165, 155)); + featureColours.put("signal peptide", new Color(0, 155, 165)); + featureColours.put("site", new Color(0, 145, 175)); + featureColours.put("splice variant", new Color(0, 135, 185)); + featureColours.put("strand", new Color(0, 125, 195)); + featureColours.put("topological domain", new Color(0, 115, 205)); + featureColours.put("transit peptide", new Color(0, 105, 215)); + featureColours.put("transmembrane region", new Color(0, 95, 225)); + featureColours.put("turn", new Color(0, 85, 235)); + featureColours.put("unsure residue", new Color(0, 75, 245)); + featureColours.put("zinc finger region", new Color(0, 65, 255)); } - } } + + + diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index 7cb3763..fcca0c1 100755 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -25,10 +25,8 @@ import java.awt.*; import java.awt.event.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; -public class Finder - extends GFinder +public class Finder extends Panel { AlignViewport av; AlignmentPanel ap; @@ -40,6 +38,15 @@ public class Finder int resIndex = 0; public Finder(final AlignmentPanel ap) { + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } + this.av = ap.av; this.ap = ap; frame = new Frame(); @@ -297,4 +304,71 @@ public class Finder } + Label jLabel1 = new Label(); + protected TextField textfield = new TextField(); + protected Button findAll = new Button(); + protected Button findNext = new Button(); + Panel jPanel1 = new Panel(); + GridLayout gridLayout1 = new GridLayout(); + protected Button createNewGroup = new Button(); + + + private void jbInit() throws Exception { + jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel1.setText("Find"); + jLabel1.setBounds(new Rectangle(3, 30, 34, 15)); + this.setLayout(null); + textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + textfield.setText(""); + textfield.setBounds(new Rectangle(40, 27, 133, 21)); + textfield.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(KeyEvent e) { + textfield_keyTyped(e); + } + }); + textfield.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + textfield_actionPerformed(e); + } + }); + findAll.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + findAll.setLabel("Find all"); + findAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + findAll_actionPerformed(e); + } + }); + findNext.setEnabled(false); + findNext.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + findNext.setLabel("Find Next"); + findNext.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + findNext_actionPerformed(e); + } + }); + jPanel1.setBounds(new Rectangle(180, 5, 141, 64)); + jPanel1.setLayout(gridLayout1); + gridLayout1.setHgap(0); + gridLayout1.setRows(3); + gridLayout1.setVgap(2); + createNewGroup.setEnabled(false); + createNewGroup.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + createNewGroup.setLabel("Create new group"); + createNewGroup.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + createNewGroup_actionPerformed(e); + } + }); + jPanel1.add(findNext, null); + jPanel1.add(findAll, null); + jPanel1.add(createNewGroup, null); + this.add(textfield, null); + this.add(jLabel1, null); + this.add(jPanel1, null); + } + + void textfield_keyTyped(KeyEvent e) { + findNext.setEnabled(true); + } + } diff --git a/src/jalview/appletgui/FontChooser.java b/src/jalview/appletgui/FontChooser.java index 17fe98a..27e2a93 100755 --- a/src/jalview/appletgui/FontChooser.java +++ b/src/jalview/appletgui/FontChooser.java @@ -21,10 +21,11 @@ package jalview.appletgui; import java.awt.*; -import jalview.jbappletgui.*; +import java.awt.event.ActionEvent; +import java.awt.event.ItemEvent; public class FontChooser - extends GFontChooser + extends Panel { AlignmentPanel ap; TreePanel tp; @@ -34,6 +35,15 @@ public class FontChooser public FontChooser(TreePanel tp) { + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } + this.tp = tp; oldFont = tp.getTreeFont(); init(); @@ -152,5 +162,90 @@ public class FontChooser } changeFont(); } + Label label1 = new Label(); + protected Choice fontSize = new Choice(); + protected Choice fontStyle = new Choice(); + Label label2 = new Label(); + Label label3 = new Label(); + protected Choice fontName = new Choice(); + Button ok = new Button(); + Button cancel = new Button(); + Panel panel1 = new Panel(); + Panel panel2 = new Panel(); + Panel panel3 = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + Panel panel4 = new Panel(); + Panel panel5 = new Panel(); + BorderLayout borderLayout4 = new BorderLayout(); + + + private void jbInit() throws Exception { + label1.setFont(new java.awt.Font("Verdana", 0, 11)); + label1.setAlignment(Label.RIGHT); + label1.setText("Font: "); + this.setLayout(borderLayout4); + fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); + fontSize.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fontSize_actionPerformed(); + } + }); + fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); + fontStyle.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fontStyle_actionPerformed(); + } + }); + label2.setAlignment(Label.RIGHT); + label2.setFont(new java.awt.Font("Verdana", 0, 11)); + label2.setText("Size: "); + label3.setAlignment(Label.RIGHT); + label3.setFont(new java.awt.Font("Verdana", 0, 11)); + label3.setText("Style: "); + fontName.setFont(new java.awt.Font("Verdana", 0, 11)); + fontName.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fontName_actionPerformed(); + } + }); + ok.setFont(new java.awt.Font("Verdana", 0, 11)); + ok.setLabel("OK"); + ok.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + ok_actionPerformed(); + } + }); + cancel.setFont(new java.awt.Font("Verdana", 0, 11)); + cancel.setLabel("Cancel"); + cancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cancel_actionPerformed(); + } + }); + this.setBackground(Color.white); + panel1.setLayout(borderLayout1); + panel2.setLayout(borderLayout3); + panel3.setLayout(borderLayout2); + panel5.setBackground(Color.white); + panel4.setBackground(Color.white); + panel1.setBackground(Color.white); + panel2.setBackground(Color.white); + panel3.setBackground(Color.white); + panel1.add(label1, BorderLayout.WEST); + panel1.add(fontName, BorderLayout.CENTER); + panel5.add(panel1, null); + panel5.add(panel3, null); + panel5.add(panel2, null); + panel2.add(label3, BorderLayout.WEST); + panel2.add(fontStyle, BorderLayout.CENTER); + panel3.add(label2, BorderLayout.WEST); + panel3.add(fontSize, BorderLayout.CENTER); + this.add(panel4, BorderLayout.SOUTH); + panel4.add(ok, null); + panel4.add(cancel, null); + this.add(panel5, BorderLayout.CENTER); + } } diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index a277adb..9773019 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -74,13 +74,8 @@ public class IdCanvas gg.setColor(Color.black); } - String string = s.getName(); - if (av.getShowFullId()) - { - string = s.getDisplayId(); - } - gg.drawString(string, 0, + gg.drawString( s.getDisplayId(av.getShowJVSuffix()), 0, ((i - starty) * charHeight) + ypos + charHeight - (charHeight / 5)); @@ -260,12 +255,9 @@ public class IdCanvas av.charHeight); gg.setColor(currentTextColor); - String string = av.alignment.getSequenceAt(i).getName(); - if (av.getShowFullId()) - { - string = av.alignment.getSequenceAt(i).getDisplayId(); - } - gg.drawString(string, 0, + + gg.drawString(av.alignment.getSequenceAt(i) + .getDisplayId(av.getShowJVSuffix()), 0, ((i - starty) * av.charHeight) + av.charHeight - (av.charHeight / 5)); } diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index b6e6a2b..d159a4c 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -116,6 +116,8 @@ public class IdPanel //DEFAULT LINK IS FIRST IN THE LINK LIST int seq = av.getIndex(y); String id = av.getAlignment().getSequenceAt(seq).getName(); + if (id.indexOf("|") > -1) + id = id.substring(id.lastIndexOf("|") + 1); String target = links.elementAt(0).toString(); target = target.substring(0, target.indexOf("|")); @@ -127,7 +129,8 @@ public class IdPanel try { - jalview.bin.JalviewLite.showURL(url, target); + + alignPanel.alignFrame.showURL(url, target); } catch (Exception ex) { diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 7910f2d..23bfd09 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -39,7 +39,8 @@ public class OverviewPanel // Can set different properties in this seqCanvas than // main visible SeqCanvas - SeqCanvas overviewSeq; + SequenceRenderer sr; + //FeatureRenderer fr; Frame nullFrame; @@ -52,9 +53,14 @@ public class OverviewPanel nullFrame = new Frame(); nullFrame.addNotify(); - overviewSeq = new SeqCanvas(av); - overviewSeq.isOverview = true; - overviewSeq.sr.renderGaps = false; + + sr = new SequenceRenderer(av); + sr.graphics = nullFrame.getGraphics(); + sr.renderGaps( false ); + //fr = new FeatureRenderer(av); + //fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency; + //fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed; + // scale the initial size of overviewpanel to shape of alignment @@ -231,31 +237,40 @@ public class OverviewPanel float sampleCol = (float) alwidth / (float) width; float sampleRow = (float) alheight / (float) sequencesHeight; + int lastcol=-1, lastrow=-1; + Color color = Color.white; for (int col = 0; col < width; col++) { for (int row = 0; row < sequencesHeight; row++) { - overviewSeq.drawPanel(mg, - (int) (col * sampleCol), - (int) (col * sampleCol), - (int) (row * sampleRow), - (int) (row * sampleRow) + 1, - (int) (col * sampleCol), - (int) (row * sampleRow), 0); - mg.translate(0, 1); + if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) + { + mg.setColor(color); + mg.fillRect(col,row,1,1); + continue; + } + + lastrow = (int)(row*sampleRow); + lastcol = (int)(col*sampleCol); + + color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol); + + mg.setColor(color); + mg.fillRect(col,row,1,1); if (av.conservation != null) + { + mg.translate(col, sequencesHeight); ap.annotationPanel.drawGraph(mg, av.conservation, (int) (sampleCol) + 1, graphHeight, (int) (col * sampleCol), (int) (col * sampleCol) + 1); - + mg.translate(-col, -sequencesHeight); + } } - mg.translate(0, -sequencesHeight); - mg.translate(1, 0); + } - } System.gc(); resizing = false; diff --git a/src/jalview/appletgui/PCAPanel.java b/src/jalview/appletgui/PCAPanel.java index 026ca09..0368d2a 100755 --- a/src/jalview/appletgui/PCAPanel.java +++ b/src/jalview/appletgui/PCAPanel.java @@ -26,10 +26,10 @@ import java.awt.event.*; import jalview.analysis.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; + public class PCAPanel - extends GPCAPanel implements Runnable + extends Frame implements Runnable { PCA pca; int top; @@ -40,6 +40,22 @@ public class PCAPanel public PCAPanel(AlignViewport av) { + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + for (int i = 1; i < 8; i++) + { + xCombobox.addItem("dim " + i); + yCombobox.addItem("dim " + i); + zCombobox.addItem("dim " + i); + } + this.av = av; if (av.getSelectionGroup()!=null && av.getSelectionGroup().getSize() > 3) { @@ -170,5 +186,87 @@ public class PCAPanel { rc.showLabels( labels.getState() ); } + Panel jPanel2 = new Panel(); + Label jLabel1 = new Label(); + Label jLabel2 = new Label(); + Label jLabel3 = new Label(); + protected Choice xCombobox = new Choice(); + protected Choice yCombobox = new Choice(); + protected Choice zCombobox = new Choice(); + FlowLayout flowLayout1 = new FlowLayout(); + BorderLayout borderLayout1 = new BorderLayout(); + MenuBar menuBar1 = new MenuBar(); + Menu menu1 = new Menu(); + Menu menu2 = new Menu(); + protected CheckboxMenuItem labels = new CheckboxMenuItem(); + MenuItem values = new MenuItem(); + + private void jbInit() + throws Exception + { + this.setLayout(borderLayout1); + jPanel2.setLayout(flowLayout1); + jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel1.setText("x="); + jLabel2.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel2.setText("y="); + jLabel3.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel3.setText("z="); + jPanel2.setBackground(Color.white); + zCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + zCombobox.addItemListener(new java.awt.event.ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + zCombobox_actionPerformed(null); + } + }); + yCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + yCombobox.addItemListener(new java.awt.event.ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + yCombobox_actionPerformed(null); + } + }); + xCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + xCombobox.addItemListener(new java.awt.event.ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + xCombobox_actionPerformed(null); + } + }); + this.setMenuBar(menuBar1); + menu1.setLabel("File"); + menu2.setLabel("View"); + labels.setLabel("Labels"); + labels.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent itemEvent) + { + labels_itemStateChanged(itemEvent); + } + }); + values.setLabel("Output Values..."); + values.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + values_actionPerformed(actionEvent); + } + }); + this.add(jPanel2, BorderLayout.SOUTH); + jPanel2.add(jLabel1, null); + jPanel2.add(xCombobox, null); + jPanel2.add(jLabel2, null); + jPanel2.add(yCombobox, null); + jPanel2.add(jLabel3, null); + jPanel2.add(zCombobox, null); + menuBar1.add(menu1); + menuBar1.add(menu2); + menu2.add(labels); + menu1.add(values); + } } diff --git a/src/jalview/appletgui/PairwiseAlignPanel.java b/src/jalview/appletgui/PairwiseAlignPanel.java index d5243e3..910a206 100755 --- a/src/jalview/appletgui/PairwiseAlignPanel.java +++ b/src/jalview/appletgui/PairwiseAlignPanel.java @@ -25,17 +25,24 @@ import java.awt.event.*; import jalview.analysis.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; +import java.awt.*; public class PairwiseAlignPanel - extends GPairwiseAlignPanel + extends Panel { Vector sequences = new Vector(); AlignmentPanel ap; public PairwiseAlignPanel(AlignmentPanel ap) { - super(); + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } this.ap = ap; float scores[][] = new float[ap.av.alignment.getHeight()][ap.av.alignment. getHeight()]; @@ -54,7 +61,7 @@ public class PairwiseAlignPanel as.calcScoreMatrix(); as.traceAlignment(); - as.printAlignment(); + as.printAlignment(System.out); scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length; totscore = totscore + scores[i][j]; @@ -93,5 +100,27 @@ public class PairwiseAlignPanel "Pairwise Aligned Sequences"); } + protected ScrollPane scrollPane = new ScrollPane(); + protected TextArea textarea = new TextArea(); + protected Button viewInEditorButton = new Button(); + Panel jPanel1 = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + + private void jbInit() throws Exception { + this.setLayout(borderLayout1); + textarea.setFont(new java.awt.Font("Monospaced", 0, 12)); + textarea.setText(""); + viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12)); + viewInEditorButton.setLabel("View in alignment editor"); + viewInEditorButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + viewInEditorButton_actionPerformed(e); + } + }); + this.add(scrollPane, BorderLayout.CENTER); + scrollPane.add(textarea); + this.add(jPanel1, BorderLayout.SOUTH); + jPanel1.add(viewInEditorButton, null); + } } diff --git a/src/jalview/appletgui/RedundancyPanel.java b/src/jalview/appletgui/RedundancyPanel.java index 8aed730..3e3691b 100755 --- a/src/jalview/appletgui/RedundancyPanel.java +++ b/src/jalview/appletgui/RedundancyPanel.java @@ -24,10 +24,8 @@ import java.util.*; import java.awt.event.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; -public class RedundancyPanel - extends GSliderPanel +public class RedundancyPanel extends SliderPanel { AlignmentPanel ap; @@ -35,6 +33,8 @@ public class RedundancyPanel public RedundancyPanel(AlignmentPanel ap) { + super(ap, 0, false, null); + this.ap = ap; label.setText("Enter the redundancy threshold"); diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index 5daa320..370de5f 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -36,6 +36,8 @@ public class RotatableCanvas RotatableMatrix idmat = new RotatableMatrix(3, 3); RotatableMatrix objmat = new RotatableMatrix(3, 3); RotatableMatrix rotmat = new RotatableMatrix(3, 3); + String tooltip; + int toolx, tooly; //RubberbandRectangle rubberband; @@ -291,6 +293,10 @@ public class RotatableCanvas return getPreferredSize(); } + public void update(Graphics g) + { + paint(g); + } public void paint(Graphics g) { if (points == null) @@ -323,6 +329,12 @@ public class RotatableCanvas drawAxes(ig); } + if(tooltip!=null) + { + ig.setColor(Color.red); + ig.drawString(tooltip, toolx, tooly); + } + g.drawImage(img, 0, 0, this); } } @@ -389,14 +401,7 @@ public class RotatableCanvas getName(), x - 3, y - 4); } - } -// //Now the rectangle -// if (rectx2 != -1 && recty2 != -1) { -// g.setColor(Color.white); -// -// g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); -// } } public Dimension minimumsize() @@ -417,7 +422,6 @@ public class RotatableCanvas public void keyPressed(KeyEvent evt) { - requestFocus(); if (evt.getKeyCode() == KeyEvent.VK_UP) { scalefactor = (float) (scalefactor * 1.1); @@ -507,27 +511,26 @@ public class RotatableCanvas repaint(); } - // private void fireSequenceSelectionEvent(Selection sel) { - // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); - //} public void mouseMoved(MouseEvent evt) { - // SequenceI found = findPoint(evt.getX(), evt.getY()); + SequenceI found = findPoint(evt.getX(), evt.getY()); + if(found==null) + tooltip = null; + else + { + tooltip = found.getName(); + toolx = evt.getX(); + tooly = evt.getY(); + } + repaint(); } public void mouseDragged(MouseEvent evt) { mx = evt.getX(); my = evt.getY(); - //Check if this is a rectangle drawing drag - if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) - { -// rectx2 = evt.getX(); -// recty2 = evt.getY(); - } - else - { + rotmat.setIdentity(); rotmat.rotate( (float) (my - omy), 'x'); @@ -557,8 +560,6 @@ public class RotatableCanvas omy = my; paint(this.getGraphics()); - } - } public void rectSelect(int x1, int y1, int x2, int y2) @@ -614,26 +615,5 @@ public class RotatableCanvas return null; } } - /* public boolean handleRubberbandEvent(RubberbandEvent evt) { - System.out.println("Rubberband handler called in RotatableCanvas with " + - evt.getBounds()); - - Rubberband rb = (Rubberband)evt.getSource(); - - // Clear the current selection (instance variable) - //if ((rb.getModifiers() & Event.SHIFT_MASK) == 0) { - // clearSelection(); - //} - - if (rb.getComponent() == this) { - Rectangle bounds = evt.getBounds(); - rectSelect(bounds.x,bounds.y,bounds.x+bounds.width,bounds.y+bounds.height); - } - - redrawneeded = true; - paint(this.getGraphics()); - - return true; - }*/ } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 1de9418..5d02825 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -43,7 +43,6 @@ public class SeqCanvas boolean fastPaint = false; - boolean isOverview = false; public SeqCanvas(AlignViewport av) { @@ -51,9 +50,30 @@ public class SeqCanvas fr = new FeatureRenderer(av); sr = new SequenceRenderer(av); PaintRefresher.Register(this, av.alignment); + } + public AlignViewport getViewport() + { + return av; + } + + public FeatureRenderer getFeatureRenderer() + { + return fr; } + MCview.AppletPDBCanvas pdbCanvas; + public SequenceRenderer getSequenceRenderer() + { + return sr; + } + + public void setPDBCanvas(MCview.AppletPDBCanvas pc) + { + pdbCanvas = pc; + } + + void drawNorthScale(Graphics g, int startx, int endx, int ypos) { int scalestartx = startx - startx % 10 + 10; @@ -254,6 +274,10 @@ public class SeqCanvas g.drawImage(img, 0, 0, this); + if (pdbCanvas != null) + { + pdbCanvas.updateSeqColours(); + } } int LABEL_WEST, LABEL_EAST; @@ -368,12 +392,12 @@ public class SeqCanvas if(av.showAnnotation) { - g.translate(0, cHeight + ypos); + g.translate(0, cHeight + ypos+4); if(annotations==null) annotations = new AnnotationPanel(av); annotations.drawComponent( g, startRes, endx + 1); - g.translate(0, -cHeight - ypos); + g.translate(0, -cHeight - ypos-4); } g.translate(-LABEL_WEST, 0); @@ -447,7 +471,7 @@ public class SeqCanvas group = (SequenceGroup) groups.elementAt(0); groupIndex = 0; } - if (group != null && !isOverview) + if (group != null) { do { @@ -473,10 +497,12 @@ public class SeqCanvas group.sequences.contains(av.alignment.getSequenceAt( i))) { - if ((bottom == -1) && - !group.sequences.contains( - av.alignment.getSequenceAt(i + 1))) - { + + if (bottom == -1) + { + if(i == y2-1 || // Dont check for i+1 if on the bottom row + !group.sequences.contains(av.alignment.getSequenceAt(i+1 ))) + bottom = sy + av.charHeight; } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 9ed48b2..9030341 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -290,35 +290,38 @@ public class SeqPanel } } - ap.alignFrame.statusBar.setText(text.toString()); + if(seqCanvas.pdbCanvas!=null && sequence==seqCanvas.pdbCanvas.sequence) + { + seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res)); + } + // use aa to see if the mouse pointer is on a - if (av.showSequenceFeatures) + if (av.showSequenceFeatures && sequence.getSequenceFeatures()!=null) { Vector features = sequence.getSequenceFeatures(); Enumeration e = features.elements(); - StringBuffer sbuffer = new StringBuffer(); + text.append(" Sequence Feature: "); while (e.hasMoreElements()) { SequenceFeature sf = (SequenceFeature) e.nextElement(); - if (sf.getStart() <= sequence.findPosition(res) && + if (sf.getBegin() <= sequence.findPosition(res) && sf.getEnd() >= sequence.findPosition(res)) { - if (sbuffer.length() > 0) - { - sbuffer.append("; "); - } - sbuffer.append(sf.getType() + " " + sf.getDescription()); + text.append(sf.getDescription()); if (sf.getStatus().length() > 0) { - sbuffer.append(" (" + sf.getStatus() + ")"); + text.append(" (" + sf.getStatus() + ")"); } + text.append("; "); } } } + ap.alignFrame.statusBar.setText(text.toString()); + } public void doMouseDragged(MouseEvent evt) @@ -504,6 +507,9 @@ public class SeqPanel oldSeq = seq; startWrapBlock=wrappedBlock; + if(seq==-1) + return; + SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); if (sequence == null || res > sequence.getLength()) diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index c413588..c68e85c 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -44,11 +44,24 @@ public class SequenceRenderer renderGaps = b; } - public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) + public Color getResidueBoxColour(SequenceI seq, int i) { - getBoxColour(cs, seq, i); + allGroups = av.alignment.findAllGroups(seq); + + if (inCurrentSequenceGroup(i)) + { + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.globalColourScheme, seq, i); + } + return resBoxColour; - } + } void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) { @@ -62,6 +75,14 @@ public class SequenceRenderer } } + Image offscreen; + public Color findSequenceColour(SequenceI seq, int i) + { + allGroups = av.alignment.findAllGroups(seq); + drawBoxes(seq, i,i, 0, 0, 1,1); + return resBoxColour; + } + public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, int start, int end, int x1, int y1, int width, int height) diff --git a/src/jalview/appletgui/SliderPanel.java b/src/jalview/appletgui/SliderPanel.java index 3e23728..a53e9dd 100755 --- a/src/jalview/appletgui/SliderPanel.java +++ b/src/jalview/appletgui/SliderPanel.java @@ -25,11 +25,9 @@ import java.awt.*; import java.awt.event.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; import jalview.schemes.*; -public class SliderPanel - extends GSliderPanel +public class SliderPanel extends Panel { AlignmentPanel ap; boolean forConservation = true; @@ -153,6 +151,11 @@ public class SliderPanel public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, ColourSchemeI cs) { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } this.ap = ap; this.cs = cs; forConservation = forConserve; @@ -258,4 +261,76 @@ public class SliderPanel return Integer.parseInt(valueField.getText()); } + // this is used for conservation colours, PID colours and redundancy threshold + protected Scrollbar slider = new Scrollbar(); + protected TextField valueField = new TextField(); + protected Label label = new Label(); + Panel jPanel1 = new Panel(); + Panel jPanel2 = new Panel(); + protected Button applyButton = new Button(); + protected Button undoButton = new Button(); + FlowLayout flowLayout1 = new FlowLayout(); + protected Checkbox allGroupsCheck = new Checkbox(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + FlowLayout flowLayout2 = new FlowLayout(); + + private void jbInit() throws Exception { + this.setLayout(borderLayout2); + + // slider.setMajorTickSpacing(10); + // slider.setMinorTickSpacing(1); + // slider.setPaintTicks(true); + slider.setBackground(Color.white); + slider.setFont(new java.awt.Font("Verdana", 0, 11)); + slider.setOrientation(0); + valueField.setFont(new java.awt.Font("Verdana", 0, 11)); + valueField.setText(" "); + valueField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + valueField_actionPerformed(e); + } + }); + label.setFont(new java.awt.Font("Verdana", 0, 11)); + label.setText("set this label text"); + jPanel1.setLayout(borderLayout1); + jPanel2.setLayout(flowLayout1); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + applyButton_actionPerformed(e); + } + }); + undoButton.setEnabled(false); + undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); + undoButton.setLabel("Undo"); + undoButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + undoButton_actionPerformed(e); + } + }); + allGroupsCheck.setEnabled(false); + allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); + allGroupsCheck.setLabel("Apply threshold to all groups"); + allGroupsCheck.setName("Apply to all Groups"); + this.setBackground(Color.white); + this.setForeground(Color.black); + jPanel2.add(label, null); + jPanel2.add(applyButton, null); + jPanel2.add(undoButton, null); + jPanel2.add(allGroupsCheck); + jPanel1.add(valueField, java.awt.BorderLayout.EAST); + jPanel1.add(slider, java.awt.BorderLayout.CENTER); + this.add(jPanel1, java.awt.BorderLayout.SOUTH); + this.add(jPanel2, java.awt.BorderLayout.CENTER); + } + + protected void applyButton_actionPerformed(ActionEvent e) + { + } + + protected void undoButton_actionPerformed(ActionEvent e) + { + } } diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index d4202c3..e3f6c3c 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -356,6 +356,7 @@ public class TreeCanvas g.setFont(font); + FontMetrics fm = g.getFontMetrics(font); if (nameHash.size() == 0) diff --git a/src/jalview/appletgui/TreePanel.java b/src/jalview/appletgui/TreePanel.java index 3e26a4b..99ad412 100755 --- a/src/jalview/appletgui/TreePanel.java +++ b/src/jalview/appletgui/TreePanel.java @@ -22,19 +22,17 @@ package jalview.appletgui; import java.util.*; import java.awt.event.*; +import java.awt.*; import jalview.analysis.*; import jalview.datamodel.*; import jalview.io.*; -import jalview.jbappletgui.*; -public class TreePanel - extends GTreePanel +public class TreePanel extends Frame { SequenceI[] seq; String type; String pwtype; - AlignmentPanel ap; int start; int end; TreeCanvas treeCanvas; @@ -58,7 +56,16 @@ public class TreePanel public TreePanel(AlignViewport av, Vector seqVector, String type, String pwtype, int s, int e) { - super(); + try + { + jbInit(); + this.setMenuBar(jMenuBar1); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + initTreePanel(av, seqVector, type, pwtype, s, e, null); } @@ -74,7 +81,16 @@ public class TreePanel public TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree, String type, String pwtype) { - super(); + try + { + jbInit(); + this.setMenuBar(jMenuBar1); + } + catch (Exception e) + { + e.printStackTrace(); + } + initTreePanel(av, seqVector, type, pwtype, 0, seqVector.size(), newtree); } @@ -151,7 +167,7 @@ public class TreePanel { jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); String output = fout.print(false, true); - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame.applet); + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, null); cap.setText(output); java.awt.Frame frame = new java.awt.Frame(); frame.add(cap); @@ -192,4 +208,71 @@ public class TreePanel treeCanvas.setMarkPlaceholders(placeholdersMenu.getState()); } + BorderLayout borderLayout1 = new BorderLayout(); + protected ScrollPane scrollPane = new ScrollPane(); + MenuBar jMenuBar1 = new MenuBar(); + Menu jMenu2 = new Menu(); + protected MenuItem fontSize = new MenuItem(); + protected CheckboxMenuItem bootstrapMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem distanceMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem placeholdersMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem fitToWindow = new CheckboxMenuItem(); + Menu fileMenu = new Menu(); + MenuItem newickOutput = new MenuItem(); + + private void jbInit() throws Exception { + setLayout(borderLayout1); + this.setBackground(Color.white); + this.setFont(new java.awt.Font("Verdana", 0, 12)); + jMenu2.setLabel("View"); + fontSize.setLabel("Font..."); + fontSize.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + fontSize_actionPerformed(e); + } + }); + bootstrapMenu.setLabel("Show Bootstrap Values"); + bootstrapMenu.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + bootstrapMenu_actionPerformed(null); + } + }); + distanceMenu.setLabel("Show Distances"); + distanceMenu.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + distanceMenu_actionPerformed(null); + } + }); + placeholdersMenu.setLabel("Mark Unassociated Leaves"); + placeholdersMenu.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + placeholdersMenu_actionPerformed(null); + } + }); + fitToWindow.setState(true); + fitToWindow.setLabel("Fit To Window"); + fitToWindow.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fitToWindow_actionPerformed(null); + } + }); + fileMenu.setLabel("File"); + newickOutput.setLabel("Newick Format"); + newickOutput.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + newickOutput_actionPerformed(actionEvent); + } + }); + + add(scrollPane, BorderLayout.CENTER); + jMenuBar1.add(fileMenu); + jMenuBar1.add(jMenu2); + jMenu2.add(fitToWindow); + jMenu2.add(fontSize); + jMenu2.add(distanceMenu); + jMenu2.add(bootstrapMenu); + jMenu2.add(placeholdersMenu); + fileMenu.add(newickOutput); + } + } diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 36df306..7cd0391 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -25,11 +25,10 @@ import java.awt.*; import java.awt.event.*; import jalview.datamodel.*; -import jalview.jbappletgui.*; import jalview.schemes.*; public class UserDefinedColours - extends GUserDefinedColours + extends Panel { AlignmentPanel ap; @@ -49,7 +48,11 @@ public class UserDefinedColours public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) { - super(); + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } frame = new Frame(); frame.add(this); jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, 345); @@ -262,4 +265,136 @@ public class UserDefinedColours frame.setVisible(false); } + + protected Panel buttonPanel = new Panel(); + protected GridLayout gridLayout = new GridLayout(); + Panel jPanel2 = new Panel(); + protected Button okButton = new Button(); + protected Button applyButton = new Button(); + protected Button cancelButton = new Button(); + protected Scrollbar rScroller = new Scrollbar(); + Label label1 = new Label(); + protected TextField rText = new TextField(); + Label label4 = new Label(); + protected Scrollbar gScroller = new Scrollbar(); + protected TextField gText = new TextField(); + Label label5 = new Label(); + protected Scrollbar bScroller = new Scrollbar(); + protected TextField bText = new TextField(); + protected Panel target = new Panel(); + + private void jbInit() throws Exception { + this.setLayout(null); + buttonPanel.setLayout(gridLayout); + gridLayout.setColumns(6); + gridLayout.setRows(4); + okButton.setFont(new java.awt.Font("Verdana", 0, 11)); + okButton.setLabel("OK"); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + okButton_actionPerformed(e); + } + }); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + applyButton_actionPerformed(e); + } + }); + cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); + cancelButton.setLabel("Cancel"); + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cancelButton_actionPerformed(e); + } + }); + this.setBackground(new Color(212, 208, 223)); + jPanel2.setBounds(new Rectangle(0, 265, 400, 35)); + buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); + rScroller.setMaximum(256); + rScroller.setMinimum(0); + rScroller.setOrientation(0); + rScroller.setUnitIncrement(1); + rScroller.setVisibleAmount(1); + rScroller.setBounds(new Rectangle(36, 27, 119, 19)); + rScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + rScroller_adjustmentValueChanged(e); + } + }); + label1.setAlignment(Label.RIGHT); + label1.setText("R"); + label1.setBounds(new Rectangle(19, 30, 16, 15)); + rText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + rText.setText("0 "); + rText.setBounds(new Rectangle(156, 27, 53, 19)); + rText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + rText_actionPerformed(e); + } + }); + label4.setAlignment(Label.RIGHT); + label4.setText("G"); + label4.setBounds(new Rectangle(15, 56, 20, 15)); + gScroller.setMaximum(256); + gScroller.setMinimum(0); + gScroller.setOrientation(0); + gScroller.setUnitIncrement(1); + gScroller.setVisibleAmount(1); + gScroller.setBounds(new Rectangle(35, 52, 120, 20)); + gScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + gScroller_adjustmentValueChanged(e); + } + }); + gText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + gText.setText("0 "); + gText.setBounds(new Rectangle(156, 52, 53, 20)); + gText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + gText_actionPerformed(e); + } + }); + label5.setAlignment(Label.RIGHT); + label5.setText("B"); + label5.setBounds(new Rectangle(14, 82, 20, 15)); + bScroller.setMaximum(256); + bScroller.setMinimum(0); + bScroller.setOrientation(0); + bScroller.setUnitIncrement(1); + bScroller.setVisibleAmount(1); + bScroller.setBounds(new Rectangle(35, 78, 120, 20)); + bScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + bScroller_adjustmentValueChanged(e); + } + }); + bText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + bText.setText("0 "); + bText.setBounds(new Rectangle(157, 78, 52, 20)); + bText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + bText_actionPerformed(e); + } + }); + target.setBackground(Color.black); + target.setBounds(new Rectangle(229, 26, 134, 79)); + this.add(jPanel2, null); + jPanel2.add(okButton, null); + jPanel2.add(applyButton, null); + jPanel2.add(cancelButton, null); + this.add(buttonPanel, null); + this.add(target, null); + this.add(gScroller); + this.add(rScroller); + this.add(bScroller); + this.add(label5); + this.add(label4); + this.add(label1); + this.add(gText); + this.add(rText); + this.add(bText); +} + } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 2899abb..1a67c05 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -57,8 +57,11 @@ public class Jalview System.out.println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n" +"-nodisplay\tRun Jalview without User Interface.\n" +"-props FILE\tUse the given Jalview properties file instead of users default.\n" - +"-groups FILE\tUse the given file to mark groups on the alignment. \nGroups file is in the following tab delimited format\n" - +"TEXTSEQUENCE_IDSEQUENCE_INDEXSTART_RESIDUEEND_RESIDUECOLOUR\n" + +"-groups FILE\tUse the given file to mark groups on the alignment." + +"\nThe first lines of the groups file lists the GroupName and GroupColours" + +" to be used in the alignment. Use the GROUPNAME label for each of your sequences. " + +"\nGROUPNAMEGROUPCOLOUR\n" + +"TEXTSEQUENCE_IDSEQUENCE_INDEXSTART_RESIDUEEND_RESIDUEGROUPNAME\n" +"SequenceID is used in preference to SequenceIndex if both are provided.\n" +"Enter ID_NOT_SPECIFIED for SEQUENCE_ID or -1 for SEQUENCE_INDEX if unknown.\n" +"COLOUR can be hexadecimal RGB or 'red', 'blue' etc.\n\n" diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 1e94a0d..d5801df 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -40,18 +40,18 @@ public class JalviewLite extends Applet { static int lastFrameX = 200; static int lastFrameY = 200; - static Applet applet; boolean fileFound = true; String file = "No file"; Button launcher = new Button("Start Jalview"); + AlignFrame currentAlignFrame; + + /** * init method for Jalview Applet */ public void init() { - applet = this; - int r = 255; int g = 255; int b = 255; @@ -73,22 +73,42 @@ public class JalviewLite extends Applet } } + param = getParameter("label"); + if(param != null) + launcher.setLabel(param); + this.setBackground(new Color(r, g, b)); - file = getParameter("file"); + param = getParameter("features"); + if(param!=null) + { + if(param.indexOf("://")==-1) + param = getCodeBase() + param; + } + final String featuresFile = param; + + file = getParameter("file"); + final JalviewLite applet = this; if (file != null) { add(launcher); - file = applet.getCodeBase() + file; + if(file.indexOf("://")==-1) + file = getCodeBase() + file; + launcher.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { String format = jalview.io.IdentifyFile.Identify(file, "URL"); - LoadFile(file, "URL", format); - } + LoadingThread loader = new LoadingThread(file, + "URL", + format, + featuresFile, + applet); + loader.start(); + } }); } else @@ -98,6 +118,7 @@ public class JalviewLite extends Applet } } + public static void main(String [] args) { if(args.length!=1) @@ -106,9 +127,8 @@ public class JalviewLite extends Applet System.exit(1); } - String format = jalview.io.IdentifyFile.Identify(args[0],"File"); - SequenceI[] sequences = new FormatAdapter().readFile(args[0], "File", format); + SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format); if ( (sequences != null) && (sequences.length > 0)) { @@ -117,50 +137,6 @@ public class JalviewLite extends Applet } } - /** - * Displays the given URL in a new browser window - * - * @param url URL to display in browser window. - *
New window will be named "HELP_WINDOW" - */ - public static void showURL(String url) - { - showURL(url, "HELP"); - } - - public static void showURL(String url, String target) - { - if(applet==null) - { - System.out.println("Not running as applet - no browser available."); - } - else - { - try - { - applet.getAppletContext().showDocument(new java.net.URL(url), - target); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - } - - - /** - * Starts a new LoadingThread for loading an alignment file - * - * @param file file name including full path to file - * @param protocol file or URL or paste - * @param format Fasta, Clustal, PFAM, MSF, PIR, BLC, Jalview - */ - public void LoadFile(String file, String protocol, String format) - { - LoadingThread loader = new LoadingThread(file, protocol, format, this); - loader.start(); - } /** * Initialises and displays a new java.awt.Frame @@ -182,12 +158,36 @@ public class JalviewLite extends Applet { public void windowClosing(WindowEvent e) { + lastFrameX -=40; + lastFrameY-=40; frame.dispose(); } }); frame.setVisible(true); } + public String getAlignment(String format) + { + return getAlignment(format, "true"); + } + + public String getAlignment(String format, String suffix) + { + try + { + boolean seqlimits = suffix.equalsIgnoreCase("true"); + + String reply = new AppletFormatAdapter().formatSequences(format, + currentAlignFrame.viewport.getAlignment().getSequences(), seqlimits); + return reply; + } + catch (Exception ex) + {ex.printStackTrace(); + return "Error retrieving alignment in " + format + " format. "; + + } + } + /** * This paints the background surrounding the "Launch Jalview button" *
@@ -213,27 +213,54 @@ public class JalviewLite extends Applet String file; String protocol; String format; - JalviewLite jlapplet; + String featuresFile; + JalviewLite applet; - public LoadingThread(String file, String protocol, String format, - JalviewLite applet) + public LoadingThread(String file, + String protocol, + String format, + String features, + JalviewLite applet) { this.file = file; this.protocol = protocol; this.format = format; - this.jlapplet = applet; + featuresFile = features; + this.applet = applet; } public void run() { SequenceI[] sequences = null; - sequences = new FormatAdapter().readFile(file, protocol, format); + sequences = new AppletFormatAdapter().readFile(file, protocol, format); if ((sequences != null) && (sequences.length > 0)) { - AlignFrame af = new AlignFrame(new Alignment(sequences), - jlapplet, file); - af.statusBar.setText("Successfully loaded file " + file); + currentAlignFrame = new AlignFrame(new Alignment(sequences), + applet, file); + currentAlignFrame.statusBar.setText("Successfully loaded file " + file); + + if(featuresFile!=null) + currentAlignFrame.parseFeaturesFile(featuresFile); + + String pdbfile = applet.getParameter("PDBFILE"); + if(pdbfile!=null) + { + if(pdbfile.indexOf("://")==-1) + pdbfile = getCodeBase() + pdbfile; + + String sequence = applet.getParameter("PDBSEQ"); + + if(sequence!=null) + { + new MCview.AppletPDBViewer(pdbfile, "URL", + (Sequence)currentAlignFrame.getAlignViewport().getAlignment().findName(sequence), + currentAlignFrame.getSeqcanvas()); + + + } + + } } else { diff --git a/src/jalview/binding/Feature.java b/src/jalview/binding/Feature.java new file mode 100755 index 0000000..95d5192 --- /dev/null +++ b/src/jalview/binding/Feature.java @@ -0,0 +1,305 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Feature. + * + * @version $Revision$ $Date$ + */ +public class Feature implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _begin + */ + private int _begin; + + /** + * keeps track of state for field: _begin + */ + private boolean _has_begin; + + /** + * Field _end + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _type + */ + private java.lang.String _type; + + /** + * Field _description + */ + private java.lang.String _description; + + /** + * Field _status + */ + private java.lang.String _status; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Feature() { + super(); + } //-- jalview.binding.Feature() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteBegin + * + */ + public void deleteBegin() + { + this._has_begin= false; + } //-- void deleteBegin() + + /** + * Method deleteEnd + * + */ + public void deleteEnd() + { + this._has_end= false; + } //-- void deleteEnd() + + /** + * Returns the value of field 'begin'. + * + * @return int + * @return the value of field 'begin'. + */ + public int getBegin() + { + return this._begin; + } //-- int getBegin() + + /** + * Returns the value of field 'description'. + * + * @return String + * @return the value of field 'description'. + */ + public java.lang.String getDescription() + { + return this._description; + } //-- java.lang.String getDescription() + + /** + * Returns the value of field 'end'. + * + * @return int + * @return the value of field 'end'. + */ + public int getEnd() + { + return this._end; + } //-- int getEnd() + + /** + * Returns the value of field 'status'. + * + * @return String + * @return the value of field 'status'. + */ + public java.lang.String getStatus() + { + return this._status; + } //-- java.lang.String getStatus() + + /** + * Returns the value of field 'type'. + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method hasBegin + * + * + * + * @return boolean + */ + public boolean hasBegin() + { + return this._has_begin; + } //-- boolean hasBegin() + + /** + * Method hasEnd + * + * + * + * @return boolean + */ + public boolean hasEnd() + { + return this._has_end; + } //-- boolean hasEnd() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'begin'. + * + * @param begin the value of field 'begin'. + */ + public void setBegin(int begin) + { + this._begin = begin; + this._has_begin = true; + } //-- void setBegin(int) + + /** + * Sets the value of field 'description'. + * + * @param description the value of field 'description'. + */ + public void setDescription(java.lang.String description) + { + this._description = description; + } //-- void setDescription(java.lang.String) + + /** + * Sets the value of field 'end'. + * + * @param end the value of field 'end'. + */ + public void setEnd(int end) + { + this._end = end; + this._has_end = true; + } //-- void setEnd(int) + + /** + * Sets the value of field 'status'. + * + * @param status the value of field 'status'. + */ + public void setStatus(java.lang.String status) + { + this._status = status; + } //-- void setStatus(java.lang.String) + + /** + * Sets the value of field 'type'. + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Feature) Unmarshaller.unmarshal(jalview.binding.Feature.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/binding/FeatureSettings.java b/src/jalview/binding/FeatureSettings.java new file mode 100755 index 0000000..2ef3731 --- /dev/null +++ b/src/jalview/binding/FeatureSettings.java @@ -0,0 +1,274 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class FeatureSettings. + * + * @version $Revision$ $Date$ + */ +public class FeatureSettings implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _settingList + */ + private java.util.Vector _settingList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public FeatureSettings() { + super(); + _settingList = new Vector(); + } //-- jalview.binding.FeatureSettings() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addSetting + * + * + * + * @param vSetting + */ + public void addSetting(jalview.binding.Setting vSetting) + throws java.lang.IndexOutOfBoundsException + { + _settingList.addElement(vSetting); + } //-- void addSetting(jalview.binding.Setting) + + /** + * Method addSetting + * + * + * + * @param index + * @param vSetting + */ + public void addSetting(int index, jalview.binding.Setting vSetting) + throws java.lang.IndexOutOfBoundsException + { + _settingList.insertElementAt(vSetting, index); + } //-- void addSetting(int, jalview.binding.Setting) + + /** + * Method enumerateSetting + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateSetting() + { + return _settingList.elements(); + } //-- java.util.Enumeration enumerateSetting() + + /** + * Method getSetting + * + * + * + * @param index + * @return Setting + */ + public jalview.binding.Setting getSetting(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _settingList.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Setting) _settingList.elementAt(index); + } //-- jalview.binding.Setting getSetting(int) + + /** + * Method getSetting + * + * + * + * @return Setting + */ + public jalview.binding.Setting[] getSetting() + { + int size = _settingList.size(); + jalview.binding.Setting[] mArray = new jalview.binding.Setting[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.binding.Setting) _settingList.elementAt(index); + } + return mArray; + } //-- jalview.binding.Setting[] getSetting() + + /** + * Method getSettingCount + * + * + * + * @return int + */ + public int getSettingCount() + { + return _settingList.size(); + } //-- int getSettingCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllSetting + * + */ + public void removeAllSetting() + { + _settingList.removeAllElements(); + } //-- void removeAllSetting() + + /** + * Method removeSetting + * + * + * + * @param index + * @return Setting + */ + public jalview.binding.Setting removeSetting(int index) + { + java.lang.Object obj = _settingList.elementAt(index); + _settingList.removeElementAt(index); + return (jalview.binding.Setting) obj; + } //-- jalview.binding.Setting removeSetting(int) + + /** + * Method setSetting + * + * + * + * @param index + * @param vSetting + */ + public void setSetting(int index, jalview.binding.Setting vSetting) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _settingList.size())) { + throw new IndexOutOfBoundsException(); + } + _settingList.setElementAt(vSetting, index); + } //-- void setSetting(int, jalview.binding.Setting) + + /** + * Method setSetting + * + * + * + * @param settingArray + */ + public void setSetting(jalview.binding.Setting[] settingArray) + { + //-- copy array + _settingList.removeAllElements(); + for (int i = 0; i < settingArray.length; i++) { + _settingList.addElement(settingArray[i]); + } + } //-- void setSetting(jalview.binding.Setting) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(jalview.binding.FeatureSettings.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/binding/Features.java b/src/jalview/binding/Features.java new file mode 100755 index 0000000..4706beb --- /dev/null +++ b/src/jalview/binding/Features.java @@ -0,0 +1,118 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Features. + * + * @version $Revision$ $Date$ + */ +public class Features extends Feature +implements java.io.Serializable +{ + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Features() { + super(); + } //-- jalview.binding.Features() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Features) Unmarshaller.unmarshal(jalview.binding.Features.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/binding/JSeq.java b/src/jalview/binding/JSeq.java index 751409f..ee55945 100755 --- a/src/jalview/binding/JSeq.java +++ b/src/jalview/binding/JSeq.java @@ -15,6 +15,8 @@ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -73,6 +75,16 @@ public class JSeq implements java.io.Serializable { */ private boolean _has_id; + /** + * Field _featuresList + */ + private java.util.Vector _featuresList; + + /** + * Field _pdbidsList + */ + private java.util.Vector _pdbidsList; + //----------------/ //- Constructors -/ @@ -80,6 +92,8 @@ public class JSeq implements java.io.Serializable { public JSeq() { super(); + _featuresList = new Vector(); + _pdbidsList = new Vector(); } //-- jalview.binding.JSeq() @@ -88,6 +102,60 @@ public class JSeq implements java.io.Serializable { //-----------/ /** + * Method addFeatures + * + * + * + * @param vFeatures + */ + public void addFeatures(jalview.binding.Features vFeatures) + throws java.lang.IndexOutOfBoundsException + { + _featuresList.addElement(vFeatures); + } //-- void addFeatures(jalview.binding.Features) + + /** + * Method addFeatures + * + * + * + * @param index + * @param vFeatures + */ + public void addFeatures(int index, jalview.binding.Features vFeatures) + throws java.lang.IndexOutOfBoundsException + { + _featuresList.insertElementAt(vFeatures, index); + } //-- void addFeatures(int, jalview.binding.Features) + + /** + * Method addPdbids + * + * + * + * @param vPdbids + */ + public void addPdbids(jalview.binding.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException + { + _pdbidsList.addElement(vPdbids); + } //-- void addPdbids(jalview.binding.Pdbids) + + /** + * Method addPdbids + * + * + * + * @param index + * @param vPdbids + */ + public void addPdbids(int index, jalview.binding.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException + { + _pdbidsList.insertElementAt(vPdbids, index); + } //-- void addPdbids(int, jalview.binding.Pdbids) + + /** * Method deleteColour * */ @@ -124,6 +192,30 @@ public class JSeq implements java.io.Serializable { } //-- void deleteStart() /** + * Method enumerateFeatures + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateFeatures() + { + return _featuresList.elements(); + } //-- java.util.Enumeration enumerateFeatures() + + /** + * Method enumeratePdbids + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumeratePdbids() + { + return _pdbidsList.elements(); + } //-- java.util.Enumeration enumeratePdbids() + + /** * Returns the value of field 'colour'. * * @return int @@ -146,6 +238,54 @@ public class JSeq implements java.io.Serializable { } //-- int getEnd() /** + * Method getFeatures + * + * + * + * @param index + * @return Features + */ + public jalview.binding.Features getFeatures(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _featuresList.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Features) _featuresList.elementAt(index); + } //-- jalview.binding.Features getFeatures(int) + + /** + * Method getFeatures + * + * + * + * @return Features + */ + public jalview.binding.Features[] getFeatures() + { + int size = _featuresList.size(); + jalview.binding.Features[] mArray = new jalview.binding.Features[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.binding.Features) _featuresList.elementAt(index); + } + return mArray; + } //-- jalview.binding.Features[] getFeatures() + + /** + * Method getFeaturesCount + * + * + * + * @return int + */ + public int getFeaturesCount() + { + return _featuresList.size(); + } //-- int getFeaturesCount() + + /** * Returns the value of field 'id'. * * @return int @@ -157,6 +297,54 @@ public class JSeq implements java.io.Serializable { } //-- int getId() /** + * Method getPdbids + * + * + * + * @param index + * @return Pdbids + */ + public jalview.binding.Pdbids getPdbids(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _pdbidsList.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Pdbids) _pdbidsList.elementAt(index); + } //-- jalview.binding.Pdbids getPdbids(int) + + /** + * Method getPdbids + * + * + * + * @return Pdbids + */ + public jalview.binding.Pdbids[] getPdbids() + { + int size = _pdbidsList.size(); + jalview.binding.Pdbids[] mArray = new jalview.binding.Pdbids[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.binding.Pdbids) _pdbidsList.elementAt(index); + } + return mArray; + } //-- jalview.binding.Pdbids[] getPdbids() + + /** + * Method getPdbidsCount + * + * + * + * @return int + */ + public int getPdbidsCount() + { + return _pdbidsList.size(); + } //-- int getPdbidsCount() + + /** * Returns the value of field 'start'. * * @return int @@ -262,6 +450,54 @@ public class JSeq implements java.io.Serializable { } //-- void marshal(org.xml.sax.ContentHandler) /** + * Method removeAllFeatures + * + */ + public void removeAllFeatures() + { + _featuresList.removeAllElements(); + } //-- void removeAllFeatures() + + /** + * Method removeAllPdbids + * + */ + public void removeAllPdbids() + { + _pdbidsList.removeAllElements(); + } //-- void removeAllPdbids() + + /** + * Method removeFeatures + * + * + * + * @param index + * @return Features + */ + public jalview.binding.Features removeFeatures(int index) + { + java.lang.Object obj = _featuresList.elementAt(index); + _featuresList.removeElementAt(index); + return (jalview.binding.Features) obj; + } //-- jalview.binding.Features removeFeatures(int) + + /** + * Method removePdbids + * + * + * + * @param index + * @return Pdbids + */ + public jalview.binding.Pdbids removePdbids(int index) + { + java.lang.Object obj = _pdbidsList.elementAt(index); + _pdbidsList.removeElementAt(index); + return (jalview.binding.Pdbids) obj; + } //-- jalview.binding.Pdbids removePdbids(int) + + /** * Sets the value of field 'colour'. * * @param colour the value of field 'colour'. @@ -284,6 +520,40 @@ public class JSeq implements java.io.Serializable { } //-- void setEnd(int) /** + * Method setFeatures + * + * + * + * @param index + * @param vFeatures + */ + public void setFeatures(int index, jalview.binding.Features vFeatures) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _featuresList.size())) { + throw new IndexOutOfBoundsException(); + } + _featuresList.setElementAt(vFeatures, index); + } //-- void setFeatures(int, jalview.binding.Features) + + /** + * Method setFeatures + * + * + * + * @param featuresArray + */ + public void setFeatures(jalview.binding.Features[] featuresArray) + { + //-- copy array + _featuresList.removeAllElements(); + for (int i = 0; i < featuresArray.length; i++) { + _featuresList.addElement(featuresArray[i]); + } + } //-- void setFeatures(jalview.binding.Features) + + /** * Sets the value of field 'id'. * * @param id the value of field 'id'. @@ -295,6 +565,40 @@ public class JSeq implements java.io.Serializable { } //-- void setId(int) /** + * Method setPdbids + * + * + * + * @param index + * @param vPdbids + */ + public void setPdbids(int index, jalview.binding.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _pdbidsList.size())) { + throw new IndexOutOfBoundsException(); + } + _pdbidsList.setElementAt(vPdbids, index); + } //-- void setPdbids(int, jalview.binding.Pdbids) + + /** + * Method setPdbids + * + * + * + * @param pdbidsArray + */ + public void setPdbids(jalview.binding.Pdbids[] pdbidsArray) + { + //-- copy array + _pdbidsList.removeAllElements(); + for (int i = 0; i < pdbidsArray.length; i++) { + _pdbidsList.addElement(pdbidsArray[i]); + } + } //-- void setPdbids(jalview.binding.Pdbids) + + /** * Sets the value of field 'start'. * * @param start the value of field 'start'. diff --git a/src/jalview/binding/JalviewModelSequence.java b/src/jalview/binding/JalviewModelSequence.java index 4ac40d5..cbb50d5 100755 --- a/src/jalview/binding/JalviewModelSequence.java +++ b/src/jalview/binding/JalviewModelSequence.java @@ -60,6 +60,11 @@ public class JalviewModelSequence implements java.io.Serializable { */ private java.util.Vector _treeList; + /** + * Field _featureSettings + */ + private jalview.binding.FeatureSettings _featureSettings; + //----------------/ //- Constructors -/ @@ -275,6 +280,17 @@ public class JalviewModelSequence implements java.io.Serializable { } //-- java.util.Enumeration enumerateViewport() /** + * Returns the value of field 'featureSettings'. + * + * @return FeatureSettings + * @return the value of field 'featureSettings'. + */ + public jalview.binding.FeatureSettings getFeatureSettings() + { + return this._featureSettings; + } //-- jalview.binding.FeatureSettings getFeatureSettings() + + /** * Method getJGroup * * @@ -681,6 +697,16 @@ public class JalviewModelSequence implements java.io.Serializable { } //-- jalview.binding.Viewport removeViewport(int) /** + * Sets the value of field 'featureSettings'. + * + * @param featureSettings the value of field 'featureSettings'. + */ + public void setFeatureSettings(jalview.binding.FeatureSettings featureSettings) + { + this._featureSettings = featureSettings; + } //-- void setFeatureSettings(jalview.binding.FeatureSettings) + + /** * Method setJGroup * * diff --git a/src/jalview/binding/JalviewModelSequence2.java b/src/jalview/binding/JalviewModelSequence2.java deleted file mode 100755 index 2cfd72c..0000000 --- a/src/jalview/binding/JalviewModelSequence2.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * This class was automatically generated with - * Castor 0.9.6, using an XML - * Schema. - * $Id$ - */ -package jalview.binding; - -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; - -import org.xml.sax.ContentHandler; - -//---------------------------------/ -//- Imported classes and packages -/ -//---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; - -import java.util.Enumeration; -import java.util.Vector; - - -/** - * Class JalviewModelSequence2. - * - * @version $Revision$ $Date$ - */ -public class JalviewModelSequence2 implements java.io.Serializable -{ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _items - */ - private java.util.Vector _items; - - //----------------/ - //- Constructors -/ - //----------------/ - public JalviewModelSequence2() - { - super(); - _items = new Vector(); - } - - //-- jalview.binding.JalviewModelSequence2() - //-----------/ - - /** - * DOCUMENT ME! - * - * @param vJalviewModelSequence2Item DOCUMENT ME! - * - * @throws java.lang.IndexOutOfBoundsException DOCUMENT ME! - */ - public void addJalviewModelSequence2Item( - jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) - throws java.lang.IndexOutOfBoundsException - { - _items.addElement(vJalviewModelSequence2Item); - } - - //-- void addJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) - - /** - * Method addJalviewModelSequence2Item - * - * - * - * @param index - * @param vJalviewModelSequence2Item - */ - public void addJalviewModelSequence2Item(int index, - jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) - throws java.lang.IndexOutOfBoundsException - { - _items.insertElementAt(vJalviewModelSequence2Item, index); - } - - //-- void addJalviewModelSequence2Item(int, jalview.binding.JalviewModelSequence2Item) - - /** - * Method enumerateJalviewModelSequence2Item - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateJalviewModelSequence2Item() - { - return _items.elements(); - } - - //-- java.util.Enumeration enumerateJalviewModelSequence2Item() - - /** - * Method getJalviewModelSequence2Item - * - * - * - * @param index - * @return JalviewModelSequence2Item - */ - public jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item( - int index) throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _items.size())) - { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.JalviewModelSequence2Item) _items.elementAt(index); - } - - //-- jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item(int) - - /** - * Method getJalviewModelSequence2Item - * - * - * - * @return JalviewModelSequence2Item - */ - public jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() - { - int size = _items.size(); - jalview.binding.JalviewModelSequence2Item[] mArray = new jalview.binding.JalviewModelSequence2Item[size]; - - for (int index = 0; index < size; index++) - { - mArray[index] = (jalview.binding.JalviewModelSequence2Item) _items.elementAt(index); - } - - return mArray; - } - - //-- jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() - - /** - * Method getJalviewModelSequence2ItemCount - * - * - * - * @return int - */ - public int getJalviewModelSequence2ItemCount() - { - return _items.size(); - } - - //-- int getJalviewModelSequence2ItemCount() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try - { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) - { - return false; - } - - return true; - } - - //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, - org.exolab.castor.xml.ValidationException - { - Marshaller.marshal(this, out); - } - - //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, - org.exolab.castor.xml.ValidationException - { - Marshaller.marshal(this, handler); - } - - //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Method removeAllJalviewModelSequence2Item - * - */ - public void removeAllJalviewModelSequence2Item() - { - _items.removeAllElements(); - } - - //-- void removeAllJalviewModelSequence2Item() - - /** - * Method removeJalviewModelSequence2Item - * - * - * - * @param index - * @return JalviewModelSequence2Item - */ - public jalview.binding.JalviewModelSequence2Item removeJalviewModelSequence2Item( - int index) - { - java.lang.Object obj = _items.elementAt(index); - _items.removeElementAt(index); - - return (jalview.binding.JalviewModelSequence2Item) obj; - } - - //-- jalview.binding.JalviewModelSequence2Item removeJalviewModelSequence2Item(int) - - /** - * Method setJalviewModelSequence2Item - * - * - * - * @param index - * @param vJalviewModelSequence2Item - */ - public void setJalviewModelSequence2Item(int index, - jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _items.size())) - { - throw new IndexOutOfBoundsException(); - } - - _items.setElementAt(vJalviewModelSequence2Item, index); - } - - //-- void setJalviewModelSequence2Item(int, jalview.binding.JalviewModelSequence2Item) - - /** - * Method setJalviewModelSequence2Item - * - * - * - * @param jalviewModelSequence2ItemArray - */ - public void setJalviewModelSequence2Item( - jalview.binding.JalviewModelSequence2Item[] jalviewModelSequence2ItemArray) - { - //-- copy array - _items.removeAllElements(); - - for (int i = 0; i < jalviewModelSequence2ItemArray.length; i++) - { - _items.addElement(jalviewModelSequence2ItemArray[i]); - } - } - - //-- void setJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, - org.exolab.castor.xml.ValidationException - { - return (jalview.binding.JalviewModelSequence2) Unmarshaller.unmarshal(jalview.binding.JalviewModelSequence2.class, - reader); - } - - //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } - - //-- void validate() -} diff --git a/src/jalview/binding/JalviewModelSequence2Item.java b/src/jalview/binding/JalviewModelSequence2Item.java deleted file mode 100755 index 6e54565..0000000 --- a/src/jalview/binding/JalviewModelSequence2Item.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * This class was automatically generated with - * Castor 0.9.6, using an XML - * Schema. - * $Id$ - */ - -package jalview.binding; - -//---------------------------------/ -//- Imported classes and packages -/ -//---------------------------------/ - -import java.util.*; - -/** - * Class JalviewModelSequence2Item. - * - * @version $Revision$ $Date$ - */ -public class JalviewModelSequence2Item - implements java.io.Serializable -{ - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _userColourSchemeList - */ - private java.util.Vector _userColourSchemeList; - - //----------------/ - //- Constructors -/ - //----------------/ - - public JalviewModelSequence2Item() - { - super(); - _userColourSchemeList = new Vector(); - } //-- jalview.binding.JalviewModelSequence2Item() - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addUserColourScheme - * - * - * - * @param vUserColourScheme - */ - public void addUserColourScheme(jalview.binding.UserColourScheme - vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { - _userColourSchemeList.addElement(vUserColourScheme); - } //-- void addUserColourScheme(jalview.binding.UserColourScheme) - - /** - * Method addUserColourScheme - * - * - * - * @param index - * @param vUserColourScheme - */ - public void addUserColourScheme(int index, - jalview.binding.UserColourScheme - vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { - _userColourSchemeList.insertElementAt(vUserColourScheme, index); - } //-- void addUserColourScheme(int, jalview.binding.UserColourScheme) - - /** - * Method enumerateUserColourScheme - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateUserColourScheme() - { - return _userColourSchemeList.elements(); - } //-- java.util.Enumeration enumerateUserColourScheme() - - /** - * Method getUserColourScheme - * - * - * - * @param index - * @return UserColourScheme - */ - public jalview.binding.UserColourScheme getUserColourScheme(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ( (index < 0) || (index > _userColourSchemeList.size())) - { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.UserColourScheme) _userColourSchemeList.elementAt( - index); - } //-- jalview.binding.UserColourScheme getUserColourScheme(int) - - /** - * Method getUserColourScheme - * - * - * - * @return UserColourScheme - */ - public jalview.binding.UserColourScheme[] getUserColourScheme() - { - int size = _userColourSchemeList.size(); - jalview.binding.UserColourScheme[] mArray = new jalview.binding. - UserColourScheme[size]; - for (int index = 0; index < size; index++) - { - mArray[index] = (jalview.binding.UserColourScheme) _userColourSchemeList. - elementAt(index); - } - return mArray; - } //-- jalview.binding.UserColourScheme[] getUserColourScheme() - - /** - * Method getUserColourSchemeCount - * - * - * - * @return int - */ - public int getUserColourSchemeCount() - { - return _userColourSchemeList.size(); - } //-- int getUserColourSchemeCount() - - /** - * Method removeAllUserColourScheme - * - */ - public void removeAllUserColourScheme() - { - _userColourSchemeList.removeAllElements(); - } //-- void removeAllUserColourScheme() - - /** - * Method removeUserColourScheme - * - * - * - * @param index - * @return UserColourScheme - */ - public jalview.binding.UserColourScheme removeUserColourScheme(int index) - { - java.lang.Object obj = _userColourSchemeList.elementAt(index); - _userColourSchemeList.removeElementAt(index); - return (jalview.binding.UserColourScheme) obj; - } //-- jalview.binding.UserColourScheme removeUserColourScheme(int) - - /** - * Method setUserColourScheme - * - * - * - * @param index - * @param vUserColourScheme - */ - public void setUserColourScheme(int index, - jalview.binding.UserColourScheme - vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ( (index < 0) || (index > _userColourSchemeList.size())) - { - throw new IndexOutOfBoundsException(); - } - _userColourSchemeList.setElementAt(vUserColourScheme, index); - } //-- void setUserColourScheme(int, jalview.binding.UserColourScheme) - - /** - * Method setUserColourScheme - * - * - * - * @param userColourSchemeArray - */ - public void setUserColourScheme(jalview.binding.UserColourScheme[] - userColourSchemeArray) - { - //-- copy array - _userColourSchemeList.removeAllElements(); - for (int i = 0; i < userColourSchemeArray.length; i++) - { - _userColourSchemeList.addElement(userColourSchemeArray[i]); - } - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) - -} diff --git a/src/jalview/binding/Pdbentry.java b/src/jalview/binding/Pdbentry.java new file mode 100755 index 0000000..7e0ae30 --- /dev/null +++ b/src/jalview/binding/Pdbentry.java @@ -0,0 +1,326 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Pdbentry. + * + * @version $Revision$ $Date$ + */ +public class Pdbentry implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _id + */ + private java.lang.String _id; + + /** + * Field _type + */ + private java.lang.String _type; + + /** + * Field _items + */ + private java.util.Vector _items; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Pdbentry() { + super(); + _items = new Vector(); + } //-- jalview.binding.Pdbentry() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addPdbentryItem + * + * + * + * @param vPdbentryItem + */ + public void addPdbentryItem(jalview.binding.PdbentryItem vPdbentryItem) + throws java.lang.IndexOutOfBoundsException + { + _items.addElement(vPdbentryItem); + } //-- void addPdbentryItem(jalview.binding.PdbentryItem) + + /** + * Method addPdbentryItem + * + * + * + * @param index + * @param vPdbentryItem + */ + public void addPdbentryItem(int index, jalview.binding.PdbentryItem vPdbentryItem) + throws java.lang.IndexOutOfBoundsException + { + _items.insertElementAt(vPdbentryItem, index); + } //-- void addPdbentryItem(int, jalview.binding.PdbentryItem) + + /** + * Method enumeratePdbentryItem + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumeratePdbentryItem() + { + return _items.elements(); + } //-- java.util.Enumeration enumeratePdbentryItem() + + /** + * Returns the value of field 'id'. + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Method getPdbentryItem + * + * + * + * @param index + * @return PdbentryItem + */ + public jalview.binding.PdbentryItem getPdbentryItem(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _items.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.PdbentryItem) _items.elementAt(index); + } //-- jalview.binding.PdbentryItem getPdbentryItem(int) + + /** + * Method getPdbentryItem + * + * + * + * @return PdbentryItem + */ + public jalview.binding.PdbentryItem[] getPdbentryItem() + { + int size = _items.size(); + jalview.binding.PdbentryItem[] mArray = new jalview.binding.PdbentryItem[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.binding.PdbentryItem) _items.elementAt(index); + } + return mArray; + } //-- jalview.binding.PdbentryItem[] getPdbentryItem() + + /** + * Method getPdbentryItemCount + * + * + * + * @return int + */ + public int getPdbentryItemCount() + { + return _items.size(); + } //-- int getPdbentryItemCount() + + /** + * Returns the value of field 'type'. + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllPdbentryItem + * + */ + public void removeAllPdbentryItem() + { + _items.removeAllElements(); + } //-- void removeAllPdbentryItem() + + /** + * Method removePdbentryItem + * + * + * + * @param index + * @return PdbentryItem + */ + public jalview.binding.PdbentryItem removePdbentryItem(int index) + { + java.lang.Object obj = _items.elementAt(index); + _items.removeElementAt(index); + return (jalview.binding.PdbentryItem) obj; + } //-- jalview.binding.PdbentryItem removePdbentryItem(int) + + /** + * Sets the value of field 'id'. + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Method setPdbentryItem + * + * + * + * @param index + * @param vPdbentryItem + */ + public void setPdbentryItem(int index, jalview.binding.PdbentryItem vPdbentryItem) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _items.size())) { + throw new IndexOutOfBoundsException(); + } + _items.setElementAt(vPdbentryItem, index); + } //-- void setPdbentryItem(int, jalview.binding.PdbentryItem) + + /** + * Method setPdbentryItem + * + * + * + * @param pdbentryItemArray + */ + public void setPdbentryItem(jalview.binding.PdbentryItem[] pdbentryItemArray) + { + //-- copy array + _items.removeAllElements(); + for (int i = 0; i < pdbentryItemArray.length; i++) { + _items.addElement(pdbentryItemArray[i]); + } + } //-- void setPdbentryItem(jalview.binding.PdbentryItem) + + /** + * Sets the value of field 'type'. + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Pdbentry) Unmarshaller.unmarshal(jalview.binding.Pdbentry.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/binding/PdbentryItem.java b/src/jalview/binding/PdbentryItem.java new file mode 100755 index 0000000..d797520 --- /dev/null +++ b/src/jalview/binding/PdbentryItem.java @@ -0,0 +1,197 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.Serializable; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; + +/** + * Class PdbentryItem. + * + * @version $Revision$ $Date$ + */ +public class PdbentryItem implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _propertyList + */ + private java.util.Vector _propertyList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public PdbentryItem() { + super(); + _propertyList = new Vector(); + } //-- jalview.binding.PdbentryItem() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(jalview.binding.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(jalview.binding.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, jalview.binding.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, jalview.binding.Property) + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public jalview.binding.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Property) _propertyList.elementAt(index); + } //-- jalview.binding.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public jalview.binding.Property[] getProperty() + { + int size = _propertyList.size(); + jalview.binding.Property[] mArray = new jalview.binding.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.binding.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- jalview.binding.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public jalview.binding.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (jalview.binding.Property) obj; + } //-- jalview.binding.Property removeProperty(int) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, jalview.binding.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException(); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, jalview.binding.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(jalview.binding.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(jalview.binding.Property) + +} diff --git a/src/jalview/binding/Pdbids.java b/src/jalview/binding/Pdbids.java new file mode 100755 index 0000000..4875b8b --- /dev/null +++ b/src/jalview/binding/Pdbids.java @@ -0,0 +1,118 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Pdbids. + * + * @version $Revision$ $Date$ + */ +public class Pdbids extends Pdbentry +implements java.io.Serializable +{ + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Pdbids() { + super(); + } //-- jalview.binding.Pdbids() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Pdbids) Unmarshaller.unmarshal(jalview.binding.Pdbids.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/binding/Property.java b/src/jalview/binding/Property.java new file mode 100755 index 0000000..c0a1cdd --- /dev/null +++ b/src/jalview/binding/Property.java @@ -0,0 +1,173 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Property. + * + * @version $Revision$ $Date$ + */ +public class Property implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _name + */ + private java.lang.String _name; + + /** + * Field _value + */ + private java.lang.String _value; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Property() { + super(); + } //-- jalview.binding.Property() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Returns the value of field 'value'. + * + * @return String + * @return the value of field 'value'. + */ + public java.lang.String getValue() + { + return this._value; + } //-- java.lang.String getValue() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Sets the value of field 'value'. + * + * @param value the value of field 'value'. + */ + public void setValue(java.lang.String value) + { + this._value = value; + } //-- void setValue(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Property) Unmarshaller.unmarshal(jalview.binding.Property.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/binding/Setting.java b/src/jalview/binding/Setting.java new file mode 100755 index 0000000..7b56676 --- /dev/null +++ b/src/jalview/binding/Setting.java @@ -0,0 +1,253 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.binding; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Setting. + * + * @version $Revision$ $Date$ + */ +public class Setting implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _type + */ + private java.lang.String _type; + + /** + * Field _colour + */ + private int _colour; + + /** + * keeps track of state for field: _colour + */ + private boolean _has_colour; + + /** + * Field _display + */ + private boolean _display; + + /** + * keeps track of state for field: _display + */ + private boolean _has_display; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Setting() { + super(); + } //-- jalview.binding.Setting() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteColour + * + */ + public void deleteColour() + { + this._has_colour= false; + } //-- void deleteColour() + + /** + * Method deleteDisplay + * + */ + public void deleteDisplay() + { + this._has_display= false; + } //-- void deleteDisplay() + + /** + * Returns the value of field 'colour'. + * + * @return int + * @return the value of field 'colour'. + */ + public int getColour() + { + return this._colour; + } //-- int getColour() + + /** + * Returns the value of field 'display'. + * + * @return boolean + * @return the value of field 'display'. + */ + public boolean getDisplay() + { + return this._display; + } //-- boolean getDisplay() + + /** + * Returns the value of field 'type'. + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method hasColour + * + * + * + * @return boolean + */ + public boolean hasColour() + { + return this._has_colour; + } //-- boolean hasColour() + + /** + * Method hasDisplay + * + * + * + * @return boolean + */ + public boolean hasDisplay() + { + return this._has_display; + } //-- boolean hasDisplay() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'colour'. + * + * @param colour the value of field 'colour'. + */ + public void setColour(int colour) + { + this._colour = colour; + this._has_colour = true; + } //-- void setColour(int) + + /** + * Sets the value of field 'display'. + * + * @param display the value of field 'display'. + */ + public void setDisplay(boolean display) + { + this._display = display; + this._has_display = true; + } //-- void setDisplay(boolean) + + /** + * Sets the value of field 'type'. + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Setting) Unmarshaller.unmarshal(jalview.binding.Setting.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index ac8f47a..338294b 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -29,40 +29,30 @@ import java.util.*; */ public class Alignment implements AlignmentI { + protected Alignment dataset; protected Vector sequences; protected Vector groups = new Vector(); protected Vector superGroup = new Vector(); protected char gapCharacter = '-'; - protected boolean isNucleotide = true; - + protected int type = NUCLEOTIDE; + public static final int PROTEIN = 0; + public static final int NUCLEOTIDE = 1; /** DOCUMENT ME!! */ public AlignmentAnnotation[] annotations; - /** DOCUMENT ME!! */ - public boolean featuresAdded = false; - /** Make an alignment from an array of Sequences. * * @param sequences */ public Alignment(SequenceI[] seqs) { - int i=0, iSize = seqs.length, j, jSize; - while(isNucleotide && iNAME/25-100 - * - * @return Sequence matching query, if found. If not found returns null. - */ - public SequenceI findbyDisplayId(String name); /** * Finds index of a given sequence in the alignment. @@ -304,4 +296,10 @@ public interface AlignmentI */ public void setNucleotide(boolean b); + + public Alignment getDataset(); + + public void setDataset(Alignment dataset); + + } diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java new file mode 100755 index 0000000..75e0cc8 --- /dev/null +++ b/src/jalview/datamodel/DBRefEntry.java @@ -0,0 +1,23 @@ +package jalview.datamodel; + +public class DBRefEntry +{ + String source, version, accessionId; + + public DBRefEntry(String source, String version, String accessionId) + { + this.source = source; + this.version = version; + this.accessionId = accessionId; + } + + public String getSource() + { return source; } + + public String getVersion() + { return version; } + + public String getAccessionId() + { return accessionId; } + +} diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java new file mode 100755 index 0000000..9e651fb4 --- /dev/null +++ b/src/jalview/datamodel/PDBEntry.java @@ -0,0 +1,36 @@ +package jalview.datamodel; + +import java.util.*; +public class PDBEntry +{ + String type; + String id; + Hashtable properties; + + public PDBEntry() + { } + + public void setType(String type) + { this.type = type; } + + public String getType() + { return type; } + + public void setId(String id) + { this.id = id; } + + public String getId() + { return id; } + + public void setProperty(Hashtable property) + { + this.properties = property; + } + + public Hashtable getProperty() + { + return properties; + } + + +} diff --git a/src/jalview/datamodel/Provenance.java b/src/jalview/datamodel/Provenance.java new file mode 100755 index 0000000..e52c855 --- /dev/null +++ b/src/jalview/datamodel/Provenance.java @@ -0,0 +1,26 @@ +package jalview.datamodel; +import java.util.*; + +public class Provenance +{ + Vector entries = new Vector(); + public Provenance() + { + + } + + public ProvenanceEntry[] getEntries() + { + ProvenanceEntry [] ret = new ProvenanceEntry[entries.size()]; + for(int i=0; i - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + public void setStatus(String status) + { + this.status = status; + } + } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index b7c9197..82d38b4 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -45,6 +45,7 @@ public interface SequenceI */ public String getName(); + /** * DOCUMENT ME! * @@ -64,7 +65,7 @@ public interface SequenceI * * @return DOCUMENT ME! */ - public String getDisplayId(); + public String getDisplayId(boolean jvsuffix); /** * DOCUMENT ME! @@ -224,12 +225,30 @@ public interface SequenceI * * @param id DOCUMENT ME! */ - public void setPDBId(String id); + public void setPDBId(Vector ids); /** * DOCUMENT ME! * * @return DOCUMENT ME! */ - public String getPDBId(); + public Vector getPDBId(); + + public void addPDBId(PDBEntry entry); + + public String getVamsasId(); + + public void setVamsasId(String id); + + public void setDBRef(Vector dbs); + + public Vector getDBRef(); + + public void addDBRef(DBRefEntry entry); + + public void addSequenceFeature(SequenceFeature sf); + + public void setDatasetSequence(SequenceI seq); + + public SequenceI getDatasetSequence(); } diff --git a/src/jalview/datamodel/UniprotEntry.java b/src/jalview/datamodel/UniprotEntry.java new file mode 100755 index 0000000..0c5e314 --- /dev/null +++ b/src/jalview/datamodel/UniprotEntry.java @@ -0,0 +1,74 @@ +package jalview.datamodel; + +import java.util.*; + +public class UniprotEntry +{ + + UniprotSequence sequence; + Vector name; + Vector accession; + Vector feature; + Vector dbrefs; + Vector proteinName; + + public void setAccession(Vector items) + { + accession = items; + } + + public void setFeature(Vector items) + { + feature = items; + } + + public Vector getFeature() { + return feature; + } + + + public Vector getAccession() + { + return accession; + } + + public void setProteinName(Vector items) + { + proteinName = items; + } + + public Vector getProteinName() + { + return proteinName; + } + + public void setName(Vector na) + { + name = na; + } + public Vector getName() + { + return name; + } + + public UniprotSequence getUniprotSequence() + { + return sequence; + } + + public void setUniprotSequence(UniprotSequence seq) + { + sequence = seq; + } + + public Vector getDbReference() + { + return dbrefs; + } + + public void setDbReference(Vector dbref) + { + this.dbrefs = dbref; + } + +} diff --git a/src/jalview/datamodel/UniprotFile.java b/src/jalview/datamodel/UniprotFile.java new file mode 100755 index 0000000..5acb300 --- /dev/null +++ b/src/jalview/datamodel/UniprotFile.java @@ -0,0 +1,15 @@ +package jalview.datamodel; +import java.util.Vector; + +public class UniprotFile +{ + Vector _items; + + public void setUniprotEntries(Vector items) { + _items = items; + } + + public Vector getUniprotEntries() { + return _items; + } +} diff --git a/src/jalview/datamodel/UniprotSequence.java b/src/jalview/datamodel/UniprotSequence.java new file mode 100755 index 0000000..9233889 --- /dev/null +++ b/src/jalview/datamodel/UniprotSequence.java @@ -0,0 +1,24 @@ +package jalview.datamodel; + +public class UniprotSequence +{ + /** + * internal content storage + */ + private java.lang.String _content = ""; + + public void setContent(String seq) + { + StringBuffer sb = new StringBuffer(); + for(int i=0; i-1) + { + seq = new Sequence(id.substring(0, space),""); + seq.setDescription(id.substring(space+1)); + } + else + { + seq = new Sequence(id, ""); + } + + return seq; + } + + /** + * Creates the output id. + * Adds prefix Uniprot format source|id + * And suffix Jalview /start-end + * + * @String id Id to be parsed + */ + String printId(SequenceI seq) + { + return seq.getDisplayId(jvSuffix); + } + } diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java new file mode 100755 index 0000000..f8b809e --- /dev/null +++ b/src/jalview/io/AppletFormatAdapter.java @@ -0,0 +1,184 @@ + /* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + */ + package jalview.io; + + import jalview.datamodel.*; + + import java.util.Vector; + + + /** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ + public class AppletFormatAdapter + { + /** DOCUMENT ME!! */ + public static final Vector formats = new Vector(); + + static + { + formats.addElement("BLC"); + formats.addElement("CLUSTAL"); + formats.addElement("FASTA"); + formats.addElement("MSF"); + formats.addElement("PileUp"); + formats.addElement("PIR"); + formats.addElement("PFAM"); + } + + AlignFile afile = null; + + /** + * DOCUMENT ME! + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * @param format DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI[] readFile(String inFile, String type, String format) + { + try + { + if (format.equals("FASTA")) + { + afile = new FastaFile(inFile, type); + } + else if (format.equals("MSF")) + { + afile = new MSFfile(inFile, type); + } + else if (format.equals("PileUp")) + { + afile = new PileUpfile(inFile, type); + } + else if (format.equals("CLUSTAL")) + { + afile = new ClustalFile(inFile, type); + } + else if (format.equals("BLC")) + { + afile = new BLCFile(inFile, type); + } + else if (format.equals("PIR")) + { + afile = new PIRFile(inFile, type); + } + else if (format.equals("PFAM")) + { + afile = new PfamFile(inFile, type); + } + + return afile.getSeqsAsArray(); + } + catch (Exception e) + { + System.err.println("Failed to read alignment using the '" + format + + "' reader.\n"+e); + + // Finally test if the user has pasted just the sequence, no id + if(type.equalsIgnoreCase("Paste")) + { + try{ + // Possible sequence is just residues with no label + afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste"); + return afile.getSeqsAsArray(); + }catch(Exception ex) + { + System.err.println("Failed to read alignment using the 'FASTA' reader.\n"+e); + ex.printStackTrace(); + } + + } + } + + return null; + } + + + /** + * DOCUMENT ME! + * + * @param format DOCUMENT ME! + * @param seqs DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String formatSequences(String format, + Vector seqs, + boolean jvsuffix) + { + SequenceI[] s = new SequenceI[seqs.size()]; + + for (int i = 0; i < seqs.size(); i++) + s[i] = (SequenceI) seqs.elementAt(i); + + try + { + AlignFile afile = null; + + if (format.equalsIgnoreCase("FASTA")) + { + afile = new FastaFile(); + } + else if (format.equalsIgnoreCase("MSF")) + { + afile = new MSFfile(); + } + else if (format.equalsIgnoreCase("PileUp")) + { + afile = new PileUpfile(); + } + else if (format.equalsIgnoreCase("CLUSTAL")) + { + afile = new ClustalFile(); + } + else if (format.equalsIgnoreCase("BLC")) + { + afile = new BLCFile(); + } + else if (format.equalsIgnoreCase("PIR")) + { + afile = new PIRFile(); + } + else if (format.equalsIgnoreCase("PFAM")) + { + afile = new PfamFile(); + } + + afile.addJVSuffix(jvsuffix); + + afile.setSeqs(s); + + return afile.print(); + } + catch (Exception e) + { + System.err.println("Failed to write alignment as a '" + format + + "' file\n"); + e.printStackTrace(); + } + + return null; + } + } diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index 0edcb63..a7cc1ea 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -105,60 +105,19 @@ public class BLCFile extends AlignFile if (abracket > -1) { - if (line.indexOf(" ") > -1) // - { - ///Colur it be this format? - //>54402046 0 1 137 137: - // or this?? - // 1 >L1H14 30539 343 - try - { - ids.addElement(line.substring(abracket + 1, - line.indexOf(" ", abracket + 1))); - - // remove p Value - line = line.substring(abracket + 1); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - - int value = Integer.parseInt(line.substring(0, - line.indexOf(" "))); - starts.addElement(value + ""); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - value = Integer.parseInt(line.substring(0, - line.indexOf(" "))); - ends.addElement(value + ""); - } - catch (Exception ex) - { - System.err.println("Error during blockfile read."); - ex.printStackTrace(); - starts.addElement("1"); - ends.addElement("-1"); - } - } - else - { - if (line.indexOf("/") > -1) - { - ids.addElement(line.substring(abracket + 1, - line.indexOf("/"))); - line = line.substring(line.indexOf("/") + 1); - starts.addElement(line.substring(0, - line.indexOf("-"))); - ends.addElement(line.substring(line.indexOf("-") + - 1)); - } - else - { - ids.addElement(line.substring(abracket + 1)); - starts.addElement("1"); - ends.addElement("-1"); - } - } + if (line.indexOf(" ") > -1) // + { + line = line.substring(abracket + 1, + line.indexOf(" ", abracket + 1)); + } + else + line = line.substring(abracket+1); + + + Sequence seq = parseId(line); + ids.addElement(seq.getName()); + starts.addElement(seq.getStart() + ""); + ends.addElement(seq.getEnd() + ""); } } while (!idsFound); @@ -217,17 +176,22 @@ public class BLCFile extends AlignFile * * @return DOCUMENT ME! */ - public static String print(SequenceI[] s) + public String print(SequenceI[] s) { StringBuffer out = new StringBuffer(); - + /** + * A general parser for ids. Will look for dbrefs in + * Uniprot format source|id + * And also Jalview /start-end + * + * @String id Id to be parsed + */ int i = 0; int max = -1; while ((i < s.length) && (s[i] != null)) { - out.append(">" + s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd() + "\n"); + out.append(">" + printId(s[i]) +"\n"); if (s[i].getSequence().length() > max) { diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 71e86b3..e72e0df 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -27,7 +27,6 @@ import jalview.util.*; public class ClustalFile extends AlignFile { - Vector ids; public ClustalFile() { @@ -47,7 +46,6 @@ public class ClustalFile public void initData() { super.initData(); - ids = new Vector(); } public void parse() @@ -57,8 +55,9 @@ public class ClustalFile Vector headers = new Vector(); Hashtable seqhash = new Hashtable(); - - String line; + StringBuffer tempseq; + String line, id; + StringTokenizer str; try { @@ -66,14 +65,13 @@ public class ClustalFile { if (line.indexOf(" ") != 0) { - StringTokenizer str = new StringTokenizer(line, " "); - String id = ""; + str = new StringTokenizer(line, " "); if (str.hasMoreTokens()) { id = str.nextToken(); - if (id.equals("CLUSTAL")) + if (id.equalsIgnoreCase("CLUSTAL")) { flag = true; } @@ -81,8 +79,6 @@ public class ClustalFile { if (flag) { - StringBuffer tempseq; - if (seqhash.containsKey(id)) { tempseq = (StringBuffer) seqhash.get(id); @@ -105,6 +101,8 @@ public class ClustalFile } } } + else + flag = true; } } } @@ -121,9 +119,6 @@ public class ClustalFile //Add sequences to the hash for (i = 0; i < headers.size(); i++) { - int start = 1; - int end = -1; - if (seqhash.get(headers.elementAt(i)) != null) { if (maxLength < seqhash.get(headers.elementAt(i)).toString() @@ -133,40 +128,8 @@ public class ClustalFile .length(); } - String head = headers.elementAt(i).toString(); - - if (head.indexOf("/") > 0) - { - StringTokenizer st = new StringTokenizer(head, "/"); - - if (st.countTokens() == 2) - { - ids.addElement(st.nextToken()); - - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) - { - start = Integer.valueOf(st.nextToken()) - .intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } - } - else - { - ids.addElement(headers.elementAt(i)); - } - } - else - { - ids.addElement(headers.elementAt(i)); - } - - Sequence newSeq = new Sequence(ids.elementAt(i).toString(), - seqhash.get(headers.elementAt(i). - toString()) - .toString(), start, end); + Sequence newSeq = parseId(headers.elementAt(i).toString()); + newSeq.setSequence( seqhash.get(headers.elementAt(i).toString()).toString() ); seqs.addElement(newSeq); } @@ -185,7 +148,7 @@ public class ClustalFile return print(getSeqsAsArray()); } - public static String print(SequenceI[] s) + public String print(SequenceI[] s) { StringBuffer out = new StringBuffer("CLUSTAL\n\n"); @@ -196,8 +159,7 @@ public class ClustalFile while ( (i < s.length) && (s[i] != null)) { - String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd(); + String tmp = printId(s[i]); if (s[i].getSequence().length() > max) { @@ -228,8 +190,7 @@ public class ClustalFile while ( (j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(s[j].getName() + - "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); + out.append(new Format("%-" + maxid + "s").form( printId(s[j]) + " ")); int start = i * len; int end = start + len; diff --git a/src/jalview/io/EBIFetchClient.java b/src/jalview/io/EBIFetchClient.java index eebbfc8..0012ffe 100755 --- a/src/jalview/io/EBIFetchClient.java +++ b/src/jalview/io/EBIFetchClient.java @@ -18,6 +18,8 @@ */ package jalview.io; +import java.io.*; + import org.apache.axis.AxisFault; import org.apache.axis.client.*; import org.apache.axis.encoding.XMLType; @@ -118,6 +120,46 @@ public class EBIFetchClient } } + public static void main (String [] args) + { + EBIFetchClient ebi = new EBIFetchClient(); + String[] result = ebi.fetchData("uniprot:25K89D_SARPE;G6PblobD_HUMAN", + "xml", null); + + try{ + java.io.PrintWriter out = new java.io.PrintWriter( + new java.io.FileWriter("out.xml")); + + + for(int i=0; i 0) { - // Do we have an id line? - // JBPNote - this code needs to be standardised to EBI/whatever for the - // >dbref/dbref/dbref|refid1|refid2|refid3 'human-readable' style of naming (should it really exist) - if (line.substring(0, 1).equals(">")) + if (line.charAt(0)=='>') { if (count != 0) { - if (sstart != 0) - { - seqs.addElement(new Sequence(id, seq.toString(), - sstart, send)); - } - else - { - seqs.addElement(new Sequence(id, seq.toString(), 1, - seq.length())); - } + seq.setSequence(sb.toString()); + seqs.addElement(seq); } - count++; - - StringTokenizer str = new StringTokenizer(line, " "); - - id = str.nextToken(); - id = id.substring(1); - - com.stevesoft.pat.Regex dbId = new com.stevesoft.pat.Regex( - "[A-Za-z-]+/?[A-Za-z-]+\\|(\\w+)\\|(.+)"); - - // JBPNote At the moment - we don't get rid of the friendly names but this - // behaviour is probably wrong in the long run. - if (dbId.search(id)) - { - String dbid = dbId.stringMatched(1); - String idname = dbId.stringMatched(2); - - if ((idname.length() > 0) && - (idname.indexOf("_") > -1)) - { - id = idname; // use the friendly name - apparently no dbid - } - else if (dbid.length() > 1) - { - id = dbid; // ignore the friendly name - we lose uniprot accession ID otherwise - } - } - - if (id.indexOf("/") > 0) - { - StringTokenizer st = new StringTokenizer(id, "/"); - - if (st.countTokens() == 2) - { - id = st.nextToken(); - - String tmp = st.nextToken(); + seq = parseId(line.substring(1)); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) - { - sstart = Integer.valueOf(st.nextToken()) - .intValue(); - send = Integer.valueOf(st.nextToken()).intValue(); - } - } - } - - seq = new StringBuffer(); + count++; + sb = new StringBuffer(); } else { - seq = seq.append(line); + sb.append(line); } } } if (count > 0) { - if (!isValidProteinSequence(seq.toString().toUpperCase())) + if (!isValidProteinSequence(sb.toString().toUpperCase())) { throw new IOException("Invalid protein sequence"); } - if (sstart != 0) - { - seqs.addElement(new Sequence(id, seq.toString().toUpperCase(), - sstart, send)); - } - else - { - seqs.addElement(new Sequence(id, seq.toString().toUpperCase(), - 1, seq.length())); - } + seq.setSequence(sb.toString()); + seqs.addElement(seq); } } - /** - * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static String print(SequenceI[] s) - { - return print(s, 72); - } - - /** - * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * @param len DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static String print(SequenceI[] s, int len) - { - return print(s, len, true); - } - - /** - * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * @param len DOCUMENT ME! - * @param gaps DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static String print(SequenceI[] s, int len, boolean gaps) - { - return print(s, len, gaps, true); - } /** * DOCUMENT ME! @@ -231,43 +121,34 @@ public class FastaFile extends AlignFile * * @return DOCUMENT ME! */ - public static String print(SequenceI[] s, int len, boolean gaps, - boolean displayId) + public String print(SequenceI[] s) { + int len = 72; StringBuffer out = new StringBuffer(); int i = 0; while ((i < s.length) && (s[i] != null)) { - String seq = ""; - - if (gaps) - { - seq = s[i].getSequence(); - } - else - { - seq = AlignSeq.extractGaps("-. ", s[i].getSequence()); - } + out.append(">" + printId(s[i])); + if(s[i].getDescription()!=null) + out.append(" "+s[i].getDescription()); - // used to always put this here: + "/" + s[i].getStart() + "-" + s[i].getEnd() + - out.append(">" + - ((displayId) ? s[i].getDisplayId() : s[i].getName()) + "\n"); + out.append("\n"); - int nochunks = (seq.length() / len) + 1; + int nochunks = (s[i].getLength() / len) + 1; for (int j = 0; j < nochunks; j++) { int start = j * len; int end = start + len; - if (end < seq.length()) + if (end < s[i].getLength()) { - out.append(seq.substring(start, end) + "\n"); + out.append(s[i].getSequence(start, end) + "\n"); } - else if (start < seq.length()) + else if (start < s[i].getLength()) { - out.append(seq.substring(start) + "\n"); + out.append(s[i].getSequence(start, s[i].getLength()) + "\n"); } } diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 61c2331..0c8554a 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -29,79 +29,8 @@ import java.util.Vector; * @author $author$ * @version $Revision$ */ -public class FormatAdapter +public class FormatAdapter extends AppletFormatAdapter { - /** DOCUMENT ME!! */ - public static final Vector formats = new Vector(); - - static - { - formats.addElement("FASTA"); - formats.addElement("MSF"); - formats.addElement("PileUp"); - formats.addElement("CLUSTAL"); - formats.addElement("BLC"); - formats.addElement("PIR"); - formats.addElement("PFAM"); - } - - AlignFile afile = null; - - /** - * DOCUMENT ME! - * - * @param inFile DOCUMENT ME! - * @param type DOCUMENT ME! - * @param format DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public SequenceI[] readFile(String inFile, String type, String format) - { - try - { - if (format.equals("FASTA")) - { - afile = new FastaFile(inFile, type); - } - else if (format.equals("MSF")) - { - afile = new MSFfile(inFile, type); - } - else if (format.equals("PileUp")) - { - afile = new PileUpfile(inFile, type); - } - else if (format.equals("CLUSTAL")) - { - afile = new ClustalFile(inFile, type); - } - else if (format.equals("BLC")) - { - afile = new BLCFile(inFile, type); - } - else if (format.equals("PIR")) - { - afile = new PIRFile(inFile, type); - } - else if (format.equals("PFAM")) - { - afile = new PfamFile(inFile, type); - } - - return afile.getSeqsAsArray(); - } - catch (Exception e) - { - System.err.println("Failed to read alignment using the '" + format + - "' reader."); - e.printStackTrace(); - } - - return null; - } - - /** * DOCUMENT ME! * @@ -124,30 +53,44 @@ public class FormatAdapter if (format.equalsIgnoreCase("FASTA")) { afile = new FastaFile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("FASTA_JVSUFFIX", true)); } else if (format.equalsIgnoreCase("MSF")) { - afile = new MSFfile(); + afile = new MSFfile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("MSF_JVSUFFIX", true)); } else if (format.equalsIgnoreCase("PileUp")) { afile = new PileUpfile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("PILEUP_JVSUFFIX", true)); } else if (format.equalsIgnoreCase("CLUSTAL")) { afile = new ClustalFile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("CLUSTAL_JVSUFFIX", true)); } else if (format.equalsIgnoreCase("BLC")) { afile = new BLCFile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("BLC_JVSUFFIX", true)); } else if (format.equalsIgnoreCase("PIR")) { afile = new PIRFile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("PIR_JVSUFFIX", true)); } else if (format.equalsIgnoreCase("PFAM")) { afile = new PfamFile(); + afile.addJVSuffix( + jalview.bin.Cache.getDefault("PFAM_JVSUFFIX", true)); } afile.setSeqs(s); diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index 201ff0c..beb8829 100755 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -24,18 +24,19 @@ import java.awt.*; import jalview.datamodel.*; import jalview.gui.*; -import jalview.schemes.*; public class HTMLOutput { AlignViewport av; SequenceRenderer sr; + FeatureRenderer fr; Color color; - public HTMLOutput(AlignViewport av) + public HTMLOutput(AlignViewport av, SequenceRenderer sr, FeatureRenderer fr) { this.av = av; - sr = new SequenceRenderer(av); + this.sr = sr; + this.fr = fr; JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. getProperty( @@ -110,9 +111,7 @@ public class HTMLOutput "\n"); ////////////// - SequenceGroup[] groups; SequenceI seq; - ColourSchemeI cs = null; AlignmentI alignment = av.getAlignment(); // draws the top row, the measure rule @@ -132,40 +131,26 @@ public class HTMLOutput for (i = 0; i < alignment.getHeight(); i++) { seq = alignment.getSequenceAt(i); - groups = alignment.findAllGroups(seq); - if (av.getShowFullId()) - { - out.println(""); - } - else - { - out.println(""); - } + for (int res = 0; res < seq.getLength(); res++) { - cs = av.getGlobalColourScheme(); - - if (groups != null) + if (!jalview.util.Comparison.isGap(seq.getCharAt(res))) { - for (int k = 0; k < groups.length; k++) - { - if ( (groups[k].getStartRes() <= res) && - (groups[k].getEndRes() >= res)) - { - cs = groups[k].cs; + color = sr.getResidueBoxColour(seq, res); - break; - } - } + color = fr.findFeatureColour(color, seq, res); } + else + color = Color.white; - color = sr.getResidueBoxColour(cs, seq, res); - if (color.getRGB() < -1) + if (color.getRGB() < -1) { out.println(""); - out.println(""); - - for (int i = startRes + 10; i < endRes; i += 10) + if(av.getScaleAboveWrapped()) { - out.println(""); - } + out.println(""); - // out.println(""); - out.println(""); + if (av.getScaleLeftWrapped()) + out.println(""); + else + out.println(""); + + + for (int i = startRes + 10; i < endRes; i += 10) + { + out.println(""); + } + + out.println(""); + } + int startPos, endPos; for (int s = 0; s < al.getHeight(); s++) { out.println(""); seq = al.getSequenceAt(s); - groups = al.findAllGroups(seq); - if (av.getShowFullId()) - { - out.println(""); - } - else + + + if(av.getScaleLeftWrapped()) { - out.println(""); + else + out.println(""); } + for (int res = startRes; res < endRes; res++) { - cs = av.getGlobalColourScheme(); - - if (groups != null) + if (!jalview.util.Comparison.isGap(seq.getCharAt(res))) { - for (int k = 0; k < groups.length; k++) - { - if ( (groups[k].getStartRes() <= res) && - (groups[k].getEndRes() >= res)) - { - cs = groups[k].cs; + color = sr.getResidueBoxColour(seq, res); - break; - } - } + color = fr.findFeatureColour(color, seq, res); } - - color = sr.getResidueBoxColour(cs, seq, res); + else + color = Color.white; if (color.getRGB() < -1) { @@ -290,8 +278,25 @@ public class HTMLOutput { out.println(""); } + + + } + + if(av.getScaleRightWrapped() && + endRes < startRes + av.getWrappedWidth()) + { + out.println(""); + } + + + if(av.getScaleRightWrapped() && startPos " + endPos + + "  "); } + out.println(""); } diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 729a860..f4beccb 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -110,7 +110,7 @@ public class IdentifyFile // could be BLC file, read next line to confirm data = reader.readLine(); - if (data.indexOf(">") > -1) + if (data.indexOf(">") > -1 || data.indexOf("*") >-1 ) { reply = "BLC"; } diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index 2cef0fe..179204e 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -155,30 +155,11 @@ public class MSFfile extends AlignFile maxLength = head.length(); } - if (head.indexOf("/") > 0) - { - StringTokenizer st = new StringTokenizer(head, "/"); - - if (st.countTokens() == 2) - { - head = st.nextToken(); - - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) - { - start = Integer.valueOf(st.nextToken()).intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } - } - } - - // Replace ~ with a sensible gap character seq = seq.replace('~', '-'); - Sequence newSeq = new Sequence(head, seq, start, end); + Sequence newSeq = parseId(head); + newSeq.setSequence(seq); seqs.addElement(newSeq); } @@ -197,7 +178,7 @@ public class MSFfile extends AlignFile * * @return DOCUMENT ME! */ - public static int checkSum(String seq) + public int checkSum(String seq) { int check = 0; String sequence = seq.toUpperCase(); @@ -223,17 +204,6 @@ public class MSFfile extends AlignFile return check % 10000; } - /** - * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static String print(SequenceI[] s) - { - return print(s, false); - } /** * DOCUMENT ME! @@ -243,9 +213,11 @@ public class MSFfile extends AlignFile * * @return DOCUMENT ME! */ - public static String print(SequenceI[] seqs, boolean is_NA) + public String print(SequenceI[] seqs) { + boolean is_NA = jalview.util.Comparison.isNucleotide(seqs); + SequenceI [] s = new SequenceI[seqs.length]; StringBuffer out = new StringBuffer("!!" + (is_NA ? "NA" : "AA") + @@ -265,7 +237,7 @@ public class MSFfile extends AlignFile { if (sb.charAt(ii) == '.') { - sb.replace(ii, ii + 1, "~"); + sb.setCharAt(ii, '~'); } else break; @@ -275,7 +247,7 @@ public class MSFfile extends AlignFile { if (sb.charAt(ii) == '.') { - sb.replace(ii, ii + 1, "~"); + sb.setCharAt(ii,'~'); } else break; @@ -317,9 +289,7 @@ public class MSFfile extends AlignFile while ((i < s.length) && (s[i] != null)) { - nameBlock[i] = new String(" Name: " + s[i].getName() - + "/" + s[i].getStart() + "-" + s[i].getEnd() - +" "); + nameBlock[i] = new String(" Name: " + printId(s[i])+" "); idBlock[i] = new String("Len: " + maxLenpad.form(s[i].getSequence().length()) + " Check: " + @@ -373,11 +343,9 @@ public class MSFfile extends AlignFile while ((j < s.length) && (s[j] != null)) { - String name = s[j].getName(); - // out.append(new Format("%-" + maxid + "s").form(name)+ " "); + String name = printId( s[j] ); - out.append(new Format("%-" + maxid + "s").form(name - + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); + out.append(new Format("%-" + maxid + "s").form(name+" ")); for (int k = 0; k < 5; k++) diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index 65890a9..d4b818b 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -48,9 +48,6 @@ public class PIRFile { try { - String id; - String start; - String end; StringBuffer sequence; String line = null; @@ -62,31 +59,11 @@ public class PIRFile continue; } - id = "No id"; - start = "1"; - end = "-1"; - - try - { - int slashIndex = line.indexOf("/"); - if(slashIndex!=-1) - { - id = line.substring(line.indexOf(";") + 1, line.indexOf("/")); - line = line.substring(line.indexOf("/") + 1); - start = line.substring(0, line.indexOf("-")); - end = line.substring(line.indexOf("-") + 1); - } - else - { - id = line.substring(line.indexOf(";")+1); - } - } - catch (Exception ex) - { }// Default id, start and end unchanged + Sequence newSeq = parseId(line.substring(line.indexOf(";") + 1)); sequence = new StringBuffer(); - line = nextLine(); // this is the title line + newSeq.setDescription(nextLine()); // this is the title line boolean starFound = false; @@ -108,9 +85,7 @@ public class PIRFile { sequence.setLength(sequence.length() - 1); - Sequence newSeq = new Sequence(id, sequence.toString(), - Integer.parseInt(start), - Integer.parseInt(end)); + newSeq.setSequence(sequence.toString()); seqs.addElement(newSeq); } } @@ -126,41 +101,27 @@ public class PIRFile return print(getSeqsAsArray()); } - public static String print(SequenceI[] s) - { - return print(s, 72, true); - } - - public static String print(SequenceI[] s, int len) - { - return print(s, len, true); - } - - public static String print(SequenceI[] s, int len, boolean gaps) + public String print(SequenceI[] s) { + boolean is_NA = jalview.util.Comparison.isNucleotide(s); + int len = 72; StringBuffer out = new StringBuffer(); int i = 0; while ( (i < s.length) && (s[i] != null)) { - String seq = ""; + String seq = s[i].getSequence(); + seq = seq + "*"; - if (gaps) - { - seq = s[i].getSequence() + "*"; - } + out.append(">P1;" + printId(s[i]) + "\n"); + + if(s[i].getDescription()!=null) + out.append(s[i].getDescription()+"\n"); else { - seq = AlignSeq.extractGaps(s[i].getSequence(), "-"); - seq = AlignSeq.extractGaps(seq, "."); - seq = AlignSeq.extractGaps(seq, " "); - seq = seq + "*"; + out.append(s[i].getName()+" "+ (s[i].getEnd() - s[i].getStart() + 1)); + out.append( is_NA ? " bases\n" : " residues\n"); } - - out.append(">P1;" + s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd() + "\n"); - out.append(" Dummy title\n"); - int nochunks = (seq.length() / len) + 1; for (int j = 0; j < nochunks; j++) diff --git a/src/jalview/io/PfamFile.java b/src/jalview/io/PfamFile.java index 9a6ca54..ec52bac 100755 --- a/src/jalview/io/PfamFile.java +++ b/src/jalview/io/PfamFile.java @@ -27,7 +27,6 @@ import jalview.util.*; public class PfamFile extends AlignFile { - Vector ids; public PfamFile() { @@ -47,7 +46,6 @@ public class PfamFile public void initData() { super.initData(); - ids = new Vector(); } public void parse() @@ -113,45 +111,11 @@ public class PfamFile .length(); } - String head = headers.elementAt(i).toString(); - int start = 1; - int end = -1; - if (head.indexOf("/") > 0) - { - StringTokenizer st = new StringTokenizer(head, "/"); - - if (st.countTokens() == 2) - { - ids.addElement(st.nextToken()); - - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) - { - start = Integer.valueOf(st.nextToken()).intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } - } - else - { - ids.addElement(headers.elementAt(i)); - } - } - else - { - ids.addElement(headers.elementAt(i)); - } - - Sequence newSeq = null; - - newSeq = new Sequence(ids.elementAt(i).toString(), - seqhash.get(headers.elementAt(i).toString()) - .toString(), start, end); + Sequence newSeq = parseId(headers.elementAt(i).toString()); + newSeq.setSequence( seqhash.get(headers.elementAt(i).toString()).toString()); seqs.addElement(newSeq); - if (!isValidProteinSequence(newSeq.getSequence())) { throw new IOException( @@ -166,7 +130,7 @@ public class PfamFile } } - public static String print(SequenceI[] s) + public String print(SequenceI[] s) { StringBuffer out = new StringBuffer(""); @@ -177,8 +141,7 @@ public class PfamFile while ( (i < s.length) && (s[i] != null)) { - String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd(); + String tmp = printId(s[i]); if (s[i].getSequence().length() > max) { @@ -202,8 +165,7 @@ public class PfamFile while ( (j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(s[j].getName() + - "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); + out.append(new Format("%-" + maxid + "s").form( printId(s[j])+" ")); out.append(s[j].getSequence() + "\n"); j++; diff --git a/src/jalview/io/PileUpfile.java b/src/jalview/io/PileUpfile.java index 8c8a3ea..c945fd5 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -30,170 +30,53 @@ package jalview.io; * **/ import java.io.*; -import java.util.*; import jalview.datamodel.*; import jalview.util.*; -public class PileUpfile - extends AlignFile +public class PileUpfile extends MSFfile { - public PileUpfile() - { - } - - public PileUpfile(String inStr) - { - super(inStr); - } - public PileUpfile(String inFile, String type) - throws IOException - { - super(inFile, type); - } - - public void parse() - { - int i = 0; - boolean seqFlag = false; - String key = new String(); - Vector headers = new Vector(); - Hashtable seqhash = new Hashtable(); - String line; - - try + /** + * Creates a new MSFfile object. + */ + public PileUpfile() { - while ( (line = nextLine()) != null) - { - StringTokenizer str = new StringTokenizer(line); - - while (str.hasMoreTokens()) - { - String inStr = str.nextToken(); - - //If line has header information add to the headers vector - if (inStr.indexOf("Name:") != -1) - { - key = str.nextToken(); - headers.addElement(key); - } - - //if line has // set SeqFlag to 1 so we know sequences are coming - if (inStr.indexOf("//") != -1) - { - seqFlag = true; - } - - //Process lines as sequence lines if seqFlag is set - if ( (inStr.indexOf("//") == -1) && (seqFlag == true)) - { - //seqeunce id is the first field - key = inStr; - - StringBuffer tempseq; - - //Get sequence from hash if it exists - if (seqhash.containsKey(key)) - { - tempseq = (StringBuffer) seqhash.get(key); - } - else - { - tempseq = new StringBuffer(); - seqhash.put(key, tempseq); - } - - //loop through the rest of the words - while (str.hasMoreTokens()) - { - //append the word to the sequence - tempseq.append(str.nextToken()); - } - } - } - } } - catch (IOException e) + /** + * Creates a new MSFfile object. + * + * @param inStr DOCUMENT ME! + */ + public PileUpfile(String inStr) { - System.err.println("Exception parsing PileUpfile " + e); - e.printStackTrace(); + super(inStr); } - this.noSeqs = headers.size(); - - //Add sequences to the hash - for (i = 0; i < headers.size(); i++) + /** + * Creates a new MSFfile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public PileUpfile(String inFile, String type) throws IOException { - if (seqhash.get(headers.elementAt(i)) != null) - { - String head = headers.elementAt(i).toString(); - String seq = seqhash.get(head).toString(); - - int start = 1; - int end = -1; - - if (maxLength < head.length()) - { - maxLength = head.length(); - } - - if (head.indexOf("/") > 0) - { - StringTokenizer st = new StringTokenizer(head, "/"); - - if (st.countTokens() == 2) - { - head = st.nextToken(); - - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) - { - start = Integer.valueOf(st.nextToken()).intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } - } - } - - Sequence newSeq = new Sequence(head, seq, start, end); - - seqs.addElement(newSeq); - } - else - { - System.err.println( - "PileUpfile Parser: Can't find sequence for " + - headers.elementAt(i)); - } + super(inFile, type); } - } - - public static int checkSum(String seq) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() { - - int check = 0; - - String sequence = seq.toUpperCase(); - - for (int i = 0; i < sequence.length(); i++) - { - if (i < sequence.length()) - { - int value = sequence.charAt(i); - if (value != -1) - { - check += (i % 57 + 1) * value; - } - } - - } - - return check % 10000; + return print(getSeqsAsArray()); } - public static String print(SequenceI[] s) + + public String print(SequenceI[] s) { StringBuffer out = new StringBuffer("PileUp\n\n"); @@ -217,8 +100,7 @@ public class PileUpfile while ( (i < s.length) && (s[i] != null)) { String seq = s[i].getSequence(); - out.append(" Name: " + s[i].getName() + - "/" + s[i].getStart() + "-" + s[i].getEnd() + + out.append(" Name: " + printId(s[i]) + " oo Len: " + s[i].getSequence().length() + " Check: " + checksums[i] + " Weight: 1.00\n"); @@ -259,11 +141,9 @@ public class PileUpfile while ( (j < s.length) && (s[j] != null)) { - String name = s[j].getName(); - // out.append(new Format("%-" + maxid + "s").form(name) + " "); + String name = printId(s[j]); - out.append(new Format("%-" + maxid + "s").form(name - + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); + out.append(new Format("%-" + maxid + "s").form(name + " ")); for (int k = 0; k < 5; k++) { @@ -309,9 +189,4 @@ public class PileUpfile return out.toString(); } - - public String print() - { - return print(getSeqsAsArray()); - } } diff --git a/src/jalview/io/SequenceFeatureFetcher.java b/src/jalview/io/SequenceFeatureFetcher.java index 94713ea..d980b0a 100755 --- a/src/jalview/io/SequenceFeatureFetcher.java +++ b/src/jalview/io/SequenceFeatureFetcher.java @@ -26,6 +26,12 @@ import java.io.*; import java.util.*; +import org.exolab.castor.mapping.Mapping; + +import org.exolab.castor.xml.*; +import jalview.analysis.AlignSeq; + + /** * DOCUMENT ME! @@ -35,527 +41,299 @@ import java.util.*; */ public class SequenceFeatureFetcher implements Runnable { - AlignmentI align; - AlignmentPanel ap; - ArrayList unknownSequences; - CutAndPasteTransfer output = new CutAndPasteTransfer(); - StringBuffer sbuffer = new StringBuffer(); - - /** - * Creates a new SequenceFeatureFetcher object. - * - * @param align DOCUMENT ME! - * @param ap DOCUMENT ME! - */ - public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap) - { - unknownSequences = new ArrayList(); - this.align = align; - this.ap = ap; - - Thread thread = new Thread(this); - thread.start(); - } - - /** - * DOCUMENT ME! - */ - public void run() - { - RandomAccessFile out = null; - - try - { - String cache = System.getProperty("user.home") + - "/.jalview.uniprot.xml"; - - File test = new File(cache); - - if (!test.exists()) - { - out = new RandomAccessFile(cache, "rw"); - out.writeBytes("\n"); - out.writeBytes("\n"); - } - else - { - out = new RandomAccessFile(cache, "rw"); - - // open exisiting cache and remove from the end - long lastLine = 0; - String data; - - while ((data = out.readLine()) != null) - { - if (data.indexOf("") > -1) - { - lastLine = out.getFilePointer(); - } - } - - out.seek(lastLine); - } - - int seqIndex = 0; - Vector sequences = align.getSequences(); - while (seqIndex < sequences.size()) - { - ArrayList ids = new ArrayList(); + AlignmentI align; + AlignmentI dataset; + AlignmentPanel ap; + ArrayList unknownSequences; + CutAndPasteTransfer output = new CutAndPasteTransfer(); + StringBuffer sbuffer = new StringBuffer(); + boolean uniprotFlag = false; - for (int i = 0; (seqIndex < sequences.size()) && (i < 50); - seqIndex++, i++) - { - SequenceI sequence = (SequenceI) sequences.get(seqIndex); - ids.add(sequence.getName()); - } + public SequenceFeatureFetcher() + {} - tryLocalCacheFirst(ids, align); + public Vector getUniprotEntries(File file) + { - if (ids.size() > 0) - { - StringBuffer remainingIds = new StringBuffer("uniprot:"); + UniprotFile uni = new UniprotFile(); + try + { + // 1. Load the mapping information from the file + Mapping map = new Mapping(uni.getClass().getClassLoader()); + java.net.URL url = getClass().getResource("/uniprot_mapping.xml"); + map.loadMapping(url); - for (int i = 0; i < ids.size(); i++) - remainingIds.append(ids.get(i) + ";"); + // 2. Unmarshal the data + Unmarshaller unmar = new Unmarshaller(); + unmar.setIgnoreExtraElements(true); + unmar.setMapping(map); + uni = (UniprotFile) unmar.unmarshal(new FileReader(file)); - EBIFetchClient ebi = new EBIFetchClient(); - String[] result = ebi.fetchData(remainingIds.toString(), - "xml", null); + } + catch (Exception e) + { + System.out.println("Error getUniprotEntries() "+e); + } + return uni.getUniprotEntries(); + } + + /** + * Creates a new SequenceFeatureFetcher object. + * + * @param align DOCUMENT ME! + * @param ap DOCUMENT ME! + */ + public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap) + { + unknownSequences = new ArrayList(); + this.align = align; + this.dataset = align.getDataset(); + this.ap = ap; + + Thread thread = new Thread(this); + thread.start(); + } + + /** + * DOCUMENT ME! + */ + public void run() + { + try + { + int seqIndex = 0; + Vector sequences = dataset.getSequences(); - if (result != null) - { - ReadUniprotFile(result, out, align); - } - } - } + while (seqIndex < sequences.size()) + { + Vector ids = new Vector(); - if (out != null) + for (int i = 0; (seqIndex < sequences.size()) && (i < 50); + seqIndex++, i++) + { + Sequence sequence = (Sequence) sequences.get(seqIndex); + if(sequence.getSequenceFeatures()==null) + { + if (!ids.contains(sequence.getName())) { - out.writeBytes("\n"); - out.close(); + ids.add(sequence.getName()); + unknownSequences.add(sequence); } - } - catch (Exception ex) - { - ex.printStackTrace(); + } } - findMissingIds(align); - - if (sbuffer.length() > 0) + /////////////////////////////////// + ///READ FROM EBI + if (ids.size() > 0) { - output.setText( - "Your sequences have been matched to Uniprot. Some of the ids have been\n" + - "altered, most likely the start/end residue will have been updated.\n" + - "Save your alignment to maintain the updated id.\n\n" + - sbuffer.toString()); - Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300); + StringBuffer remainingIds = new StringBuffer("uniprot:"); + for (int i = 0; i < ids.size(); i++) + { + if(ids.get(i).toString().indexOf("|")>-1) + { + remainingIds.append(ids.get(i).toString().substring( + ids.get(i).toString().lastIndexOf("|") + 1)); + uniprotFlag = true; + } + remainingIds.append(ids.get(i) + ";"); + } + EBIFetchClient ebi = new EBIFetchClient(); + File file = ebi.fetchDataAsFile(remainingIds.toString(), + "xml", "raw"); + + + + if (file != null) + { + ReadUniprotFile(file, ids); + } } + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } - if (unknownSequences.size() > 0) - { - //ignore for now!!!!!!!!!! - // WSWUBlastClient blastClient = new WSWUBlastClient(align, unknownSequences); - } + if (sbuffer.length() > 0) + { + output.setText( + "Your sequences have been matched to Uniprot. Some of the ids have been\n" + + "altered, most likely the start/end residue will have been updated.\n" + + "Save your alignment to maintain the updated id.\n\n" + + sbuffer.toString()); + Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300); + // The above is the dataset, we must now find out the index + // of the viewed sequence - jalview.gui.PaintRefresher.Refresh(null, align); } - /** - * DOCUMENT ME! - * - * @param result DOCUMENT ME! - * @param out DOCUMENT ME! - * @param align DOCUMENT ME! - */ - void ReadUniprotFile(String[] result, RandomAccessFile out, AlignmentI align) - { - SequenceI sequence = null; - Vector features = null; - String type; - String description; - String status; - String start; - String end; - String pdb = null; - - for (int r = 0; r < result.length; r++) - { - if ((sequence == null) && (result[r].indexOf("") > -1)) - { - long filePointer = 0; - - if (out != null) - { - try - { - filePointer = out.getFilePointer(); - out.writeBytes("\n"); - } - catch (Exception ex) - { - } - } - - String seqName = parseElement(result[r], "", out); - sequence = align.findName(seqName); - - if (sequence == null) - { - sequence = align.findName(seqName.substring(0, - seqName.indexOf('_'))); - - if (sequence != null) - { - sbuffer.append("changing " + sequence.getName() + - " to " + seqName + "\n"); - sequence.setName(seqName); - } - } - - if (sequence == null) - { - sbuffer.append("UNIPROT updated suggestion is " + - result[r] + "\n"); - sequence = align.findName(result[r]); - - // this entry has been suggested by ebi. - // doesn't match id in alignment file - try - { - out.setLength(filePointer); - } - catch (Exception ex) - { - } - - // now skip to next entry - while (result[r].indexOf("") == -1) - r++; - } - - features = new Vector(); - type = ""; - start = "0"; - end = "0"; - description = ""; - status = ""; - pdb = ""; - } + promptBeforeBlast(); - if (sequence == null) - { - continue; - } + } - if (result[r].indexOf(" -1) - { - pdb = parseValue(result[r], "value=", out); - sequence.setPDBId(pdb); - } - if (result[r].indexOf("feature type") > -1) - { - type = parseValue(result[r], "type=", out); - description = parseValue(result[r], "description=", null); - status = parseValue(result[r], "status=", null); - - while (result[r].indexOf("position") == -1) - { - r++; // - } - - // r++; - if (result[r].indexOf("begin") > -1) - { - start = parseValue(result[r], "position=", out); - end = parseValue(result[++r], "position=", out); - } - else - { - start = parseValue(result[r], "position=", out); - end = parseValue(result[r], "position=", null); - } - - int sstart = Integer.parseInt(start); - int eend = Integer.parseInt(end); - - if (out != null) - { - try - { - out.writeBytes("\n"); - } - catch (Exception ex) - { - } - } - - SequenceFeature sf = new SequenceFeature(type, sstart, eend, - description, status); - features.add(sf); - } + void promptBeforeBlast() + { + // This must be outside the run() body as java 1.5 + // will not return any value from the OptionPane to the expired thread. + if (unknownSequences.size() > 0) + { + int reply = javax.swing.JOptionPane.showConfirmDialog( + Desktop.desktop, "Couldn't find a match for "+unknownSequences.size()+" sequences." + +"\nPerform blast for unknown sequences?", + "Blast for Unidentified Sequences", + javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); - if (result[r].indexOf("") == -1) - { - seqString.append(result[r]); - - if (out != null) - { - try - { - out.writeBytes(result[r] + "\n"); - } - catch (Exception ex) - { - } - } - } - - if (out != null) - { - try - { - out.writeBytes(result[r] + "\n"); - } - catch (Exception ex) - { - } - } - - StringBuffer nonGapped = new StringBuffer(); - - for (int i = 0; i < sequence.getSequence().length(); i++) - { - if (!jalview.util.Comparison.isGap(sequence.getCharAt(i))) - { - nonGapped.append(sequence.getCharAt(i)); - } - } - - int absStart = seqString.toString().indexOf(nonGapped.toString()); - - if (absStart == -1) - { - unknownSequences.add(sequence.getName()); - features = null; - sbuffer.append(sequence.getName() + - " SEQUENCE NOT %100 MATCH \n"); - - continue; - } - - int absEnd = absStart + nonGapped.toString().length(); - absStart += 1; - - if ((absStart != sequence.getStart()) || - (absEnd != sequence.getEnd())) - { - sbuffer.append("Updated: " + sequence.getName() + " " + - sequence.getStart() + "/" + sequence.getEnd() + - " to " + absStart + "/" + absEnd + "\n"); - } - - sequence.setStart(absStart); - sequence.setEnd(absEnd); - } + if(reply == javax.swing.JOptionPane.YES_OPTION) + new WSWUBlastClient(ap, align, unknownSequences); + } - if (result[r].indexOf("") > -1) - { - if (features != null) - { - sequence.setSequenceFeatures(features); - } - - features = null; - sequence = null; - - if (out != null) - { - try - { - out.writeBytes("\n"); - } - catch (Exception ex) - { - } - } - } - } - } - /** - * DOCUMENT ME! - * - * @param align DOCUMENT ME! - */ - void findMissingIds(AlignmentI align) - { - String data; - ArrayList cachedIds = new ArrayList(); + ap.repaint(); + } - try - { - if(jalview.bin.Cache.getProperty("UNIPROT_CACHE")==null) - return; + /** + * DOCUMENT ME! + * + * @param result DOCUMENT ME! + * @param out DOCUMENT ME! + * @param align DOCUMENT ME! + */ + void ReadUniprotFile(File file, Vector ids) + { + if(!file.exists()) + return; - BufferedReader in = new BufferedReader(new FileReader( - jalview.bin.Cache.getProperty("UNIPROT_CACHE"))); + SequenceI sequence = null; - while ((data = in.readLine()) != null) - { - if (data.indexOf("name") > -1) - { - String name = parseElement(data, "", null); - cachedIds.add(name); - } - } - } - catch (Exception ex) + Vector entries = getUniprotEntries(file); + + int i, iSize = entries==null?0:entries.size(); + UniprotEntry entry; + for (i = 0; i < iSize; i++) + { + entry = (UniprotEntry) entries.elementAt(i); + String idmatch = entry.getAccession().elementAt(0).toString(); + sequence = dataset.findName(idmatch); + + if (sequence == null) + { + //Sequence maybe Name, not Accession + idmatch = entry.getName().elementAt(0).toString(); + sequence = dataset.findName(idmatch); + } + + if(sequence!=null) + ids.remove(sequence.getName()); + + else if (sequence == null && uniprotFlag) + { + sequence = dataset.findName("UniProt/Swiss-Prot|"+entry.getAccession().elementAt(0)+"|"+idmatch); + ids.remove(idmatch); + } + + if(sequence ==null) + { + System.out.println(idmatch+" not found"); + continue; + } + + unknownSequences.remove(sequence); + + String nonGapped = AlignSeq.extractGaps("-. ", sequence.getSequence()); + + int absStart = entry.getUniprotSequence().getContent().indexOf( + nonGapped.toString()); + + if (absStart == -1) + { + // Is UniprotSequence contained in dataset sequence? + absStart = nonGapped.toString().indexOf(entry.getUniprotSequence().getContent()); + if(absStart == -1) { - ex.printStackTrace(); - } + unknownSequences.add(sequence.getName()); + sbuffer.append(sequence.getName() + + " SEQUENCE NOT %100 MATCH \n"); - for (int i = 0; i < align.getHeight(); i++) - if (!cachedIds.contains(align.getSequenceAt(i).getName())) + continue; + } + else + { + if(entry.getFeature()!=null) + { + Enumeration e = entry.getFeature().elements(); + while (e.hasMoreElements()) { - unknownSequences.add(align.getSequenceAt(i).getName()); + SequenceFeature sf = (SequenceFeature) e.nextElement(); + sf.setBegin(sf.getBegin() + absStart + 1); + sf.setEnd(sf.getEnd() + absStart + 1); } - } + } - /** - * DOCUMENT ME! - * - * @param ids DOCUMENT ME! - * @param align DOCUMENT ME! - */ - void tryLocalCacheFirst(ArrayList ids, AlignmentI align) - { - ArrayList cacheData = new ArrayList(); + sbuffer.append(sequence.getName() + + " HAS "+absStart+" PREFIXED RESIDUES COMPARED TO UNIPROT - ANY SEQUENCE FEATURES" + +" HAVE BEEN ADJUSTED ACCORDINGLY \n"); + absStart = 0; + } - try - { - if(jalview.bin.Cache.getProperty("UNIPROT_CACHE")==null) - return; + } - BufferedReader in = new BufferedReader(new FileReader( - jalview.bin.Cache.getProperty("UNIPROT_CACHE"))); + int absEnd = absStart + nonGapped.toString().length(); + absStart += 1; - // read through cache file, if the cache has sequences we're looking for - // add the lines to a new String array, Readthis new array and - // make sure we remove the ids from the list to retrieve from EBI - String data; + Enumeration e = entry.getDbReference().elements(); + Vector onlyPdbEntries = new Vector(); + while(e.hasMoreElements()) + { + PDBEntry pdb = (PDBEntry)e.nextElement(); + if(!pdb.getType().equals("PDB")) + continue; - while ((data = in.readLine()) != null) - { - if (data.indexOf("name") > -1) - { - String name = parseElement(data, "", null); - - if (ids.contains(name)) - { - cacheData.add(""); - cacheData.add(data); - - while (data.indexOf("") == -1) - { - data = in.readLine(); - cacheData.add(data); - } - - cacheData.add(data); - - ids.remove(name); - } - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } + onlyPdbEntries.addElement(pdb); + } - String[] localData = new String[cacheData.size()]; - cacheData.toArray(localData); + sequence.setPDBId(onlyPdbEntries); + sequence.setSequenceFeatures(entry.getFeature()); + sequence.setStart(absStart); + sequence.setEnd(absEnd); - if ((localData != null) && (localData.length > 0)) - { - ReadUniprotFile(localData, null, align); - } - } - /** - * DOCUMENT ME! - * - * @param line DOCUMENT ME! - * @param tag DOCUMENT ME! - * @param out DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - String parseValue(String line, String tag, RandomAccessFile out) - { - if (out != null) + int n = 0; + SequenceI seq2; + while (n < align.getHeight()) + { + //This loop enables multiple sequences with the same + //id to have features added and seq limits updated + seq2 = align.getSequenceAt(n); + if (seq2.getName().equals(idmatch)) { - try - { - out.writeBytes(line + "\n"); - } - catch (Exception ex) - { - } - } - int index = line.indexOf(tag) + tag.length() + 1; + nonGapped = AlignSeq.extractGaps("-. ", seq2.getSequence()); - if (index == tag.length()) - { - return ""; - } + absStart = sequence.getSequence().indexOf(nonGapped); + absEnd = absStart + nonGapped.toString().length() - 1; - return line.substring(index, line.indexOf("\"", index + 1)); - } + // This is the Viewd alignment sequences + // No need to tell the user of the dataset updates + if ( (seq2.getStart() != absStart+sequence.getStart()) + || (seq2.getEnd() != absEnd+sequence.getStart())) + { + sbuffer.append("Updated: " + seq2.getName() + " " + + seq2.getStart() + "/" + seq2.getEnd() + + " to " + (absStart + sequence.getStart()) + "/" + + (absEnd + sequence.getStart()) + "\n"); - /** - * DOCUMENT ME! - * - * @param line DOCUMENT ME! - * @param tag DOCUMENT ME! - * @param out DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - String parseElement(String line, String tag, RandomAccessFile out) - { - if (out != null) - { - try - { - out.writeBytes(line + "\n"); - } - catch (Exception ex) - { - } + seq2.setStart(absStart + sequence.getStart()); + seq2.setEnd(absEnd + sequence.getStart()); + } } - int index = line.indexOf(tag) + tag.length(); - - return line.substring(index, line.indexOf(" -1) + if (data.indexOf(">UNIPROT") > -1) { - int index = data.indexOf("database=\"uniprot\" id=") + 23; - id2 = data.substring(index, data.indexOf("\"", index)); + int index = data.indexOf(">UNIPROT") + 9; + id2 = data.substring(index, data.indexOf(" ", index)); - while (data.indexOf("") == -1) + boolean identitiesFound = false; + while (!identitiesFound) { data = st.nextToken(); - if (data.indexOf("") > -1) + if (data.indexOf("Identities") > -1) { - int value = Integer.parseInt(data.substring(data.indexOf( - "") + 10, - data.indexOf(""))); + identitiesFound = true; + + int value = Integer.parseInt(data.substring(data.indexOf( + "(") + 1, + data.indexOf("%"))); if (value >= maxFound) { maxFound = value; buffer.append(" " + id2 + " " + value + "%; "); + suggestedIds.addElement( new Object[]{seq, id2}); } } } } } - output.setText(output.getText() + buffer.toString()); + output.appendText(buffer.toString()); + } + + void updateIds() + { + // This must be outside the run() body as java 1.5 + // will not return any value from the OptionPane to the expired thread. + int reply = JOptionPane.showConfirmDialog( + Desktop.desktop, "Automatically update suggested ids?", + "Auto replace sequence ids", JOptionPane.YES_NO_OPTION); + + if (reply == JOptionPane.YES_OPTION) + { + Enumeration keys = suggestedIds.elements(); + while(keys.hasMoreElements()) + { + Object [] object = (Object[])keys.nextElement(); + + Sequence oldseq = (Sequence)object[0]; + + oldseq.setName( object[1].toString() ); + + // Oldseq is actually in the dataset, we must find the + // Visible seq and change its name also. + for (int i = 0; i < al.getHeight(); i++) + { + if (al.getSequenceAt(i).getDatasetSequence() == oldseq) + { + al.getSequenceAt(i).setName(oldseq.getName()); + break; + } + } + + Vector entries = oldseq.getDBRef(); + if (entries != null) + { + DBRefEntry entry = (DBRefEntry) entries.elementAt(0); + oldseq.addDBRef(new jalview.datamodel. + DBRefEntry("UNIPROT", + "0", + entry.getAccessionId())); + } + } + } + ap.repaint(); + } class ImageTwirler extends Thread @@ -163,20 +216,24 @@ public class WSWUBlastClient { } } + + if (jobsRunning == 0) + { + updateIds(); + } } } class BlastThread extends Thread { - String sequence; - String seqid; + Sequence sequence; String jobid; boolean jobComplete = false; - BlastThread(String id, String sequence) + BlastThread(Sequence sequence) { - this.sequence = sequence; - seqid = id; + System.out.println("blasting for: "+sequence.getName()); + this.sequence = sequence; } public void run() @@ -187,27 +244,23 @@ public class WSWUBlastClient { try { - Call call = (Call) new Service().createCall(); - call.setTargetEndpointAddress(new java.net.URL( - "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast")); - call.setOperationName(new QName("WSWUBlast", "polljob")); - - String result = (String) call.invoke(new Object[] - { - jobid, "xml" - }); - - if ((result.indexOf("JOB PENDING") == -1) && - (result.indexOf("JOB RUNNING") == -1)) - { - parseResult(seqid, result); - jobComplete = true; - jobsRunning--; - } - - Thread.sleep(5000); - - // System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug + WSWUBlastService service = new WSWUBlastServiceLocator(); + WSWUBlast wublast = service.getWSWUBlast(); + WSFile[] results = wublast.getResults(jobid); + + if(results!=null) + { + String result = new String(wublast.poll(jobid, "tooloutput")); + parseResult(sequence, result); + jobComplete = true; + jobsRunning--; + } + else + { + Thread.sleep(10000); + System.out.println("WSWuBlastClient: I'm alive " + + sequence.getName() + " " + jobid); // log.debug + } } catch (Exception ex) { @@ -217,38 +270,36 @@ public class WSWUBlastClient void StartJob() { - HashMap params = new HashMap(); - params.put("database", "uniprot"); - params.put("sensitivity", "low"); - params.put("sort", "totalscore"); - params.put("matrix", "pam10"); - params.put("program", "blastp"); - params.put("alignments", "5"); - params.put("outformat", "xml"); - params.put("searchtype", "1"); - - byte[] seqbytes = sequence.getBytes(); + InputParams params = new InputParams(); + + params.setProgram("blastp"); + params.setDatabase("uniprot"); + params.setMatrix("pam10"); + + params.setNumal(5); + params.setSensitivity("low"); + params.setSort("totalscore"); + params.setOutformat("txt"); + params.setAsync(true); try { - Call call = (Call) new Service().createCall(); - call.setTargetEndpointAddress(new java.net.URL( - "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast")); - call.setOperationName(new QName("WSWUBlast", "doWUBlast")); - - String result = (String) call.invoke(new Object[] - { - params, seqbytes - }); - jobid = result; - System.out.println( - "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast JobId '" + - jobid + "'"); + Data inputs[] = new Data[1]; + Data input= new Data(); + input.setType("sequence"); + input.setContent(AlignSeq.extractGaps("-. ",sequence.getSequence())); + inputs[0]=input; + + WSWUBlastService service = new WSWUBlastServiceLocator(); + WSWUBlast wublast = service.getWSWUBlast(); + jobid = wublast.runWUBlast(params, inputs); } catch (Exception exp) { - System.err.println("WSWUBlastClient error:\n" + exp.toString()); - exp.printStackTrace(); + jobComplete = true; + jobsRunning--; + System.err.println("WSWUBlastClient error:\n" + exp.toString()); + exp.printStackTrace(); } } } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index ddb2bcd..bb69a54 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -21,7 +21,6 @@ package jalview.jbgui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import javax.swing.event.*; import jalview.schemes.*; @@ -99,7 +98,7 @@ public class GAlignFrame public JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); JMenuItem createPNG = new JMenuItem(); protected JMenuItem font = new JMenuItem(); - public JCheckBoxMenuItem fullSeqId = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem(); JMenuItem epsFile = new JMenuItem(); JMenuItem LoadtreeMenuItem = new JMenuItem(); public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); @@ -113,6 +112,11 @@ public class GAlignFrame JMenu jMenu2 = new JMenu(); JMenuItem padGapsMenuitem = new JMenuItem(); protected ButtonGroup colours = new ButtonGroup(); + JMenuItem vamsasStore = new JMenuItem(); + protected JCheckBoxMenuItem showTranslation = new JCheckBoxMenuItem(); + //protected JTabbedPane tabbedPane = new JTabbedPane(); + public JMenuItem featureSettings = new JMenuItem(); + JMenuItem fetchSequence = new JMenuItem(); public GAlignFrame() { @@ -471,21 +475,6 @@ public class GAlignFrame }); this.getContentPane().setLayout(borderLayout1); alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11)); - alignFrameMenuBar.addAncestorListener(new AncestorListener() - { - public void ancestorAdded(AncestorEvent event) - { - alignFrameMenuBar_ancestorAdded(event); - } - - public void ancestorRemoved(AncestorEvent event) - { - } - - public void ancestorMoved(AncestorEvent event) - { - } - }); statusBar.setBackground(Color.white); statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); statusBar.setBorder(BorderFactory.createLineBorder(Color.black)); @@ -822,13 +811,14 @@ public class GAlignFrame font_actionPerformed(e); } }); - fullSeqId.setText("Show Full Sequence ID"); - fullSeqId.setState( jalview.bin.Cache.getDefault("SHOW_FULL_ID",true)); - fullSeqId.addActionListener(new java.awt.event.ActionListener() + + seqLimits.setText("Show Sequence Limits"); + seqLimits.setState( jalview.bin.Cache.getDefault("SHOW_JVSUFFIX",true)); + seqLimits.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { - fullSeqId_actionPerformed(e); + seqLimit_actionPerformed(e); } }); epsFile.setText("EPS"); @@ -906,6 +896,49 @@ public class GAlignFrame padGapsMenuitem_actionPerformed(e); } }); + vamsasStore.setVisible(false); + vamsasStore.setText("VAMSAS store"); + vamsasStore.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + vamsasStore_actionPerformed(e); + } + }); + showTranslation.setText("Translate cDNA"); + showTranslation.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + showTranslation_actionPerformed(e); + } + }); + + /* tabbedPane.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent ece) + { + + tabSelected(); + } + });*/ + featureSettings.setEnabled(false); + featureSettings.setText("Feature Settings..."); + featureSettings.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + featureSettings_actionPerformed(e); + } + }); + fetchSequence.setText("Fetch Sequence..."); + fetchSequence.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + fetchSequence_actionPerformed(e); + } + }); alignFrameMenuBar.add(fileMenu); alignFrameMenuBar.add(editMenu); alignFrameMenuBar.add(searchMenu); @@ -913,6 +946,8 @@ public class GAlignFrame alignFrameMenuBar.add(colourMenu); alignFrameMenuBar.add(calculateMenu); alignFrameMenuBar.add(webService); + fileMenu.add(fetchSequence); + fileMenu.add(vamsasStore); fileMenu.add(saveAlignmentMenu); fileMenu.add(jMenu2); fileMenu.add(outputTextboxMenu); @@ -944,7 +979,7 @@ public class GAlignFrame viewMenu.add(font); viewMenu.addSeparator(); viewMenu.add(wrapMenuItem); - viewMenu.add(fullSeqId); + viewMenu.add(seqLimits); viewMenu.add(scaleAbove); viewMenu.add(scaleLeft); viewMenu.add(scaleRight); @@ -953,7 +988,9 @@ public class GAlignFrame viewMenu.add(colourTextMenuItem); viewMenu.add(renderGapsMenuItem); viewMenu.add(annotationPanelMenuItem); + viewMenu.addSeparator(); viewMenu.add(sequenceFeatures); + viewMenu.add(featureSettings); viewMenu.addSeparator(); viewMenu.add(overviewMenuItem); colourMenu.add(applyToAllGroups); @@ -981,9 +1018,12 @@ public class GAlignFrame calculateMenu.addSeparator(); calculateMenu.add(pairwiseAlignmentMenuItem); calculateMenu.add(PCAMenuItem); + calculateMenu.addSeparator(); + calculateMenu.add(showTranslation); webServiceNoServices=new JMenuItem(""); webService.add(webServiceNoServices); this.getContentPane().add(statusBar, BorderLayout.SOUTH); + // this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER); jMenu1.add(pasteNew); jMenu1.add(pasteThis); sort.add(sortIDMenuItem); @@ -1110,10 +1150,6 @@ public class GAlignFrame { } - protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) - { - } - protected void clustalColour_actionPerformed(ActionEvent e) { } @@ -1226,10 +1262,16 @@ public class GAlignFrame { } - protected void fullSeqId_actionPerformed(ActionEvent e) + protected void seqLimit_actionPerformed(ActionEvent e) { } + public void seqDBRef_actionPerformed(ActionEvent e) + { + + } + + public void createEPS(java.io.File f) { } @@ -1262,27 +1304,44 @@ public class GAlignFrame { } - protected void preferences_actionPerformed(ActionEvent e) + + + protected void saveAlignmentMenu_actionPerformed(ActionEvent e) + { + } + + protected void padGapsMenuitem_actionPerformed(ActionEvent e) { } - protected void msaAlignMenuItem_actionPerformed(ActionEvent e) + + public void vamsasStore_actionPerformed(ActionEvent e) { + } - protected void alignFrameMenuBar_ancestorAdded(AncestorEvent event) + public void vamsasLoad_actionPerformed(ActionEvent e) { + } - protected void saveAlignmentMenu_actionPerformed(ActionEvent e) + public void showTranslation_actionPerformed(ActionEvent e) { + } - protected void padGapsMenuitem_actionPerformed(ActionEvent e) + public void tabSelected() + { + + } + + public void featureSettings_actionPerformed(ActionEvent e) { + } - protected void ClustalRealign_actionPerformed(ActionEvent e) + public void fetchSequence_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 65ef8dc..5505e69 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -48,8 +48,10 @@ public class GDesktop extends JFrame JMenuItem saveState = new JMenuItem(); JMenuItem loadState = new JMenuItem(); JMenu jMenu1 = new JMenu(); + JMenuItem vamsasLoad = new JMenuItem(); + JMenuItem inputSequence = new JMenuItem(); - /** + /** * Creates a new GDesktop object. */ public GDesktop() @@ -158,13 +160,31 @@ public class GDesktop extends JFrame }); jMenu1.setMnemonic('I'); jMenu1.setText("Input Alignment"); - DesktopMenubar.add(FileMenu); + vamsasLoad.setText("Vamsas"); + vamsasLoad.setVisible(false); + vamsasLoad.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + vamsasLoad_actionPerformed(e); + } + }); + inputSequence.setText("Fetch Sequence..."); + inputSequence.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + inputSequence_actionPerformed(e); + } + }); + DesktopMenubar.add(FileMenu); DesktopMenubar.add(toolsMenu); DesktopMenubar.add(HelpMenu); DesktopMenubar.add(windowMenu); FileMenu.addSeparator(); FileMenu.add(jMenu1); - FileMenu.addSeparator(); + FileMenu.add(inputSequence); + FileMenu.addSeparator(); FileMenu.add(saveState); FileMenu.add(loadState); FileMenu.addSeparator(); @@ -175,7 +195,8 @@ public class GDesktop extends JFrame jMenu1.add(inputLocalFileMenuItem); jMenu1.add(inputURLMenuItem); jMenu1.add(inputTextboxMenuItem); - } + jMenu1.add(vamsasLoad); + } /** * DOCUMENT ME! @@ -273,4 +294,14 @@ public class GDesktop extends JFrame public void loadJalviewAlign_actionPerformed(ActionEvent e) { } + + public void vamsasLoad_actionPerformed(ActionEvent e) + { + + } + + public void inputSequence_actionPerformed(ActionEvent e) + { + + } } diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 50c4cf5..2001efd 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -42,8 +42,7 @@ public class GPreferences extends JPanel BorderLayout borderLayout1 = new BorderLayout(); protected JCheckBox quality = new JCheckBox(); JPanel visualTab = new JPanel(); - protected JCheckBox fullID = new JCheckBox(); - protected JCheckBox fullScreen = new JCheckBox(); + protected JCheckBox fullScreen = new JCheckBox(); protected JCheckBox conservation = new JCheckBox(); protected JCheckBox identity = new JCheckBox(); protected JCheckBox annotations = new JCheckBox(); @@ -79,6 +78,7 @@ public class GPreferences extends JPanel protected JCheckBox useProxy = new JCheckBox(); JPanel jPanel1 = new JPanel(); TitledBorder titledBorder1 = new TitledBorder("Proxy Server"); + TitledBorder titledBorder2 = new TitledBorder("File Output"); GridBagLayout gridBagLayout2 = new GridBagLayout(); GridBagLayout gridBagLayout1 = new GridBagLayout(); GridBagLayout gridBagLayout3 = new GridBagLayout(); @@ -90,6 +90,19 @@ public class GPreferences extends JPanel JPanel exportTab = new JPanel(); JLabel epsLabel = new JLabel(); protected JComboBox epsRendering = new JComboBox(); + JLabel jLabel1 = new JLabel(); + protected JCheckBox blcjv = new JCheckBox(); + protected JCheckBox pileupjv = new JCheckBox(); + protected JCheckBox clustaljv = new JCheckBox(); + protected JCheckBox msfjv = new JCheckBox(); + protected JCheckBox fastajv = new JCheckBox(); + protected JCheckBox pfamjv = new JCheckBox(); + FlowLayout flowLayout1 = new FlowLayout(); + protected JCheckBox pirjv = new JCheckBox(); + JPanel jPanel11 = new JPanel(); + Font verdana11 = new java.awt.Font("Verdana", Font.PLAIN, 11); + protected JCheckBox seqLimit = new JCheckBox(); + GridLayout gridLayout3 = new GridLayout(); /** * Creates a new GPreferences object. */ @@ -130,36 +143,31 @@ public class GPreferences extends JPanel } }); quality.setEnabled(false); - quality.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + quality.setFont(verdana11); quality.setHorizontalAlignment(SwingConstants.RIGHT); quality.setHorizontalTextPosition(SwingConstants.LEFT); quality.setSelected(true); quality.setText("Quality"); visualTab.setBorder(new TitledBorder("Open new alignment")); visualTab.setLayout(null); - fullID.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fullID.setHorizontalAlignment(SwingConstants.RIGHT); - fullID.setHorizontalTextPosition(SwingConstants.LEFT); - fullID.setMargin(new Insets(4, 2, 2, 0)); - fullID.setText("Full Sequence ID"); - fullScreen.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fullScreen.setFont(verdana11); fullScreen.setHorizontalAlignment(SwingConstants.RIGHT); fullScreen.setHorizontalTextPosition(SwingConstants.LEFT); fullScreen.setMargin(new Insets(2, 2, 2, 0)); fullScreen.setText("Maximise Window"); conservation.setEnabled(false); - conservation.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + conservation.setFont(verdana11); conservation.setHorizontalAlignment(SwingConstants.RIGHT); conservation.setHorizontalTextPosition(SwingConstants.LEFT); conservation.setSelected(true); conservation.setText("Conservation"); identity.setEnabled(false); - identity.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + identity.setFont(verdana11); identity.setHorizontalAlignment(SwingConstants.RIGHT); identity.setHorizontalTextPosition(SwingConstants.LEFT); identity.setSelected(true); identity.setText("Consensus"); - annotations.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + annotations.setFont(verdana11); annotations.setHorizontalAlignment(SwingConstants.RIGHT); annotations.setHorizontalTextPosition(SwingConstants.LEFT); annotations.setMargin(new Insets(2, 4, 2, 0)); @@ -172,32 +180,32 @@ public class GPreferences extends JPanel annotations_actionPerformed(e); } }); - gapLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + gapLabel.setFont(verdana11); gapLabel.setHorizontalAlignment(SwingConstants.RIGHT); gapLabel.setText("Gap Symbol "); - colour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - colour.setBounds(new Rectangle(148, 171, 154, 21)); - colourLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + colour.setFont(verdana11); + colour.setBounds(new Rectangle(170, 170, 155, 21)); + colourLabel.setFont(verdana11); colourLabel.setHorizontalAlignment(SwingConstants.RIGHT); colourLabel.setText("Colour "); - fontLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fontLabel.setFont(verdana11); fontLabel.setHorizontalAlignment(SwingConstants.RIGHT); fontLabel.setText("Font "); - fontSizeCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fontSizeCB.setFont(verdana11); fontSizeCB.setBounds(new Rectangle(317, 111, 49, 21)); - fontStyleCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fontStyleCB.setFont(verdana11); fontStyleCB.setBounds(new Rectangle(365, 111, 70, 21)); - fontNameCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fontNameCB.setBounds(new Rectangle(148, 111, 169, 21)); - gapSymbolCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - gapSymbolCB.setBounds(new Rectangle(148, 141, 67, 21)); + fontNameCB.setFont(verdana11); + fontNameCB.setBounds(new Rectangle(170, 111, 147, 21)); + gapSymbolCB.setFont(verdana11); + gapSymbolCB.setBounds(new Rectangle(170, 141, 69, 21)); startupCheckbox.setText("Open file"); - startupCheckbox.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + startupCheckbox.setFont(verdana11); startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT); startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT); startupCheckbox.setSelected(true); - startupFileTextfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - startupFileTextfield.setBounds(new Rectangle(148, 232, 302, 20)); + startupFileTextfield.setFont(verdana11); + startupFileTextfield.setBounds(new Rectangle(170, 232, 271, 20)); startupFileTextfield.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) @@ -212,16 +220,16 @@ public class GPreferences extends JPanel connectTab.setLayout(gridBagLayout3); serverLabel.setText("Address"); serverLabel.setHorizontalAlignment(SwingConstants.RIGHT); - serverLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - proxyServerTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - proxyPortTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - portLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + serverLabel.setFont(verdana11); + proxyServerTB.setFont(verdana11); + proxyPortTB.setFont(verdana11); + portLabel.setFont(verdana11); portLabel.setHorizontalAlignment(SwingConstants.RIGHT); portLabel.setText("Port"); browserLabel.setFont(new java.awt.Font("SansSerif", 0, 11)); browserLabel.setHorizontalAlignment(SwingConstants.TRAILING); browserLabel.setText("Default Browser (Unix)"); - defaultBrowser.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + defaultBrowser.setFont(verdana11); defaultBrowser.setText(""); newLink.setText("New"); newLink.addActionListener(new java.awt.event.ActionListener() { @@ -268,7 +276,7 @@ public class GPreferences extends JPanel linkNameList.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11)); linkNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); linkPanel2.setLayout(borderLayout3); - linkURLList.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + linkURLList.setFont(verdana11); linkURLList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); defaultBrowser.addMouseListener(new MouseAdapter() @@ -281,7 +289,7 @@ public class GPreferences extends JPanel } } }); - useProxy.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + useProxy.setFont(verdana11); useProxy.setHorizontalAlignment(SwingConstants.RIGHT); useProxy.setHorizontalTextPosition(SwingConstants.LEADING); useProxy.setText("Use a proxy server"); @@ -294,43 +302,76 @@ public class GPreferences extends JPanel }); jPanel1.setBorder(titledBorder1); jPanel1.setLayout(gridBagLayout1); - sortby.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - sortby.setBounds(new Rectangle(148, 200, 302, 21)); - sortLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + sortby.setFont(verdana11); + sortby.setBounds(new Rectangle(170, 200, 155, 21)); + sortLabel.setFont(verdana11); sortLabel.setHorizontalAlignment(SwingConstants.RIGHT); sortLabel.setText("Sort by "); - jPanel2.setBounds(new Rectangle(7, 17, 138, 242)); + jPanel2.setBounds(new Rectangle(7, 17, 158, 242)); jPanel2.setLayout(gridLayout2); gridLayout2.setRows(8); - jPanel3.setBounds(new Rectangle(147, 46, 274, 26)); + jPanel3.setBounds(new Rectangle(168, 47, 274, 26)); exportTab.setLayout(null); - epsLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + epsLabel.setFont(verdana11); epsLabel.setHorizontalAlignment(SwingConstants.RIGHT); epsLabel.setText("EPS Rendering Style"); - epsLabel.setBounds(new Rectangle(3, 47, 134, 21)); - epsRendering.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - epsRendering.setBounds(new Rectangle(145, 47, 286, 21)); + epsLabel.setBounds(new Rectangle(9, 31, 140, 24)); + epsRendering.setFont(verdana11); + epsRendering.setBounds(new Rectangle(154, 34, 187, 21)); + jLabel1.setFont(verdana11); + jLabel1.setHorizontalAlignment(SwingConstants.CENTER); + jLabel1.setText("Append /start-end (/15-380)"); + jLabel1.setFont(verdana11); + fastajv.setFont(verdana11); + fastajv.setHorizontalAlignment(SwingConstants.LEFT); + clustaljv.setText("Clustal "); + blcjv.setText("BLC "); + fastajv.setText("Fasta "); + msfjv.setText("MSF "); + pfamjv.setText("PFAM "); + pileupjv.setText("Pileup "); + msfjv.setFont(verdana11); + msfjv.setHorizontalAlignment(SwingConstants.LEFT); + pirjv.setText("PIR "); + jPanel11.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + jPanel11.setBorder(titledBorder2); + jPanel11.setBounds(new Rectangle(30, 72, 196, 182)); + jPanel11.setLayout(gridLayout3); + blcjv.setFont(verdana11); + blcjv.setHorizontalAlignment(SwingConstants.LEFT); + clustaljv.setFont(verdana11); + clustaljv.setHorizontalAlignment(SwingConstants.LEFT); + pfamjv.setFont(verdana11); + pfamjv.setHorizontalAlignment(SwingConstants.LEFT); + pileupjv.setFont(verdana11); + pileupjv.setHorizontalAlignment(SwingConstants.LEFT); + pirjv.setFont(verdana11); + pirjv.setHorizontalAlignment(SwingConstants.LEFT); + seqLimit.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + seqLimit.setHorizontalAlignment(SwingConstants.RIGHT); + seqLimit.setHorizontalTextPosition(SwingConstants.LEADING); + seqLimit.setText("Full Sequence Id"); + gridLayout3.setRows(8); jPanel2.add(fullScreen); jPanel2.add(annotations); - jPanel2.add(fullID); + jPanel2.add(seqLimit); jPanel2.add(fontLabel); jPanel2.add(gapLabel); jPanel2.add(colourLabel); jPanel2.add(sortLabel); jPanel2.add(startupCheckbox); + visualTab.add(gapSymbolCB); + visualTab.add(colour); visualTab.add(jPanel3); jPanel3.add(conservation); - jPanel3.add(quality); jPanel3.add(identity); + jPanel3.add(quality); visualTab.add(sortby); - visualTab.add(colour); visualTab.add(startupFileTextfield); visualTab.add(fontNameCB); visualTab.add(fontSizeCB); visualTab.add(fontStyleCB); - visualTab.add(gapSymbolCB); visualTab.add(jPanel2); - linkPanel.add(editLinkButtons, BorderLayout.EAST); editLinkButtons.add(newLink, null); editLinkButtons.add(editLink, null); @@ -370,8 +411,6 @@ public class GPreferences extends JPanel , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 0, 0, 15), 307, 1)); - exportTab.add(epsLabel); - exportTab.add(epsRendering); jPanel1.add(useProxy, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0 , GridBagConstraints.WEST, @@ -383,8 +422,19 @@ public class GPreferences extends JPanel gapSymbolCB.setRenderer(dlcr); tabbedPane.add(visualTab, "Visual"); - tabbedPane.add(connectTab, "Connections"); - tabbedPane.add(exportTab, "Export"); + tabbedPane.add(connectTab,"Connections"); + tabbedPane.add(exportTab, "Output"); + jPanel11.add(jLabel1); + jPanel11.add(blcjv); + jPanel11.add(clustaljv); + jPanel11.add(fastajv); + jPanel11.add(msfjv); + jPanel11.add(pfamjv); + jPanel11.add(pileupjv); + jPanel11.add(pirjv); + exportTab.add(epsLabel); + exportTab.add(epsRendering); + exportTab.add(jPanel11); } /** diff --git a/src/jalview/jbgui/GTreePanel.java b/src/jalview/jbgui/GTreePanel.java index 4301a75..a70920c 100755 --- a/src/jalview/jbgui/GTreePanel.java +++ b/src/jalview/jbgui/GTreePanel.java @@ -41,7 +41,6 @@ public class GTreePanel JMenuItem epsTree = new JMenuItem(); JMenu saveAsMenu = new JMenu(); JMenuItem textbox = new JMenuItem(); - public GTreePanel() { try @@ -203,4 +202,9 @@ public class GTreePanel public void textbox_actionPerformed(ActionEvent e) { } + + public void fullid_actionPerformed(ActionEvent e) + { + + } } diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 4906eb7..d25707f 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -1135,20 +1135,6 @@ public class ResidueProperties propHash.put("polar", polar); } - public static Hashtable chainColours = new Hashtable(); - - static - { - chainColours.put("A", Color.red); - chainColours.put("B", Color.orange); - chainColours.put("C", Color.yellow); - chainColours.put("D", Color.green); - chainColours.put("E", Color.cyan); - chainColours.put("F", Color.blue); - chainColours.put("G", Color.magenta); - chainColours.put("H", Color.pink); - } - private ResidueProperties() { } @@ -1234,7 +1220,7 @@ public class ResidueProperties String key = (String) e.nextElement(); Vector tmp = (Vector) codonHash.get(key); - if (tmp.contains(codon)) + if (tmp.contains(codon.toUpperCase())) { return key; } @@ -1242,9 +1228,4 @@ public class ResidueProperties return null; } - - public static Hashtable getChainColours() - { - return chainColours; - } } diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 9a86696..e48c0ca 100755 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -29,215 +29,246 @@ import jalview.datamodel.*; */ public class Comparison { - /** DOCUMENT ME!! */ - public static String GapChars = " .-"; - - /** - * DOCUMENT ME! - * - * @param ii DOCUMENT ME! - * @param jj DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static float compare(SequenceI ii, SequenceI jj) + /** DOCUMENT ME!! */ + public static String GapChars = " .-"; + + /** + * DOCUMENT ME! + * + * @param ii DOCUMENT ME! + * @param jj DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static float compare(SequenceI ii, SequenceI jj) + { + return Comparison.compare(ii, jj, 0, ii.getLength() - 1); + } + + /** + * this was supposed to be an ungapped pid calculation + * @param ii SequenceI + * @param jj SequenceI + * @param start int + * @param end int + * @return float + */ + public static float compare(SequenceI ii, SequenceI jj, int start, int end) + { + String si = ii.getSequence(); + String sj = jj.getSequence(); + + int ilen = si.length() - 1; + int jlen = sj.length() - 1; + + while (jalview.util.Comparison.isGap(si.charAt(start + ilen))) { - return Comparison.compare(ii, jj, 0, ii.getLength() - 1); + ilen--; } - /** - * this was supposed to be an ungapped pid calculation - * @param ii SequenceI - * @param jj SequenceI - * @param start int - * @param end int - * @return float - */ - public static float compare(SequenceI ii, SequenceI jj, int start, int end) + while (jalview.util.Comparison.isGap(sj.charAt(start + jlen))) { - String si = ii.getSequence(); - String sj = jj.getSequence(); + jlen--; + } - int ilen = si.length() - 1; - int jlen = sj.length() - 1; + int count = 0; + int match = 0; + float pid = -1; - while (jalview.util.Comparison.isGap(si.charAt(start + ilen))) - { - ilen--; - } - - while (jalview.util.Comparison.isGap(sj.charAt(start + jlen))) + if (ilen > jlen) + { + for (int j = 0; j < jlen; j++) + { + if (si.substring(start + j, start + j + 1).equals(sj.substring(start + + j, start + j + 1))) { - jlen--; + match++; } - int count = 0; - int match = 0; - float pid = -1; + count++; + } - if (ilen > jlen) - { - for (int j = 0; j < jlen; j++) - { - if (si.substring(start + j, start + j + 1).equals(sj.substring(start + - j, start + j + 1))) - { - match++; - } - - count++; - } - - pid = (float) match / (float) ilen * 100; - } - else + pid = (float) match / (float) ilen * 100; + } + else + { + for (int j = 0; j < jlen; j++) + { + if (si.substring(start + j, start + j + 1).equals(sj.substring(start + + j, start + j + 1))) { - for (int j = 0; j < jlen; j++) - { - if (si.substring(start + j, start + j + 1).equals(sj.substring(start + - j, start + j + 1))) - { - match++; - } - - count++; - } - - pid = (float) match / (float) jlen * 100; + match++; } - return pid; + count++; + } + + pid = (float) match / (float) jlen * 100; } - /** - * this is a gapped PID calculation - * - * @param s1 SequenceI - * @param s2 SequenceI - * @return float - */ - public static float PID(SequenceI s1, SequenceI s2) + return pid; + } + + /** + * this is a gapped PID calculation + * + * @param s1 SequenceI + * @param s2 SequenceI + * @return float + */ + public static float PID(SequenceI s1, SequenceI s2) + { + int len; + + if (s1.getSequence().length() > s2.getSequence().length()) { - int len; + len = s1.getSequence().length(); + } + else + { + len = s2.getSequence().length(); + } - if (s1.getSequence().length() > s2.getSequence().length()) - { - len = s1.getSequence().length(); - } - else + int bad = 0; + + for (int i = 0; i < len; i++) + { + char chr1; + char chr2; + + if (i < s1.getSequence().length()) + { + chr1 = Character.toUpperCase(s1.getSequence().charAt(i)); + } + else + { + chr1 = '.'; + } + + if (i < s2.getSequence().length()) + { + chr2 = Character.toUpperCase(s2.getSequence().charAt(i)); + } + else + { + chr2 = '.'; + } + + if (! (jalview.util.Comparison.isGap(chr1)) && + ! (jalview.util.Comparison.isGap(chr2))) + { + if (chr1 != chr2) { - len = s2.getSequence().length(); + bad++; } + } + } - int bad = 0; + return ( (float) 100 * (len - bad)) / len; + } - for (int i = 0; i < len; i++) - { - char chr1; - char chr2; - - if (i < s1.getSequence().length()) - { - chr1 = Character.toUpperCase(s1.getSequence().charAt(i)); - } - else - { - chr1 = '.'; - } - - if (i < s2.getSequence().length()) - { - chr2 = Character.toUpperCase(s2.getSequence().charAt(i)); - } - else - { - chr2 = '.'; - } - - if (!(jalview.util.Comparison.isGap(chr1)) && - !(jalview.util.Comparison.isGap(chr2))) - { - if (chr1 != chr2) - { - bad++; - } - } - } + // Another pid with region specification + public static float PID(SequenceI s1, SequenceI s2, int start, int end) + { + int len; - return ((float) 100 * (len - bad)) / len; + if (s1.getSequence().length() > s2.getSequence().length()) + { + len = s1.getSequence().length(); + } + else + { + len = s2.getSequence().length(); } - // Another pid with region specification - public static float PID(SequenceI s1, SequenceI s2, int start, int end) + if (end < len) { - int len; + len = end; + } - if (s1.getSequence().length() > s2.getSequence().length()) - { - len = s1.getSequence().length(); - } - else - { - len = s2.getSequence().length(); - } + if (len < start) + { + start = len - 1; // we just use a single residue for the difference + } - if (end < len) - { - len = end; - } + int bad = 0; - if (len < start) + for (int i = start; i < len; i++) + { + char chr1; + char chr2; + + if (i < s1.getSequence().length()) + { + chr1 = Character.toUpperCase(s1.getSequence().charAt(i)); + } + else + { + chr1 = '.'; + } + + if (i < s2.getSequence().length()) + { + chr2 = Character.toUpperCase(s2.getSequence().charAt(i)); + } + else + { + chr2 = '.'; + } + + if (! (jalview.util.Comparison.isGap(chr1)) && + ! (jalview.util.Comparison.isGap(chr2))) + { + if (chr1 != chr2) { - start = len - 1; // we just use a single residue for the difference + bad++; } + } + } - int bad = 0; - - for (int i = start; i < len; i++) + return ( (float) 100 * (len - bad)) / len; + } + + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static boolean isGap(char c) + { + return (c == '-' || c == '.' || c == ' ') ? true : false; + } + + public static boolean isNucleotide(SequenceI [] seqs) + { + int i = 0, iSize = seqs.length, j, jSize; + float nt = 0, aa = 0; + char c; + while (i < iSize) + { + jSize = seqs[i].getLength(); + for (j = 0; j < jSize; j++) + { + c = seqs[i].getCharAt(j); + if ('a' <= c && c <= 'z') + c -= ('a' - 'A'); + + if (c == 'A' || c == 'G' || c == 'C' || c == 'T' || c == 'U') + nt++; + else if (!jalview.util.Comparison.isGap( seqs[i].getCharAt(j))) { - char chr1; - char chr2; - - if (i < s1.getSequence().length()) - { - chr1 = Character.toUpperCase(s1.getSequence().charAt(i)); - } - else - { - chr1 = '.'; - } - - if (i < s2.getSequence().length()) - { - chr2 = Character.toUpperCase(s2.getSequence().charAt(i)); - } - else - { - chr2 = '.'; - } - - if (!(jalview.util.Comparison.isGap(chr1)) && - !(jalview.util.Comparison.isGap(chr2))) - { - if (chr1 != chr2) - { - bad++; - } - } + aa++; } - - return ((float) 100 * (len - bad)) / len; + } + i++; } - /** - * DOCUMENT ME! - * - * @param c DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static boolean isGap(char c) - { - return ( c=='-' || c=='.' || c==' ' ) ? true : false; - } + if ( (nt / (nt + aa)) > 0.85f) + return true; + else + return false; + + } } diff --git a/src/jalview/util/ImageMaker.java b/src/jalview/util/ImageMaker.java new file mode 100755 index 0000000..02427f2 --- /dev/null +++ b/src/jalview/util/ImageMaker.java @@ -0,0 +1,165 @@ +package jalview.util; + +import java.awt.event.ActionEvent; +import java.awt.RenderingHints; +import javax.imageio.ImageIO; +import org.jibble.epsgraphics.EpsGraphics2D; +import jalview.gui.EPSOptions; +import java.awt.Graphics2D; +import java.io.*; +import java.awt.image.BufferedImage; +import java.awt.Graphics; +import jalview.io.*; +import java.awt.*; + + +public class ImageMaker +{ + public static final int EPS = 0; + public static final int PNG = 1; + int type = -1; + + EpsGraphics2D pg; + Graphics graphics; + FileOutputStream out; + BufferedImage bi; + + public ImageMaker(Component parent, int type, String title, + int width, int height, File file, String EPStitle) + { + this.type = type; + + if (file == null) + { + JalviewFileChooser chooser; + chooser = type == EPS ? getEPSChooser() : getPNGChooser(); + + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle(title); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(parent); + + if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION) + { + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + + file = chooser.getSelectedFile(); + } + } + + try + { + out = new FileOutputStream(file); + + if (type == EPS) + setupEPS(width, height, EPStitle); + else + setupPNG(width, height); + } + catch (Exception ex) + { + System.out.println("Error creating " + (type == EPS ? "EPS" : "PNG") + + " file."); + } + } + + public Graphics getGraphics() + { + return graphics; + } + + + void setupPNG(int width, int height) + { + bi = new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + graphics = bi.getGraphics(); + Graphics2D ig2 = (Graphics2D) graphics; + ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + } + + public void writeImage() + { + try{ + switch(type) + { + case EPS: + pg.flush(); + pg.close(); + break; + case PNG: + ImageIO.write(bi, "png", out); + out.close(); + break; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + void setupEPS(int width, int height, String title) + { + boolean accurateText = true; + + String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING", + "Prompt each time"); + + // If we need to prompt, and if the GUI is visible then + // Prompt for EPS rendering style + if (renderStyle.equalsIgnoreCase("Prompt each time") + && ! + (System.getProperty("java.awt.headless") != null + && System.getProperty("java.awt.headless").equals("true"))) + { + EPSOptions eps = new EPSOptions(); + renderStyle = eps.getValue(); + + if (renderStyle == null || eps.cancelled) + return; + } + + if (renderStyle.equalsIgnoreCase("text")) + { + accurateText = false; + } + + try { + pg = new EpsGraphics2D(title, out, 0, 0, width, + height); + Graphics2D ig2 = (Graphics2D) pg; + ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + pg.setAccurateTextMode(accurateText); + + graphics = pg; + } + catch (Exception ex) { } + } + + + JalviewFileChooser getPNGChooser() + { + return new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] + {"png"}, + new String[] + {"Portable network graphics"}, + "Portable network graphics"); + } + + JalviewFileChooser getEPSChooser() + { + return new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] + {"eps"}, + new String[] + {"Encapsulated Postscript"}, + "Encapsulated Postscript"); + } +} diff --git a/src/jalview/ws/JPredClient.java b/src/jalview/ws/JPredClient.java index fdf0cec..4cb8aee 100755 --- a/src/jalview/ws/JPredClient.java +++ b/src/jalview/ws/JPredClient.java @@ -173,7 +173,8 @@ public class JPredClient msf[0].getSequence())); this.msa = new vamsas.objects.simple.Msfalignment(); - msa.setMsf(jalview.io.PileUpfile.print(msf)); + jalview.io.PileUpfile pileup = new jalview.io.PileUpfile(); + msa.setMsf(pileup.print(msf)); } public void run() diff --git a/src/jalview/ws/MsaWSClient.java b/src/jalview/ws/MsaWSClient.java index 6d46e4b..479f22f 100755 --- a/src/jalview/ws/MsaWSClient.java +++ b/src/jalview/ws/MsaWSClient.java @@ -57,7 +57,7 @@ public class MsaWSClient */ public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle, SequenceI[] msa, - boolean submitGaps, boolean preserveOrder) + boolean submitGaps, boolean preserveOrder, Alignment seqdataset) { if (!sh.getAbstractName().equals("MsaWS")) @@ -81,13 +81,13 @@ public class MsaWSClient return; } - startMsaWSClient(altitle, msa, submitGaps, preserveOrder); + startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset); } private void startMsaWSClient(String altitle, SequenceI[] msa, - boolean submitGaps, boolean preserveOrder) + boolean submitGaps, boolean preserveOrder, Alignment seqdataset) { if (!locateWebService()) { @@ -99,7 +99,7 @@ public class MsaWSClient MsaWSThread musclethread = new MsaWSThread(WebServiceName + " alignment of " + altitle, msa, - submitGaps, preserveOrder); + submitGaps, preserveOrder, seqdataset); wsInfo.setthisService(musclethread); musclethread.start(); } @@ -145,20 +145,22 @@ public class MsaWSClient vamsas.objects.simple.SequenceSet seqs = new vamsas.objects.simple. SequenceSet(); Hashtable SeqNames = null; - boolean submitGaps = false; // and always store and recover sequence order + boolean submitGaps = false; // pass sequences including gaps to alignment service boolean preserveOrder = true; // and always store and recover sequence order String jobId; String alTitle; // name which will be used to form new alignment window. int allowedServerExceptions = 3; // thread dies if too many exceptions. boolean jobComplete = false; + Alignment dataset; // dataset to which the new alignment will be associated. + MsaWSThread(String title, SequenceI[] msa, boolean subgaps, - boolean presorder) + boolean presorder, Alignment seqset) { alTitle = title; submitGaps = subgaps; preserveOrder = presorder; - + dataset = seqset; OutputHeader = wsInfo.getProgressText(); SeqNames = new Hashtable(); @@ -467,7 +469,9 @@ public class MsaWSClient jalview.analysis.SeqsetUtils.deuniquify(SeqNames, seqs); Alignment al = new Alignment(seqs); - + if (dataset!=null) { + al.setDataset(dataset); + } // TODO: JBPNote Should also rename the query sequence sometime... AlignFrame af = new AlignFrame(al); af.addSortByOrderMenuItem(ServiceName + " Ordering", -- 1.7.10.2
" + seq.getDisplayId() + - "  
" + seq.getName() + + String id = seq.getDisplayId(av.getShowJVSuffix()); + + out.println("
" + id + "  " + @@ -190,9 +175,7 @@ public class HTMLOutput //////////////////////////////////// /// How many sequences and residues can we fit on a printable page? AlignmentI al = av.getAlignment(); - SequenceGroup[] groups; SequenceI seq; - ColourSchemeI cs = null; String r; String g; String b; @@ -211,54 +194,59 @@ public class HTMLOutput endRes = al.getWidth(); } - out.println("
 " + i + "
|
" + i + - // "
|
  " + i + "
|
" + seq.getDisplayId() + + startPos = seq.findPosition( startRes ); + endPos = seq.findPosition( endRes )-1; + + String id = seq.getDisplayId(av.getShowJVSuffix()); + + out.println("" + id + "  " + seq.getName() + + if(startPos > seq.getEnd() || endPos==0) + out.println(" " + startPos + "  " + seq.getCharAt(res) + "" + +"