From: Paolo Di Tommaso Date: Mon, 9 Apr 2012 19:35:48 +0000 (+0200) Subject: JAL-1065 - Visualize T-Coffee quality scores for an alignment X-Git-Tag: Archived_Release_2_7~4^2^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=34d8b4dc08dcd27c3b5ac3bf7811f709b4db5938;p=jalview.git JAL-1065 - Visualize T-Coffee quality scores for an alignment --- diff --git a/.classpath b/.classpath index d26fa6c..0c39740 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,9 @@ + + @@ -38,8 +40,9 @@ - + + diff --git a/examples/appletParameters.html b/examples/appletParameters.html index 3cc5403..0ce01ef 100644 --- a/examples/appletParameters.html +++ b/examples/appletParameters.html @@ -286,6 +286,6 @@ true Show the jalview button on the page. When false, JalviewLite will open immediately. sortByTree true or false (default is false) automatically sort the associated alignment view by the tree when a new tree is opened. showTreeBootstrapstrue or false (default is true)show or hide branch bootstraps showTreeDistancestrue or false (default is true)show or hide branch lengths showUnlinkedTreeNodestrue or false (default is false)indicate if unassociated nodes should be highlighted in the tree view heightScale 1.0 or greater Adjust the height of each cell in the alignment grid relative to the height of a character in the alignment font. (since 2.5.1) - widthScale 1.0 or greater Adjust the width of each cell in the alignment grid relative to the width of a character in the alignment font. (since 2.5.1) centrecolumnlabels true of false (default is false) When true, text labels associated with a column in the alignment will be shown centered with respect to the column. (since 2.4) showUnconserved true of false (default is false) When true, only gaps and symbols different to the consensus sequence for a column will be shown. Useful for visualizing alignments exhibiting low sequence variation, where it is important to highlight mutations. (since 2.5) upperCase bold or other value Indicate a text style to apply to uppercase sequence symbols. Currently, only bold is supported. automaticScrolling true of false (default is true) When true, alignment panels will automatically scroll to show any regions of the alignment highlighted due to javascript events or when mousing over a position in an associated structure. (since 2.6) showGroupConsensus true of false (default is false) When true, shows consensus annotation row for any groups on the alignment. (since 2.7) showGroupConservation true of false (default is false) When true, shows amino-acid property conservation annotation row for any groups on the alignment. (since 2.7) showConsensusHistogram true of false (default is true) When true, shows the percentage occurence of the consensus symbol for each column as a histogram above the consensus sequence row. (since 2.7) showSequenceLogo true of false (default is false) When true, shows a sequence logo above the consensus sequence (overlaid above the Consensus Histogram, if visible, with symbols coloured using the alignment's default colourscheme). (since 2.7) oninit after_init() name of javascript function that will be called after the jalviewLite instance has completed its initialisation. (since 2.7) relaxedidmatch true or false (default is false) When true, use stem based matching to identify sequences that match features imported from a GFF or Jalview sequence features file, and for associating PDB data (passed on PDBfile parguments) with sequences (based on a given destination sequence ID). (since 2.7) alignpdbfiles true or false (default is false) When true, and jalviewLite is able to use jmol as a structure viewer, attempt to show a superposition of all structures loaded onto the alignment, superimposed using the aligned regions of corresponding sequences. [experimental] (since 2.7) externalstructureviewer true or false (default is false) re-route jmol colouring commands, selection and mouseover events to an external viewer using javascript callbacks. [experimental] (since 2.7) annotationcolour_max colour name or RGB hex triplet (default is red) Default colour used for maximum value when shading by annotation. (since 2.7) annotationcolour_min colour name or RGB hex triplet (default is orange) Default colour used for minimum value when shading by annotation. (since 2.7) jalviewhelpurl absolute or relative url or javascript function prefixed by javascript: (default is http://www.jalview.org/help.html) Optional parameter allowing modification of the default Jalview Help URL normally opened when JalviewLite's 'Help' menu item is selected. (since 2.7) resolvetocodebase True or False (False) Set to true to re-instate pre-JalviewLite 2.7 behaviour where relative URLs were prepended with the applet 'codebase' rather than the current document base URL before resolution. (since 2.7) + widthScale 1.0 or greater Adjust the width of each cell in the alignment grid relative to the width of a character in the alignment font. (since 2.5.1) centrecolumnlabels true of false (default is false) When true, text labels associated with a column in the alignment will be shown centered with respect to the column. (since 2.4) showUnconserved true of false (default is false) When true, only gaps and symbols different to the consensus sequence for a column will be shown. Useful for visualizing alignments exhibiting low sequence variation, where it is important to highlight mutations. (since 2.5) upperCase bold or other value Indicate a text style to apply to uppercase sequence symbols. Currently, only bold is supported. automaticScrolling true of false (default is true) When true, alignment panels will automatically scroll to show any regions of the alignment highlighted due to javascript events or when mousing over a position in an associated structure. (since 2.6) showGroupConsensus true of false (default is false) When true, shows consensus annotation row for any groups on the alignment. (since 2.7) showGroupConservation true of false (default is false) When true, shows amino-acid property conservation annotation row for any groups on the alignment. (since 2.7) showConsensusHistogram true of false (default is true) When true, shows the percentage occurence of the consensus symbol for each column as a histogram above the consensus sequence row. (since 2.7) showSequenceLogo true of false (default is false) When true, shows a sequence logo above the consensus sequence (overlaid above the Consensus Histogram, if visible, with symbols coloured using the alignment's default colourscheme). (since 2.7) oninit after_init() name of javascript function that will be called after the jalviewLite instance has completed its initialisation. (since 2.7) relaxedidmatch true or false (default is false) When true, use stem based matching to identify sequences that match features imported from a GFF or Jalview sequence features file, and for associating PDB data (passed on PDBfile parguments) with sequences (based on a given destination sequence ID). (since 2.7) alignpdbfiles true or false (default is false) When true, and jalviewLite is able to use jmol as a structure viewer, attempt to show a superposition of all structures loaded onto the alignment, superimposed using the aligned regions of corresponding sequences. [experimental] (since 2.7) externalstructureviewer true or false (default is false) re-route jmol colouring commands, selection and mouseover events to an external viewer using javascript callbacks. [experimental] (since 2.7) annotationcolour_max colour name or RGB hex triplet (default is red) Default colour used for maximum value when shading by annotation. (since 2.7) annotationcolour_min colour name or RGB hex triplet (default is orange) Default colour used for minimum value when shading by annotation. (since 2.7) jalviewhelpurl absolute or relative url or javascript function prefixed by javascript: (default is http://www.jalview.org/help.html) Optional parameter allowing modification of the default Jalview Help URL normally opened when JalviewLite's 'Help' menu item is selected. (since 2.7) resolvetocodebase True or False (False) Set to true to re-instate pre-JalviewLite 2.7 behaviour where relative URLs were prepended with the applet 'codebase' rather than the current document base URL before resolution. (since 2.7) scoreFile file Multiple sequences aligment scores file. Currently is supported only the T-Coffee score_ascii file format

 

\ No newline at end of file diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 5790bc3..c1dbf30 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -17,23 +17,78 @@ */ package jalview.appletgui; -import java.net.*; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import jalview.analysis.*; +import jalview.analysis.AAFrequency; +import jalview.analysis.AlignmentSorter; +import jalview.analysis.Conservation; import jalview.api.SequenceStructureBinding; import jalview.bin.JalviewLite; -import jalview.commands.*; -import jalview.datamodel.*; -import jalview.io.*; -import jalview.schemes.*; +import jalview.commands.CommandI; +import jalview.commands.EditCommand; +import jalview.commands.OrderCommand; +import jalview.commands.RemoveGapColCommand; +import jalview.commands.RemoveGapsCommand; +import jalview.commands.SlideSequencesCommand; +import jalview.commands.TrimRegionCommand; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.AlignmentOrder; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.io.AnnotationFile; +import jalview.io.AppletFormatAdapter; +import jalview.io.FeaturesFile; +import jalview.io.TCoffeeScoreFile; +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ClustalxColourScheme; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.ResidueProperties; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TCoffeeColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; import jalview.structure.StructureSelectionManager; -public class AlignFrame extends EmbmenuFrame implements ActionListener, - ItemListener, KeyListener +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.CheckboxMenuItem; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLEncoder; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.StringTokenizer; +import java.util.Vector; + +public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemListener, KeyListener { public AlignmentPanel alignPanel; @@ -44,11 +99,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, int DEFAULT_HEIGHT = 500; String jalviewServletURL; + + TCoffeeScoreFile tcoffeeScoreFile; - public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, - String title, boolean embedded) + public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, String title, boolean embedded) { - if (applet != null) { jalviewServletURL = applet.getParameter("APPLICATION_URL"); @@ -684,6 +739,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { loadAnnotations(); } + else if( source == loadScores ) { + loadScores(); + } else if (source == outputAnnotations) { outputAnnotations(true); @@ -939,6 +997,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { changeColour(new Blosum62ColourScheme()); } + else if (source == tcoffeeColour) { + changeColour(new TCoffeeColourScheme(tcoffeeScoreFile)); + } else if (source == annotationColour) { new AnnotationColourChooser(viewport, alignPanel); @@ -1028,6 +1089,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300); } + + public void loadScores() { + //TODO + + } public String outputAnnotations(boolean displayTextbox) { @@ -2244,7 +2310,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, cs.setConsensus(viewport.hconsensus); - } + } viewport.setGlobalColourScheme(cs); if (viewport.getColourAppliesToAllGroups()) @@ -2694,6 +2760,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MenuItem loadTree = new MenuItem("Load Associated Tree ..."); MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ..."); + + MenuItem loadScores = new MenuItem("Load Associated T-Coffee scores ..."); MenuItem outputFeatures = new MenuItem("Export Features ..."); @@ -2772,6 +2840,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, MenuItem PIDColour = new MenuItem(); MenuItem BLOSUM62Colour = new MenuItem(); + + MenuItem tcoffeeColour = new MenuItem(); MenuItem njTreeBlosumMenuItem = new MenuItem(); @@ -2896,6 +2966,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, loadTree.addActionListener(this); loadAnnotations.addActionListener(this); + loadScores.addActionListener(this); outputFeatures.addActionListener(this); outputAnnotations.addActionListener(this); selectAllSequenceMenuItem.addActionListener(this); @@ -2961,8 +3032,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, PIDColour.addActionListener(this); BLOSUM62Colour.setLabel("BLOSUM62 Score"); BLOSUM62Colour.addActionListener(this); - avDistanceTreeBlosumMenuItem - .setLabel("Average Distance Using BLOSUM62"); + tcoffeeColour.setLabel("T-Coffee Scores"); + tcoffeeColour.setEnabled(false); // it will enabled only if a score file is provided + tcoffeeColour.addActionListener(this); + avDistanceTreeBlosumMenuItem .setLabel("Average Distance Using BLOSUM62"); avDistanceTreeBlosumMenuItem.addActionListener(this); njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62"); njTreeBlosumMenuItem.addActionListener(this); @@ -3107,7 +3180,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, fileMenu.add(inputText); fileMenu.add(loadTree); fileMenu.add(loadAnnotations); - + fileMenu.add(loadScores); + fileMenu.addSeparator(); fileMenu.add(outputTextboxMenu); fileMenu.add(outputFeatures); @@ -3168,6 +3242,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, colourMenu.add(turnColour); colourMenu.add(buriedColour); colourMenu.add(nucleotideColour); + colourMenu.add(tcoffeeColour); colourMenu.add(userDefinedColour); colourMenu.addSeparator(); colourMenu.add(conservationMenuItem); @@ -3595,4 +3670,27 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public String getSequenceSetId() { return viewport.getSequenceSetId(); } + + + /** + * Load the (T-Coffee) score file from the specified url + * + * @param url The absolute path from where download and read the score file + * @throws IOException + */ + public void loadScoreFile( URL url ) throws IOException { + + TCoffeeScoreFile file = TCoffeeScoreFile.load( new InputStreamReader( url.openStream() ) ); + if( file == null ) { + throw new RuntimeException("The file provided does not match the T-Coffee scores file format"); + } + + tcoffeeColour.setEnabled(true); + tcoffeeScoreFile = file; + + // switch to this color + changeColour(new TCoffeeColourScheme(tcoffeeScoreFile)); + } + + } diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index 857472b..32ff59a 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -17,10 +17,15 @@ */ package jalview.appletgui; -import java.awt.*; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.schemes.ColourSchemeI; -import jalview.datamodel.*; -import jalview.schemes.*; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; public class SequenceRenderer implements jalview.api.SequenceRenderer { @@ -82,7 +87,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer { if (cs != null) { - resBoxColour = cs.findColour(seq.getCharAt(i), i); + resBoxColour = cs.findColour(seq.getCharAt(i), i, seq.getIndex()); } else if (forOverview && !jalview.util.Comparison.isGap(seq.getCharAt(i))) diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 7220321..4ebe3b7 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -17,13 +17,31 @@ */ package jalview.appletgui; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; -import jalview.schemes.*; +import jalview.datamodel.SequenceGroup; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.GraduatedColor; +import jalview.schemes.ResidueProperties; +import jalview.schemes.UserColourScheme; + +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dialog; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.Scrollbar; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.MouseEvent; +import java.util.Vector; public class UserDefinedColours extends Panel implements ActionListener, AdjustmentListener @@ -379,7 +397,7 @@ public class UserDefinedColours extends Panel implements ActionListener, { try { - col = oldColourScheme.findColour(aa.charAt(0), -1); + col = oldColourScheme.findColour(aa.charAt(0), -1, -1); } catch (Exception ex) { } diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 0cba50e..5785ed1 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -1821,8 +1821,7 @@ public class JalviewLite extends Applet implements if (protocol == jalview.io.AppletFormatAdapter.PASTE) { - newAlignFrame.setTitle("Sequences from " - + applet.getDocumentBase()); + newAlignFrame.setTitle("Sequences from " + applet.getDocumentBase()); } newAlignFrame.statusBar.setText("Successfully loaded file " + file); @@ -1863,6 +1862,25 @@ public class JalviewLite extends Applet implements } } + + /* + * Try to load T-Coffee score file + */ + String sScoreFile = applet.getParameter("scoreFile"); + if( sScoreFile != null && !"".equals(sScoreFile) ) { + try { + URL urlScore = new URL(sScoreFile); + newAlignFrame.loadScoreFile(urlScore); + //TODO check the scores matrix matches the MSA dimensions + + } + catch( Exception e ) { + // TODO error message log (shows a warning dialogbox?) + System.err.printf("Cannot read score file: '%s'. Cause: %s \n", sScoreFile, e.getMessage()); + } + } + + // /////////////////////////// // modify display of features // we do this before any features have been loaded, ensuring any hidden groups are hidden when features first displayed diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 52d9a72..cc541be 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -17,9 +17,10 @@ */ package jalview.datamodel; -import java.util.*; +import jalview.analysis.AlignSeq; -import jalview.analysis.*; +import java.util.Enumeration; +import java.util.Vector; /** * @@ -53,6 +54,11 @@ public class Sequence implements SequenceI * to the residues of this sequence */ Vector annotation; + + /** + * The index of the sequence in a MSA + */ + int index = -1; /** array of seuqence features - may not be null for a valid sequence object */ public SequenceFeature[] sequenceFeatures; @@ -1172,4 +1178,17 @@ public class Sequence implements SequenceI } } + /** + * @return The index (zero-based) on this sequence in the MSA. + * It returns {@code -1} if this information is not available. + */ + public int getIndex() { return index; } + + /** + * Defines the position of this sequence in the MSA. + * Use the value {@code -1} if this information is undefined. + * + * @param The position for this sequence. This value is zero-based (zero for this first sequence) + */ + public void setIndex(int value) { index = value; } } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index d1e3853..87c964f 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -17,7 +17,7 @@ */ package jalview.datamodel; -import java.util.*; +import java.util.Vector; /** * DOCUMENT ME! @@ -348,5 +348,15 @@ public interface SequenceI * null or mapping from entry's numbering to local start/end */ public void transferAnnotation(SequenceI entry, Mapping mp); + + /** + * @param index The sequence index in the MSA + */ + public void setIndex(int index); + + /** + * @return The index of the sequence in the alignment + */ + public int getIndex(); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 2ecd947..b3e34fb 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -55,6 +55,7 @@ import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; import jalview.io.JnetAnnotationMaker; import jalview.io.NewickFile; +import jalview.io.TCoffeeScoreFile; import jalview.jbgui.GAlignFrame; import jalview.schemes.Blosum62ColourScheme; import jalview.schemes.BuriedColourScheme; @@ -67,11 +68,11 @@ import jalview.schemes.NucleotideColourScheme; import jalview.schemes.PIDColourScheme; import jalview.schemes.ResidueProperties; import jalview.schemes.StrandColourScheme; +import jalview.schemes.TCoffeeColourScheme; import jalview.schemes.TaylorColourScheme; import jalview.schemes.TurnColourScheme; import jalview.schemes.UserColourScheme; import jalview.schemes.ZappoColourScheme; -import jalview.ws.WSMenuEntryProviderI; import jalview.ws.jws1.Discoverer; import jalview.ws.jws2.Jws2Discoverer; @@ -141,6 +142,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignViewport viewport; Vector alignPanels = new Vector(); + + TCoffeeScoreFile tcoffeeScoreFile; /** * Last format used to load or save alignments in this window @@ -3859,7 +3862,70 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } } - + + @Override + public void loadScores_actionPerformed(ActionEvent e) + { + // Pick the tree file + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Select a T-Coffee scores ascii file"); + chooser.setToolTipText("Load a score file"); + + int value = chooser.showOpenDialog(null); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String sFilePath = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", sFilePath); + + + try + { + TCoffeeScoreFile result = TCoffeeScoreFile.load(new File(sFilePath)); + if( result == null ) { throw new RuntimeException("The file provided does not match the T-Coffee scores file format"); } + + // TODO check that the loaded scores matches the current MSA 'dimension' + changeColour( new TCoffeeColourScheme(result) ); + tcoffeeScoreFile = result; + tcoffeeColour.setEnabled(true); + tcoffeeColour.setSelected(true); + + } + catch (Exception ex) { + JOptionPane.showMessageDialog( + Desktop.desktop, + ex.getMessage(), + "Problem reading tree file", + JOptionPane.WARNING_MESSAGE); + + ex.printStackTrace(); + } + } + + } + + + @Override + protected void tcoffeeColorScheme_actionPerformed(ActionEvent e) { + if( tcoffeeScoreFile != null ) { + changeColour( new TCoffeeColourScheme(tcoffeeScoreFile) ); + } + } + +// /** +// * Load the (T-Coffee) score file from the specified url +// * +// * @param url The absolute path from where download and read the score file +// * @throws IOException +// */ +// public void loadScoreFile(URL url ) throws IOException { +// +// TCoffeeScoreFile result = new TCoffeeScoreFile(); +// result.parse( new InputStreamReader( url.openStream() ) ); +// tcoffeeScoreFile = result; +// } + public TreePanel ShowNewickTree(NewickFile nf, String title) { return ShowNewickTree(nf, title, 600, 500, 4, 5); diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index b3dfc97..15f1928 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -17,10 +17,14 @@ */ package jalview.gui; -import java.awt.*; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.schemes.ColourSchemeI; -import jalview.datamodel.*; -import jalview.schemes.*; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; /** * DOCUMENT ME! @@ -111,7 +115,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer { if (cs != null) { - resBoxColour = cs.findColour(seq.getCharAt(i), i); + resBoxColour = cs.findColour(seq.getCharAt(i), i, seq.getIndex()); } else if (forOverview && !jalview.util.Comparison.isGap(seq.getCharAt(i))) diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 792ef7d..8566e82 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -17,18 +17,32 @@ */ package jalview.gui; -import java.io.*; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; - -import jalview.datamodel.*; -import jalview.io.*; -import jalview.jbgui.*; -import jalview.schemes.*; +import jalview.datamodel.SequenceGroup; +import jalview.io.JalviewFileChooser; +import jalview.jbgui.GUserDefinedColours; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ResidueProperties; +import jalview.schemes.UserColourScheme; + +import java.awt.Color; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.StringTokenizer; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; /** * DOCUMENT ME! @@ -372,7 +386,7 @@ public class UserDefinedColours extends GUserDefinedColours implements { try { - col = oldColourScheme.findColour(aa.charAt(0), -1); + col = oldColourScheme.findColour(aa.charAt(0), -1, -1); } catch (Exception ex) { } diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index ad834be..be79ab5 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -17,10 +17,15 @@ */ package jalview.io; -import java.io.*; -import java.util.*; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceI; -import jalview.datamodel.*; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; /** * DOCUMENT ME! @@ -37,7 +42,7 @@ public abstract class AlignFile extends FileParse /** * Sequences to be added to form a new alignment. */ - protected Vector seqs; + protected Vector seqs; /** * annotation to be added to generated alignment object @@ -73,10 +78,12 @@ public abstract class AlignFile extends FileParse public AlignFile(String inFile, String type) throws IOException { super(inFile, type); - initData(); - parse(); + // sets the index of each sequence in the alignment + for( int i=0,c=seqs.size(); i getSeqs() { return seqs; } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 6253e36..c7249de 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -17,13 +17,35 @@ */ package jalview.jbgui; -import java.awt.*; -import java.awt.event.*; - -import javax.swing.*; -import javax.swing.event.*; - -import jalview.schemes.*; +import jalview.schemes.ColourSchemeProperty; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; public class GAlignFrame extends JInternalFrame { @@ -113,6 +135,9 @@ public class GAlignFrame extends JInternalFrame protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem tcoffeeColour = new JRadioButtonMenuItem(); + + JMenuItem njTreeBlosumMenuItem = new JMenuItem(); JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(); @@ -176,6 +201,8 @@ public class GAlignFrame extends JInternalFrame JMenuItem epsFile = new JMenuItem(); JMenuItem LoadtreeMenuItem = new JMenuItem(); + + JMenuItem loadScoresMenuItem = new JMenuItem(); public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); @@ -417,6 +444,7 @@ public class GAlignFrame extends JInternalFrame colours.add(PIDColour); colours.add(BLOSUM62Colour); colours.add(nucleotideColour); + colours.add(tcoffeeColour); setColourSelected(jalview.bin.Cache .getDefault("DEFAULT_COLOUR", "None")); @@ -486,6 +514,10 @@ public class GAlignFrame extends JInternalFrame nucleotideColour.setSelected(true); break; + + case ColourSchemeProperty.TCOFFEE: + tcoffeeColour.setSelected(true); + break; case ColourSchemeProperty.USER_DEFINED: userDefinedColour.setSelected(true); @@ -1090,6 +1122,18 @@ public class GAlignFrame extends JInternalFrame nucleotideColour_actionPerformed(e); } }); + + tcoffeeColour.setText("T-Coffee scores"); + tcoffeeColour.setEnabled(false); + tcoffeeColour.addActionListener( new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + tcoffeeColorScheme_actionPerformed(e); + } + } ); + + deleteGroups.setText("Undefine groups"); deleteGroups.setAccelerator(javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_U, Toolkit.getDefaultToolkit() @@ -1202,7 +1246,7 @@ public class GAlignFrame extends JInternalFrame } }); LoadtreeMenuItem.setActionCommand("Load a tree for this sequence set"); - LoadtreeMenuItem.setText("Load Associated Tree"); + LoadtreeMenuItem.setText("Load Associated Tree"); LoadtreeMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -1210,6 +1254,17 @@ public class GAlignFrame extends JInternalFrame LoadtreeMenuItem_actionPerformed(e); } }); + + loadScoresMenuItem.setActionCommand("Load T-Coffee scores"); + loadScoresMenuItem.setText("Load T-Coffee scores"); + loadScoresMenuItem.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + loadScores_actionPerformed(e); + } + }); + scaleAbove.setVisible(false); scaleAbove.setText("Scale Above"); scaleAbove.addActionListener(new java.awt.event.ActionListener() @@ -1696,6 +1751,7 @@ public class GAlignFrame extends JInternalFrame fileMenu.add(exportAnnotations); fileMenu.add(LoadtreeMenuItem); fileMenu.add(associatedData); + fileMenu.add(loadScoresMenuItem); fileMenu.addSeparator(); fileMenu.add(closeMenuItem); editMenu.add(undoMenuItem); @@ -1760,6 +1816,7 @@ public class GAlignFrame extends JInternalFrame colourMenu.add(turnColour); colourMenu.add(buriedColour); colourMenu.add(nucleotideColour); + colourMenu.add(tcoffeeColour); colourMenu.add(userDefinedColour); colourMenu.addSeparator(); colourMenu.add(conservationMenuItem); @@ -2224,7 +2281,32 @@ public class GAlignFrame extends JInternalFrame protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { + + } + + /** + * Template method to handle the 'load T-Coffee scores' menu event. + *

+ * Subclasses override this method to provide a custom action. + * + * @param event The raised event + */ + protected void loadScores_actionPerformed(ActionEvent event) { + + } + + + /** + * Template method to handle the 'Color T-Coffee scores' menu event. + *

+ * Subclasses override this method to provide a custom action. + * + * @param event The raised event + */ + protected void tcoffeeColorScheme_actionPerformed(ActionEvent event) { + } + protected void jpred_actionPerformed(ActionEvent e) {