<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/lib/plugin.jar"/>
<classpathentry kind="lib" path="lib/activation.jar"/>
<classpathentry kind="lib" path="lib/axis.jar" sourcepath="D:/axis-1_2RC2-src/axis-1_2RC2"/>
<classpathentry kind="lib" path="lib/commons-discovery.jar"/>
<classpathentry kind="lib" path="lib/Jmol-12.2.4.jar"/>
<classpathentry kind="lib" path="appletlib/JmolApplet-12.2.4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin.jar"/>
+ <classpathentry kind="lib" path="appletlib/JmolApplet-12.2.4.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="classes"/>
</classpath>
<td>true</td>
<td>Show the jalview button on the page. When false, JalviewLite will open immediately.</td>
</tr>\r </tr>\r <tr><td>sortByTree</td>\r <td>true or false (default is false)</td>\r <td>automatically sort the associated alignment view by the tree when a new tree is opened.</td>\r </tr>\r <tr>\r <td>showTreeBootstraps</td><td>true or false (default is true)</td><td>show or hide branch bootstraps</td>\r </tr>\r <tr><td>showTreeDistances</td><td>true or false (default is true)</td><td>show or hide branch lengths</td></tr>\r <tr><td>showUnlinkedTreeNodes</td><td>true or false (default is false)</td><td>indicate if unassociated nodes should be highlighted in the tree view</td>\r </tr>\r <tr><td>heightScale</td>\r <td>1.0 or greater</td>\r <td>Adjust the height of each cell in the alignment grid relative to the height of a character in the alignment font. (<em>since 2.5.1</em>)</td>\r </tr>
- <tr><td>widthScale</td>\r <td>1.0 or greater</td>\r <td>Adjust the width of each cell in the alignment grid relative to the width of a character in the alignment font. (<em>since 2.5.1</em>)</td>\r </tr>\r <tr><td>centrecolumnlabels</td>\r <td>true of false (default is false)</td>\r <td>When true, text labels associated with a column in the alignment will be shown centered with respect to the column. (<em>since 2.4</em>)</td>\r <tr><td>showUnconserved</td>\r <td>true of false (default is false)</td>\r <td>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. (<em>since 2.5</em>)</td>\r </tr>\r <tr><td>upperCase</td>\r <td><em>bold</em> or other value</td>\r <td>Indicate a text style to apply to uppercase sequence symbols. Currently, only <strong>bold</strong> is supported.</td>\r </tr>\r <tr><td>automaticScrolling</td>\r <td>true of false (default is true)</td>\r <td>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. (<em>since 2.6</em>)</td>\r </tr>\r \r <tr><td>showGroupConsensus</td>\r <td>true of false (default is false)</td>\r <td>When true, shows consensus annotation row for any groups on the alignment. (<em>since 2.7</em>)</td>\r </tr>\r \r <tr><td>showGroupConservation</td>\r <td>true of false (default is false)</td>\r <td>When true, shows amino-acid property conservation annotation row for any groups on the alignment. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>showConsensusHistogram</td>\r <td>true of false (default is true)</td>\r <td>When true, shows the percentage occurence of the consensus symbol for each column as a histogram above the consensus sequence row. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>showSequenceLogo</td>\r <td>true of false (default is false)</td>\r <td>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). (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>oninit</td>\r <td><em>after_init()</em></td>\r <td>name of javascript function that will be called after the jalviewLite instance has completed its initialisation. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>relaxedidmatch</td>\r <td><em>true or false (default is false)</em></td>\r <td>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). (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>alignpdbfiles</td>\r <td><em>true or false (default is false)</em></td>\r <td>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] (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>externalstructureviewer</td>\r <td><em>true or false (default is false)</em></td>\r <td>re-route jmol colouring commands, selection and mouseover events to an external viewer using javascript callbacks. [experimental] (<em>since 2.7</em>)</td>\r \r </tr>\r <tr><td>annotationcolour_max</td>\r <td>colour name or RGB hex triplet (default is red)</td>\r <td>Default colour used for maximum value when shading by annotation. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>annotationcolour_min</td>\r <td>colour name or RGB hex triplet (default is orange)</td>\r <td>Default colour used for minimum value when shading by annotation. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>jalviewhelpurl</td>\r <td>absolute or relative url or javascript function prefixed by <em>javascript:</em> (default is http://www.jalview.org/help.html)</td>\r <td>Optional parameter allowing modification of the default Jalview Help URL normally opened when JalviewLite's 'Help' menu item is selected. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>resolvetocodebase</td>\r <td>True or False (False)</td>\r <td>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. (<em>since 2.7</em>)</td>\r </tr>\r \r </table>
+ <tr><td>widthScale</td>\r <td>1.0 or greater</td>\r <td>Adjust the width of each cell in the alignment grid relative to the width of a character in the alignment font. (<em>since 2.5.1</em>)</td>\r </tr>\r <tr><td>centrecolumnlabels</td>\r <td>true of false (default is false)</td>\r <td>When true, text labels associated with a column in the alignment will be shown centered with respect to the column. (<em>since 2.4</em>)</td>\r <tr><td>showUnconserved</td>\r <td>true of false (default is false)</td>\r <td>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. (<em>since 2.5</em>)</td>\r </tr>\r <tr><td>upperCase</td>\r <td><em>bold</em> or other value</td>\r <td>Indicate a text style to apply to uppercase sequence symbols. Currently, only <strong>bold</strong> is supported.</td>\r </tr>\r <tr><td>automaticScrolling</td>\r <td>true of false (default is true)</td>\r <td>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. (<em>since 2.6</em>)</td>\r </tr>\r \r <tr><td>showGroupConsensus</td>\r <td>true of false (default is false)</td>\r <td>When true, shows consensus annotation row for any groups on the alignment. (<em>since 2.7</em>)</td>\r </tr>\r \r <tr><td>showGroupConservation</td>\r <td>true of false (default is false)</td>\r <td>When true, shows amino-acid property conservation annotation row for any groups on the alignment. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>showConsensusHistogram</td>\r <td>true of false (default is true)</td>\r <td>When true, shows the percentage occurence of the consensus symbol for each column as a histogram above the consensus sequence row. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>showSequenceLogo</td>\r <td>true of false (default is false)</td>\r <td>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). (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>oninit</td>\r <td><em>after_init()</em></td>\r <td>name of javascript function that will be called after the jalviewLite instance has completed its initialisation. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>relaxedidmatch</td>\r <td><em>true or false (default is false)</em></td>\r <td>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). (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>alignpdbfiles</td>\r <td><em>true or false (default is false)</em></td>\r <td>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] (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>externalstructureviewer</td>\r <td><em>true or false (default is false)</em></td>\r <td>re-route jmol colouring commands, selection and mouseover events to an external viewer using javascript callbacks. [experimental] (<em>since 2.7</em>)</td>\r \r </tr>\r <tr><td>annotationcolour_max</td>\r <td>colour name or RGB hex triplet (default is red)</td>\r <td>Default colour used for maximum value when shading by annotation. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>annotationcolour_min</td>\r <td>colour name or RGB hex triplet (default is orange)</td>\r <td>Default colour used for minimum value when shading by annotation. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>jalviewhelpurl</td>\r <td>absolute or relative url or javascript function prefixed by <em>javascript:</em> (default is http://www.jalview.org/help.html)</td>\r <td>Optional parameter allowing modification of the default Jalview Help URL normally opened when JalviewLite's 'Help' menu item is selected. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>resolvetocodebase</td>\r <td>True or False (False)</td>\r <td>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. (<em>since 2.7</em>)</td>\r </tr>\r <tr><td>scoreFile</td>\r <td>file</td>\r <td>Multiple sequences aligment scores file. Currently is supported only the T-Coffee score_ascii file format</td>\r </tr>\r\r \r </table>
<p align="center"> </p>
<!-- InstanceEndEditable --></td>\r </tr>\r </table>\r</div>\r</body>\r<!-- InstanceEnd --></html>\r
\ No newline at end of file
*/\r
package jalview.appletgui;\r
\r
-import java.net.*;\r
-import java.util.*;\r
-\r
-import java.awt.*;\r
-import java.awt.event.*;\r
-\r
-import jalview.analysis.*;\r
+import jalview.analysis.AAFrequency;\r
+import jalview.analysis.AlignmentSorter;\r
+import jalview.analysis.Conservation;\r
import jalview.api.SequenceStructureBinding;\r
import jalview.bin.JalviewLite;\r
-import jalview.commands.*;\r
-import jalview.datamodel.*;\r
-import jalview.io.*;\r
-import jalview.schemes.*;\r
+import jalview.commands.CommandI;\r
+import jalview.commands.EditCommand;\r
+import jalview.commands.OrderCommand;\r
+import jalview.commands.RemoveGapColCommand;\r
+import jalview.commands.RemoveGapsCommand;\r
+import jalview.commands.SlideSequencesCommand;\r
+import jalview.commands.TrimRegionCommand;\r
+import jalview.datamodel.Alignment;\r
+import jalview.datamodel.AlignmentI;\r
+import jalview.datamodel.AlignmentOrder;\r
+import jalview.datamodel.ColumnSelection;\r
+import jalview.datamodel.PDBEntry;\r
+import jalview.datamodel.Sequence;\r
+import jalview.datamodel.SequenceGroup;\r
+import jalview.datamodel.SequenceI;\r
+import jalview.io.AnnotationFile;\r
+import jalview.io.AppletFormatAdapter;\r
+import jalview.io.FeaturesFile;\r
+import jalview.io.TCoffeeScoreFile;\r
+import jalview.schemes.Blosum62ColourScheme;\r
+import jalview.schemes.BuriedColourScheme;\r
+import jalview.schemes.ClustalxColourScheme;\r
+import jalview.schemes.ColourSchemeI;\r
+import jalview.schemes.HelixColourScheme;\r
+import jalview.schemes.HydrophobicColourScheme;\r
+import jalview.schemes.NucleotideColourScheme;\r
+import jalview.schemes.PIDColourScheme;\r
+import jalview.schemes.ResidueProperties;\r
+import jalview.schemes.StrandColourScheme;\r
+import jalview.schemes.TCoffeeColourScheme;\r
+import jalview.schemes.TaylorColourScheme;\r
+import jalview.schemes.TurnColourScheme;\r
+import jalview.schemes.ZappoColourScheme;\r
import jalview.structure.StructureSelectionManager;\r
\r
-public class AlignFrame extends EmbmenuFrame implements ActionListener,\r
- ItemListener, KeyListener\r
+import java.awt.BorderLayout;\r
+import java.awt.Canvas;\r
+import java.awt.CheckboxMenuItem;\r
+import java.awt.Color;\r
+import java.awt.Font;\r
+import java.awt.FontMetrics;\r
+import java.awt.Frame;\r
+import java.awt.Graphics;\r
+import java.awt.Label;\r
+import java.awt.Menu;\r
+import java.awt.MenuBar;\r
+import java.awt.MenuItem;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.awt.event.FocusEvent;\r
+import java.awt.event.FocusListener;\r
+import java.awt.event.ItemEvent;\r
+import java.awt.event.ItemListener;\r
+import java.awt.event.KeyEvent;\r
+import java.awt.event.KeyListener;\r
+import java.awt.event.WindowAdapter;\r
+import java.awt.event.WindowEvent;\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+import java.net.URL;\r
+import java.net.URLEncoder;\r
+import java.util.Enumeration;\r
+import java.util.Hashtable;\r
+import java.util.StringTokenizer;\r
+import java.util.Vector;\r
+\r
+public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemListener, KeyListener\r
{\r
public AlignmentPanel alignPanel;\r
\r
int DEFAULT_HEIGHT = 500;\r
\r
String jalviewServletURL;\r
+ \r
+ TCoffeeScoreFile tcoffeeScoreFile;\r
\r
- public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet,\r
- String title, boolean embedded)\r
+ public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, String title, boolean embedded)\r
{\r
-\r
if (applet != null)\r
{\r
jalviewServletURL = applet.getParameter("APPLICATION_URL");\r
{\r
loadAnnotations();\r
}\r
+ else if( source == loadScores ) {\r
+ loadScores();\r
+ }\r
else if (source == outputAnnotations)\r
{\r
outputAnnotations(true);\r
{\r
changeColour(new Blosum62ColourScheme());\r
}\r
+ else if (source == tcoffeeColour) {\r
+ changeColour(new TCoffeeColourScheme(tcoffeeScoreFile));\r
+ }\r
else if (source == annotationColour)\r
{\r
new AnnotationColourChooser(viewport, alignPanel);\r
jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300);\r
\r
}\r
+ \r
+ public void loadScores() {\r
+ //TODO\r
+ \r
+ }\r
\r
public String outputAnnotations(boolean displayTextbox)\r
{\r
\r
cs.setConsensus(viewport.hconsensus);\r
\r
- }\r
+ } \r
viewport.setGlobalColourScheme(cs);\r
\r
if (viewport.getColourAppliesToAllGroups())\r
MenuItem loadTree = new MenuItem("Load Associated Tree ...");\r
\r
MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ...");\r
+ \r
+ MenuItem loadScores = new MenuItem("Load Associated T-Coffee scores ...");\r
\r
MenuItem outputFeatures = new MenuItem("Export Features ...");\r
\r
MenuItem PIDColour = new MenuItem();\r
\r
MenuItem BLOSUM62Colour = new MenuItem();\r
+ \r
+ MenuItem tcoffeeColour = new MenuItem();\r
\r
MenuItem njTreeBlosumMenuItem = new MenuItem();\r
\r
\r
loadTree.addActionListener(this);\r
loadAnnotations.addActionListener(this);\r
+ loadScores.addActionListener(this);\r
outputFeatures.addActionListener(this);\r
outputAnnotations.addActionListener(this);\r
selectAllSequenceMenuItem.addActionListener(this);\r
PIDColour.addActionListener(this);\r
BLOSUM62Colour.setLabel("BLOSUM62 Score");\r
BLOSUM62Colour.addActionListener(this);\r
- avDistanceTreeBlosumMenuItem\r
- .setLabel("Average Distance Using BLOSUM62");\r
+ tcoffeeColour.setLabel("T-Coffee Scores");\r
+ tcoffeeColour.setEnabled(false); // it will enabled only if a score file is provided\r
+ tcoffeeColour.addActionListener(this);\r
+ avDistanceTreeBlosumMenuItem .setLabel("Average Distance Using BLOSUM62");\r
avDistanceTreeBlosumMenuItem.addActionListener(this);\r
njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");\r
njTreeBlosumMenuItem.addActionListener(this);\r
fileMenu.add(inputText);\r
fileMenu.add(loadTree);\r
fileMenu.add(loadAnnotations);\r
-\r
+ fileMenu.add(loadScores);\r
+ \r
fileMenu.addSeparator();\r
fileMenu.add(outputTextboxMenu);\r
fileMenu.add(outputFeatures);\r
colourMenu.add(turnColour);\r
colourMenu.add(buriedColour);\r
colourMenu.add(nucleotideColour);\r
+ colourMenu.add(tcoffeeColour);\r
colourMenu.add(userDefinedColour);\r
colourMenu.addSeparator();\r
colourMenu.add(conservationMenuItem);\r
public String getSequenceSetId() {\r
return viewport.getSequenceSetId();\r
}\r
+ \r
+ \r
+ /**\r
+ * Load the (T-Coffee) score file from the specified url \r
+ * \r
+ * @param url The absolute path from where download and read the score file\r
+ * @throws IOException \r
+ */\r
+ public void loadScoreFile( URL url ) throws IOException {\r
+ \r
+ TCoffeeScoreFile file = TCoffeeScoreFile.load( new InputStreamReader( url.openStream() ) );\r
+ if( file == null ) {\r
+ throw new RuntimeException("The file provided does not match the T-Coffee scores file format");\r
+ }\r
+ \r
+ tcoffeeColour.setEnabled(true);\r
+ tcoffeeScoreFile = file;\r
+ \r
+ // switch to this color\r
+ changeColour(new TCoffeeColourScheme(tcoffeeScoreFile));\r
+ }\r
+ \r
+ \r
}\r
*/
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
{
{
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)))
*/
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
{
try
{
- col = oldColourScheme.findColour(aa.charAt(0), -1);
+ col = oldColourScheme.findColour(aa.charAt(0), -1, -1);
} catch (Exception ex)
{
}
\r
if (protocol == jalview.io.AppletFormatAdapter.PASTE)\r
{\r
- newAlignFrame.setTitle("Sequences from "\r
- + applet.getDocumentBase());\r
+ newAlignFrame.setTitle("Sequences from " + applet.getDocumentBase());\r
}\r
\r
newAlignFrame.statusBar.setText("Successfully loaded file " + file);\r
}\r
}\r
\r
+\r
+ /*\r
+ * Try to load T-Coffee score file\r
+ */\r
+ String sScoreFile = applet.getParameter("scoreFile");\r
+ if( sScoreFile != null && !"".equals(sScoreFile) ) {\r
+ try {\r
+ URL urlScore = new URL(sScoreFile);\r
+ newAlignFrame.loadScoreFile(urlScore);\r
+ //TODO check the scores matrix matches the MSA dimensions\r
+ \r
+ }\r
+ catch( Exception e ) {\r
+ // TODO error message log (shows a warning dialogbox?)\r
+ System.err.printf("Cannot read score file: '%s'. Cause: %s \n", sScoreFile, e.getMessage());\r
+ }\r
+ }\r
+ \r
+\r
// ///////////////////////////\r
// modify display of features\r
// we do this before any features have been loaded, ensuring any hidden groups are hidden when features first displayed\r
*/
package jalview.datamodel;
-import java.util.*;
+import jalview.analysis.AlignSeq;
-import jalview.analysis.*;
+import java.util.Enumeration;
+import java.util.Vector;
/**
*
* 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;
}
}
+ /**
+ * @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; }
}
*/
package jalview.datamodel;
-import java.util.*;
+import java.util.Vector;
/**
* DOCUMENT ME!
* 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();
}
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;
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;
AlignViewport viewport;
Vector alignPanels = new Vector();
+
+ TCoffeeScoreFile tcoffeeScoreFile;
/**
* Last format used to load or save alignments in this window
}
}
}
-
+
+ @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);
*/
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!
{
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)))
*/
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!
{
try
{
- col = oldColourScheme.findColour(aa.charAt(0), -1);
+ col = oldColourScheme.findColour(aa.charAt(0), -1, -1);
} catch (Exception ex)
{
}
*/
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!
/**
* Sequences to be added to form a new alignment.
*/
- protected Vector seqs;
+ protected Vector<SequenceI> seqs;
/**
* annotation to be added to generated alignment object
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<c; i++ ) {
+ seqs.get(i).setIndex(i);
+ }
}
/**
super(source);
initData();
parse();
+ // sets the index of each sequence in the alignment
+ for( int i=0,c=seqs.size(); i<c; i++ ) {
+ seqs.get(i).setIndex(i);
+ }
}
/**
* Return the seqs Vector
*/
- public Vector getSeqs()
+ public Vector<SequenceI> getSeqs()
{
return seqs;
}
--- /dev/null
+package jalview.io;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A file parse for T-Coffee score ascii format. This file contains the alignment consensus
+ * for each resude in any sequence.
+ * <p>
+ * This file is procuded by <code>t_coffee</code> providing the option
+ * <code>-output=score_ascii </code> to the program command line
+ *
+ * An example file is the following
+ *
+ * <pre>
+ * T-COFFEE, Version_9.02.r1228 (2012-02-16 18:15:12 - Revision 1228 - Build 336)
+ * Cedric Notredame
+ * CPU TIME:0 sec.
+ * SCORE=90
+ * *
+ * BAD AVG GOOD
+ * *
+ * 1PHT : 89
+ * 1BB9 : 90
+ * 1UHC : 94
+ * 1YCS : 94
+ * 1OOT : 93
+ * 1ABO : 94
+ * 1FYN : 94
+ * 1QCF : 94
+ * cons : 90
+ *
+ * 1PHT 999999999999999999999999998762112222543211112134
+ * 1BB9 99999999999999999999999999987-------4322----2234
+ * 1UHC 99999999999999999999999999987-------5321----2246
+ * 1YCS 99999999999999999999999999986-------4321----1-35
+ * 1OOT 999999999999999999999999999861-------3------1135
+ * 1ABO 99999999999999999999999999986-------422-------34
+ * 1FYN 99999999999999999999999999985-------32--------35
+ * 1QCF 99999999999999999999999999974-------2---------24
+ * cons 999999999999999999999999999851000110321100001134
+ *
+ *
+ * 1PHT ----------5666642367889999999999889
+ * 1BB9 1111111111676653-355679999999999889
+ * 1UHC ----------788774--66789999999999889
+ * 1YCS ----------78777--356789999999999889
+ * 1OOT ----------78877--356789999999997-67
+ * 1ABO ----------687774--56779999999999889
+ * 1FYN ----------6888842356789999999999889
+ * 1QCF ----------6878742356789999999999889
+ * cons 00100000006877641356789999999999889
+ * </pre>
+ *
+ *
+ * @author Paolo Di Tommaso
+ *
+ */
+public class TCoffeeScoreFile {
+
+ /** The {@link Header} structure holder */
+ Header header;
+
+ /**
+ * Holds the consensues values for each sequences. It uses a LinkedHashMap to maintaint the
+ * insertion order.
+ */
+ LinkedHashMap<String,StringBuilder> scores = new LinkedHashMap<String,StringBuilder>();
+
+
+ /**
+ * Parse the specified file.
+ *
+ * @param file The file to be parsed
+ */
+ public static TCoffeeScoreFile load(File file) {
+ try {
+ return load(new FileReader(file));
+ }
+ catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Parse the provided reader for the T-Coffee scores file format
+ *
+ * @param reader
+ */
+ public static TCoffeeScoreFile load(Reader reader) {
+
+ try {
+ BufferedReader in = (BufferedReader) (reader instanceof BufferedReader ? reader : new BufferedReader(reader));
+ TCoffeeScoreFile result = new TCoffeeScoreFile();
+ result.doParsing(in);
+ return result.header != null && result.scores != null ? result : null;
+ }
+ catch( Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * The default constructor is marked as {@code protected} since this class is meant to created
+ * through the {@link #load(File)} or {@link #load(Reader)} factory methods
+ */
+ protected TCoffeeScoreFile() { }
+
+ /**
+ * Get the string of score values for the specified seqeunce ID.
+ * @param id The sequence ID
+ * @return The scores as a string of values e.g. {@code 99999987-------432}.
+ * It return an empty string when the specified ID is missing.
+ */
+ public String getScoresFor( String id ) {
+ return scores.containsKey(id) ? scores.get(id).toString() : "";
+ }
+
+ /**
+ * @return The list of score string as a {@link List} object, in the same ordeer of the insertion i.e. in the MSA
+ */
+ public List<String> getScoresList() {
+ List<String> result = new ArrayList<String>( scores.size() );
+ for( Map.Entry<String,StringBuilder> it : scores.entrySet() ) {
+ result.add(it.getValue().toString());
+ }
+
+ return result;
+ }
+
+ /**
+ * @return The parsed score values a matrix of bytes
+ */
+ public byte[][] getScoresArray() {
+ byte[][] result = new byte[ scores.size() ][];
+
+ int rowCount = 0;
+ for( Map.Entry<String,StringBuilder> it : scores.entrySet() ) {
+ String line = it.getValue().toString();
+ byte[] seqValues = new byte[ line.length() ];
+ for( int j=0, c=line.length(); j<c; j++ ) {
+
+ byte val = (byte)(line.charAt(j) - '0');
+
+ seqValues[j] = ( val >= 0 && val <= 9 ) ? val : -1;
+ }
+
+ result[rowCount++] = seqValues;
+ }
+
+ return result;
+ }
+
+
+ private void doParsing(BufferedReader in) throws IOException {
+
+ /*
+ * read the header
+ */
+ header = readHeader(in);
+
+ if( header == null ) { return; }
+
+
+ /*
+ * initilize the structure
+ */
+ for( Map.Entry<String,Integer> entry : header.scores.entrySet() ) {
+ scores.put( entry.getKey(), new StringBuilder());
+ }
+
+ /*
+ * go with the reading
+ */
+ Block block;
+ while( (block = readBlock(in, header.scores.size())) != null ) {
+
+ /*
+ * append sequences read in the block
+ */
+ for( Map.Entry<String,String> entry : block.items.entrySet() ) {
+ StringBuilder scoreStringBuilder = scores.get(entry.getKey());
+ if( scoreStringBuilder == null ) {
+ throw new RuntimeException(String.format("Invalid T-Coffee score file. Sequence ID '%s' is not declared in header section", entry.getKey()));
+ }
+
+ scoreStringBuilder.append( entry.getValue() );
+ }
+
+ }
+
+ }
+
+
+ static int parseInt( String str ) {
+ try {
+ return Integer.parseInt(str);
+ }
+ catch( NumberFormatException e ) {
+ // TODO report a warning ?
+ return 0;
+ }
+ }
+
+ /**
+ * Reaad the header section in the T-Coffee score file format
+ *
+ * @param reader The scores reader
+ * @return The parser {@link Header} instance
+ * @throws RuntimeException when the header is not in the expected format
+ */
+ static Header readHeader(BufferedReader reader) {
+
+ Header result = null;
+ try {
+ result = new Header();
+ result.head = reader.readLine();
+
+ String line;
+
+ while( (line = reader.readLine()) != null ) {
+ if( line.startsWith("SCORE=")) {
+ result.score = parseInt( line.substring(6).trim() );
+ break;
+ }
+ }
+
+ if( (line=reader.readLine())==null || !"*".equals(line.trim())) return null;
+ if( (line=reader.readLine())==null || !"BAD AVG GOOD".equals(line.trim())) return null;
+ if( (line=reader.readLine())==null || !"*".equals(line.trim())) return null;
+
+ /*
+ * now are expected a list if sequences ID up to the first blank line
+ */
+ while( (line=reader.readLine()) != null ) {
+ if( "".equals(line) ) {
+ break;
+ }
+
+ int p = line.indexOf(":");
+ if( p == -1 ) {
+ // TODO report a warning
+ continue;
+ }
+
+ String id = line.substring(0,p).trim();
+ int val = parseInt(line.substring(p+1).trim());
+ if( "".equals(id) ) {
+ // TODO report warning
+ continue;
+ }
+
+ result.scores.put(id,val);
+ }
+
+ }
+ catch( IOException e ) {
+ throw new RuntimeException("Cannot parse T-Coffee score ascii file", e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Read a scores block ihe provided stream.
+ *
+ * @param reader The stream to parse
+ * @param size The expected number of the sequence to be read
+ * @return The {@link Block} instance read or {link null} null if the end of file has reached.
+ * @throws IOException Something went wrong on the 'wire'
+ */
+ static Block readBlock( BufferedReader reader, int size ) throws IOException {
+ Block result = new Block(size);
+ String line;
+
+ /*
+ * read blank lines (eventually)
+ */
+ while( (line=reader.readLine()) != null && "".equals(line.trim())) {
+ // consume blank lines
+ }
+
+ if( line == null ) return null;
+
+ /*
+ * read the scores block
+ */
+ do {
+ if( "".equals(line.trim()) ) {
+ // terminated
+ break;
+ }
+
+ // split the line on the first blank
+ // the first part have to contain the sequence id
+ // theramining part are the scores values
+ int p = line.indexOf(" ");
+ if( p == -1 ) {
+ //TODO This is an unexpected condition, log a warning or throw an exception ?
+ continue;
+ }
+
+ String id = line.substring(0,p).trim();
+ String val = line.substring(p+1).trim();
+
+ result.items.put(id, val);
+
+ } while( (line = reader.readLine()) != null );
+
+
+ return result;
+ }
+
+ /*
+ * The score file header
+ */
+ static class Header {
+ String head;
+ int score;
+
+ LinkedHashMap<String,Integer> scores = new LinkedHashMap<String,Integer>();
+
+ public int getScoreAvg() { return score; }
+
+ public int getScoreFor( String ID ) {
+
+ return scores.containsKey(ID) ? scores.get(ID) : -1;
+
+ }
+ }
+
+ /*
+ * Hold a single block values block in the score file
+ */
+ static class Block {
+ int size;
+ Map<String,String> items;
+
+ public Block( int size ) {
+ this.size = size;
+ this.items = new HashMap<String,String>(size);
+ }
+
+ String getScoresFor( String id ) {
+ return items.get(id);
+ }
+
+ String getConsensus() {
+ return items.get("cons");
+ }
+ }
+
+
+
+}
*/
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
{
protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
+ protected JRadioButtonMenuItem tcoffeeColour = new JRadioButtonMenuItem();
+
+
JMenuItem njTreeBlosumMenuItem = new JMenuItem();
JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem();
JMenuItem epsFile = new JMenuItem();
JMenuItem LoadtreeMenuItem = new JMenuItem();
+
+ JMenuItem loadScoresMenuItem = new JMenuItem();
public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
colours.add(PIDColour);
colours.add(BLOSUM62Colour);
colours.add(nucleotideColour);
+ colours.add(tcoffeeColour);
setColourSelected(jalview.bin.Cache
.getDefault("DEFAULT_COLOUR", "None"));
nucleotideColour.setSelected(true);
break;
+
+ case ColourSchemeProperty.TCOFFEE:
+ tcoffeeColour.setSelected(true);
+ break;
case ColourSchemeProperty.USER_DEFINED:
userDefinedColour.setSelected(true);
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()
}
});
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)
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()
fileMenu.add(exportAnnotations);
fileMenu.add(LoadtreeMenuItem);
fileMenu.add(associatedData);
+ fileMenu.add(loadScoresMenuItem);
fileMenu.addSeparator();
fileMenu.add(closeMenuItem);
editMenu.add(undoMenuItem);
colourMenu.add(turnColour);
colourMenu.add(buriedColour);
colourMenu.add(nucleotideColour);
+ colourMenu.add(tcoffeeColour);
colourMenu.add(userDefinedColour);
colourMenu.addSeparator();
colourMenu.add(conservationMenuItem);
protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
{
+
+ }
+
+ /**
+ * Template method to handle the 'load T-Coffee scores' menu event.
+ * <p>
+ * 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.
+ * <p>
+ * 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)
{
*/
package jalview.schemes;
-import java.awt.*;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.GraphLine;
-import jalview.datamodel.*;
+import java.awt.Color;
public class AnnotationColourGradient extends ResidueColourScheme
{
*
* @return DOCUMENT ME!
*/
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
Color currentColour = Color.white;
if (colourScheme != null)
{
- currentColour = colourScheme.findColour(c, j);
+ currentColour = colourScheme.findColour(c, j, sequenceIndex);
}
else if (range != 0)
{
*/
package jalview.schemes;
-import java.awt.*;
+import jalview.analysis.AAFrequency;
-import jalview.analysis.*;
+import java.awt.Color;
public class Blosum62ColourScheme extends ResidueColourScheme
{
super();
}
- public Color findColour(char res, int j)
+ @Override
+ public Color findColour(char res, int j, int sequenceIndex)
{
if ('a' <= res && res <= 'z')
{
*/
package jalview.schemes;
-import java.util.*;
+import jalview.datamodel.SequenceI;
-import java.awt.*;
-
-import jalview.datamodel.*;
+import java.awt.Color;
+import java.util.Hashtable;
+import java.util.Vector;
public class ClustalxColourScheme extends ResidueColourScheme // implements
// IParameterizable
ResidueColour[19] = colours[0]; // V
}
+ @Override
public Color findColour(char c)
{
return Color.pink;
}
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
Color currentColour;
*/
package jalview.schemes;
-import java.awt.*;
+import java.awt.Color;
public interface ColourSchemeI
{
public Color findColour(char c);
- public Color findColour(char c, int j);
+ public Color findColour(char c, int j, int sequenceIndex);
public void setConsensus(java.util.Hashtable[] h);
*/
package jalview.schemes;
-import java.awt.*;
+import java.awt.Color;
/**
* ColourSchemeProperty Binds names to hardwired colourschemes and tries to deal
public static final int PURINEPYRIMIDINE = 13;
public static final int COVARIATION = 14;
+
+ public static final int TCOFFEE = 15;
+
/**
* index of first colourscheme (includes 'None')
{
ret = NUCLEOTIDE;
}
+ else if (name.equalsIgnoreCase("T-Coffee scores"))
+ {
+ ret = TCOFFEE;
+ }
+
else if (name.equalsIgnoreCase("User Defined"))
{
ret = USER_DEFINED;
*/
package jalview.schemes;
-import java.awt.*;
+import java.awt.Color;
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
+ @Override
public Color findColour(char c)
{
// System.out.println("called"); log.debug
*
* @return DOCUMENT ME!
*/
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
Color currentColour;
if ((threshold == 0) || aboveThreshold(c, j))
*/
package jalview.schemes;
-import java.awt.*;
+import jalview.analysis.AAFrequency;
+import jalview.datamodel.SequenceGroup;
-import jalview.analysis.*;
-import jalview.datamodel.*;
+import java.awt.Color;
public class PIDColourScheme extends ResidueColourScheme
{
this.thresholds = ResidueProperties.pidThresholds;
}
- public Color findColour(char c, int j)
+
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
if ('a' <= c && c <= 'z')
{
*/
package jalview.schemes;
-import java.util.*;
+import jalview.analysis.AAFrequency;
+import jalview.analysis.Conservation;
-import java.awt.*;
-
-import jalview.analysis.*;
+import java.awt.Color;
+import java.util.Hashtable;
/**
* DOCUMENT ME!
: colors[ResidueProperties.aaIndex[c]];
}
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
Color currentColour;
*/
package jalview.schemes;
-import java.awt.*;
+import java.awt.Color;
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
if (threshold > 0)
{
--- /dev/null
+package jalview.schemes;
+
+import jalview.io.TCoffeeScoreFile;
+
+import java.awt.Color;
+
+/**
+ * Defines the color score for T-Coffee MSA
+ * <p>
+ * See http://tcoffee.org
+ *
+ *
+ * @author Paolo Di Tommaso
+ *
+ */
+public class TCoffeeColourScheme extends ResidueColourScheme {
+
+ static final Color[] colors = {
+ new Color( 102, 102, 255 ), // #6666FF
+ new Color( 0, 255, 0), // #00FF00
+ new Color( 102, 255, 0), // #66FF00
+ new Color( 204, 255, 0), // #CCFF00
+ new Color( 255, 255, 0), // #FFFF00
+ new Color( 255, 204, 0), // #FFCC00
+ new Color( 255, 153, 0), // #FF9900
+ new Color( 255, 102, 0), // #FF6600
+ new Color( 255, 51, 0), // #FF3300
+ new Color( 255, 34, 0) // #FF2000
+ };
+
+
+ byte[][] scoreMatrix = null;
+
+ /**
+ * Initialize the color sheme based on the content of the T-Coffee score file
+ *
+ * @param scoreFile
+ */
+ public TCoffeeColourScheme(TCoffeeScoreFile scoreFile) {
+
+ scoreMatrix = scoreFile != null ? scoreFile.getScoresArray() : null;
+
+ }
+
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex) {
+
+ if( scoreMatrix == null ) {
+ return Color.white;
+ }
+
+ if( sequenceIndex<0 || sequenceIndex >= scoreMatrix.length ) {
+ System.out.printf("Sequence index out of range for the T-Coffee color scheme. Index: %s\n", sequenceIndex);
+ return Color.white;
+ }
+
+ byte[] seqScores = scoreMatrix[sequenceIndex];
+ if( j < 0 || j>= seqScores.length ) {
+ System.out.printf("Residue index out of range for the T-Coffee color scheme. Sequence %s - residue: %s\n", sequenceIndex, j);
+ return Color.white;
+ }
+
+ byte val = seqScores[j];
+ return val >= 0 && val < colors.length ? colors[val] : Color.white;
+ }
+}
*/
package jalview.schemes;
-import java.util.*;
-
-import java.awt.*;
+import java.awt.Color;
+import java.util.StringTokenizer;
public class UserColourScheme extends ResidueColourScheme
{
}
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, int sequenceIndex)
{
Color currentColour;
int index = ResidueProperties.aaIndex[c];
--- /dev/null
+package jalview.io;
+
+import static org.junit.Assert.*;
+import jalview.io.TCoffeeScoreFile.Block;
+import jalview.io.TCoffeeScoreFile.Header;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+
+import org.junit.Test;
+
+public class TCoffeeScoreFileTest {
+
+ final static File SCORE_FILE = new File("./test/jalview/io/tcoffee.score_ascii");
+
+ @Test
+ public void testReadHeader() throws FileNotFoundException {
+
+ Header header = TCoffeeScoreFile.readHeader( new BufferedReader(new FileReader(SCORE_FILE)) );
+ assertNotNull(header);
+ assertEquals( "T-COFFEE, Version_9.02.r1228 (2012-02-16 18:15:12 - Revision 1228 - Build 336)", header.head );
+ assertEquals( 90, header.score );
+ assertEquals( 89, header.getScoreFor("1PHT") );
+ assertEquals( 90, header.getScoreFor("1BB9") );
+ assertEquals( 94, header.getScoreFor("1UHC") );
+ assertEquals( 94, header.getScoreFor("1YCS") );
+ assertEquals( 93, header.getScoreFor("1OOT") );
+ assertEquals( 94, header.getScoreFor("1ABO") );
+ assertEquals( 94, header.getScoreFor("1FYN") );
+ assertEquals( 94, header.getScoreFor("1QCF") );
+ assertEquals( 90, header.getScoreFor("cons") );
+ }
+
+
+ @Test
+ public void testWrongFile() {
+ TCoffeeScoreFile result = TCoffeeScoreFile.load(new File("./test/jalview/io/tcoffee.fasta_aln"));
+ assertNull(result);
+ }
+
+ @Test
+ public void testReadBlock( ) throws IOException {
+
+ String BLOCK = "\n" +
+ "\n" +
+ "\n" +
+ "1PHT 999999999999999999999999998762112222543211112134\n" +
+ "1BB9 99999999999999999999999999987-------4322----2234 \n" +
+ "1UHC 99999999999999999999999999987-------5321----2246\n" +
+ "1YCS 99999999999999999999999999986-------4321----1-35\n" +
+ "1OOT 999999999999999999999999999861-------3------1135 \n" +
+ "1ABO 99999999999999999999999999986-------422-------34\n" +
+ "1FYN 99999999999999999999999999985-------32--------35\n" +
+ "1QCF 99999999999999999999999999974-------2---------24\n" +
+ "cons 999999999999999999999999999851000110321100001134\n" +
+ "\n" +
+ "\n";
+
+ Block block = TCoffeeScoreFile.readBlock(new BufferedReader(new StringReader(BLOCK)), 0);
+ assertNotNull(block);
+ assertEquals( "999999999999999999999999998762112222543211112134", block.getScoresFor("1PHT") );
+ assertEquals( "99999999999999999999999999987-------4322----2234", block.getScoresFor("1BB9") );
+ assertEquals( "99999999999999999999999999987-------5321----2246", block.getScoresFor("1UHC") );
+ assertEquals( "99999999999999999999999999986-------4321----1-35", block.getScoresFor("1YCS") );
+ assertEquals( "999999999999999999999999999861-------3------1135", block.getScoresFor("1OOT") );
+ assertEquals( "99999999999999999999999999986-------422-------34", block.getScoresFor("1ABO") );
+ assertEquals( "99999999999999999999999999985-------32--------35", block.getScoresFor("1FYN") );
+ assertEquals( "99999999999999999999999999974-------2---------24", block.getScoresFor("1QCF") );
+ assertEquals( "999999999999999999999999999851000110321100001134", block.getConsensus() );
+ }
+
+ @Test
+ public void testParse() throws FileNotFoundException {
+
+ TCoffeeScoreFile parser = TCoffeeScoreFile.load(new BufferedReader(new FileReader(SCORE_FILE)) );
+
+ assertEquals( "999999999999999999999999998762112222543211112134----------5666642367889999999999889", parser.getScoresFor("1PHT") );
+ assertEquals( "99999999999999999999999999987-------4322----22341111111111676653-355679999999999889", parser.getScoresFor("1BB9") );
+ assertEquals( "99999999999999999999999999987-------5321----2246----------788774--66789999999999889", parser.getScoresFor("1UHC") );
+ assertEquals( "99999999999999999999999999986-------4321----1-35----------78777--356789999999999889", parser.getScoresFor("1YCS") );
+ assertEquals( "999999999999999999999999999861-------3------1135----------78877--356789999999997-67", parser.getScoresFor("1OOT") );
+ assertEquals( "99999999999999999999999999986-------422-------34----------687774--56779999999999889", parser.getScoresFor("1ABO") );
+ assertEquals( "99999999999999999999999999985-------32--------35----------6888842356789999999999889", parser.getScoresFor("1FYN") );
+ assertEquals( "99999999999999999999999999974-------2---------24----------6878742356789999999999889", parser.getScoresFor("1QCF") );
+ assertEquals( "99999999999999999999999999985100011032110000113400100000006877641356789999999999889", parser.getScoresFor("cons") );
+ }
+
+
+ @Test
+ public void testGetAsList() throws FileNotFoundException {
+
+ TCoffeeScoreFile parser = TCoffeeScoreFile.load(new BufferedReader(new FileReader(SCORE_FILE)) );
+
+ List<String> scores = parser.getScoresList();
+ assertEquals( "999999999999999999999999998762112222543211112134----------5666642367889999999999889", scores.get(0) );
+ assertEquals( "99999999999999999999999999987-------4322----22341111111111676653-355679999999999889", scores.get(1) );
+ assertEquals( "99999999999999999999999999987-------5321----2246----------788774--66789999999999889", scores.get(2) );
+ assertEquals( "99999999999999999999999999986-------4321----1-35----------78777--356789999999999889", scores.get(3) );
+ assertEquals( "999999999999999999999999999861-------3------1135----------78877--356789999999997-67", scores.get(4) );
+ assertEquals( "99999999999999999999999999986-------422-------34----------687774--56779999999999889", scores.get(5) );
+ assertEquals( "99999999999999999999999999985-------32--------35----------6888842356789999999999889", scores.get(6) );
+ assertEquals( "99999999999999999999999999974-------2---------24----------6878742356789999999999889", scores.get(7) );
+ assertEquals( "99999999999999999999999999985100011032110000113400100000006877641356789999999999889", scores.get(8) );
+
+ }
+
+
+ @Test
+ public void testGetAsArray() throws FileNotFoundException {
+
+ TCoffeeScoreFile parser = TCoffeeScoreFile.load(new BufferedReader(new FileReader(SCORE_FILE)) );
+
+ byte[][] scores = parser.getScoresArray();
+
+ assertEquals( 9, scores[0][0] );
+ assertEquals( 9, scores[1][0] );
+ assertEquals( 9, scores[2][0] );
+ assertEquals( 9, scores[3][0] );
+ assertEquals( 9, scores[4][0] );
+ assertEquals( 9, scores[5][0] );
+ assertEquals( 9, scores[6][0] );
+ assertEquals( 9, scores[7][0] );
+ assertEquals( 9, scores[8][0] );
+
+ assertEquals( 5, scores[0][36] );
+ assertEquals( 4, scores[1][36] );
+ assertEquals( 5, scores[2][36] );
+ assertEquals( 4, scores[3][36] );
+ assertEquals( -1, scores[4][36] );
+ assertEquals( 4, scores[5][36] );
+ assertEquals( 3, scores[6][36] );
+ assertEquals( 2, scores[7][36] );
+ assertEquals( 3, scores[8][36] );
+
+ }
+
+
+
+}
--- /dev/null
+>1PHT
+YQYRALYDYKKEREEDIDLHLGDILTVNKGSLVALGFSDGQEARPEEI--
+--------GWLNGYNETTGERGDFPGTYVEYIG
+>1BB9
+FKVQAQHDYTATDTDELQLKAGDVVLVIP-------FQNP----EEQDEG
+WLMGVKESDWNQHK-ELEKCRGVFPENFTERVQ
+>1UHC
+QVYFAVYTFKARNPNELSVSANQKLKILE-------FKDV----TGNT--
+--------EWWLAE--VNGKKGYVPSNYIRKTE
+>1YCS
+GVIYALWDYEPQNDDELPMKEGDCMTIIH-------REDE----D-EI--
+--------EWWWA--RLNDKEGYVPRNLLGLYP
+>1OOT
+PKAVALYSFAGEESGDLPFRKGDVITILKK-------S------DSQN--
+--------DWWTG--RVNGREGIFPANYVE-LV
+>1ABO
+NLFVALYDFVASGDNTLSITKGEKLRVLG-------YNH-------NG--
+--------EWCEAQ--TKNGQGWVPSNYITPVN
+>1FYN
+TLFVALYDYEARTEDDLSFHKGEKFQILN-------SS--------EG--
+--------DWWEARSLTTGETGYIPSNYVAPVD
+>1QCF
+IIVVALYDYEAIHHEDLSFQKGDQMVVLE-------E---------SG--
+--------EWWKARSLATRKEGYIPSNYVARVD
\ No newline at end of file
--- /dev/null
+T-COFFEE, Version_9.02.r1228 (2012-02-16 18:15:12 - Revision 1228 - Build 336)
+Cedric Notredame
+CPU TIME:0 sec.
+SCORE=90
+*
+ BAD AVG GOOD
+*
+1PHT : 89
+1BB9 : 90
+1UHC : 94
+1YCS : 94
+1OOT : 93
+1ABO : 94
+1FYN : 94
+1QCF : 94
+cons : 90
+
+1PHT 999999999999999999999999998762112222543211112134
+1BB9 99999999999999999999999999987-------4322----2234
+1UHC 99999999999999999999999999987-------5321----2246
+1YCS 99999999999999999999999999986-------4321----1-35
+1OOT 999999999999999999999999999861-------3------1135
+1ABO 99999999999999999999999999986-------422-------34
+1FYN 99999999999999999999999999985-------32--------35
+1QCF 99999999999999999999999999974-------2---------24
+cons 999999999999999999999999999851000110321100001134
+
+
+1PHT ----------5666642367889999999999889
+1BB9 1111111111676653-355679999999999889
+1UHC ----------788774--66789999999999889
+1YCS ----------78777--356789999999999889
+1OOT ----------78877--356789999999997-67
+1ABO ----------687774--56779999999999889
+1FYN ----------6888842356789999999999889
+1QCF ----------6878742356789999999999889
+cons 00100000006877641356789999999999889