Merge remote-tracking branch 'origin/Tcoffee_JAL-1065' into develop
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 22 May 2012 11:20:02 +0000 (12:20 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 22 May 2012 11:25:34 +0000 (12:25 +0100)
conflicts due to refactoring according to JAL-972, JAL-968, JAL-968
Conflicts:
.classpath
examples/appletParameters.html
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/jbgui/GAlignFrame.java

33 files changed:
.classpath
.project
examples/appletParameters.html
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/SequenceRenderer.java
src/jalview/appletgui/UserDefinedColours.java
src/jalview/bin/JalviewLite.java
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java
src/jalview/datamodel/AnnotatedCollectionI.java [new file with mode: 0644]
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/datamodel/SequenceI.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/SequenceRenderer.java
src/jalview/gui/UserDefinedColours.java
src/jalview/io/AlignFile.java
src/jalview/io/TCoffeeScoreFile.java [new file with mode: 0644]
src/jalview/jbgui/GAlignFrame.java
src/jalview/schemes/AnnotationColourGradient.java
src/jalview/schemes/Blosum62ColourScheme.java
src/jalview/schemes/ClustalxColourScheme.java
src/jalview/schemes/ColourSchemeI.java
src/jalview/schemes/ColourSchemeProperty.java
src/jalview/schemes/NucleotideColourScheme.java
src/jalview/schemes/PIDColourScheme.java
src/jalview/schemes/ResidueColourScheme.java
src/jalview/schemes/ScoreColourScheme.java
src/jalview/schemes/TCoffeeColourScheme.java [new file with mode: 0644]
src/jalview/schemes/UserColourScheme.java
test/jalview/io/TCoffeeScoreFileTest.java [new file with mode: 0644]
test/jalview/io/tcoffee.fasta_aln [new file with mode: 0644]
test/jalview/io/tcoffee.score_ascii [new file with mode: 0644]

index af48f6e..6cffc21 100644 (file)
@@ -2,6 +2,7 @@
 <classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="utils"/>
+       <classpathentry kind="src" path="test"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="lib" path="lib/activation.jar"/>
        <classpathentry kind="lib" path="lib/axis.jar" sourcepath="D:/axis-1_2RC2-src/axis-1_2RC2"/>
@@ -45,7 +46,7 @@
        <classpathentry kind="lib" path="lib/spring-core-3.0.5.RELEASE.jar"/>
        <classpathentry kind="lib" path="lib/spring-web-3.0.5.RELEASE.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin.jar"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin.java"/>
        <classpathentry kind="lib" path="/Users/jimp/git/jalview_clean/lib/VARNAv3-9-dev.jar"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
index b0a39c0..5f4b511 100644 (file)
--- a/.project
+++ b/.project
@@ -37,6 +37,7 @@
                </buildCommand>
        </buildSpec>
        <natures>
+               <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
                <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
                <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
index 261bfa3..39cd9fb 100644 (file)
@@ -1,7 +1,145 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r<html><!-- InstanceBegin template="/Templates/jtemplate.dwt" codeOutsideHTMLIsLocked="false" -->\r<head>\r<!-- InstanceBeginEditable name="doctitle" -->
-<TITLE>Applet Parameters</TITLE>
-<!-- InstanceEndEditable --> \r<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="keywords" content="jalview,multiple,sequence,alignment,editor,viewer,java,download,barton group,protein,dna,das,distributed annotation system">\r<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> \r<style type="text/css">\r<!--\rtd {\r     font-family: Geneva, Arial, Helvetica, sans-serif;\r     font-size: 12px;\r}\r.plain {\r    font-family: Verdana, Arial, Helvetica, sans-serif;\r    font-size: 14px;\r       text-decoration: none;\r}\r.plain:hover{\r background-color:#000000; color: #F2F2FF;\r}\r \r-->\r</style>\r\r<script language="JavaScript">\rfunction genHref()\r{\rvar s1 = "ml:ljvwr", s2 = "athpai.g", s3 = "ioe@leo ", href="";\rfor(i=0; i<8; i++)\r{href = href + s1.charAt(i) + s2.charAt(i) + s3.charAt(i);   }\rwindow.location=href;\r}\rfunction getEventTarget(e)\r{\rif(!e)\re = window.event;\rif(e.target)\rreturn e.target;\rreturn e.srcElement;\r}\r\r</script>\r</head>\r\r<body alink="#000000" vlink="#000000" link="#000000">\r<script type="text/javascript">\rvar gaJsHost = (("https:" == document.location.protocol) ? \r"https://ssl." : "http://www.");\rdocument.write(unescape("%3Cscript src='" + gaJsHost + \r"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));\r</script>\r<script type="text/javascript">\rtry{\rvar pageTracker = _gat._getTracker("UA-9060947-1");\rpageTracker._trackPageview();\r} catch(err) {}\r</script>\r<div align="left"> \r  <table width="805" height="100" cellpadding="5">\r    <tr>\r      <td background="../jalview.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.compbio.dundee.ac.uk" target="NEW"><img src="../uodc_r1_c1.gif" width="143" height="101" border="1"></a></td>\r    </tr>\r  </table>\r  <table width="805" border="0" cellpadding="5" cellspacing="5">\r    <tr> \r      <td width="183" valign="top" bgcolor="#F2F2FF" border="5"> \r       \r       <div align="center">\r          <table width="182" height="386" border="0" cellpadding="0" cellspacing="0">\r            <tr> \r              <td align="left" valign="middle"><a href="../index.html" class="plain">Home</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="../overview.html" class="plain">Overview</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="../download.html" class="plain">Download</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="applets.html" class="plain">Applet \r                Version</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="examples.html" class="plain">Screenshots</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="../faq.html" class="plain">FAQ</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="../documentList.html" class="plain">Documentation</a></td>\r            </tr>\r            <tr>\r              <td align="left" valign="middle" ><a href="../releaseHistory.html" class="plain">Release \r                history</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="../source/source.html" class="plain">Source \r                Code</a></td>\r            </tr>\r                   <tr> \r              <td align="left" valign="middle"><a href="../versions.html" class="plain">Development Version</a></td>\r            </tr>\r                   <tr> \r              <td align="left" valign="middle"><a href="../links.html" class="plain">Links</a></td>\r            </tr>\r            <tr> \r              <td align="left" valign="middle"><a href="http://www.jalview.org/mailman/listinfo/jalview-announce" class="plain" target="NEW">News \r                Mailing List</a></td>\r            </tr>\r            <tr>\r              <td align="left" valign="middle"><a\r            href="http://www.jalview.org/mailman/listinfo/jalview-discuss"\r            class="plain" target="NEW">Discussion Mailing List</a><br><br><em>Please send problems<br>and\r            bug reports to the discussion list.</em></td>\r            </tr>\r            <tr></tr>\r            <tr>\r              <!--<td align="left" valign="middle"><br>\r                Please send problems<br>and\r            bug reports to:<br><a href="#" onClick="javascript:genHref();"><img src="../help.gif" width="123" height="19" border="0"></a></td>-->\r            </tr>\r          </table>\r\r        </div>\r\r        <div align="center"> <a href="http://www.bbsrc.ac.uk/" target="NEW"><br>\r          <img src="../bbsrc-new.gif" width="179" height="64" border="1"></a> \r        </div>\r        </td>\r      <td valign="top" width="587" bgcolor="#F2F2FF"><!-- InstanceBeginEditable name="Contents" --> 
-        <p>\r                                           <strong>Quick Links:<ul><li>Download the applet jar file from <a\r                                                       href="jalviewApplet.jar">here</a>\r                                              </li>\r                                          <li>Parameters are described <a href="#parameters">below</a></li>\r                                              <li>The javascript API is described <a\r                                                         href="jalviewLiteJs.html">here</a></li>\r                                                </ul></strong>\r                                 </p>\r                                   
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><!-- InstanceBegin template="/Templates/jtemplate.dwt" codeOutsideHTMLIsLocked="false" -->
+<head>
+<!-- InstanceBeginEditable name="doctitle" -->\r
+<TITLE>Applet Parameters</TITLE>\r
+<!-- InstanceEndEditable --> 
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="keywords" content="jalview,multiple,sequence,alignment,editor,viewer,java,download,barton group,protein,dna,das,distributed annotation system">
+<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> 
+<style type="text/css">
+<!--
+td {
+       font-family: Geneva, Arial, Helvetica, sans-serif;
+       font-size: 12px;
+}
+.plain {
+       font-family: Verdana, Arial, Helvetica, sans-serif;
+       font-size: 14px;
+       text-decoration: none;
+}
+.plain:hover{
+       background-color:#000000; color: #F2F2FF;
+}
+-->
+</style>
+
+<script language="JavaScript">
+function genHref()
+{
+var s1 = "ml:ljvwr", s2 = "athpai.g", s3 = "ioe@leo ", href="";
+for(i=0; i<8; i++)
+{href = href + s1.charAt(i) + s2.charAt(i) + s3.charAt(i);     }
+window.location=href;
+}
+function getEventTarget(e)
+{
+if(!e)
+e = window.event;
+if(e.target)
+return e.target;
+return e.srcElement;
+}
+
+</script>
+</head>
+
+<body alink="#000000" vlink="#000000" link="#000000">
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? 
+"https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + 
+"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try{
+var pageTracker = _gat._getTracker("UA-9060947-1");
+pageTracker._trackPageview();
+} catch(err) {}
+</script>
+<div align="left"> 
+  <table width="805" height="100" cellpadding="5">
+    <tr>
+      <td background="../jalview.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.compbio.dundee.ac.uk" target="NEW"><img src="../uodc_r1_c1.gif" width="143" height="101" border="1"></a></td>
+    </tr>
+  </table>
+  <table width="805" border="0" cellpadding="5" cellspacing="5">
+    <tr> 
+      <td width="183" valign="top" bgcolor="#F2F2FF" border="5"> 
+         
+         <div align="center">
+          <table width="182" height="386" border="0" cellpadding="0" cellspacing="0">
+            <tr> 
+              <td align="left" valign="middle"><a href="../index.html" class="plain">Home</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="../overview.html" class="plain">Overview</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="../download.html" class="plain">Download</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="applets.html" class="plain">Applet 
+                Version</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="examples.html" class="plain">Screenshots</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="../faq.html" class="plain">FAQ</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="../documentList.html" class="plain">Documentation</a></td>
+            </tr>
+            <tr>
+              <td align="left" valign="middle" ><a href="../releaseHistory.html" class="plain">Release 
+                history</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="../source/source.html" class="plain">Source 
+                Code</a></td>
+            </tr>
+                       <tr> 
+              <td align="left" valign="middle"><a href="../versions.html" class="plain">Development Version</a></td>
+            </tr>
+                       <tr> 
+              <td align="left" valign="middle"><a href="../links.html" class="plain">Links</a></td>
+            </tr>
+            <tr> 
+              <td align="left" valign="middle"><a href="http://www.jalview.org/mailman/listinfo/jalview-announce" class="plain" target="NEW">News 
+                Mailing List</a></td>
+            </tr>
+            <tr>
+              <td align="left" valign="middle"><a
+            href="http://www.jalview.org/mailman/listinfo/jalview-discuss"
+            class="plain" target="NEW">Discussion Mailing List</a><br><br><em>Please send problems<br>and
+            bug reports to the discussion list.</em></td>
+            </tr>
+            <tr></tr>
+            <tr>
+              <!--<td align="left" valign="middle"><br>
+                Please send problems<br>and
+            bug reports to:<br><a href="#" onClick="javascript:genHref();"><img src="../help.gif" width="123" height="19" border="0"></a></td>-->
+            </tr>
+          </table>
+
+        </div>
+
+        <div align="center"> <a href="http://www.bbsrc.ac.uk/" target="NEW"><br>
+          <img src="../bbsrc-new.gif" width="179" height="64" border="1"></a> 
+        </div>
+        </td>
+      <td valign="top" width="587" bgcolor="#F2F2FF"><!-- InstanceBeginEditable name="Contents" --> \r
+        <p>
+                                               <strong>Quick Links:<ul><li>Download the applet jar file from <a
+                                                       href="jalviewApplet.jar">here</a>
+                                               </li>
+                                               <li>Parameters are described <a href="#parameters">below</a></li>
+                                               <li>The javascript API is described <a
+                                                               href="jalviewLiteJs.html">here</a></li>
+                                               </ul></strong>
+                                       </p>
+                                       
         <h3 align="left">Useful to know!!</h3>
         <ul>
           <li>Package all your data files into a single (or multiple) zip / jar 
             </font></li>
           <li> Use Jalview for input to a HTML form. For an example of how to 
             code this using Javascript, click <a href="formComplete.html">here</a>. 
-            <br>
-          </li>
+            <br>\r
+          </li>\r
           <li>Embed Jalview into the web page, without the &quot;Start Jalview&quot; 
             button by setting the embed parameter to true;<br>
             &lt;param name=&quot;embedded&quot;
           value=&quot;true&quot;&gt; </li>
-        </ul>\r        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.8</font></strong></p>\r        <ul>\r        <li><font size="2">Normalised sequence logo display\r        </font></li>\r        <li><font size="2">RNA secondary structure annotation row\r        </font></li>\r        </ul>\r        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.7.1</font></strong></p>\r        <ul>\r<li><font size="2">Jmol compatibility updated to Jmol 12.2.x series - <a href="JmolApplet-12.2.4.jar">download the JmolApplet here</a></font></li>\r<li>To use Jmol as the structure viewer for Jalview, you must include \r            the jar file in the applet archive argument thus:<br>\r            <pre>archive=&quot;jalviewApplet.jar,Jmol-12.2.4.jar&quot;</pre></font>\r          </li>\r          <li>Jmol 12.2.x requires at least Java 1.6 to run in the clients web browser. If the client does not have \r            Java 1.6, or if the Jmol-12.2.jar is not added to the archive, the \r            original Jalview structure viewer will still be available. <br>\r          </li>\r          \r        </ul>\r        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.7</font></strong></p>\r        <ul>\r        <li><font size="2">Javascript callbacks capabilities<ul><li>oninit parameter and methods for registering javascript handlers for selections, mouseovers and linking to Jmol applets on the page.</li>\r        <li>To use javascript callbacks, ensure the applet tag includes the '<a href="http://download.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/java_js.html">mayscript</a>' attribute - either as a parameter (&lt;param name="mayscript" value="true"/;gt;) or as a bare attribute in the applet html tag).</li></ul></font>\r        </li>\r        <li><font size="2">New <a href="jalviewLiteJs.html">jalviewLite java api</a> methods for selecting, highlighting, scrolling and reordering sequences in an alignment view.\r        </font></li></ul>\r        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.6</font></strong></p>\r        <ul>\r        <li><font size="2">Jmol compatibility updated to Jmol 12.1.x series</font></li>\r          <li>Jalview 2.6 works only with Jmol version 12.1.13 or later. You can use the JmolApplet.jar from \r          the Jmol binary distribution available at the Jmol Sourceforge site, \r          or <a href="JmolApplet-12.1.13.jar">download the Jmol applet from here</a></li>\r          <li><font size="2">Minimum recommended version of Java runtime for the applet is now 1.5 (JalviewLite v2.6 without the Jmol viewer may work ok on earlier Java environments but compatibility can no-longer be guaranteed).</font></li>\r          </ul>
-        <br><strong><font size="2">**NEW FEATURES** in Jalview 2.5</font></strong></p>\r        <ul>\r        <li><font size="2">New parameters to control display of tree annotation, width of alignment columns, and to disable the jalview button and check for Jmol on startup.</font></li>\r         </ul>        \r        <br><strong><font size="2">**NEW FEATURES** in Jalview 2.4</font></strong></p>
+        </ul>
+        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.8</font></strong></p>
+        <ul>
+        <li><font size="2">Normalised sequence logo display
+        </font></li>
+        <li><font size="2">RNA secondary structure annotation row
+        </font></li>
+        </ul>
+        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.7.1</font></strong></p>
+        <ul>
+<li><font size="2">Jmol compatibility updated to Jmol 12.2.x series - <a href="JmolApplet-12.2.4.jar">download the JmolApplet here</a></font></li>
+<li>To use Jmol as the structure viewer for Jalview, you must include 
+            the jar file in the applet archive argument thus:<br>
+            <pre>archive=&quot;jalviewApplet.jar,Jmol-12.2.4.jar&quot;</pre></font>
+          </li>
+          <li>Jmol 12.2.x requires at least Java 1.6 to run in the clients web browser. If the client does not have 
+            Java 1.6, or if the Jmol-12.2.jar is not added to the archive, the 
+            original Jalview structure viewer will still be available. <br>
+          </li>
+          
+        </ul>
+        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.7</font></strong></p>
+        <ul>
+        <li><font size="2">Javascript callbacks capabilities<ul><li>oninit parameter and methods for registering javascript handlers for selections, mouseovers and linking to Jmol applets on the page.</li>
+        <li>To use javascript callbacks, ensure the applet tag includes the '<a href="http://download.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/java_js.html">mayscript</a>' attribute - either as a parameter (&lt;param name="mayscript" value="true"/;gt;) or as a bare attribute in the applet html tag).</li></ul></font>
+        </li>
+        <li><font size="2">New <a href="jalviewLiteJs.html">jalviewLite java api</a> methods for selecting, highlighting, scrolling and reordering sequences in an alignment view.
+        </font></li></ul>
+        <p><strong><font size="2">**NEW FEATURES** in Jalview 2.6</font></strong></p>
+        <ul>
+        <li><font size="2">Jmol compatibility updated to Jmol 12.1.x series</font></li>
+          <li>Jalview 2.6 works only with Jmol version 12.1.13 or later. You can use the JmolApplet.jar from 
+          the Jmol binary distribution available at the Jmol Sourceforge site, 
+          or <a href="JmolApplet-12.1.13.jar">download the Jmol applet from here</a></li>
+          <li><font size="2">Minimum recommended version of Java runtime for the applet is now 1.5 (JalviewLite v2.6 without the Jmol viewer may work ok on earlier Java environments but compatibility can no-longer be guaranteed).</font></li>
+               </ul>
+        <br><strong><font size="2">**NEW FEATURES** in Jalview 2.5</font></strong></p>
+        <ul>
+        <li><font size="2">New parameters to control display of tree annotation, width of alignment columns, and to disable the jalview button and check for Jmol on startup.</font></li>
+               </ul>        
+        <br><strong><font size="2">**NEW FEATURES** in Jalview 2.4</font></strong></p>
         <ul>
         <li><font size="2">New applet API methods for feature display control, views, and obtaining current selection via javascript.</font></li>
           <li><font size="2">Group show and hide parameters:
             <font size="2">&lt;param name=&quot;PDBFile3&quot; value=&quot;Third.pdb 
             D=SeqX B=SeqY C=SeqZ&quot;&gt; </font> <br>
           </li>
-          <li>Note parameter &quot;PDBSeq&quot; is no longer required.<br>
+          <li>Note parameter &quot;PDBSeq&quot; is no longer required.<br>\r
           </li>
           <li>Jalview 2.3 was updated to work with Jmol 11. See the <a href="../versions.html">versions archive if you want to download the old Jmol applet</a>.</li> 
             <p>&nbsp;</p>
             <font face="Courier New, Courier, mono">&lt;param name=&quot;userDefinedColour&quot; 
             value=&quot;D,E=red; K,R,H=0022FF; C=yellow&quot;&gt;</font><br>
           </li>
-          <li>Param <font face="Courier New, Courier, mono">showFeatureSettings</font> 
+          <li>Param <font face="Courier New, Courier, mono">showFeatureSettings</font>
             - this will display the feature settings window when the applet starts.<br>
           </li>
           <li>Param <font face="Courier New, Courier, mono">Application_URL value=&quot;http://www.jalview.org/services/launchApp&quot;<br>
           <tr><td>showbutton</td>
           <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>normaliseLogo</td>\r          <td>true of false (default is false)</td>\r          <td>When true, all sequence logos will be normalised (all symbol stacks add up to full height of annotation row), rather than being scaled according to the fraction of symbols identical to the consensus. (<em>since 2.7.1</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>
+          </tr>
+                 <tr><td>sortByTree</td>
+                 <td>true or false (default is false)</td>
+                 <td>automatically sort the associated alignment view by the tree when a new tree is opened.</td>
+                 </tr>
+                 <tr>
+                  <td>showTreeBootstraps</td><td>true or false (default is true)</td><td>show or hide branch bootstraps</td>
+                       </tr>
+       <tr><td>showTreeDistances</td><td>true or false (default is true)</td><td>show or hide branch lengths</td></tr>
+       <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>
+       </tr>
+          <tr><td>heightScale</td>
+          <td>1.0 or greater</td>
+          <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>
+          </tr>
+          <tr><td>widthScale</td>
+          <td>1.0 or greater</td>
+          <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>
+          </tr>
+          <tr><td>centrecolumnlabels</td>
+          <td>true of false (default is false)</td>
+          <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>
+          <tr><td>showUnconserved</td>
+          <td>true of false (default is false)</td>
+          <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>
+          </tr>
+          <tr><td>upperCase</td>
+          <td><em>bold</em> or other value</td>
+          <td>Indicate a text style to apply to uppercase sequence symbols. Currently, only <strong>bold</strong> is supported.</td>
+          </tr>
+          <tr><td>automaticScrolling</td>
+          <td>true of false (default is true)</td>
+          <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>
+          </tr>
+          
+          <tr><td>showGroupConsensus</td>
+          <td>true of false (default is false)</td>
+          <td>When true, shows consensus annotation row for any groups on the alignment. (<em>since 2.7</em>)</td>
+          </tr>
+          
+          <tr><td>showGroupConservation</td>
+          <td>true of false (default is false)</td>
+          <td>When true, shows amino-acid property conservation annotation row for any groups on the alignment. (<em>since 2.7</em>)</td>
+          </tr>
+          <tr><td>showConsensusHistogram</td>
+          <td>true of false (default is true)</td>
+          <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>
+          </tr>
+          <tr><td>showSequenceLogo</td>
+          <td>true of false (default is false)</td>
+          <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>
+          </tr>
+          <tr><td>normaliseLogo</td>
+          <td>true of false (default is false)</td>
+          <td>When true, all sequence logos will be normalised (all symbol stacks add up to full height of annotation row), rather than being scaled according to the fraction of symbols identical to the consensus. (<em>since 2.7.1</em>)</td>
+          </tr>
+          <tr><td>oninit</td>
+          <td><em>after_init()</em></td>
+          <td>name of javascript function that will be called after the jalviewLite instance has completed its initialisation. (<em>since 2.7</em>)</td>
+          </tr>
+          <tr><td>relaxedidmatch</td>
+          <td><em>true or false (default is false)</em></td>
+          <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>
+          </tr>
+          <tr><td>alignpdbfiles</td>
+          <td><em>true or false (default is false)</em></td>
+          <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>
+          </tr>
+          <tr><td>externalstructureviewer</td>
+          <td><em>true or false (default is false)</em></td>
+          <td>re-route jmol colouring commands, selection and mouseover events to an external viewer using javascript callbacks. [experimental] (<em>since 2.7</em>)</td>
+          
+          </tr>
+          <tr><td>annotationcolour_max</td>
+          <td>colour name or RGB hex triplet (default is red)</td>
+          <td>Default colour used for maximum value when shading by annotation. (<em>since 2.7</em>)</td>
+          </tr>
+          <tr><td>annotationcolour_min</td>
+          <td>colour name or RGB hex triplet (default is orange)</td>
+          <td>Default colour used for minimum value when shading by annotation. (<em>since 2.7</em>)</td>
+          </tr>
+          <tr><td>jalviewhelpurl</td>
+          <td>absolute or relative url or javascript function prefixed by <em>javascript:</em> (default is http://www.jalview.org/help.html)</td>
+          <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>
+          </tr>
+          <tr><td>resolvetocodebase</td>
+          <td>True or False (False)</td>
+          <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>
+          </tr>
+          <tr><td>scoreFile</td>
+          <td>file</td>
+          <td>Multiple sequences aligment scores file. Currently is supported only the T-Coffee score_ascii file format</td>
+          </tr>
+                  </table>
         <p align="center">&nbsp;</p>
-        <!-- InstanceEndEditable --></td>\r    </tr>\r  </table>\r</div>\r</body>\r<!-- InstanceEnd --></html>\r
\ No newline at end of file
+        <!-- InstanceEndEditable --></td>
+    </tr>
+  </table>
+</div>
+</body>
+<!-- InstanceEnd --></html>
index ea5ead8..276fbda 100644 (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.PurinePyrimidineColourScheme;\r
+import jalview.schemes.RNAHelicesColourChooser;\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
@@ -44,11 +101,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   int DEFAULT_HEIGHT = 500;\r
 \r
   String jalviewServletURL;\r
+  \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
@@ -697,6 +753,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {\r
       loadAnnotations();\r
     }\r
+    else if( source == loadScores ) {\r
+       loadScores();\r
+    }\r
     else if (source == outputAnnotations)\r
     {\r
       outputAnnotations(true);\r
@@ -960,6 +1019,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {\r
       changeColour(new Blosum62ColourScheme());\r
     }\r
+    else if (source == tcoffeeColour) {\r
+        changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));\r
+    }\r
     else if (source == annotationColour)\r
     {\r
       new AnnotationColourChooser(viewport, alignPanel);\r
@@ -1049,6 +1111,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     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
@@ -2272,7 +2339,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \r
       cs.setConsensus(viewport.getSequenceConsensusHash());\r
 \r
-    }\r
+    }             \r
     viewport.setGlobalColourScheme(cs);\r
 \r
     if (viewport.getColourAppliesToAllGroups())\r
@@ -2297,7 +2364,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         {\r
           try\r
           {\r
-            sg.cs = (ColourSchemeI) cs.getClass().newInstance();\r
+            sg.cs = cs.getClass().newInstance();\r
           } catch (Exception ex)\r
           {\r
             ex.printStackTrace();\r
@@ -2722,6 +2789,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   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
@@ -2803,6 +2872,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   MenuItem PIDColour = new MenuItem();\r
 \r
   MenuItem BLOSUM62Colour = new MenuItem();\r
+  \r
+  MenuItem tcoffeeColour = new MenuItem();\r
 \r
   MenuItem njTreeBlosumMenuItem = new MenuItem();\r
 \r
@@ -2927,6 +2998,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 \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
@@ -2996,8 +3068,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     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
@@ -3142,7 +3216,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     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
@@ -3204,6 +3279,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     colourMenu.add(buriedColour);\r
     colourMenu.add(nucleotideColour);\r
     colourMenu.add(purinePyrimidineColour);\r
+    colourMenu.add(tcoffeeColour);\r
     colourMenu.add(userDefinedColour);\r
     colourMenu.addSeparator();\r
     colourMenu.add(conservationMenuItem);\r
@@ -3632,4 +3708,41 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   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
+         // TODO: refactor to string/standard jalview data importer\r
+         TCoffeeScoreFile file = TCoffeeScoreFile.load( new InputStreamReader( url.openStream() ) );\r
+         if( file == null ) {\r
+        // TODO: raise a dialog box here rather than bomb out.\r
+            \r
+                 throw new RuntimeException("The file provided does not match the T-Coffee scores file format");\r
+         }\r
+         \r
+         /*\r
+          * check that the score matrix matches the alignment dimensions\r
+          */\r
+         AlignmentI aln; \r
+         if( (aln=viewport.getAlignment()) != null && (aln.getHeight() != file.getHeight() || aln.getWidth() != file.getWidth()) ) {\r
+           // TODO: raise a dialog box here rather than bomb out.\r
+           throw new RuntimeException("The scores matrix does not match the alignment dimensions");\r
+                 \r
+         }\r
+         \r
+          // TODO add parameter to indicate if matching should be done\r
+         if (file.annotateAlignment(alignPanel.getAlignment(), false))\r
+         {\r
+                 tcoffeeColour.setEnabled(true);\r
+                 // switch to this color\r
+                 changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));\r
+          }\r
+  }\r
+  \r
+  \r
 }\r
index afbc7e3..044fcbe 100755 (executable)
  */
 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);
     }
     else if (forOverview
             && !jalview.util.Comparison.isGap(seq.getCharAt(i)))
index 77fd5ec..73df35f 100755 (executable)
  */
 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, null);
       } catch (Exception ex)
       {
       }
index 311e48d..342ff4c 100644 (file)
@@ -1823,8 +1823,7 @@ public class JalviewLite extends Applet implements
 \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
@@ -1865,6 +1864,24 @@ public class JalviewLite extends Applet implements
           }\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
+               \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
index 04977e8..708e566 100755 (executable)
@@ -805,10 +805,9 @@ public class Alignment implements AlignmentI
     annotations = temp;
   }
 
+  @Override
   /**
-   * DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
+   * returns all annotation on the alignment
    */
   public AlignmentAnnotation[] getAlignmentAnnotation()
   {
index a193997..a79106a 100755 (executable)
@@ -22,7 +22,7 @@ import java.util.*;
 /**
  * Data structure to hold and manipulate a multiple sequence alignment
  */
-public interface AlignmentI
+public interface AlignmentI extends AnnotatedCollectionI
 {
   /**
    * Calculates the number of sequences in an alignment
diff --git a/src/jalview/datamodel/AnnotatedCollectionI.java b/src/jalview/datamodel/AnnotatedCollectionI.java
new file mode 100644 (file)
index 0000000..d7a0339
--- /dev/null
@@ -0,0 +1,14 @@
+package jalview.datamodel;
+
+import java.util.List;
+
+public interface AnnotatedCollectionI
+{
+
+  /**
+   * TODO: decide if null is a valid response if there is no annotation on the object
+   * @return null
+   */
+  AlignmentAnnotation[] getAlignmentAnnotation();
+
+}
index b0969b5..cdb1921 100755 (executable)
  */
 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; }
 }
index 6bee416..e7c1a85 100755 (executable)
@@ -30,7 +30,7 @@ import jalview.schemes.*;
  * @author $author$
  * @version $Revision$
  */
-public class SequenceGroup
+public class SequenceGroup implements AnnotatedCollectionI
 {
   String groupName;
 
@@ -482,7 +482,10 @@ public class SequenceGroup
     {
       return;
     }
-
+    if (cs!=null)
+    {
+      cs.alignmentChanged(this);
+    }
     try
     {
       Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes,
@@ -1185,4 +1188,32 @@ public class SequenceGroup
   {
     return normaliseSequenceLogo;
   }
+  @Override
+  /**
+   * returns a new array with all annotation involving this group
+   */
+  public AlignmentAnnotation[] getAlignmentAnnotation()
+  {
+    // TODO add in other methods like 'getAlignmentAnnotation(String label), etc'
+    ArrayList<AlignmentAnnotation> annot = new ArrayList<AlignmentAnnotation>();
+    for (SequenceI seq:(Vector<SequenceI>)sequences)
+    {
+      for (AlignmentAnnotation al: seq.getAnnotation())
+      {
+        if (al.groupRef==this)
+        {
+          annot.add(al);
+        }
+      }
+    }
+    if (consensus!=null)
+    {
+      annot.add(consensus);
+    }
+    if (conservation!=null)
+    {
+      annot.add(conservation);
+    }
+    return annot.toArray(new AlignmentAnnotation[0]);
+  }
 }
index 3d91004..33045d0 100755 (executable)
@@ -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();
 
 }
index 9b571f2..6896fb7 100755 (executable)
@@ -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;
@@ -69,6 +70,7 @@ import jalview.schemes.PurinePyrimidineColourScheme;
 import jalview.schemes.RNAHelicesColourChooser;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TCoffeeColourScheme;
 import jalview.schemes.TaylorColourScheme;
 import jalview.schemes.TurnColourScheme;
 import jalview.schemes.UserColourScheme;
@@ -144,7 +146,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   AlignViewport viewport;
 
   Vector alignPanels = new Vector();
-
+  
   /**
    * Last format used to load or save alignments in this window
    */
@@ -3053,6 +3055,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void changeColour(ColourSchemeI cs)
   {
+    // TODO: compare with applet and pull up to model method
     int threshold = 0;
 
     if (cs != null)
@@ -3124,7 +3127,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         {
           try
           {
-            sg.cs = (ColourSchemeI) cs.getClass().newInstance();
+            sg.cs = cs.getClass().newInstance();
           } catch (Exception ex)
           {
           }
@@ -3922,7 +3925,84 @@ 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 ) { 
+                      // TODO: raise a dialog box here rather than bomb out.
+                 
+                         throw new RuntimeException("The file provided does not match the T-Coffee scores file format"); 
+                 }
+
+                 /*
+                  * check that the score matrix matches the alignment dimensions
+                  */
+                 AlignmentI aln; 
+                 if( (aln=viewport.getAlignment()) != null && (aln.getHeight() != result.getHeight() || aln.getWidth() != result.getWidth()) ) {
+                     // TODO: raise a dialog box here rather than bomb out.
+                   throw new RuntimeException("The scores matrix does not match the alignment dimensions");
+                 }
+                 if (result.annotateAlignment(alignPanel.getAlignment(), true))
+                 {
+                         tcoffeeColour.setEnabled(true);
+                         tcoffeeColour.setSelected(true);
+                         // switch to this color
+                         changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
+                 } else {
+                   tcoffeeColour.setEnabled(false);
+                   tcoffeeColour.setSelected(false);
+                 }
+             } 
+             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) {
+         changeColour( new TCoffeeColourScheme(alignPanel.getAlignment()) );
+  }
+  
+//  /**
+//   * 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);
index ad704c3..b294282 100755 (executable)
  */
 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);
     }
     else if (forOverview
             && !jalview.util.Comparison.isGap(seq.getCharAt(i)))
index aefc9c8..53e4ad3 100755 (executable)
  */
 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, null);
         } catch (Exception ex)
         {
         }
index a4fb830..3ef7210 100755 (executable)
  */
 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<SequenceI> 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<c; i++ ) {  
+       seqs.get(i).setIndex(i);  
+    }
   }
 
   /**
@@ -91,12 +98,16 @@ public abstract class AlignFile extends FileParse
     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;
   }
diff --git a/src/jalview/io/TCoffeeScoreFile.java b/src/jalview/io/TCoffeeScoreFile.java
new file mode 100644 (file)
index 0000000..6cab3ae
--- /dev/null
@@ -0,0 +1,474 @@
+package jalview.io;
+
+import jalview.analysis.SequenceIdMatcher;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.SequenceI;
+
+import java.awt.Color;
+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>();
+
+       Integer fWidth;
+
+       /**
+        * 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);
+               }
+       }
+               
+       /**
+        * @return The 'height' of the score matrix i.e. the numbers of score rows that should matches 
+        * the number of sequences in the alignment
+        */
+       public int getHeight() {
+               // the last entry will always be the 'global' alingment consensus scores, so it is removed 
+               // from the 'height' count to make this value compatible with the number of sequences in the MSA
+               return scores != null && scores.size() > 0 ? scores.size()-1 : 0;
+       }
+       
+       /**
+        * @return The 'width' of the score matrix i.e. the number of columns. 
+        * Since teh score value are supposd to be calculated for an 'aligned' MSA, all the entries 
+        * have to have the same width.  
+        */
+       public int getWidth() {
+               return fWidth != null ? fWidth : 0;
+       }
+       
+       /**
+        * 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() );
+                       }
+               }
+               
+               /*
+                * verify that all rows have the same width
+                */
+               for( StringBuilder str : scores.values() ) {
+                       if( fWidth == null ) {
+                               fWidth = str.length();
+                       }
+                       else if( fWidth != str.length() ) {
+                               throw new RuntimeException("Invalid T-Coffee score file: All the score sequences must have the same length");
+                       }
+               }
+               
+               
+               
+       }
+
+
+       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");
+               }
+       }
+       /**
+        * TCOFFEE score colourscheme
+        */
+       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
+               };
+       public final static String TCOFFEE_SCORE="TCoffeeScore";
+       /**
+        * generate annotation for this TCoffee score set on the given alignment
+        * @param al alignment to annotate
+        * @param matchids if true, annotate sequences based on matching sequence names
+        * @return true if alignment annotation was modified, false otherwise.
+        */
+       public boolean annotateAlignment(AlignmentI al, boolean matchids)
+       {
+         boolean added=false;
+         int i=0;
+         SequenceIdMatcher sidmatcher = new SequenceIdMatcher(al.getSequencesArray());
+         byte[][] scoreMatrix=getScoresArray();
+         // for 2.8 - we locate any existing TCoffee annotation and remove it first before adding this.
+         for (Map.Entry<String,StringBuilder> id:scores.entrySet())
+         {
+           byte[] srow=scoreMatrix[i];
+           SequenceI s;
+           if (matchids)
+           {
+             s=sidmatcher.findIdMatch(id.getKey());
+           } else {
+             s=al.getSequenceAt(i);
+           }
+           i++;
+            if (s==null && i!=scores.size() && !id.getKey().equals("cons"))
+            {
+              System.err.println("No "+(matchids ? "match ":" sequences left ")+" for TCoffee score set : "+id.getKey());
+              continue;
+            }
+            int jSize=al.getWidth()< srow.length ? al.getWidth() : srow.length;
+           Annotation[] annotations=new Annotation[al.getWidth()];
+           for (int j=0;j<jSize;j++) {
+             byte val = srow[j];
+             annotations[j]=new Annotation(s==null ? ""+val:null,s==null ? ""+val:null,(char) val,val*1f,val >= 0 && val < colors.length ? colors[val] : Color.white);
+           }
+           AlignmentAnnotation aa=null;
+           if (s!=null)
+           {
+             // TODO - set per sequence score
+             aa=new AlignmentAnnotation(TCOFFEE_SCORE, "Score for "+id.getKey(), annotations);
+             
+             aa.setSequenceRef(s);
+             aa.visible=false;
+             aa.belowAlignment=false;
+           } else {
+             aa=new AlignmentAnnotation("T-COFFEE", "TCoffee column reliability score", annotations);
+              aa.belowAlignment=true;
+             aa.visible=true;
+             
+           }
+           al.addAnnotation(aa);
+           added=true;
+         }
+         return added;
+       }
+         
+
+}
index 7ea492f..6e8b420 100755 (executable)
  */
 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
 {
@@ -120,6 +142,9 @@ public class GAlignFrame extends JInternalFrame
   // protected JRadioButtonMenuItem covariationColour = new
   // JRadioButtonMenuItem();
 
+  protected JRadioButtonMenuItem tcoffeeColour = new JRadioButtonMenuItem();
+  
   JMenuItem njTreeBlosumMenuItem = new JMenuItem();
 
   JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem();
@@ -181,6 +206,8 @@ public class GAlignFrame extends JInternalFrame
   JMenuItem epsFile = new JMenuItem();
 
   JMenuItem LoadtreeMenuItem = new JMenuItem();
+  
+  JMenuItem loadScoresMenuItem = new JMenuItem();
 
   public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
 
@@ -428,6 +455,7 @@ public class GAlignFrame extends JInternalFrame
     colours.add(nucleotideColour);
     colours.add(purinePyrimidineColour);
     // colours.add(covariationColour);
+    colours.add(tcoffeeColour);
 
     setColourSelected(jalview.bin.Cache
             .getDefault("DEFAULT_COLOUR", "None"));
@@ -497,6 +525,10 @@ public class GAlignFrame extends JInternalFrame
         nucleotideColour.setSelected(true);
 
         break;
+        
+      case ColourSchemeProperty.TCOFFEE:
+       tcoffeeColour.setSelected(true);
+       break;
 
       case ColourSchemeProperty.PURINEPYRIMIDINE:
         purinePyrimidineColour.setSelected(true);
@@ -1146,6 +1178,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()
@@ -1258,7 +1302,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)
@@ -1266,6 +1310,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()
@@ -1762,6 +1817,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);
@@ -1829,6 +1885,7 @@ public class GAlignFrame extends JInternalFrame
     colourMenu.add(nucleotideColour);
     colourMenu.add(purinePyrimidineColour);
     // colourMenu.add(covariationColour);
+    colourMenu.add(tcoffeeColour);
     colourMenu.add(userDefinedColour);
     colourMenu.addSeparator();
     colourMenu.add(conservationMenuItem);
@@ -2308,7 +2365,32 @@ public class GAlignFrame extends JInternalFrame
 
   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)
   {
index 41ee01c..6c46d0e 100755 (executable)
  */
 package jalview.schemes;
 
-import java.awt.*;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.GraphLine;
+import jalview.datamodel.SequenceI;
 
-import jalview.datamodel.*;
+import java.awt.Color;
 
 public class AnnotationColourGradient extends ResidueColourScheme
 {
@@ -152,7 +154,8 @@ public class AnnotationColourGradient extends ResidueColourScheme
    * 
    * @return DOCUMENT ME!
    */
-  public Color findColour(char c, int j)
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     Color currentColour = Color.white;
 
@@ -202,7 +205,7 @@ public class AnnotationColourGradient extends ResidueColourScheme
 
           if (colourScheme != null)
           {
-            currentColour = colourScheme.findColour(c, j);
+            currentColour = colourScheme.findColour(c, j, seq);
           }
           else if (range != 0)
           {
index e9ac579..0f04168 100755 (executable)
  */
 package jalview.schemes;
 
-import java.awt.*;
-
-import jalview.analysis.*;
+import jalview.analysis.AAFrequency;
 
+import java.awt.Color;
+import jalview.datamodel.SequenceI;
 public class Blosum62ColourScheme extends ResidueColourScheme
 {
   public Blosum62ColourScheme()
@@ -28,7 +28,8 @@ public class Blosum62ColourScheme extends ResidueColourScheme
     super();
   }
 
-  public Color findColour(char res, int j)
+  @Override
+  public Color findColour(char res, int j, SequenceI seq)
   {
     if ('a' <= res && res <= 'z')
     {
index 14f0ce6..273efb8 100755 (executable)
  */
 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
@@ -251,12 +251,14 @@ public class ClustalxColourScheme extends ResidueColourScheme // implements
     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, SequenceI seq)
   {
     Color currentColour;
 
index 5c036e3..9ebe791 100755 (executable)
  */
 package jalview.schemes;
 
-import java.awt.*;
+import java.awt.Color;
+
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceI;
 
 public interface ColourSchemeI
 {
   public Color findColour(char c);
 
-  public Color findColour(char c, int j);
+  public Color findColour(char c, int j, SequenceI seq);
 
   public void setConsensus(java.util.Hashtable[] h);
 
@@ -39,4 +42,6 @@ public interface ColourSchemeI
 
   public void setThreshold(int ct, boolean ignoreGaps);
 
+  public void alignmentChanged(AnnotatedCollectionI alignment);
+
 }
index f06c10f..cbd345c 100755 (executable)
@@ -17,7 +17,7 @@
  */
 package jalview.schemes;
 
-import java.awt.*;
+import java.awt.Color;
 
 /**
  * ColourSchemeProperty Binds names to hardwired colourschemes and tries to deal
@@ -81,6 +81,9 @@ public class ColourSchemeProperty
   public static final int PURINEPYRIMIDINE = 13;
 
   public static final int COVARIATION = 14;
+  
+  public static final int TCOFFEE = 15;
+  
 
   /**
    * index of first colourscheme (includes 'None')
@@ -145,6 +148,11 @@ public class ColourSchemeProperty
     {
       ret = NUCLEOTIDE;
     }
+    else if (name.equalsIgnoreCase("T-Coffee scores"))
+    {
+      ret = TCOFFEE;
+    }
+
     else if (name.equalsIgnoreCase("User Defined"))
     {
       ret = USER_DEFINED;
@@ -400,20 +408,21 @@ public class ColourSchemeProperty
   }
 
   /**
-   * DOCUMENT ME!
+   * Construct an instance of ColourSchemeI corresponding to the given colourscheme index
    * 
    * @param seqs
-   *          DOCUMENT ME!
+   *          sequences to be coloured by colourscheme
    * @param width
-   *          DOCUMENT ME!
+   *          geometry of alignment
    * @param index
-   *          DOCUMENT ME!
+   *          colourscheme number 
    * 
-   * @return DOCUMENT ME!
+   * @return null or an instance of the colourscheme configured to colour given sequence set
    */
   public static ColourSchemeI getColour(java.util.Vector seqs, int width,
           int index)
   {
+    // TODO 3.0 2.8 refactor signature to take an alignmentI like container so colourschemes based on annotation can be initialised
     ColourSchemeI cs = null;
 
     switch (index)
index 0e2ecff..2c63ddb 100755 (executable)
@@ -17,7 +17,9 @@
  */
 package jalview.schemes;
 
-import java.awt.*;
+import jalview.datamodel.SequenceI;
+
+import java.awt.Color;
 
 /**
  * DOCUMENT ME!
@@ -43,6 +45,7 @@ public class NucleotideColourScheme extends ResidueColourScheme
    * 
    * @return DOCUMENT ME!
    */
+  @Override
   public Color findColour(char c)
   {
     // System.out.println("called"); log.debug
@@ -59,7 +62,8 @@ public class NucleotideColourScheme extends ResidueColourScheme
    * 
    * @return DOCUMENT ME!
    */
-  public Color findColour(char c, int j)
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     Color currentColour;
     if ((threshold == 0) || aboveThreshold(c, j))
index 4e07cba..5301267 100755 (executable)
  */
 package jalview.schemes;
 
-import java.awt.*;
+import jalview.analysis.AAFrequency;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
 
-import jalview.analysis.*;
-import jalview.datamodel.*;
+import java.awt.Color;
 
 public class PIDColourScheme extends ResidueColourScheme
 {
@@ -36,7 +37,9 @@ public class PIDColourScheme extends ResidueColourScheme
     this.thresholds = ResidueProperties.pidThresholds;
   }
 
-  public Color findColour(char c, int j)
+  
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     if ('a' <= c && c <= 'z')
     {
index bc1e92b..90833c9 100755 (executable)
  */
 package jalview.schemes;
 
-import java.util.*;
+import jalview.analysis.AAFrequency;
+import jalview.analysis.Conservation;
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceI;
 
-import java.awt.*;
-
-import jalview.analysis.*;
+import java.awt.Color;
+import java.util.Hashtable;
 
 /**
  * DOCUMENT ME!
@@ -82,7 +84,8 @@ public class ResidueColourScheme implements ColourSchemeI
             : colors[ResidueProperties.aaIndex[c]];
   }
 
-  public Color findColour(char c, int j)
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     Color currentColour;
 
@@ -102,6 +105,7 @@ public class ResidueColourScheme implements ColourSchemeI
 
     return currentColour;
   }
+  @Override public void alignmentChanged(AnnotatedCollectionI alignment) {};
 
   /**
    * Get the percentage threshold for this colour scheme
index ca76c8e..116bbd8 100755 (executable)
@@ -17,7 +17,9 @@
  */
 package jalview.schemes;
 
-import java.awt.*;
+import jalview.datamodel.SequenceI;
+
+import java.awt.Color;
 
 /**
  * DOCUMENT ME!
@@ -85,7 +87,8 @@ public class ScoreColourScheme extends ResidueColourScheme
    * 
    * @return DOCUMENT ME!
    */
-  public Color findColour(char c, int j)
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     if (threshold > 0)
     {
diff --git a/src/jalview/schemes/TCoffeeColourScheme.java b/src/jalview/schemes/TCoffeeColourScheme.java
new file mode 100644 (file)
index 0000000..bbd2a23
--- /dev/null
@@ -0,0 +1,84 @@
+package jalview.schemes;
+
+import jalview.analysis.SequenceIdMatcher;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.SequenceI;
+import jalview.io.TCoffeeScoreFile;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.IdentityHashMap;
+import java.util.TreeMap;
+
+/**
+ * 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
+       };
+
+
+       IdentityHashMap<SequenceI, Color[]> seqMap;
+       /**
+        * the color scheme needs to look at the alignment to get and cache T-COFFEE scores 
+        * 
+        * @param alignment - annotated sequences to be searched
+        */
+       public TCoffeeColourScheme(AnnotatedCollectionI alignment) {
+         alignmentChanged(alignment);
+       }
+       @Override public void alignmentChanged(AnnotatedCollectionI alignment)
+       {
+          // assume only one set of TCOFFEE scores - but could have more than one potentially.
+          ArrayList<AlignmentAnnotation> annots = new ArrayList<AlignmentAnnotation>();
+          // Search alignment to get all tcoffee annotation and pick one set of annotation to use to colour seqs.
+          seqMap = new IdentityHashMap<SequenceI, Color[]>();
+          for (AlignmentAnnotation al:alignment.getAlignmentAnnotation())
+          {
+            if (al.sequenceRef!=null && !al.belowAlignment && al.label!=null && (al.label==TCoffeeScoreFile.TCOFFEE_SCORE || al.label.equals(TCoffeeScoreFile.TCOFFEE_SCORE)))
+            {
+              annots.add(al);
+              Color[] scores=new Color[al.annotations.length];
+              int i=0;
+              for (Annotation an:al.annotations)
+              {
+                scores[i++]=(an!=null) ? an.colour : Color.white;
+              }
+              seqMap.put(al.sequenceRef, scores);
+            }
+          }
+       }
+       @Override
+       public Color findColour(char c, int j, SequenceI seq) {
+          Color[] cols;
+
+         if( seqMap==null || (cols=seqMap.get(seq))==null) {
+           return Color.white;
+         }
+         
+         if( j < 0 || j>= cols.length ) {
+           return Color.white;
+         }
+         return cols[j];
+       }
+}
index 5034134..cdc618e 100755 (executable)
@@ -17,9 +17,9 @@
  */
 package jalview.schemes;
 
-import java.util.*;
-
-import java.awt.*;
+import java.awt.Color;
+import java.util.StringTokenizer;
+import jalview.datamodel.SequenceI;
 
 public class UserColourScheme extends ResidueColourScheme
 {
@@ -201,7 +201,8 @@ public class UserColourScheme extends ResidueColourScheme
 
   }
 
-  public Color findColour(char c, int j)
+  @Override
+  public Color findColour(char c, int j, SequenceI seq)
   {
     Color currentColour;
     int index = ResidueProperties.aaIndex[c];
diff --git a/test/jalview/io/TCoffeeScoreFileTest.java b/test/jalview/io/TCoffeeScoreFileTest.java
new file mode 100644 (file)
index 0000000..7257e14
--- /dev/null
@@ -0,0 +1,152 @@
+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 testHeightAndWidth() {
+               TCoffeeScoreFile result = TCoffeeScoreFile.load(new File("./test/jalview/io/tcoffee.score_ascii"));
+               assertNotNull(result);
+               assertEquals( 8, result.getHeight() );
+               assertEquals( 83, result.getWidth() );
+       }       
+       
+       @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] );
+               
+       } 
+       
+       
+       
+}
diff --git a/test/jalview/io/tcoffee.fasta_aln b/test/jalview/io/tcoffee.fasta_aln
new file mode 100644 (file)
index 0000000..63b12b1
--- /dev/null
@@ -0,0 +1,24 @@
+>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
diff --git a/test/jalview/io/tcoffee.score_ascii b/test/jalview/io/tcoffee.score_ascii
new file mode 100644 (file)
index 0000000..2b533a3
--- /dev/null
@@ -0,0 +1,37 @@
+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