<classpathentry kind="lib" path="lib/jetty-http-9.2.10.v20150310.jar"/>
<classpathentry kind="lib" path="lib/jetty-io-9.2.10.v20150310.jar"/>
<classpathentry kind="lib" path="lib/java-json.jar"/>
- <classpathentry kind="lib" path="lib/Jmol-14.2.14_2015.06.11.jar"/>
+ <classpathentry kind="lib" path="lib/Jmol-14.6.4_2016.10.26.jar"/>
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
<classpathentry kind="lib" path="lib/biojava-core-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/biojava-ontology-4.1.0.jar"/>
Licensing information for each library is given below:
JGoogleAnalytics_0.3.jar APL 2.0 License - http://code.google.com/p/jgoogleanalytics/
-Jmol-14.2.14_2015.06.11.jar GPL/LGPLv2 http://sourceforge.net/projects/jmol/files/
+Jmol-14.6.4_2016.10.26.jar GPL/LGPLv2 http://sourceforge.net/projects/jmol/files/
VARNAv3-93.jar GPL licenced software by K�vin Darty, Alain Denise and Yann Ponty. http://varna.lri.fr
activation.jar
apache-mime4j-0.6.jar
<property name="packageDir" value="dist" />
<property name="outputJar" value="jalview.jar" />
<!-- Jalview Applet JMol Jar Dependency -->
- <property name="jmolJar" value="JmolApplet-14.2.14_2015.06.11.jar" />
+ <property name="jmolJar" value="JmolApplet-14.6.4_2016.10.26.jar" />
<property name="varnaJar" value="VARNAv3-93.jar" />
<property name="jsoup" value="jsoup-1.8.1.jar" />
<property name="jsonSimple" value="json_simple-1.1.jar" />
<td>Main Jalview Applet Jar</td>
</tr>
<tr>
- <td><a href="http://www.jalview.org/builds/develop/examples/JmolApplet-14.2.14_2015.06.11.jar">JmolApplet-14.2.14_2015.06.11.jar</a> </td>
+ <td><a href="http://www.jalview.org/builds/develop/examples/JmolApplet-14.6.4_2016.10.26.jar">JmolApplet-14.6.4_2016.10.26.jar</a> </td>
<td>Jmol Applet Jar</td>
</tr>
<tr>
<p>To run Jalview applet in your web page download the Jars listed above. The snippet below shows a minimal code for embedding Jalview applet into a web page.
<pre><code>
-<applet code="jalview.bin.JalviewLite" width="756" height="560" archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+<applet code="jalview.bin.JalviewLite" width="756" height="560" archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox" />
<param name="file" value="plantfdx.fa" />
<param name="features" value="plantfdx.features" />
<td width="10%" valign="center">
<applet
code="jalview.bin.JalviewLite" width="140" height="35"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file" value="uniref50.fa"/>
<param name="treeFile" value="ferredoxin.nw"/>
<tr>
<td width="10%" valign="center"><applet
code="jalview.bin.JalviewLite" width="140" height="35"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file" value="uniref50.fa"/>
<param name="features" value="exampleFeatures.txt"/>
<tr>
<td width="10%" valign="center"><applet
code="jalview.bin.JalviewLite" width="140" height="35"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file" value="uniref50.fa"/>
<param name="showFullId" value="false"/>
<tr>
<td width="10%" valign="center"><applet
code="jalview.bin.JalviewLite" width="140" height="35"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file" value="jpred_msa.fasta"/>
<param name="jnetfile" value="jpred_msa.seq.concise"/>
<tr>
<td width="10%" valign="center"><applet
code="jalview.bin.JalviewLite" width="140" height="35"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file" value="RF00031_folded.stk"/>
<param name="showFullId" value="false"/>
<td width="10%" valign="center">
<applet
code="jalview.bin.JalviewLite" width="140" height="35"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file2" value="estrogenReceptorCdna_frag.fa"/>
<param name="file" value="estrogenReceptorProtein_frag.fa"/>
<a href="view-source:http://www.jalview.org/builds/develop/examples/embedded.html" target="_blank">View the source code for this example here</a> (If the link doesn't work on your browser try going to <a href="http://www.jalview.org/builds/develop/examples/embedded.html">this page</a> and viewing the page source manually).<p>
<applet
code="jalview.bin.JalviewLite" width="756" height="560"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="file" value="plantfdx.fa"/>
<param name="features" value="plantfdx.features"/>
<script language="JavaScript">
// instead of this, we use a custom JmolApplet spec
// jmolInitialize('jmol');
-jmolInitialize("","JmolApplet-14.2.14_2015.06.11.jar");
+jmolInitialize("","JmolApplet-14.6.4_2016.10.26.jar");
</script>
<script>
var loglevel=1;
var _jvA=new Object();
_jvA.attributes = {
code : 'jalview.bin.JalviewLite',
- archive : 'jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar',
+ archive : 'jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar',
width : '500',
height : '350',
mayscript : 'True',
</div>
<div>
<applet
- code="jalview.bin.JalviewLite" width="500" height="350" id="jvA" mayscript="mayscript" archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ code="jalview.bin.JalviewLite" width="500" height="350" id="jvA" mayscript="mayscript" archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="permissions" value="sandbox"/>
<param name="java_arguments" value="-Xmx256m"/>
<param name="externalstructureviewer" value="true"/>
<a href="view-source:http://www.jalview.org/builds/develop/examples/formComplete.html" target="_blank">View the source here to see how it has been done</a> (If the link doesn't work on your browser try going to <a href="http://www.jalview.org/builds/develop/examples/formComplete.html">this page</a> and viewing the page source manually).<br/>
<a name="api">View the full <a href="javascript:doSubmit('jalviewLiteJs')">JalviewLite API documentation</a>.</a>
<applet code="jalview.bin.JalviewLite" width="0" height="0"
- archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar" name="Jalview">
+ archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar" name="Jalview">
<param name="file" value="plantfdx.fa"/>
<param name="features" value="plantfdx.features"/>
</SCRIPT>
<form name="Form1">
<applet name="JalviewLite" code="jalview.bin.JalviewLite"
-archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar" width="0" height="0">
+archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar" width="0" height="0">
<param name="debug" value="true"/>
<param name="showbutton" value="false"/>
</applet>
<applet
- code="jalview.bin.JalviewLite" width="800" height="300" id="jvapp" mayscript="True" scriptable="True" archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ code="jalview.bin.JalviewLite" width="800" height="300" id="jvapp" mayscript="True" scriptable="True" archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="oninit" value="lJvApp"/>
<param name="automaticScrolling" value="true"/>
<param name="file" value="plantfdx.fa"/>
<applet
- code="jalview.bin.JalviewLite" width="800" height="300" id="jvfollower" mayscript="True" scriptable="True" archive="jalviewApplet.jar,JmolApplet-14.2.14_2015.06.11.jar,java-json.jar,json_simple-1.1.jar">
+ code="jalview.bin.JalviewLite" width="800" height="300" id="jvfollower" mayscript="True" scriptable="True" archive="jalviewApplet.jar,JmolApplet-14.6.4_2016.10.26.jar,java-json.jar,json_simple-1.1.jar">
<param name="oninit" value="lJvFollow"/>
<param name="file" value="plantfdx.fa"/>
<param name="annotations" value="plantfdx.annotations"/>
number and chain code ([RES]Num:Chain). Moving the mouse over an
associated residue in an alignment window highlights the associated
atoms in the displayed structures. When residues are selected in the
- Chimera window, they are highlighted on the alignment. For
- comprehensive details of Chimera's commands, refer to the tool's
- Help menu.
+ Chimera window, they are highlighted on the alignment.
+ <p>For comprehensive details of Chimera's commands, refer to the
+ tool's Help menu.</p>
+ <p>
+ <strong>Selecting residues in Jalview from Chimera</strong><br />
+ When a selection is highlighted in a Jalview window, use the
+ <em>Select→Select Highlighted Region</em> or press <em>B</em>
+ to add the mapped positions to the alignment window's column
+ selection.
+ </p>
<p>
Basic screen operations (see <a
href="http://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/mouse.html">Chimera
<td><div align="left">Create Scalable Vector Graphics
file FILE from alignment.</div></td>
</tr>
+ <tr>
+ <td><div align="center">-biojsMSA FILE</div></td>
+ <td><div align="left">Write an HTML page to display
+ the alignment with the <a href="biojsmsa.html">
+ BioJS MSAviewer MSA</a>
+ </div>
+ </td>
+ </tr>
</table>
</body>
</html>
based structure superposition was added in Jalview 2.6</em>
</p>
<p>
- <strong>Controls</strong><br> The structure is by default
- rendered as a ribbon diagram. Moving the mouse over the structure
- brings up tooltips giving the residue name, PDB residue number and
- chain code, atom name and number
- ([RES]Num:Chain.AtomName#AtomNumber). If a mapping exists to a
- residue in any associated sequences, then this will be highlighted
- in each one's alignment window. The converse also occurs - moving
- the mouse over an associated residue in an alignment window
- highlights the associated atoms in the displayed structures.
+ <strong>Controls</strong><br> The structure is by default rendered
+ as a ribbon diagram. Moving the mouse over the structure brings up
+ tooltips giving the residue name, PDB residue number and chain code,
+ atom name and number ([RES]Num:Chain.AtomName#AtomNumber). If a
+ mapping exists to a residue in any associated sequences, then this
+ will be highlighted in each one's alignment window. The converse
+ also occurs - moving the mouse over an associated residue in an
+ alignment window highlights the associated atoms in the displayed
+ structures. Press B or use
+ <em>Select→Select Highlighted columns</em> from any linked
+ alignment window to mark the columns highlighted after mousing over
+ the structure.
</p>
<p>Selecting a residue highlights its associated sequence residue
and alpha carbon location. Double clicking an atom allows distances
Settings" under the "View" menu to change the
visibility and colour of the new sequence feature.</p>
<p>
+ <p>
+ <strong>Selecting regions from Search Results</strong>
+ </p>
+ <p>
+ Press 'B' or select the <em>Select Highlighted Columns</em> option
+ from the alignment window's select menu to add columns containing
+ highlighted search results to the alignment window's column
+ selection.
+ </p>
+ <p>
+
<strong>A quick Regular Expression Guide</strong>
</p>
<p>A regular expression is not just a simple text query - although
<td>Both</td>
<td>Launches the search window</td>
</tr>
+ <tr><td><strong>B</strong></td>
+ <td>Both</td>
+ <td>Mark the currently highlighted columns</td>
+ </tr>
+ <tr><td><strong>Alt 'B'</strong></td>
+ <td>Both</td>
+ <td>Mark all but the currently highlighted columns</td>
+ </tr>
+ <tr><td><strong>Control 'B'</strong></td>
+ <td>Both</td>
+ <td>Toggle the marks on the currently highlighted
+ columns (or all others if Alt is pressed)</td>
+ </tr>
<tr>
<td><strong>H</strong></td>
<td>Both</td>
Columns by Annotation</a></strong> <br /> <em>Select or Hide
columns in the alignment according to secondary structure,
labels and values shown in alignment annotation rows. </em></li>
+ <li><strong>Select Highlighted Columns</strong> <br /> <em>Selects
+ the columns currently highlighted as a result of a find, mouse
+ over, or selection event from a linked structure viewer or other
+ application. Modifiers will work on some platforms: ALT will add
+ all but the highlighted set to the column selection, and CTRL
+ (or META) will toggle the selection. </em></li>
</ul></li>
<li><strong>View</strong>
<ul>
Columns by Annotation</a></strong> <br /> <em>Select or Hide columns
in the alignment according to secondary structure, labels and
values shown in alignment annotation rows. </em></li>
+ <li><strong>Select Highlighted Columns</strong> <br /> <em>Selects
+ the columns currently highlighted as a result of a find, mouse
+ over, or selection event from a linked structure viewer or other
+ application. Modifiers will work on some platforms: ALT will add
+ all but the highlighted set to the column selection, and CTRL
+ (or META) will toggle the selection. </em></li>
</ul>
</body>
</html>
<td width="60" nowrap>
<div align="center">
<strong><a name="Jalview.2.10.1">2.10.1</a><br />
- <em>22/11/2016</em></strong>
+ <em>24/11/2016</em></strong>
</div>
</td>
<td><div align="left">
- <em>General</em>
- <ul>
- <li><!-- JAL-98 -->Improved memory usage: sparse arrays used for all consensus calculations</li>
- <li><!-- JAL- --></li>
+ <em>General</em>
+ <ul>
+ <li>
+ <!-- JAL-98 -->Improved memory usage: sparse arrays used
+ for all consensus calculations
+ </li>
+ <li>
+ <!-- JAL-2177 -->Updated Jmol shipped with applet and
+ desktop to 14.6.4
+ </li>
+ <li>
+ <!-- -->
+ </li>
+
</ul>
<em>Application</em>
<ul>
- <li><!-- JAL-1723 -->Sequence ID tool tips have been tamed (databases sorted alphabetically, abridged ID sets) </li>
- <li><!-- JAL-2282-->New replacement token for creating URLs <em>just</em> from database cross references. Users with custom links will receive a warning dialog asking them to update their preferences.</li>
- <li><!-- JAL-2287-->Cancel button and escape listener on dialog warning user about disconnecting Jalview from a Chimera session</li>
- <li><!-- JAL-2281-->Custom URL links for database cross-references are matched to database name regardless of case</li>
- <li></li>
-
+ <li>
+ <!-- JAL-1723 -->Sequence ID tool tips have been tamed
+ (databases sorted alphabetically, abridged ID sets)
+ </li>
+ <li>
+ <!-- JAL-2282-->New replacement token for creating URLs <em>just</em>
+ from database cross references. Users with custom links
+ will receive a warning dialog asking them to update their
+ preferences.
+ </li>
+ <li>
+ <!-- JAL-2287-->Cancel button and escape listener on
+ dialog warning user about disconnecting Jalview from a
+ Chimera session
+ </li>
+ <li>
+ <!-- JAL-2320-->Jalview's chimera control window closes if
+ the Chimera it is connected to is shut down
+ </li>
+ <li>
+ <!-- JAL-2281-->Custom URL links for database
+ cross-references are matched to database name regardless
+ of case
+ </li>
+ <li>
+ <!-- JAL-1738-->Select highlighted columns menu item and
+ keystroke (B) to mark columns containing highlighted
+ regions from structure selections or results of a Find
+ operation
+ </li>
+ <li>
+ <!-- JAL-2284-->Command line option for batch-generation
+ of HTML pages rendering alignment data with the BioJS
+ MSAviewer
+ </li>
+
</ul>
<em>Applet</em>
</ul>
<em>Build and deployment</em>
<ul>
- <li></li>
+ <li>Updated Jalview's Certum code signing certificate
+ for 2016-2017</li>
</ul>
- </div>
- </td>
+ </div></td>
<td>
<div align="left">
<em>General</em>
<ul>
- <li><!-- JAL-2286 -->Columns with more than one modal residue are not coloured or thresholded according to percent identity (first observed in Jalview 2.8.2)</li>
- <li><!-- JAL-2301 -->Threonine incorrectly reported as not hydrophobic</li>
- <li><!-- JAL-2318 -->Updates to documentation pages (above PID threshold, amino acid properties)</li>
- <li><!-- JAL-2292 -->Lower case residues in sequences are not reported as mapped to residues in a structure file in the View Mapping report</li>
+ <li>
+ <!-- JAL-2286 -->Columns with more than one modal residue
+ are not coloured or thresholded according to percent
+ identity (first observed in Jalview 2.8.2)
+ </li>
+ <li>
+ <!-- JAL-2301 -->Threonine incorrectly reported as not
+ hydrophobic
+ </li>
+ <li>
+ <!-- JAL-2318 -->Updates to documentation pages (above PID
+ threshold, amino acid properties)
+ </li>
+ <li>
+ <!-- JAL-2292 -->Lower case residues in sequences are not
+ reported as mapped to residues in a structure file in the
+ View Mapping report
+ </li>
+ <li>
+ <!--JAL-2324 -->Identical features with non-numeric scores
+ could be added multiple times to a sequence
+ </li>
+ <li>
+ <!--JAL-2323, JAL-2333,JAL-2335,JAL-2327 -->Disulphide
+ bond features shown as two highlighted residues rather
+ than a range in linked structure views, and treated
+ correctly when selecting and computing trees from features
+ </li>
+
</ul>
<em>Application</em>
<ul>
- <li><!-- JAL-2282-->Custom URL links for specific database names without regular expressions also offer invalid links from Sequence ID</li>
- <li><!-- JAL-2315-->Removing a single configured link in the URL links pane in Connections preferences doesn't actually update Jalview configuration</li>
- <li><!-- JAL-2272-->CTRL-Click on a selected region to open the alignment area popup menu doesn't work on El-Capitan</li>
- <li><!-- JAL-2280 -->Jalview doesn't offer to associate mmCIF files with similarly named sequences if dropped onto the alignment</li>
- <li><!-- JAL-2312 -->Additional mappings are shown for PDB entries where more chains exist in the PDB accession than are reported in the SIFTS file</li>
- <li><!-- --></li>
- <li><!-- --></li>
- <li><!-- --></li>
+ <li>
+ <!-- JAL-2282-->Custom URL links for specific database
+ names without regular expressions also offer links from
+ Sequence ID
+ </li>
+ <li>
+ <!-- JAL-2315-->Removing a single configured link in the
+ URL links pane in Connections preferences doesn't actually
+ update Jalview configuration
+ </li>
+ <li>
+ <!-- JAL-2272-->CTRL-Click on a selected region to open
+ the alignment area popup menu doesn't work on El-Capitan
+ </li>
+ <li>
+ <!-- JAL-2280 -->Jalview doesn't offer to associate mmCIF
+ files with similarly named sequences if dropped onto the
+ alignment
+ </li>
+ <li>
+ <!-- JAL-2312 -->Additional mappings are shown for PDB
+ entries where more chains exist in the PDB accession than
+ are reported in the SIFTS file
+ </li>
+ <li>
+ <!-- JAL-2317-->Certain structures do not get mapped to
+ the structure view when displayed with Chimera
+ </li>
+ <li>
+ <!-- JAL-2317-->No chains shown in the Chimera view
+ panel's View->Show Chains submenu
+ </li>
+ <li>
+ <!--JAL-2277 -->Export as HTML with embedded SVG doesn't
+ work for wrapped alignment views
+ </li>
+ <li>
+ <!--JAL-2197 -->Rename UI components for running JPred
+ predictions from 'JNet' to 'JPred'
+ </li>
+ <li>
+ <!-- JAL-2337,JAL-2277 -->Export as PNG or SVG is
+ corrupted when annotation panel vertical scroll is not at
+ first annotation row
+ </li>
+ <li>
+ <!--JAL- -->
+ </li>
</ul>
<em>Applet</em>
<ul>
</ul>
<em>Build and deployment</em>
<ul>
- <li><!-- JAL-2308, -->Failing/passing unit tests</li>
+ <li>
+ <!-- JAL-2308, -->Failing/passing unit tests
+ </li>
</ul>
<em>New Known Issues</em>
<ul>
<!-- JAL-1887 -->Incorrect start and end reported for PDB
to sequence mapping in 'View Mappings' report
</li>
+ <li>
+ <!-- JAL-2284 -->Unable to read old Jalview projects that
+ contain non-XML data added after Jalvew wrote project.
+ </li>
+ <li><!-- JAL-2118 -->Newly created annotation row reorders
+ after clicking on it to create new annotation for a
+ column.
+ </li>
<!-- may exclude, this is an external service stability issue JAL-1941
-- > RNA 3D structure not added via DSSR service</li> -->
</ul>
</ul> <em>Applet</em>
<ul>
<li>Split frame example added to applet examples page</li>
+ </ul><em>Build and Deployment</em>
+ <ul>
+ <li><!-- JAL-1888 -->New ant target for running Jalview's test suite</li>
</ul></td>
<td>
<div align="left">
file.reference.jaxrpc.jar=lib/jaxrpc.jar
file.reference.JGoogleAnalytics_0.3.jar=lib/JGoogleAnalytics_0.3.jar
file.reference.jhall.jar=lib/jhall.jar
-file.reference.Jmol-14.2.14_2015.06.11.jar=lib/Jmol-14.2.14_2015.06.11.jar
-file.reference.JmolApplet-14.2.14_2015.06.11.jar=appletlib/JmolApplet-14.2.14_2015.06.11.jar
+file.reference.Jmol-14.6.4_2016.10.26.jar=lib/Jmol-14.6.4_2016.10.26.jar
+file.reference.JmolApplet-14.6.4_2016.10.26.jar=appletlib/JmolApplet-14.6.4_2016.10.26.jar
file.reference.log4j-1.2.8.jar=lib/log4j-1.2.8.jar
file.reference.mail.jar=lib/mail.jar
file.reference.min-jaba-client.jar=lib/min-jaba-client-2.0.jar
${file.reference.jaxrpc.jar}:\
${file.reference.JGoogleAnalytics_0.3.jar}:\
${file.reference.jhall.jar}:\
- ${file.reference.Jmol-14.2.14_2015.06.11.jar}:\
+ ${file.reference.Jmol-14.6.4_2016.10.26.jar}:\
${file.reference.miglayout-4.0-swing.jar}:\
${file.reference.log4j-1.2.8.jar}:\
${file.reference.mail.jar}:\
${file.reference.xml-apis.jar}:\
${file.reference.xercesImpl.jar}:\
${file.reference.wsdl4j.jar}:\
- ${file.reference.JmolApplet-14.2.14_2015.06.11.jar} \
+ ${file.reference.JmolApplet-14.6.4_2016.10.26.jar} \
${file.reference.varna-3.9-dev.jar}
# Space-separated list of extra javac options
javac.compilerargs=
action.colour = Colour
action.calculate = Calculate
action.select_all = Select all
+action.select_highlighted_columns = Select Highlighted Columns
+tooltip.select_highlighted_columns = Press B to mark highlighted columns, Ctrl-B to toggle, and Alt-B to mark all but highlighted columns
action.deselect_all = Deselect all
action.invert_selection = Invert selection
action.using_jmol = Using Jmol
package jalview.analysis;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
-import jalview.datamodel.Sequence;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.util.Comparison;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Vector;
+import com.stevesoft.pat.Regex;
+
public class Finder
{
/**
* Implements the search algorithms for the Find dialog box.
*/
- SearchResults searchResults;
+ SearchResultsI searchResults;
AlignmentI alignment;
- jalview.datamodel.SequenceGroup selection = null;
+ SequenceGroup selection = null;
- Vector idMatch = null;
+ Vector<SequenceI> idMatch = null;
boolean caseSensitive = false;
boolean findAll = false;
- com.stevesoft.pat.Regex regex = null;
+ Regex regex = null;
/**
- * hold's last-searched position between calles to find(false)
+ * holds last-searched position between calls to find(false)
*/
int seqIndex = 0, resIndex = -1;
{
searchString = searchString.toUpperCase();
}
- regex = new com.stevesoft.pat.Regex(searchString);
+ regex = new Regex(searchString);
regex.setIgnoreCase(!caseSensitive);
searchResults = new SearchResults();
- idMatch = new Vector();
- Sequence seq;
+ idMatch = new Vector<SequenceI>();
String item = null;
boolean found = false;
int end = alignment.getHeight();
selection = null;
}
}
+ SearchResultMatchI lastm = null;
while (!found && (seqIndex < end))
{
- seq = (Sequence) alignment.getSequenceAt(seqIndex);
+ SequenceI seq = alignment.getSequenceAt(seqIndex);
if ((selection != null && selection.getSize() > 0)
&& !selection.getSequences(null).contains(seq))
{
}
- if (regex.search(seq.getName()))
+ if (regex.search(seq.getName()) && !idMatch.contains(seq))
{
idMatch.addElement(seq);
hasResults = true;
}
if (isIncludeDescription() && seq.getDescription() != null
- && regex.search(seq.getDescription()))
+ && regex.search(seq.getDescription())
+ && !idMatch.contains(seq))
{
idMatch.addElement(seq);
hasResults = true;
}
// /Shall we ignore gaps???? - JBPNote: Add Flag for forcing this or not
- StringBuffer noGapsSB = new StringBuffer();
+ StringBuilder noGapsSB = new StringBuilder();
int insertCount = 0;
- Vector spaces = new Vector();
+ List<Integer> spaces = new ArrayList<Integer>();
for (int j = 0; j < item.length(); j++)
{
- if (!jalview.util.Comparison.isGap(item.charAt(j)))
+ if (!Comparison.isGap(item.charAt(j)))
{
noGapsSB.append(item.charAt(j));
- spaces.addElement(new Integer(insertCount));
+ spaces.add(Integer.valueOf(insertCount));
}
else
{
}
String noGaps = noGapsSB.toString();
-
for (int r = resIndex; r < noGaps.length(); r++)
{
resIndex = regex.matchedFrom();
if ((selection != null && selection.getSize() > 0)
- && ((resIndex + Integer.parseInt(spaces.elementAt(
- resIndex).toString())) < selection.getStartRes()))
+ && (resIndex + spaces.get(resIndex) < selection
+ .getStartRes()))
{
continue;
}
// if invalid string used, then regex has no matched to/from
- int sres = seq
- .findPosition(resIndex
- + Integer.parseInt(spaces.elementAt(resIndex)
- .toString()));
- int eres = seq.findPosition(regex.matchedTo()
- - 1
- + Integer.parseInt(spaces
- .elementAt(regex.matchedTo() - 1).toString()));
-
- searchResults.addResult(seq, sres, eres);
+ int sres = seq.findPosition(resIndex + spaces.get(resIndex));
+ int eres = seq.findPosition(regex.matchedTo() - 1
+ + (spaces.get(regex.matchedTo() - 1)));
+ // only add result if not contained in previous result
+ if (lastm == null
+ || (lastm.getSequence() != seq || (!(lastm.getStart() <= sres && lastm
+ .getEnd() >= eres))))
+ {
+ lastm = searchResults.addResult(seq, sres, eres);
+ }
hasResults = true;
if (!findAll)
{
}
/**
- * @return the idMatch
+ * Returns the (possibly empty) list of matching sequences (when search
+ * includes searching sequence names)
+ *
+ * @return
*/
- public Vector getIdMatch()
+ public Vector<SequenceI> getIdMatch()
{
return idMatch;
}
/**
* @return the searchResults
*/
- public SearchResults getSearchResults()
+ public SearchResultsI getSearchResults()
{
return searchResults;
}
public boolean parseFeaturesFile(String file, String protocol,
boolean relaxedIdMatching);
+ /**
+ * mark columns containing highlighted regions (e.g. from search, structure
+ * highlight, or a mouse over event in another viewer)
+ *
+ * @param invert
+ * @param extendCurrent
+ * @param toggle
+ * @return
+ */
+ boolean markHighlightedColumns(boolean invert, boolean extendCurrent,
+ boolean toggle);
+
}
import jalview.datamodel.CigarArray;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.ProfilesI;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
* @return true if group is defined on the alignment
*/
boolean isSelectionDefinedGroup();
+
+ /**
+ *
+ * @return true if there are search results on the view
+ */
+ boolean hasSearchResults();
+
+ /**
+ * set the search results for the view
+ *
+ * @param results
+ * - or null to clear current results
+ */
+ void setSearchResults(SearchResultsI results);
+
+ /**
+ * get search results for this view (if any)
+ *
+ * @return search results or null
+ */
+ SearchResultsI getSearchResults();
}
void addPDB()
{
- if (seq.getAllPDBEntries() != null)
+ Vector<PDBEntry> pdbs = seq.getAllPDBEntries();
+ if (pdbs != null&& !pdbs.isEmpty())
{
- PDBEntry entry = seq.getAllPDBEntries().firstElement();
+ PDBEntry entry = pdbs.firstElement();
if (ap.av.applet.jmolAvailable)
{
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
* there is no complement, or it is not following highlights, or no mapping
* is found, the result will be empty.
*/
- SearchResults sr = new SearchResults();
+ SearchResultsI sr = new SearchResults();
int seqOffset = findComplementScrollTarget(sr);
if (!sr.isEmpty())
{
import jalview.api.AlignmentViewPanel;
import jalview.bin.JalviewLite;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
import jalview.structure.StructureSelectionManager;
* Highlight the given results on the alignment.
*
*/
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
scrollToPosition(results);
seqPanel.seqCanvas.highlightSearchResults(results);
* @param results
* @return false if results were not found
*/
- public boolean scrollToPosition(SearchResults results)
+ public boolean scrollToPosition(SearchResultsI results)
{
return scrollToPosition(results, true);
}
* - when set, the overview will be recalculated (takes longer)
* @return false if results were not found
*/
- public boolean scrollToPosition(SearchResults results,
+ public boolean scrollToPosition(SearchResultsI results,
boolean redrawOverview)
{
- return scrollToPosition(results, redrawOverview, false);
+ return scrollToPosition(results, 0, redrawOverview, false);
}
/**
* - when set, the overview will be recalculated (takes longer)
* @return false if results were not found
*/
- public boolean scrollToPosition(SearchResults results,
+ public boolean scrollToPosition(SearchResultsI results,
+ int verticalOffset,
boolean redrawOverview, boolean centre)
{
// do we need to scroll the panel?
{
return false;
}
+ /*
+ * allow for offset of target sequence (actually scroll to one above it)
+ */
+
SequenceI seq = alignment.getSequenceAt(seqIndex);
int[] r = results.getResults(seq, 0, alignment.getWidth());
if (r == null)
{
return false;
}
+
+ /*
+ * allow for offset of target sequence (actually scroll to one above it)
+ */
+ seqIndex = Math.max(0, seqIndex - verticalOffset);
return scrollTo(start, end, seqIndex, false, redrawOverview);
}
return true;
{
start = ostart;
}
+
if (!av.getWrapAlignment())
{
/*
* @param seqOffset
* the number of visible sequences to show above the mapped region
*/
- protected void scrollToCentre(SearchResults sr, int seqOffset)
+ protected void scrollToCentre(SearchResultsI sr, int seqOffset)
{
/*
* To avoid jumpy vertical scrolling (if some sequences are gapped or not
* mapped), we can make the scroll-to location a sequence above the one
* actually mapped.
*/
- SequenceI mappedTo = sr.getResultSequence(0);
+ SequenceI mappedTo = sr.getResults().get(0).getSequence();
List<SequenceI> seqs = av.getAlignment().getSequences();
/*
{
return; // failsafe, shouldn't happen
}
- sequenceIndex = Math.max(0, sequenceIndex - seqOffset);
- sr.getResults().get(0)
- .setSequence(av.getAlignment().getSequenceAt(sequenceIndex));
/*
* Scroll to position but centring the target residue. Also set a state flag
* to prevent adjustmentValueChanged performing this recursively.
*/
setFollowingComplementScroll(true);
- scrollToPosition(sr, true, true);
+ // this should be scrollToPosition(sr,verticalOffset,
+ scrollToPosition(sr, seqOffset, true, true);
}
private void sendViewPosition()
import java.awt.Container;
import java.util.Map;
-import javajs.awt.Dimension;
-
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.console.AppletConsole;
import org.jmol.java.BS;
}
@Override
- public Dimension resizeInnerPanel(String data)
+ public int[] resizeInnerPanel(String data)
{
// TODO Auto-generated method stub
return null;
import jalview.api.FeatureColourI;
import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.io.FeaturesFile;
start.setText(features[index].getBegin() + "");
end.setText(features[index].getEnd() + "");
- SearchResults highlight = new SearchResults();
+ SearchResultsI highlight = new SearchResults();
highlight.addResult(sequences[0], features[index].getBegin(),
features[index].getEnd());
*/
package jalview.appletgui;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultMatchI;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
Frame frame;
- SearchResults searchResults;
+ SearchResultsI searchResults;
int seqIndex = 0;
frame.repaint();
frame.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent evt)
{
ap.highlightSearchResults(null);
textfield.requestFocus();
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == textfield)
SequenceFeature[] features = new SequenceFeature[searchResults
.getSize()];
- for (int i = 0; i < searchResults.getSize(); i++)
+ int i = 0;
+ for (SearchResultMatchI match : searchResults.getResults())
{
- seqs[i] = searchResults.getResultSequence(i);
+ seqs[i] = match.getSequence().getDatasetSequence();
features[i] = new SequenceFeature(textfield.getText().trim(),
- "Search Results", null, searchResults.getResultStart(i),
- searchResults.getResultEnd(i), "Search Results");
+ "Search Results", null, match.getStart(), match.getEnd(),
+ "Search Results");
+ i++;
}
if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
seqIndex = finder.getSeqIndex();
resIndex = finder.getResIndex();
searchResults = finder.getSearchResults();
- Vector idMatch = finder.getIdMatch();
+ Vector<SequenceI> idMatch = finder.getIdMatch();
boolean haveResults = false;
// set or reset the GUI
if ((idMatch.size() > 0))
textfield.setBounds(new Rectangle(40, 17, 133, 21));
textfield.addKeyListener(new java.awt.event.KeyAdapter()
{
+ @Override
public void keyTyped(KeyEvent e)
{
textfield_keyTyped(e);
package jalview.appletgui;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.renderer.ScaleRenderer;
AlignViewport av;
- SearchResults searchResults = null;
-
boolean fastPaint = false;
int cursorX = 0;
// / Highlight search Results once all sequences have been drawn
// ////////////////////////////////////////////////////////
- if (searchResults != null)
+ if (av.hasSearchResults())
{
- int[] visibleResults = searchResults.getResults(nextSeq, startRes,
+ int[] visibleResults = av.getSearchResults().getResults(nextSeq,
+ startRes,
endRes);
if (visibleResults != null)
{
}
}
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
- searchResults = results;
-
+ av.setSearchResults(results);
repaint();
}
import jalview.commands.EditCommand.Action;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
-import jalview.datamodel.SearchResults.Match;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
* @param results
* @return true if results were matched, false if not
*/
- private boolean setStatusMessage(SearchResults results)
+ private boolean setStatusMessage(SearchResultsI results)
{
AlignmentI al = this.av.getAlignment();
int sequenceIndex = al.findIndex(results);
return false;
}
SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence();
- for (Match m : results.getResults())
+ for (SearchResultMatchI m : results.getResults())
{
SequenceI seq = m.getSequence();
if (seq.getDatasetSequence() != null)
if (features != null && features.length > 0)
{
- SearchResults highlight = new SearchResults();
+ SearchResultsI highlight = new SearchResults();
highlight.addResult(sequence, features[0].getBegin(),
features[0].getEnd());
seqCanvas.highlightSearchResults(highlight);
}
@Override
- public void highlightSequence(SearchResults results)
+ public void highlightSequence(SearchResultsI results)
{
if (av.isFollowHighlight())
{
SequenceFeature[] sfs = sq.getSequenceFeatures();
if (sfs != null)
{
- /*
- * check whether the feature start/end (base 1)
- * overlaps the selection start/end
- */
int ist = sq.findIndex(sq.getStart());
int iend = sq.findIndex(sq.getEnd());
if (iend < startPosition || ist > endPosition)
// - findIndex wastes time by starting from first character and
// counting
- int i = sq.findIndex(sf.getBegin());
- int j = sq.findIndex(sf.getEnd());
- if (j < startPosition || i > endPosition)
+ int sfStartCol = sq.findIndex(sf.getBegin());
+ int sfEndCol = sq.findIndex(sf.getEnd());
+
+ if (sf.isContactFeature())
+ {
+ /*
+ * 'contact' feature - check for 'start' or 'end'
+ * position within the selected region
+ */
+ if (sfStartCol >= startPosition
+ && sfStartCol <= endPosition)
+ {
+ bs.set(sfStartCol - 1);
+ sequenceHasFeature = true;
+ }
+ if (sfEndCol >= startPosition && sfEndCol <= endPosition)
+ {
+ bs.set(sfEndCol - 1);
+ sequenceHasFeature = true;
+ }
+ continue;
+ }
+
+ /*
+ * contiguous feature - select feature positions (if any)
+ * within the selected region
+ */
+ if (sfStartCol > endPosition || sfEndCol < startPosition)
{
// feature is outside selected region
continue;
}
sequenceHasFeature = true;
- if (i < startPosition)
+ if (sfStartCol < startPosition)
{
- i = startPosition;
+ sfStartCol = startPosition;
}
- if (i < ist)
+ if (sfStartCol < ist)
{
- i = ist;
+ sfStartCol = ist;
}
- if (j > endPosition)
+ if (sfEndCol > endPosition)
{
- j = endPosition;
+ sfEndCol = endPosition;
}
- for (; i <= j; i++)
+ for (; sfStartCol <= sfEndCol; sfStartCol++)
{
- bs.set(i - 1); // convert to base 0
+ bs.set(sfStartCol - 1); // convert to base 0
}
}
}
return featuresFile;
}
+
+ @Override
+ public boolean markHighlightedColumns(boolean invert,
+ boolean extendCurrent, boolean toggle)
+ {
+ if (!viewport.hasSearchResults())
+ {
+ // do nothing if no selection exists
+ return false;
+ }
+ // JBPNote this routine could also mark rows, not just columns.
+ BitSet bs = new BitSet();
+ SequenceCollectionI sqcol = (viewport.getSelectionGroup() == null || extendCurrent) ? viewport
+ .getAlignment() : viewport.getSelectionGroup();
+
+ // this could be a lambda... - the remains of the method is boilerplate,
+ // except for the different messages for reporting selection.
+ int nseq = viewport.getSearchResults().markColumns(sqcol, bs);
+
+ ColumnSelection cs = viewport.getColumnSelection();
+ if (cs == null)
+ {
+ cs = new ColumnSelection();
+ }
+
+ if (bs.cardinality() > 0 || invert)
+ {
+ boolean changed = cs.markColumns(bs, sqcol.getStartRes(),
+ sqcol.getEndRes(), invert, extendCurrent, toggle);
+ if (changed)
+ {
+ viewport.setColumnSelection(cs);
+ alignPanel.paintAlignment(true);
+ int columnCount = invert ? (sqcol.getEndRes() - sqcol.getStartRes() + 1)
+ - bs.cardinality()
+ : bs.cardinality();
+ avcg.setStatus(MessageManager.formatMessage(
+ "label.view_controller_toggled_marked",
+ new String[] {
+ toggle ? MessageManager.getString("label.toggled")
+ : MessageManager.getString("label.marked"),
+ String.valueOf(columnCount),
+ invert ? MessageManager
+ .getString("label.not_containing")
+ : MessageManager.getString("label.containing"),
+ "Highlight", Integer.valueOf(nseq).toString() }));
+ return true;
+ }
+ }
+ else
+ {
+ avcg.setStatus(MessageManager
+ .formatMessage("No highlighted regions marked"));
+ if (!extendCurrent)
+ {
+ cs.clear();
+ alignPanel.paintAlignment(true);
+ }
+ }
+ return false;
+ }
+
}
* where highlighted regions go
*/
public void markMappedRegion(SequenceI seq, int index,
- SearchResults results)
+ SearchResultsI results)
{
int[] codon;
SequenceI ds = seq.getDatasetSequence();
* jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SearchResults)
*/
@Override
- public int findIndex(SearchResults results)
+ public int findIndex(SearchResultsI results)
{
int i = 0;
* @param results
* @return -1 or index of sequence in alignment
*/
- int findIndex(SearchResults results);
+ int findIndex(SearchResultsI results);
/**
* append sequences and annotation from another alignment object to this one.
--- /dev/null
+package jalview.datamodel;
+
+/**
+ * An interface that describes one matched region of an alignment, as one
+ * contiguous portion of a single dataset sequence
+ */
+public interface SearchResultMatchI
+{
+ /**
+ * Returns the matched sequence
+ *
+ * @return
+ */
+ SequenceI getSequence();
+
+ /**
+ * Returns the start position of the match in the sequence (base 1)
+ *
+ * @return
+ */
+ int getStart();
+
+ /**
+ * Returns the end position of the match in the sequence (base 1)
+ *
+ * @return
+ */
+ int getEnd();
+
+}
\ No newline at end of file
package jalview.datamodel;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.BitSet;
import java.util.List;
/**
* Holds a list of search result matches, where each match is a contiguous
* stretch of a single sequence.
*
- * @author gmcarstairs
+ * @author gmcarstairs amwaterhouse
*
*/
-public class SearchResults
+public class SearchResults implements SearchResultsI
{
- private List<Match> matches = new ArrayList<Match>();
+ private List<SearchResultMatchI> matches = new ArrayList<SearchResultMatchI>();
/**
* One match consists of a sequence reference, start and end positions.
* Discontiguous ranges in a sequence require two or more Match objects.
*/
- public class Match
+ public class Match implements SearchResultMatchI
{
SequenceI sequence;
int end;
/**
- * Constructor
+ * create a Match on a range of sequence. Match always holds region in
+ * forwards order, even if given in reverse order (such as from a mapping to
+ * a reverse strand); this avoids trouble for routines that highlight search
+ * results etc
*
* @param seq
* a sequence
}
else
{
+ // TODO: JBP could mark match as being specified in reverse direction
+ // for use
+ // by caller ? e.g. visualizing reverse strand highlight
this.start = end;
this.end = start;
}
}
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultMatchI#getSequence()
+ */
+ @Override
public SequenceI getSequence()
{
return sequence;
}
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultMatchI#getStart()
+ */
+ @Override
public int getStart()
{
return start;
}
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultMatchI#getEnd()
+ */
+ @Override
public int getEnd()
{
return end;
}
/**
- * Returns the string of characters in the matched region, prefixed by the
- * start position, e.g. "12CGT" or "208K"
+ * Returns a representation as "seqid/start-end"
*/
@Override
public String toString()
{
- final int from = Math.max(start - 1, 0);
- String startPosition = String.valueOf(from);
- return startPosition + getCharacters();
- }
-
- /**
- * Returns the string of characters in the matched region.
- */
- public String getCharacters()
- {
- char[] chars = sequence.getSequence();
- // convert start/end to base 0 (with bounds check)
- final int from = Math.max(start - 1, 0);
- final int to = Math.min(end, chars.length + 1);
- return String.valueOf(Arrays.copyOfRange(chars, from, to));
+ StringBuilder sb = new StringBuilder();
+ if (sequence != null)
+ {
+ sb.append(sequence.getName()).append("/");
+ }
+ sb.append(start).append("-").append(end);
+ return sb.toString();
}
public void setSequence(SequenceI seq)
@Override
public boolean equals(Object obj)
{
- if (obj == null || !(obj instanceof Match))
+ if (obj == null || !(obj instanceof SearchResultMatchI))
{
return false;
}
- Match m = (Match) obj;
- return (this.sequence == m.sequence && this.start == m.start && this.end == m.end);
+ SearchResultMatchI m = (SearchResultMatchI) obj;
+ return (sequence == m.getSequence() && start == m.getStart() && end == m
+ .getEnd());
}
}
- /**
- * This method replaces the old search results which merely held an alignment
- * index of search matches. This broke when sequences were moved around the
- * alignment
- *
- * @param seq
- * Sequence
- * @param start
- * int
- * @param end
- * int
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultsI#addResult(jalview.datamodel.SequenceI, int, int)
*/
- public void addResult(SequenceI seq, int start, int end)
+ @Override
+ public SearchResultMatchI addResult(SequenceI seq, int start, int end)
{
- matches.add(new Match(seq, start, end));
+ Match m = new Match(seq, start, end);
+ matches.add(m);
+ return m;
}
- /**
- * Quickly check if the given sequence is referred to in the search results
- *
- * @param sequence
- * (specific alignment sequence or a dataset sequence)
- * @return true if the results involve sequence
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultsI#involvesSequence(jalview.datamodel.SequenceI)
*/
+ @Override
public boolean involvesSequence(SequenceI sequence)
{
SequenceI ds = sequence.getDatasetSequence();
- for (Match m : matches)
+ for (SearchResultMatchI _m : matches)
{
- if (m.sequence != null
- && (m.sequence == sequence || m.sequence == ds))
+ SequenceI matched = _m.getSequence();
+ if (matched != null && (matched == sequence || matched == ds))
{
return true;
}
return false;
}
- /**
- * This Method returns the search matches which lie between the start and end
- * points of the sequence in question. It is optimised for returning objects
- * for drawing on SequenceCanvas
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultsI#getResults(jalview.datamodel.SequenceI, int, int)
*/
+ @Override
public int[] getResults(SequenceI sequence, int start, int end)
{
if (matches.isEmpty())
int[] tmp = null;
int resultLength, matchStart = 0, matchEnd = 0;
boolean mfound;
- for (Match m : matches)
+ Match m;
+ for (SearchResultMatchI _m : matches)
{
+ m = (Match) _m;
+
mfound = false;
if (m.sequence == sequence)
{
return result;
}
- public int getSize()
- {
- return matches.size();
- }
-
- public SequenceI getResultSequence(int index)
- {
- return matches.get(index).sequence;
- }
-
- /**
- * Returns the start position of the i'th match in the search results.
- *
- * @param i
- * @return
- */
- public int getResultStart(int i)
+ @Override
+ public int markColumns(SequenceCollectionI sqcol, BitSet bs)
{
- return matches.get(i).start;
+ int count = 0;
+ BitSet mask = new BitSet();
+ for (SequenceI s : sqcol.getSequences())
+ {
+ int[] cols = getResults(s, sqcol.getStartRes(), sqcol.getEndRes());
+ if (cols != null)
+ {
+ for (int pair = 0; pair < cols.length; pair += 2)
+ {
+ mask.set(cols[pair], cols[pair + 1] + 1);
+ }
+ }
+ }
+ // compute columns that were newly selected
+ BitSet original = (BitSet) bs.clone();
+ original.and(mask);
+ count = mask.cardinality() - original.cardinality();
+ // and mark ranges not already marked
+ bs.or(mask);
+ return count;
}
- /**
- * Returns the end position of the i'th match in the search results.
- *
- * @param i
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultsI#getSize()
*/
- public int getResultEnd(int i)
+ @Override
+ public int getSize()
{
- return matches.get(i).end;
+ return matches.size();
}
- /**
- * Returns true if no search result matches are held.
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultsI#isEmpty()
*/
+ @Override
public boolean isEmpty()
{
return matches.isEmpty();
}
- /**
- * Returns the list of matches.
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SearchResultsI#getResults()
*/
- public List<Match> getResults()
+ @Override
+ public List<SearchResultMatchI> getResults()
{
return matches;
}
/**
- * Return the results as a string of characters (bases) prefixed by start
- * position(s). Meant for use when the context ensures that all matches are to
- * regions of the same sequence (otherwise the result is meaningless).
+ * Return the results as a list of matches [seq1/from-to, seq2/from-to, ...]
*
* @return
*/
@Override
public String toString()
{
- StringBuilder result = new StringBuilder(256);
- for (Match m : matches)
- {
- result.append(m.toString());
- }
- return result.toString();
- }
-
- /**
- * Return the results as a string of characters (bases). Meant for use when
- * the context ensures that all matches are to regions of the same sequence
- * (otherwise the result is meaningless).
- *
- * @return
- */
- public String getCharacters()
- {
- StringBuilder result = new StringBuilder(256);
- for (Match m : matches)
- {
- result.append(m.getCharacters());
- }
- return result.toString();
+ return matches == null ? "" : matches.toString();
}
/**
- * Hashcode is has derived from the list of matches. This ensures that when
- * two SearchResults objects satisfy the test for equals(), then they have the
+ * Hashcode is derived from the list of matches. This ensures that when two
+ * SearchResults objects satisfy the test for equals(), then they have the
* same hashcode.
+ *
+ * @see Match#hashCode()
+ * @see java.util.AbstractList#hashCode()
*/
@Override
public int hashCode()
@Override
public boolean equals(Object obj)
{
- if (obj == null || !(obj instanceof SearchResults))
+ if (obj == null || !(obj instanceof SearchResultsI))
{
return false;
}
- SearchResults sr = (SearchResults) obj;
- return ((ArrayList<Match>) this.matches).equals(sr.matches);
+ SearchResultsI sr = (SearchResultsI) obj;
+ return matches.equals(sr.getResults());
}
}
--- /dev/null
+package jalview.datamodel;
+
+import java.util.BitSet;
+import java.util.List;
+
+/**
+ * An interface describing the result of a search or other operation which
+ * highlights matched regions of an alignment
+ */
+public interface SearchResultsI
+{
+
+ /**
+ * Adds one region to the results
+ *
+ * @param seq
+ * Sequence
+ * @param start
+ * int
+ * @param end
+ * int
+ * @return
+ */
+ SearchResultMatchI addResult(SequenceI seq, int start, int end);
+
+ /**
+ * Answers true if the search results include the given sequence (or its
+ * dataset sequence), else false
+ *
+ * @param sequence
+ * @return
+ */
+ boolean involvesSequence(SequenceI sequence);
+
+ /**
+ * Returns an array of [from, to, from, to..] matched columns (base 0) between
+ * the given start and end columns of the given sequence. Returns null if no
+ * matches overlap the specified region.
+ * <p>
+ * Implementations should provide an optimised method to return locations to
+ * highlight on a visible portion of an alignment.
+ *
+ * @param sequence
+ * @param start
+ * first column of range (base 0, inclusive)
+ * @param end
+ * last column of range base 0, inclusive)
+ * @return int[]
+ */
+ int[] getResults(SequenceI sequence, int start, int end);
+
+ /**
+ * Returns the number of matches found
+ *
+ * @return
+ */
+ int getSize();
+
+ /**
+ * Returns true if no search result matches are held.
+ *
+ * @return
+ */
+ boolean isEmpty();
+
+ /**
+ * Returns the list of matches.
+ *
+ * @return
+ */
+ List<SearchResultMatchI> getResults();
+
+ /**
+ * Set bits in a bitfield for all columns in the given sequence collection
+ * that are highlighted
+ *
+ * @param sqcol
+ * the set of sequences to search for highlighted regions
+ * @param bs
+ * bitset to set
+ * @return number of bits set
+ */
+ int markColumns(SequenceCollectionI sqcol, BitSet bs);
+}
\ No newline at end of file
return s.hashCode() + getBegin() + getEnd() + (int) getScore()
+ getStrand();
}
+
+ /**
+ * Answers true if the feature's start/end values represent two related
+ * positions, rather than ends of a range. Such features may be visualised or
+ * reported differently to features on a range.
+ */
+ public boolean isContactFeature()
+ {
+ // TODO abstract one day to a FeatureType class
+ if ("disulfide bond".equalsIgnoreCase(type)
+ || "disulphide bond".equalsIgnoreCase(type))
+ {
+ return true;
+ }
+ return false;
+ }
}
import java.util.Map;
import java.util.Vector;
-import javajs.awt.Dimension;
-
import org.jmol.adapter.smarter.SmarterJmolAdapter;
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.api.JmolSelectionListener;
}
@Override
- public Dimension resizeInnerPanel(String data)
+ public int[] resizeInnerPanel(String data)
{
// Jalview doesn't honour resize panel requests
return null;
import java.util.Map;
import java.util.Vector;
-import javajs.awt.Dimension;
-
import org.jmol.api.JmolStatusListener;
import org.jmol.api.JmolViewer;
import org.jmol.c.CBK;
* Not implemented - returns null
*/
@Override
- public Dimension resizeInnerPanel(String data)
+ public int[] resizeInnerPanel(String data)
{
return null;
}
toggleHiddenRegions(toggleSeqs, toggleCols);
break;
}
+ case KeyEvent.VK_B:
+ {
+ boolean toggleSel = evt.isControlDown() || evt.isMetaDown();
+ boolean modifyExisting = true; // always modify, don't clear
+ // evt.isShiftDown();
+ boolean invertHighlighted = evt.isAltDown();
+ avc.markHighlightedColumns(invertHighlighted, modifyExisting,
+ toggleSel);
+ break;
+ }
case KeyEvent.VK_PAGE_UP:
if (viewport.getWrapAlignment())
{
viewport.setFollowHighlight(state);
if (state)
{
- alignPanel.scrollToPosition(
- alignPanel.getSeqPanel().seqCanvas.searchResults, false);
+ alignPanel.scrollToPosition(viewport.getSearchResults(), false);
}
}
}
return false;
}
+
+ @Override
+ protected void selectHighlightedColumns_actionPerformed(
+ ActionEvent actionEvent)
+ {
+ // include key modifier check in case user selects from menu
+ avc.markHighlightedColumns(
+ (actionEvent.getModifiers() & ActionEvent.ALT_MASK) != 0,
+ true,
+ (actionEvent.getModifiers() & (ActionEvent.META_MASK | ActionEvent.CTRL_MASK)) != 0);
+ }
}
class PrintThread extends Thread
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
* there is no complement, or it is not following highlights, or no mapping
* is found, the result will be empty.
*/
- SearchResults sr = new SearchResults();
+ SearchResultsI sr = new SearchResults();
int verticalOffset = findComplementScrollTarget(sr);
if (!sr.isEmpty())
{
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
* Highlight the given results on the alignment.
*
*/
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
scrollToPosition(results);
getSeqPanel().seqCanvas.highlightSearchResults(results);
*
* @param results
*/
- public boolean scrollToPosition(SearchResults results)
+ public boolean scrollToPosition(SearchResultsI results)
{
return scrollToPosition(results, 0, true, false);
}
* @param redrawOverview
* @return
*/
- public boolean scrollToPosition(SearchResults searchResults,
+ public boolean scrollToPosition(SearchResultsI searchResults,
boolean redrawOverview)
{
return scrollToPosition(searchResults, 0, redrawOverview, false);
* if true, try to centre the search results horizontally in the view
* @return false if results were not found
*/
- public boolean scrollToPosition(SearchResults results,
+ public boolean scrollToPosition(SearchResultsI results,
int verticalOffset, boolean redrawOverview, boolean centre)
{
int startv, endv, starts, ends;
}
else
{
- return printUnwrapped(pwidth, pheight, pi, pg);
+ return printUnwrapped(pwidth, pheight, pi, pg, pg);
}
}
* @throws PrinterException
* DOCUMENT ME!
*/
- public int printUnwrapped(int pwidth, int pheight, int pi,
- Graphics... pg)
+ /**
+ * Draws the alignment image, including sequence ids, sequences, and
+ * annotation labels and annotations if shown, on either one or two Graphics
+ * context.
+ *
+ * @param pageWidth
+ * @param pageHeight
+ * @param pi
+ * @param idGraphics
+ * the graphics context for sequence ids and annotation labels
+ * @param alignmentGraphics
+ * the graphics context for sequences and annotations (may or may not
+ * be the same context as idGraphics)
+ * @return
+ * @throws PrinterException
+ */
+ public int printUnwrapped(int pageWidth, int pageHeight, int pi,
+ Graphics idGraphics, Graphics alignmentGraphics)
throws PrinterException
{
- boolean isMultiGraphics = pg.length > 1;
- int G0 = 0; // Graphic index of idPanel graphics in multi-graphics mode or
- // entire graphics for non mulit-graphics mode
- int G1 = 0; // Graphic index of alignmentPanel graphics for multi-graphics
- // mode
- if (isMultiGraphics)
- {
- G0 = 0;
- G1 = 1;
- }
-
- int idWidth = getVisibleIdWidth(false);
- FontMetrics fm = getFontMetrics(av.getFont());
- int scaleHeight = av.getCharHeight() + fm.getDescent();
-
- pg[G0].setColor(Color.white);
- pg[G0].fillRect(0, 0, pwidth, pheight);
- pg[G0].setFont(av.getFont());
+ final int idWidth = getVisibleIdWidth(false);
- // //////////////////////////////////
- // / How many sequences and residues can we fit on a printable page?
- int totalRes = (pwidth - idWidth) / av.getCharWidth();
+ /*
+ * Get the horizontal offset to where we draw the sequences.
+ * This is idWidth if using a single Graphics context, else zero.
+ */
+ final int alignmentGraphicsOffset = idGraphics != alignmentGraphics ? 0 : idWidth;
- int totalSeq = (pheight - scaleHeight) / av.getCharHeight() - 1;
+ FontMetrics fm = getFontMetrics(av.getFont());
+ int charHeight = av.getCharHeight();
+ int scaleHeight = charHeight + fm.getDescent();
- int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
+ idGraphics.setColor(Color.white);
+ idGraphics.fillRect(0, 0, pageWidth, pageHeight);
+ idGraphics.setFont(av.getFont());
- // ///////////////////////////
- // / Only print these sequences and residues on this page
- int startRes;
+ /*
+ * How many sequences and residues can we fit on a printable page?
+ */
+ int totalRes = (pageWidth - idWidth) / av.getCharWidth();
- // ///////////////////////////
- // / Only print these sequences and residues on this page
- int endRes;
+ int totalSeq = (pageHeight - scaleHeight) / charHeight - 1;
- // ///////////////////////////
- // / Only print these sequences and residues on this page
- int startSeq;
+ int alignmentWidth = av.getAlignment().getWidth();
+ int pagesWide = (alignmentWidth / totalRes) + 1;
- // ///////////////////////////
- // / Only print these sequences and residues on this page
- int endSeq;
- startRes = (pi % pagesWide) * totalRes;
- endRes = (startRes + totalRes) - 1;
+ final int startRes = (pi % pagesWide) * totalRes;
+ int endRes = (startRes + totalRes) - 1;
- if (endRes > (av.getAlignment().getWidth() - 1))
+ if (endRes > (alignmentWidth - 1))
{
- endRes = av.getAlignment().getWidth() - 1;
+ endRes = alignmentWidth - 1;
}
- startSeq = (pi / pagesWide) * totalSeq;
- endSeq = startSeq + totalSeq;
+ final int startSeq = (pi / pagesWide) * totalSeq;
+ int endSeq = startSeq + totalSeq;
- if (endSeq > av.getAlignment().getHeight())
+ int alignmentHeight = av.getAlignment().getHeight();
+ if (endSeq > alignmentHeight)
{
- endSeq = av.getAlignment().getHeight();
+ endSeq = alignmentHeight;
}
- int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1)
- * pheight;
+ int pagesHigh = ((alignmentHeight / totalSeq) + 1)
+ * pageHeight;
if (av.isShowAnnotation())
{
pagesHigh += getAnnotationPanel().adjustPanelHeight() + 3;
}
- pagesHigh /= pheight;
+ pagesHigh /= pageHeight;
if (pi >= (pagesWide * pagesHigh))
{
return Printable.NO_SUCH_PAGE;
}
+ final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight
+ + 3;
- // draw Scale
- if (isMultiGraphics)
- {
- pg[G1].translate(0, 0);
- getScalePanel().drawScale(pg[G1], startRes, endRes,
- pwidth - idWidth, scaleHeight);
- pg[G1].translate(-idWidth, scaleHeight);
- }
- else
- {
- pg[G0].translate(idWidth, 0);
- getScalePanel().drawScale(pg[G0], startRes, endRes, pwidth - idWidth,
- scaleHeight);
- pg[G0].translate(-idWidth, scaleHeight);
- }
+ /*
+ * draw the Scale at horizontal offset, then reset to top left (0, 0)
+ */
+ alignmentGraphics.translate(alignmentGraphicsOffset, 0);
+ getScalePanel().drawScale(alignmentGraphics, startRes, endRes,
+ pageWidth - idWidth, scaleHeight);
+ alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
- // //////////////
- // Draw the ids
+ /*
+ * Draw the sequence ids, offset for scale height,
+ * then reset to top left (0, 0)
+ */
+ idGraphics.translate(0, scaleHeight);
+ idGraphics.setFont(getIdPanel().getIdCanvas().getIdfont());
Color currentColor = null;
Color currentTextColor = null;
- if (isMultiGraphics)
- {
- pg[G0].translate(0, scaleHeight);
- }
- pg[G0].setFont(getIdPanel().getIdCanvas().getIdfont());
-
SequenceI seq;
for (int i = startSeq; i < endSeq; i++)
{
if ((av.getSelectionGroup() != null)
&& av.getSelectionGroup().getSequences(null).contains(seq))
{
+ /*
+ * gray out ids of sequences in selection group (if any)
+ */
currentColor = Color.gray;
currentTextColor = Color.black;
}
currentTextColor = Color.black;
}
- pg[G0].setColor(currentColor);
- pg[G0].fillRect(0, (i - startSeq) * av.getCharHeight(), idWidth,
- av.getCharHeight());
+ idGraphics.setColor(currentColor);
+ idGraphics.fillRect(0, (i - startSeq) * charHeight, idWidth,
+ charHeight);
- pg[G0].setColor(currentTextColor);
+ idGraphics.setColor(currentTextColor);
int xPos = 0;
+ String displayId = seq.getDisplayId(av.getShowJVSuffix());
if (av.isRightAlignIds())
{
- fm = pg[G0].getFontMetrics();
+ fm = idGraphics.getFontMetrics();
xPos = idWidth
- - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
+ - fm.stringWidth(displayId)
- 4;
}
- pg[G0].drawString(seq.getDisplayId(av.getShowJVSuffix()), xPos,
- (((i - startSeq) * av.getCharHeight()) + av.getCharHeight())
- - (av.getCharHeight() / 5));
+ idGraphics.drawString(displayId, xPos,
+ (((i - startSeq) * charHeight) + charHeight)
+ - (charHeight / 5));
}
+ idGraphics.setFont(av.getFont());
+ idGraphics.translate(0, -scaleHeight);
- pg[G0].setFont(av.getFont());
-
+ /*
+ * draw the sequences, offset for scale height, and id width (if using a
+ * single graphics context), then reset to (0, scale height)
+ */
+ alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
+ getSeqPanel().seqCanvas.drawPanel(alignmentGraphics, startRes, endRes,
+ startSeq, endSeq, 0);
+ alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
- // draw main sequence panel
- pg[G0].translate(idWidth, 0);
- if (isMultiGraphics)
+ if (av.isShowAnnotation() && (endSeq == alignmentHeight))
{
- pg[G1].translate(idWidth, 0);
- getSeqPanel().seqCanvas.drawPanel(pg[G1], startRes, endRes,
- startSeq, endSeq, 0);
- }
- else
- {
- getSeqPanel().seqCanvas.drawPanel(pg[G0], startRes, endRes, startSeq,
- endSeq, 0);
- }
+ /*
+ * draw annotation labels; drawComponent() translates by
+ * getScrollOffset(), so compensate for that first;
+ * then reset to (0, scale height)
+ */
+ int offset = getAlabels().getScrollOffset();
+ idGraphics.translate(0, -offset);
+ idGraphics.translate(0, alignmentDrawnHeight);
+ getAlabels().drawComponent(idGraphics, idWidth);
+ idGraphics.translate(0, -alignmentDrawnHeight);
- if (av.isShowAnnotation() && (endSeq == av.getAlignment().getHeight()))
- {
- // draw annotation label - need to offset for current scroll position
- int offset = -getAlabels().getScrollOffset();
- pg[G0].translate(0, offset);
- pg[G0].translate(-idWidth - 3,
- (endSeq - startSeq) * av.getCharHeight() + 3);
- getAlabels().drawComponent(pg[G0], idWidth);
- pg[G0].translate(idWidth + 3, 0);
- pg[G0].translate(0, -offset);
- if (isMultiGraphics)
- {
- // draw annotation - need to offset for current scroll position
- pg[G1].translate(0, offset);
- pg[G1].translate(-idWidth - 3,
- (endSeq - startSeq) * av.getCharHeight() + 3);
- pg[G1].translate(idWidth + 3, 0);
- getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(),
- av, pg[G1], -1, startRes, endRes + 1);
- pg[G1].translate(0, -offset);
- }
- else
- {
- getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(),
- av, pg[G0], -1, startRes, endRes + 1);
- pg[G0].translate(0, -offset);
- }
+ /*
+ * draw the annotations starting at
+ * (idOffset, alignmentHeight) from (0, scaleHeight)
+ */
+ alignmentGraphics.translate(alignmentGraphicsOffset, alignmentDrawnHeight);
+ getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
+ alignmentGraphics, -1, startRes, endRes + 1);
}
return Printable.PAGE_EXISTS;
if (onscreen
|| (idwidth = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
{
- return (getIdPanel().getWidth() > 0 ? getIdPanel().getWidth()
- : calculateIdWidth().width + 4);
+ int w = getIdPanel().getWidth();
+ return (w > 0 ? w : calculateIdWidth().width + 4);
}
return idwidth.intValue() + 4;
}
aDimension.getWidth(), aDimension.getHeight()
+ boarderBottomOffset, file, imageTitle,
alignFrame, pSessionId, headless);
+ Graphics graphics = im.getGraphics();
if (av.getWrapAlignment())
{
- if (im.getGraphics() != null)
+ if (graphics != null)
{
printWrappedAlignment(aDimension.getWidth(),
aDimension.getHeight() + boarderBottomOffset, 0,
- im.getGraphics());
+ graphics);
im.writeImage();
}
}
else
{
- if (im.getGraphics() != null)
+ if (graphics != null)
{
printUnwrapped(aDimension.getWidth(), aDimension.getHeight(),
- 0, im.getGraphics());
+ 0, graphics, graphics);
im.writeImage();
}
}
public void makePNGImageMap(File imgMapFile, String imageName)
{
- // /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
+ // /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS
// ////////////////////////////////////////////
int idWidth = getVisibleIdWidth(false);
FontMetrics fm = getFontMetrics(av.getFont());
{
int s, sSize = av.getAlignment().getHeight(), res, alwidth = av
.getAlignment().getWidth(), g, gSize, f, fSize, sy;
- StringBuffer text = new StringBuffer();
PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
out.println(jalview.io.HTMLOutput.getImageMapHTML());
out.println("<img src=\"" + imageName
SequenceGroup[] groups = av.getAlignment().findAllGroups(seq);
for (res = 0; res < alwidth; res++)
{
- text = new StringBuffer();
+ StringBuilder text = new StringBuilder();
String triplet = null;
if (av.getAlignment().isNucleotide())
{
{
if (text.length() < 1)
{
- text.append("<area shape=\"rect\" coords=\""
- + (idWidth + res * av.getCharWidth()) + "," + sy
- + "," + (idWidth + (res + 1) * av.getCharWidth())
- + "," + (av.getCharHeight() + sy) + "\""
- + " onMouseOver=\"toolTip('" + alIndex + " "
- + triplet);
+ text.append("<area shape=\"rect\" coords=\"")
+ .append((idWidth + res * av.getCharWidth()))
+ .append(",").append(sy).append(",")
+ .append((idWidth + (res + 1) * av.getCharWidth()))
+ .append(",").append((av.getCharHeight() + sy))
+ .append("\"").append(" onMouseOver=\"toolTip('")
+ .append(alIndex).append(" ").append(triplet);
}
if (groups[g].getStartRes() < res
&& groups[g].getEndRes() > res)
{
- text.append("<br><em>" + groups[g].getName() + "</em>");
+ text.append("<br><em>").append(groups[g].getName())
+ .append("</em>");
}
}
{
if (text.length() < 1)
{
- text.append("<area shape=\"rect\" coords=\""
- + (idWidth + res * av.getCharWidth()) + "," + sy
- + "," + (idWidth + (res + 1) * av.getCharWidth())
- + "," + (av.getCharHeight() + sy) + "\""
- + " onMouseOver=\"toolTip('" + alIndex + " "
- + triplet);
+ text.append("<area shape=\"rect\" coords=\"")
+ .append((idWidth + res * av.getCharWidth()))
+ .append(",").append(sy).append(",")
+ .append((idWidth + (res + 1) * av.getCharWidth()))
+ .append(",").append((av.getCharHeight() + sy))
+ .append("\"").append(" onMouseOver=\"toolTip('")
+ .append(alIndex).append(" ").append(triplet);
}
fSize = features.length;
for (f = 0; f < fSize; f++)
if ((features[f].getBegin() <= seq.findPosition(res))
&& (features[f].getEnd() >= seq.findPosition(res)))
{
- if (features[f].getType().equals("disulfide bond"))
+ if (features[f].isContactFeature())
{
if (features[f].getBegin() == seq.findPosition(res)
|| features[f].getEnd() == seq
.findPosition(res))
{
- text.append("<br>disulfide bond "
- + features[f].getBegin() + ":"
- + features[f].getEnd());
+ text.append("<br>").append(features[f].getType())
+ .append(" ").append(features[f].getBegin())
+ .append(":").append(features[f].getEnd());
}
}
else
&& !features[f].getType().equals(
features[f].getDescription()))
{
- text.append(" " + features[f].getDescription());
+ text.append(" ").append(features[f].getDescription());
}
if (features[f].getValue("status") != null)
{
- text.append(" (" + features[f].getValue("status")
- + ")");
+ text.append(" (").append(features[f].getValue("status"))
+ .append(")");
}
}
}
* @param verticalOffset
* the number of visible sequences to show above the mapped region
*/
- public void scrollToCentre(SearchResults sr, int verticalOffset)
+ public void scrollToCentre(SearchResultsI sr, int verticalOffset)
{
/*
* To avoid jumpy vertical scrolling (if some sequences are gapped or not
* mapped), we can make the scroll-to location a sequence above the one
* actually mapped.
*/
- SequenceI mappedTo = sr.getResultSequence(0);
+ SequenceI mappedTo = sr.getResults().get(0).getSequence();
List<SequenceI> seqs = av.getAlignment().getSequences();
/*
import jalview.api.FeatureColourI;
import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.schemes.FeatureColour;
start.setValue(new Integer(features[index].getBegin()));
end.setValue(new Integer(features[index].getEnd()));
- SearchResults highlight = new SearchResults();
+ SearchResultsI highlight = new SearchResults();
highlight.addResult(sequences[0], features[index].getBegin(),
features[index].getEnd());
*/
package jalview.gui;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultMatchI;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GFinder;
int resIndex = -1;
- SearchResults searchResults;
+ SearchResultsI searchResults;
/**
* Creates a new Finder object with no associated viewport or panel.
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
getRootPane().getActionMap().put("Cancel", new AbstractAction()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
escapeActionPerformed();
*
* @param e
*/
+ @Override
public void findNext_actionPerformed(ActionEvent e)
{
if (getFocusedViewport())
*
* @param e
*/
+ @Override
public void findAll_actionPerformed(ActionEvent e)
{
if (getFocusedViewport())
* @param e
* DOCUMENT ME!
*/
+ @Override
public void createNewGroup_actionPerformed(ActionEvent e)
{
SequenceI[] seqs = new SequenceI[searchResults.getSize()];
SequenceFeature[] features = new SequenceFeature[searchResults
.getSize()];
- for (int i = 0; i < searchResults.getSize(); i++)
+ int i = 0;
+ for (SearchResultMatchI match : searchResults.getResults())
{
- seqs[i] = searchResults.getResultSequence(i).getDatasetSequence();
+ seqs[i] = match.getSequence().getDatasetSequence();
features[i] = new SequenceFeature(textfield.getText().trim(),
- "Search Results", null, searchResults.getResultStart(i),
- searchResults.getResultEnd(i), "Search Results");
+ "Search Results", null, match.getStart(), match.getEnd(),
+ "Search Results");
+ i++;
}
if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
searchResults = finder.getSearchResults(); // find(regex,
// caseSensitive.isSelected(), )
- Vector idMatch = finder.getIdMatch();
+ Vector<SequenceI> idMatch = finder.getIdMatch();
boolean haveResults = false;
// set or reset the GUI
if ((idMatch.size() > 0))
package jalview.gui;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.renderer.ScaleRenderer;
AlignViewport av;
- SearchResults searchResults = null;
-
boolean fastPaint = false;
int LABEL_WEST;
// / Highlight search Results once all sequences have been drawn
// ////////////////////////////////////////////////////////
- if (searchResults != null)
+ if (av.hasSearchResults())
{
- int[] visibleResults = searchResults.getResults(nextSeq, startRes,
- endRes);
+ int[] visibleResults = av.getSearchResults().getResults(nextSeq,
+ startRes, endRes);
if (visibleResults != null)
{
for (int r = 0; r < visibleResults.length; r += 2)
* @param results
* DOCUMENT ME!
*/
- public void highlightSearchResults(SearchResults results)
+ public void highlightSearchResults(SearchResultsI results)
{
img = null;
- searchResults = results;
+ av.setSearchResults(results);
repaint();
}
import jalview.commands.EditCommand.Edit;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
-import jalview.datamodel.SearchResults.Match;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
StructureSelectionManager ssm;
- SearchResults lastSearchResults;
+ SearchResultsI lastSearchResults;
/**
* Creates a new SeqPanel object.
* the start of the highlighted region.
*/
@Override
- public void highlightSequence(SearchResults results)
+ public void highlightSequence(SearchResultsI results)
{
if (results == null || results.equals(lastSearchResults))
{
*
* @param results
*/
- private void setStatusMessage(SearchResults results)
+ private void setStatusMessage(SearchResultsI results)
{
AlignmentI al = this.av.getAlignment();
int sequenceIndex = al.findIndex(results);
return;
}
SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence();
- for (Match m : results.getResults())
+ for (SearchResultMatchI m : results.getResults())
{
SequenceI seq = m.getSequence();
if (seq.getDatasetSequence() != null)
if (features != null && features.size() > 0)
{
- SearchResults highlight = new SearchResults();
+ SearchResultsI highlight = new SearchResults();
highlight.addResult(sequence, features.get(0).getBegin(), features
.get(0).getEnd());
seqCanvas.highlightSearchResults(highlight);
exportStarted();
try
{
-
if (outputFile == null)
{
outputFile = getOutputFile();
}
generatedFile = new File(outputFile);
-
- String bioJSON = getBioJSONData();
- String bioJSTemplateString = HTMLOutput.readFileAsString(getCurrentBJSTemplateFile());
- String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
- .replaceAll("#sequenceData#", bioJSON).toString();
-
- PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
- generatedFile));
- out.print(generatedBioJsWithJalviewAlignmentAsJson);
- out.flush();
- out.close();
- exportCompleted();
- setProgressMessage(MessageManager.formatMessage(
- "status.export_complete", "BioJS"));
-
- } catch (NoFileSelectedException ex)
- {
- // do noting if no file was selected
- } catch (OutOfMemoryError err)
+ } catch (NoFileSelectedException e)
{
- System.out.println("########################\n" + "OUT OF MEMORY "
- + outputFile + "\n" + "########################");
- new OOMWarning("Creating Image for " + outputFile, err);
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "BioJS MSA"));
+ return;
} catch (Exception e)
{
setProgressMessage(MessageManager.formatMessage(
- "info.error_creating_file", "HTML"));
+ "info.error_creating_file", "BioJS MSA"));
e.printStackTrace();
+ return;
}
+ new Thread(this).start();
+
}
return generatedFile;
}
+ @Override
+ public void run()
+ {
+ try
+ {
+ String bioJSON = getBioJSONData();
+ String bioJSTemplateString = HTMLOutput
+ .readFileAsString(getCurrentBJSTemplateFile());
+ String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
+ .replaceAll("#sequenceData#", bioJSON).toString();
+
+ PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
+ generatedFile));
+ out.print(generatedBioJsWithJalviewAlignmentAsJson);
+ out.flush();
+ out.close();
+ setProgressMessage(MessageManager.formatMessage(
+ "status.export_complete", "BioJS"));
+ exportCompleted();
+
+ } catch (OutOfMemoryError err)
+ {
+ System.out.println("########################\n" + "OUT OF MEMORY "
+ + generatedFile + "\n" + "########################");
+ new OOMWarning("Creating Image for " + generatedFile, err);
+ } catch (Exception e)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "info.error_creating_file", "HTML"));
+ e.printStackTrace();
+ }
+
+ }
+
}
import java.util.Objects;
-public abstract class HTMLOutput
+public abstract class HTMLOutput implements Runnable
{
protected AlignmentPanel ap;
}
}
-
public String getBioJSONData()
{
+ return getBioJSONData(null);
+ }
+
+ public String getBioJSONData(AlignExportSettingI exportSettings)
+ {
if (!isEmbedData())
{
return null;
}
- AlignExportSettingI exportSettings = new AlignExportSettingI()
+ if (exportSettings == null)
{
- @Override
- public boolean isExportHiddenSequences()
+ exportSettings = new AlignExportSettingI()
{
- return true;
- }
-
- @Override
- public boolean isExportHiddenColumns()
- {
- return true;
- }
+ @Override
+ public boolean isExportHiddenSequences()
+ {
+ return true;
+ }
- @Override
- public boolean isExportAnnotations()
- {
- return true;
- }
+ @Override
+ public boolean isExportHiddenColumns()
+ {
+ return true;
+ }
- @Override
- public boolean isExportFeatures()
- {
- return true;
- }
+ @Override
+ public boolean isExportAnnotations()
+ {
+ return true;
+ }
- @Override
- public boolean isExportGroups()
- {
- return true;
- }
+ @Override
+ public boolean isExportFeatures()
+ {
+ return true;
+ }
- @Override
- public boolean isCancelled()
- {
- return false;
- }
+ @Override
+ public boolean isExportGroups()
+ {
+ return true;
+ }
- };
+ @Override
+ public boolean isCancelled()
+ {
+ return false;
+ }
+ };
+ }
AlignmentExportData exportData = jalview.gui.AlignFrame
.getAlignmentForExport(JSONFile.FILE_DESC,
ap.getAlignViewport(), exportSettings);
jvFileChooser.setFileView(new JalviewFileView());
jvFileChooser.setDialogTitle(MessageManager
- .getString("label.save_as_biojs_html"));
+ .getString("label.save_as_html"));
jvFileChooser.setToolTipText(MessageManager.getString("action.save"));
int fileChooserOpt = jvFileChooser.showSaveDialog(null);
}
else
{
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "BioJS"),
- pSessionId);
throw new NoFileSelectedException("No file was selected.");
}
return selectedFile;
*/
package jalview.io;
+import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
import jalview.gui.HTMLOptions;
import jalview.gui.OOMWarning;
public class HtmlSvgOutput extends HTMLOutput
{
- private File generatedFile;
public HtmlSvgOutput(AlignmentPanel ap)
{
}
@Override
- public void exportHTML(String file)
+ public void exportHTML(String outputFile)
{
exportStarted();
try
{
- if (file == null)
+ if (outputFile == null)
{
- file = getOutputFile();
+ outputFile = getOutputFile();
}
- generatedFile = new File(file);
+ generatedFile = new File(outputFile);
+ } catch (NoFileSelectedException e)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "HTML"));
+ return;
} catch (Exception e)
{
setProgressMessage(MessageManager.formatMessage(
e.printStackTrace();
return;
}
- new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- setProgressMessage(null);
- setProgressMessage(MessageManager.formatMessage(
- "status.exporting_alignment_as_x_file", "HTML"));
- AlignmentDimension aDimension = ap.getAlignmentDimension();
- SVGGraphics2D idPanelGraphics = new SVGGraphics2D(
- aDimension.getWidth(),
- aDimension.getHeight());
- SVGGraphics2D alignPanelGraphics = new SVGGraphics2D(
- aDimension.getWidth(),
- aDimension.getHeight());
-
- String renderStyle = jalview.bin.Cache.getDefault(
- "HTML_RENDERING", "Prompt each time");
-
- // If we need to prompt, and if the GUI is visible then
- // Prompt for rendering style
- if (renderStyle.equalsIgnoreCase("Prompt each time")
- && !isHeadless())
- {
- HTMLOptions svgOption = new HTMLOptions();
- renderStyle = svgOption.getValue();
-
- if (renderStyle == null || svgOption.cancelled)
- {
- setProgressMessage(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "HTML"));
- return;
- }
- }
-
- if (renderStyle.equalsIgnoreCase("Lineart"))
- {
- idPanelGraphics.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
- SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
- alignPanelGraphics.setRenderingHint(
- SVGHints.KEY_DRAW_STRING_TYPE,
- SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
- }
- if (ap.av.getWrapAlignment())
- {
- printWrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
- alignPanelGraphics);
- }
- else
- {
- printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
- idPanelGraphics, alignPanelGraphics);
- }
-
- String idPanelSvgData = idPanelGraphics.getSVGDocument();
- String alignPanelSvgData = alignPanelGraphics.getSVGDocument();
- String jsonData = getBioJSONData();
- String htmlData = getHtml(idPanelSvgData, alignPanelSvgData, jsonData,
- ap.av.getWrapAlignment());
- FileOutputStream out = new FileOutputStream(generatedFile);
- out.write(htmlData.getBytes());
- out.flush();
- out.close();
- exportCompleted();
- } catch (OutOfMemoryError err)
- {
- System.out.println("########################\n"
- + "OUT OF MEMORY " + generatedFile + "\n"
- + "########################");
- new OOMWarning("Creating Image for " + generatedFile, err);
- } catch (Exception e)
- {
- e.printStackTrace();
- setProgressMessage(MessageManager.formatMessage(
- "info.error_creating_file", "HTML"));
- }
- setProgressMessage(MessageManager.formatMessage(
- "status.export_complete", "HTML"));
- }
- }.start();
-
+ new Thread(this).start();
}
"Hypertext Markup Language");
}
- public int printUnwrapped(int pwidth, int pheight, int pi, Graphics... pg)
+ public int printUnwrapped(int pwidth, int pheight, int pi,
+ Graphics idGraphics, Graphics alignmentGraphics)
throws PrinterException
{
- return ap.printUnwrapped(pwidth, pheight, pi, pg);
+ return ap.printUnwrapped(pwidth, pheight, pi, idGraphics,
+ alignmentGraphics);
}
public int printWrapped(int pwidth, int pheight, int pi, Graphics... pg)
.append(alignmentSvg).append("</div>");
htmlSvg.append("<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js\"></script>\n"
+ "<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js\"></script>\n");
-
}
// javascript for launching file in Jalview
-
htmlSvg.append("<script language=\"JavaScript\">\n");
htmlSvg.append("function openJalviewUsingCurrentUrl(){\n");
htmlSvg.append(" var json = JSON.parse(document.getElementById(\"seqData\").innerHTML);\n");
htmlSvg.append(" document.body.removeChild(myForm);\n");
htmlSvg.append("}\n");
- // jquery facebox for displaying raw BioJSON data");
if (jsonData != null)
{
+ // JQuery FaceBox for displaying raw BioJSON data");
File faceBoxJsFile = new File("examples/javascript/facebox-1.3.js");
try
{
{
return generatedFile;
}
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ setProgressMessage(null);
+ setProgressMessage(MessageManager.formatMessage(
+ "status.exporting_alignment_as_x_file", "HTML"));
+ AlignmentDimension aDimension = ap.getAlignmentDimension();
+ SVGGraphics2D idPanelGraphics = new SVGGraphics2D(
+ aDimension.getWidth(), aDimension.getHeight());
+ SVGGraphics2D alignPanelGraphics = new SVGGraphics2D(
+ aDimension.getWidth(), aDimension.getHeight());
+
+ String renderStyle = jalview.bin.Cache.getDefault("HTML_RENDERING",
+ "Prompt each time");
+
+ // If we need to prompt, and if the GUI is visible then
+ // Prompt for rendering style
+ if (renderStyle.equalsIgnoreCase("Prompt each time") && !isHeadless())
+ {
+ HTMLOptions svgOption = new HTMLOptions();
+ renderStyle = svgOption.getValue();
+
+ if (renderStyle == null || svgOption.cancelled)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "HTML"));
+ return;
+ }
+ }
+
+ if (renderStyle.equalsIgnoreCase("Lineart"))
+ {
+ idPanelGraphics.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ alignPanelGraphics.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ }
+ if (ap.av.getWrapAlignment())
+ {
+ printWrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+ alignPanelGraphics);
+ }
+ else
+ {
+ printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+ idPanelGraphics, alignPanelGraphics);
+ }
+
+ String idPanelSvgData = idPanelGraphics.getSVGDocument();
+ String alignPanelSvgData = alignPanelGraphics.getSVGDocument();
+ String jsonData = getBioJSONData();
+ String htmlData = getHtml(idPanelSvgData, alignPanelSvgData,
+ jsonData, ap.av.getWrapAlignment());
+ FileOutputStream out = new FileOutputStream(generatedFile);
+ out.write(htmlData.getBytes());
+ out.flush();
+ out.close();
+ setProgressMessage(MessageManager.formatMessage(
+ "status.export_complete", "HTML"));
+ exportCompleted();
+ } catch (OutOfMemoryError err)
+ {
+ System.out.println("########################\n" + "OUT OF MEMORY "
+ + generatedFile + "\n" + "########################");
+ new OOMWarning("Creating Image for " + generatedFile, err);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ setProgressMessage(MessageManager.formatMessage(
+ "info.error_creating_file", "HTML"));
+ }
+ }
}
if (id.equals("JNETCONF"))
{
annot = new AlignmentAnnotation(preds[i].getName(),
- "JNet Output", annotations, 0f, 10f,
+ "JPred Output", annotations, 0f, 10f,
AlignmentAnnotation.BAR_GRAPH);
}
else
{
annot = new AlignmentAnnotation(preds[i].getName(),
- "JNet Output", annotations);
+ "JPred Output", annotations);
}
if (seqRef != null)
void appendFeature(final StringBuilder sb, int rpos,
Map<String, float[][]> minmax, SequenceFeature feature)
{
- String tmpString;
- if (feature.getType().equals("disulfide bond"))
+ if (feature.isContactFeature())
{
if (feature.getBegin() == rpos || feature.getEnd() == rpos)
{
{
sb.append("<br>");
}
- sb.append("disulfide bond ").append(feature.getBegin()).append(":")
+ sb.append(feature.getType()).append(" ").append(feature.getBegin())
+ .append(":")
.append(feature.getEnd());
}
}
if (feature.getDescription() != null
&& !feature.description.equals(feature.getType()))
{
- tmpString = feature.getDescription();
+ String tmpString = feature.getDescription();
String tmp2up = tmpString.toUpperCase();
int startTag = tmp2up.indexOf("<HTML>");
if (startTag > -1)
// check score should be shown
if (!Float.isNaN(feature.getScore()))
{
- float[][] rng = (minmax == null) ? null : ((float[][]) minmax
- .get(feature.getType()));
+ float[][] rng = (minmax == null) ? null : minmax.get(feature
+ .getType());
if (rng != null && rng[0] != null && rng[0][0] != rng[0][1])
{
- sb.append(" Score=" + feature.getScore());
+ sb.append(" Score=").append(String.valueOf(feature.getScore()));
}
}
String status = (String) feature.getValue("status");
alignmentProperties();
}
});
+ JMenuItem selectHighlighted = new JMenuItem(
+ MessageManager.getString("action.select_highlighted_columns"));
+ selectHighlighted.setToolTipText(MessageManager
+ .getString("tooltip.select_highlighted_columns"));
+ al = new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent actionEvent)
+ {
+ selectHighlightedColumns_actionPerformed(actionEvent);
+ }
+ };
+ selectHighlighted.addActionListener(al);
JMenu tooltipSettingsMenu = new JMenu(
MessageManager.getString("label.sequence_id_tooltip"));
JMenu autoAnnMenu = new JMenu(
selectMenu.add(grpsFromSelection);
selectMenu.add(deleteGroups);
selectMenu.add(annotationColumn);
+ selectMenu.add(selectHighlighted);
// TODO - determine if the listenToViewSelections button is needed : see bug
// JAL-574
// selectMenu.addSeparator();
// selectMenu.add(listenToViewSelections);
}
+ protected void selectHighlightedColumns_actionPerformed(
+ ActionEvent actionEvent)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
/**
* Generate the reverse sequence (or reverse complement if the flag is true)
* and add it to the alignment
}
/**
- * This is used by the Molecule Viewer and Overview to get the accurate colour
- * of the rendered sequence
+ * This is used by Structure Viewers and the Overview Window to get the
+ * feature colour of the rendered sequence, returned as an RGB value
+ *
+ * @param defaultColour
+ * @param seq
+ * @param column
+ * @return
*/
- public synchronized int findFeatureColour(int initialCol,
+ public synchronized int findFeatureColour(int defaultColour,
final SequenceI seq, int column)
{
if (!av.isShowSequenceFeatures())
{
- return initialCol;
+ return defaultColour;
}
SequenceFeature[] sequenceFeatures = seq.getSequenceFeatures();
if (lastSequenceFeatures == null || sfSize == 0)
{
- return initialCol;
+ return defaultColour;
}
if (jalview.util.Comparison.isGap(lastSeq.getCharAt(column)))
if (offscreenImage != null)
{
- offscreenImage.setRGB(0, 0, initialCol);
+ offscreenImage.setRGB(0, 0, defaultColour);
drawSequence(offscreenImage.getGraphics(), lastSeq, column, column, 0);
return offscreenImage.getRGB(0, 0);
if (currentColour == null)
{
- return initialCol;
+ return defaultColour;
}
else
{
int epos;
+ /**
+ * Draws the sequence on the graphics context, or just determines the colour
+ * that would be drawn (if flag offscreenrender is true).
+ *
+ * @param g
+ * @param seq
+ * @param start
+ * start column (or sequence position in offscreenrender mode)
+ * @param end
+ * end column (not used in offscreenrender mode)
+ * @param y1
+ * vertical offset at which to draw on the graphics
+ */
public synchronized void drawSequence(Graphics g, final SequenceI seq,
int start, int end, int y1)
{
}
sfSize = lastSequenceFeatures.length;
- String type;
for (int renderIndex = 0; renderIndex < renderOrder.length; renderIndex++)
{
- type = renderOrder[renderIndex];
-
- if (type == null || !showFeatureOfType(type))
+ String type = renderOrder[renderIndex];
+ if (!showFeatureOfType(type))
{
continue;
}
continue;
}
- if (featureGroups != null
- && sequenceFeature.featureGroup != null
- && sequenceFeature.featureGroup.length() != 0
- && featureGroups.containsKey(sequenceFeature.featureGroup)
- && !featureGroups.get(sequenceFeature.featureGroup)
- .booleanValue())
+ if (featureGroupNotShown(sequenceFeature))
{
continue;
}
+ /*
+ * check feature overlaps the visible part of the alignment,
+ * unless doing offscreenRender (to the Overview window or a
+ * structure viewer) which is not limited
+ */
if (!offscreenRender
&& (sequenceFeature.getBegin() > epos || sequenceFeature
.getEnd() < spos))
continue;
}
+ Color featureColour = getColour(sequenceFeature);
+ boolean isContactFeature = sequenceFeature.isContactFeature();
+
if (offscreenRender && offscreenImage == null)
{
- if (sequenceFeature.begin <= start
- && sequenceFeature.end >= start)
+ /*
+ * offscreen mode with no image (image is only needed if transparency
+ * is applied to feature colours) - just check feature is rendered at
+ * the requested position (start == sequence position in this mode)
+ */
+ boolean featureIsAtPosition = sequenceFeature.begin <= start
+ && sequenceFeature.end >= start;
+ if (isContactFeature)
+ {
+ featureIsAtPosition = sequenceFeature.begin == start
+ || sequenceFeature.end == start;
+ }
+ if (featureIsAtPosition)
{
// this is passed out to the overview and other sequence renderers
// (e.g. molecule viewer) to get displayed colour for rendered
// sequence
- currentColour = new Integer(getColour(sequenceFeature).getRGB());
+ currentColour = new Integer(featureColour.getRGB());
// used to be retreived from av.featuresDisplayed
// currentColour = av.featuresDisplayed
// .get(sequenceFeatures[sfindex].type);
}
}
- else if (sequenceFeature.type.equals("disulfide bond"))
+ else if (isContactFeature)
{
renderFeature(g, seq, seq.findIndex(sequenceFeature.begin) - 1,
- seq.findIndex(sequenceFeature.begin) - 1,
- getColour(sequenceFeature)
- // new Color(((Integer) av.featuresDisplayed
- // .get(sequenceFeatures[sfindex].type)).intValue())
- , start, end, y1);
+ seq.findIndex(sequenceFeature.begin) - 1, featureColour,
+ start, end, y1);
renderFeature(g, seq, seq.findIndex(sequenceFeature.end) - 1,
- seq.findIndex(sequenceFeature.end) - 1,
- getColour(sequenceFeature)
- // new Color(((Integer) av.featuresDisplayed
- // .get(sequenceFeatures[sfindex].type)).intValue())
- , start, end, y1);
+ seq.findIndex(sequenceFeature.end) - 1, featureColour,
+ start, end, y1);
}
else if (showFeature(sequenceFeature))
renderScoreFeature(g, seq,
seq.findIndex(sequenceFeature.begin) - 1,
seq.findIndex(sequenceFeature.end) - 1,
- getColour(sequenceFeature), start, end, y1,
+ featureColour, start, end, y1,
normaliseScore(sequenceFeature));
}
else
{
renderFeature(g, seq, seq.findIndex(sequenceFeature.begin) - 1,
seq.findIndex(sequenceFeature.end) - 1,
- getColour(sequenceFeature), start, end, y1);
+ featureColour, start, end, y1);
}
}
-
}
-
}
if (transparency != 1.0f && g != null)
}
/**
+ * Answers true if the feature belongs to a feature group which is not
+ * currently displayed, else false
+ *
+ * @param sequenceFeature
+ * @return
+ */
+ protected boolean featureGroupNotShown(
+ final SequenceFeature sequenceFeature)
+ {
+ return featureGroups != null
+ && sequenceFeature.featureGroup != null
+ && sequenceFeature.featureGroup.length() != 0
+ && featureGroups.containsKey(sequenceFeature.featureGroup)
+ && !featureGroups.get(sequenceFeature.featureGroup)
+ .booleanValue();
+ }
+
+ /**
* Called when alignment in associated view has new/modified features to
* discover and display.
*
*/
package jalview.structure;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
public interface SequenceListener
// TODO remove this? never called on SequenceListener type
public void mouseOverSequence(SequenceI sequence, int index, int pos);
- public void highlightSequence(jalview.datamodel.SearchResults results);
+ public void highlightSequence(SearchResultsI results);
// TODO remove this? never called
public void updateColours(SequenceI sequence, int index);
import jalview.datamodel.Annotation;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JmolParser;
import jalview.gui.IProgressIndicator;
return;
}
- SearchResults results = new SearchResults();
+ SearchResultsI results = new SearchResults();
for (AtomSpec atom : atoms)
{
SequenceI lastseq = null;
{
boolean hasSequenceListeners = handlingVamsasMo
|| !seqmappings.isEmpty();
- SearchResults results = null;
+ SearchResultsI results = null;
if (seqPos == -1)
{
seqPos = seq.findPosition(indexpos);
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
-import jalview.datamodel.SearchResults.Match;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
/*
* Determine all mappings from this position to mapped sequences.
*/
- SearchResults sr = buildSearchResults(seq, seqpos, mappings);
+ SearchResultsI sr = buildSearchResults(seq, seqpos, mappings);
if (!sr.isEmpty())
{
* @param seqmappings
* @return
*/
- public static SearchResults buildSearchResults(SequenceI seq, int index,
+ public static SearchResultsI buildSearchResults(SequenceI seq, int index,
List<AlignedCodonFrame> seqmappings)
{
- SearchResults results = new SearchResults();
+ SearchResultsI results = new SearchResults();
addSearchResults(results, seq, index, seqmappings);
return results;
}
* @param index
* @param seqmappings
*/
- public static void addSearchResults(SearchResults results, SequenceI seq,
+ public static void addSearchResults(SearchResultsI results, SequenceI seq,
int index, List<AlignedCodonFrame> seqmappings)
{
if (index >= seq.getStart() && index <= seq.getEnd())
*/
List<AlignedCodonFrame> mapping = Arrays
.asList(new AlignedCodonFrame[] { acf });
- SearchResults sr = buildSearchResults(selected,
+ SearchResultsI sr = buildSearchResults(selected,
startResiduePos, mapping);
- for (Match m : sr.getResults())
+ for (SearchResultMatchI m : sr.getResults())
{
mappedStartResidue = m.getStart();
mappedEndResidue = m.getEnd();
}
sr = buildSearchResults(selected, endResiduePos, mapping);
- for (Match m : sr.getResults())
+ for (SearchResultMatchI m : sr.getResults())
{
mappedStartResidue = Math.min(mappedStartResidue,
m.getStart());
* Get the residue position and find the mapped position.
*/
int residuePos = fromSeq.findPosition(col);
- SearchResults sr = buildSearchResults(fromSeq, residuePos, mappings);
- for (Match m : sr.getResults())
+ SearchResultsI sr = buildSearchResults(fromSeq, residuePos, mappings);
+ for (SearchResultMatchI m : sr.getResults())
{
int mappedStartResidue = m.getStart();
int mappedEndResidue = m.getEnd();
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.ProfilesI;
-import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
* the SearchResults to add to
* @return the offset (below top of visible region) of the matched sequence
*/
- protected int findComplementScrollTarget(SearchResults sr)
+ protected int findComplementScrollTarget(SearchResultsI sr)
{
final AlignViewportI complement = getCodingComplement();
if (complement == null || !complement.isFollowHighlight())
*/
private boolean selectionIsDefinedGroup = false;
+
@Override
public boolean isSelectionDefinedGroup()
{
return selectionGroup.getContext() == alignment
|| selectionIsDefinedGroup;
}
+
+ /**
+ * null, or currently highlighted results on this view
+ */
+ private SearchResultsI searchResults = null;
+
+ @Override
+ public boolean hasSearchResults()
+ {
+ return searchResults != null;
+ }
+
+ @Override
+ public void setSearchResults(SearchResultsI results)
+ {
+ searchResults = results;
+ }
+
+ @Override
+ public SearchResultsI getSearchResults()
+ {
+ return searchResults;
+ }
}
continue;
}
- if ((features[i].getBegin() <= res)
- && (features[i].getEnd() >= res))
+ // check if start/end are at res, and if not a contact feature, that res
+ // lies between start and end
+ if ((features[i].getBegin() == res || features[i].getEnd() == res)
+ || (!features[i].isContactFeature()
+ && (features[i].getBegin() < res) && (features[i]
+ .getEnd() >= res)))
{
tmp.add(features[i]);
}
return fc.isColored(sequenceFeature);
}
+ /**
+ * Answers true if the feature type is currently selected to be displayed,
+ * else false
+ *
+ * @param type
+ * @return
+ */
protected boolean showFeatureOfType(String type)
{
- return av.getFeaturesDisplayed().isVisible(type);
+ return type == null ? false : av.getFeaturesDisplayed().isVisible(type);
}
@Override
import jalview.datamodel.Annotation;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.Mapping;
-import jalview.datamodel.SearchResults;
-import jalview.datamodel.SearchResults.Match;
+import jalview.datamodel.SearchResultMatchI;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
assertEquals(1, mappings.size());
// map G to GGG
- SearchResults sr = MappingUtils.buildSearchResults(pep1, 1, mappings);
+ SearchResultsI sr = MappingUtils.buildSearchResults(pep1, 1, mappings);
assertEquals(1, sr.getResults().size());
- Match m = sr.getResults().get(0);
+ SearchResultMatchI m = sr.getResults().get(0);
assertSame(cds1Dss, m.getSequence());
assertEquals(1, m.getStart());
assertEquals(3, m.getEnd());
List<AlignedCodonFrame> pep1CdsMappings = MappingUtils
.findMappingsForSequence(cds.getSequenceAt(0), pep1Mappings);
assertEquals(1, pep1CdsMappings.size());
- SearchResults sr = MappingUtils.buildSearchResults(pep1, 1,
+ SearchResultsI sr = MappingUtils.buildSearchResults(pep1, 1,
pep1CdsMappings);
assertEquals(1, sr.getResults().size());
- Match m = sr.getResults().get(0);
+ SearchResultMatchI m = sr.getResults().get(0);
assertEquals(cds.getSequenceAt(0).getDatasetSequence(), m.getSequence());
assertEquals(1, m.getStart());
assertEquals(3, m.getEnd());
assertEquals(1, mappings.size());
// map G to GGG
- SearchResults sr = MappingUtils.buildSearchResults(pep3, 1, mappings);
+ SearchResultsI sr = MappingUtils.buildSearchResults(pep3, 1, mappings);
assertEquals(1, sr.getResults().size());
- Match m = sr.getResults().get(0);
+ SearchResultMatchI m = sr.getResults().get(0);
assertSame(cds.getSequenceAt(0).getDatasetSequence(), m.getSequence());
assertEquals(1, m.getStart());
assertEquals(3, m.getEnd());
--- /dev/null
+package jalview.analysis;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResultMatchI;
+import jalview.datamodel.SearchResultsI;
+import jalview.datamodel.Sequence;
+import jalview.gui.AlignFrame;
+import jalview.io.FileLoader;
+import jalview.io.FormatAdapter;
+
+import java.util.List;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class FinderTest
+{
+ private AlignFrame af;
+
+ private AlignmentI al;
+
+ @BeforeClass(groups = "Functional")
+ public void setUp()
+ {
+ String seqData = "seq1 ABCD--EF-GHI\n" + "seq2 A--BCDefHI\n"
+ + "seq3 --bcdEFH\n" + "seq4 aa---aMMMMMaaa\n";
+ af = new FileLoader().LoadFileWaitTillLoaded(seqData,
+ FormatAdapter.PASTE);
+ al = af.getViewport().getAlignment();
+ }
+
+ /**
+ * Test for find all matches of a regular expression
+ */
+ @Test(groups = "Functional")
+ public void testFindAll_regex()
+ {
+ Finder f = new Finder(al, null);
+ f.setFindAll(true);
+ f.find("E.H"); // 'E, any character, H'
+
+ // should match seq2 efH and seq3 EFH
+ SearchResultsI sr = f.getSearchResults();
+ assertEquals(sr.getSize(), 2);
+ List<SearchResultMatchI> matches = sr.getResults();
+ assertSame(al.getSequenceAt(1), matches.get(0).getSequence());
+ assertSame(al.getSequenceAt(2), matches.get(1).getSequence());
+ assertEquals(matches.get(0).getStart(), 5);
+ assertEquals(matches.get(0).getEnd(), 7);
+ assertEquals(matches.get(1).getStart(), 4);
+ assertEquals(matches.get(1).getEnd(), 6);
+ }
+
+ /**
+ * Test for (undocumented) find residue by position
+ */
+ @Test(groups = "Functional")
+ public void testFind_residueNumber()
+ {
+ Finder f = new Finder(al, null);
+ f.setFindAll(true);
+ f.find("9");
+
+ // seq1 and seq4 have 9 residues; no match in other sequences
+ SearchResultsI sr = f.getSearchResults();
+ assertEquals(sr.getSize(), 2);
+ List<SearchResultMatchI> matches = sr.getResults();
+ assertSame(al.getSequenceAt(0), matches.get(0).getSequence());
+ assertSame(al.getSequenceAt(3), matches.get(1).getSequence());
+ assertEquals(matches.get(0).getStart(), 9);
+ assertEquals(matches.get(0).getEnd(), 9);
+ assertEquals(matches.get(1).getStart(), 9);
+ assertEquals(matches.get(1).getEnd(), 9);
+ }
+
+ /**
+ * Test for find next action
+ */
+ @Test(groups = "Functional")
+ public void testFindNext()
+ {
+ /*
+ * start at second sequence; resIndex of -1
+ * means sequence id / description is searched
+ */
+ Finder f = new Finder(al, null, 1, -1);
+ f.find("e"); // matches id
+
+ assertTrue(f.getSearchResults().isEmpty());
+ assertEquals(f.getIdMatch().size(), 1);
+ assertSame(f.getIdMatch().get(0), al.getSequenceAt(1));
+
+ // resIndex is now 0 - for use in next find next
+ assertEquals(f.getResIndex(), 0);
+ f = new Finder(al, null, 1, 0);
+ f.find("e"); // matches in sequence
+ assertTrue(f.getIdMatch().isEmpty());
+ assertEquals(f.getSearchResults().getSize(), 1);
+ List<SearchResultMatchI> matches = f.getSearchResults().getResults();
+ assertEquals(matches.get(0).getStart(), 5);
+ assertEquals(matches.get(0).getEnd(), 5);
+ assertSame(matches.get(0).getSequence(), al.getSequenceAt(1));
+ // still in the second sequence
+ assertEquals(f.getSeqIndex(), 1);
+ // next residue position to search from is 5
+ // (used as base 0 by RegEx so the same as 6 if base 1)
+ assertEquals(f.getResIndex(), 5);
+
+ // find next from end of sequence - finds next sequence id
+ f = new Finder(al, null, 1, 5);
+ f.find("e");
+ assertEquals(f.getIdMatch().size(), 1);
+ assertSame(f.getIdMatch().get(0), al.getSequenceAt(2));
+ }
+
+ /**
+ * Test for matching within sequence descriptions
+ */
+ @Test(groups = "Functional")
+ public void testFindAll_inDescription()
+ {
+ AlignmentI al2 = new Alignment(al);
+ al2.getSequenceAt(0).setDescription("BRAF");
+ al2.getSequenceAt(1).setDescription("braf");
+ Finder f = new Finder(al2, null);
+ f.setFindAll(true);
+ f.setIncludeDescription(true);
+
+ f.find("rAF");
+ assertEquals(f.getIdMatch().size(), 2);
+ assertSame(f.getIdMatch().get(0), al2.getSequenceAt(0));
+ assertSame(f.getIdMatch().get(1), al2.getSequenceAt(1));
+ assertTrue(f.getSearchResults().isEmpty());
+
+ /*
+ * case sensitive
+ */
+ f = new Finder(al2, null);
+ f.setFindAll(true);
+ f.setCaseSensitive(true);
+ f.setIncludeDescription(true);
+
+ f.find("RAF");
+ assertEquals(f.getIdMatch().size(), 1);
+ assertSame(f.getIdMatch().get(0), al2.getSequenceAt(0));
+ assertTrue(f.getSearchResults().isEmpty());
+
+ /*
+ * match sequence id, description and sequence!
+ */
+ al2.getSequenceAt(0).setDescription("the efh sequence");
+ al2.getSequenceAt(0).setName("mouseEFHkinase");
+ al2.getSequenceAt(1).setName("humanEFHkinase");
+ f = new Finder(al2, null);
+ f.setFindAll(true);
+ f.setIncludeDescription(true);
+
+ /*
+ * sequence matches should have no duplicates
+ */
+ f.find("EFH");
+ assertEquals(f.getIdMatch().size(), 2);
+ assertSame(f.getIdMatch().get(0), al2.getSequenceAt(0));
+ assertSame(f.getIdMatch().get(1), al2.getSequenceAt(1));
+
+ assertEquals(f.getSearchResults().getSize(), 2);
+ SearchResultMatchI match = f.getSearchResults().getResults().get(0);
+ assertSame(al2.getSequenceAt(1), match.getSequence());
+ assertEquals(5, match.getStart());
+ assertEquals(7, match.getEnd());
+ match = f.getSearchResults().getResults().get(1);
+ assertSame(al2.getSequenceAt(2), match.getSequence());
+ assertEquals(4, match.getStart());
+ assertEquals(6, match.getEnd());
+ }
+
+ /**
+ * Test for matching within sequence ids
+ */
+ @Test(groups = "Functional")
+ public void testFindAll_sequenceIds()
+ {
+ Finder f = new Finder(al, null);
+ f.setFindAll(true);
+
+ /*
+ * case insensitive
+ */
+ f.find("SEQ1");
+ assertEquals(f.getIdMatch().size(), 1);
+ assertSame(f.getIdMatch().get(0), al.getSequenceAt(0));
+ assertTrue(f.getSearchResults().isEmpty());
+
+ /*
+ * case sensitive
+ */
+ f = new Finder(al, null);
+ f.setFindAll(true);
+ f.setCaseSensitive(true);
+ f.find("SEQ1");
+ assertTrue(f.getSearchResults().isEmpty());
+
+ /*
+ * match both sequence id and sequence
+ */
+ AlignmentI al2 = new Alignment(al);
+ al2.addSequence(new Sequence("aBz", "xyzabZpqrAbZ"));
+ f = new Finder(al2, null);
+ f.setFindAll(true);
+ f.find("ABZ");
+ assertEquals(f.getIdMatch().size(), 1);
+ assertSame(f.getIdMatch().get(0), al2.getSequenceAt(4));
+ assertEquals(f.getSearchResults().getSize(), 2);
+ SearchResultMatchI match = f.getSearchResults().getResults().get(0);
+ assertSame(al2.getSequenceAt(4), match.getSequence());
+ assertEquals(4, match.getStart());
+ assertEquals(6, match.getEnd());
+ match = f.getSearchResults().getResults().get(1);
+ assertSame(al2.getSequenceAt(4), match.getSequence());
+ assertEquals(10, match.getStart());
+ assertEquals(12, match.getEnd());
+ }
+
+ /**
+ * Test finding all matches of a sequence pattern in an alignment
+ */
+ @Test(groups = "Functional")
+ public void testFindAll_simpleMatch()
+ {
+ Finder f = new Finder(al, null);
+ f.setFindAll(true);
+
+ /*
+ * case insensitive first
+ */
+ f.find("EfH");
+ SearchResultsI searchResults = f.getSearchResults();
+ assertEquals(searchResults.getSize(), 2);
+ SearchResultMatchI match = searchResults.getResults().get(0);
+ assertSame(al.getSequenceAt(1), match.getSequence());
+ assertEquals(5, match.getStart());
+ assertEquals(7, match.getEnd());
+ match = searchResults.getResults().get(1);
+ assertSame(al.getSequenceAt(2), match.getSequence());
+ assertEquals(4, match.getStart());
+ assertEquals(6, match.getEnd());
+
+ /*
+ * case sensitive
+ */
+ f = new Finder(al, null);
+ f.setFindAll(true);
+ f.setCaseSensitive(true);
+ f.find("BC");
+ searchResults = f.getSearchResults();
+ assertEquals(searchResults.getSize(), 2);
+ match = searchResults.getResults().get(0);
+ assertSame(al.getSequenceAt(0), match.getSequence());
+ assertEquals(2, match.getStart());
+ assertEquals(3, match.getEnd());
+ match = searchResults.getResults().get(1);
+ assertSame(al.getSequenceAt(1), match.getSequence());
+ assertEquals(2, match.getStart());
+ assertEquals(3, match.getEnd());
+ }
+
+ /**
+ * Test for JAL-2302 to verify that sub-matches are not included in a find all
+ * result
+ */
+ @Test(groups = "Functional")
+ public void testFind_maximalResultOnly()
+ {
+ Finder f = new Finder(al, null);
+ f.setFindAll(true);
+ f.find("M+");
+ SearchResultsI searchResults = f.getSearchResults();
+ assertEquals(searchResults.getSize(), 1);
+ SearchResultMatchI match = searchResults.getResults().get(0);
+ assertSame(al.getSequenceAt(3), match.getSequence());
+ assertEquals(4, match.getStart()); // dataset sequence positions
+ assertEquals(8, match.getEnd()); // base 1
+ }
+}
import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
+import java.util.Arrays;
+
import org.testng.Assert;
import org.testng.annotations.Test;
+ "(" + s + ") should still be distinct from FER1_MAIZE (3)");
}
}
+
+ /**
+ * Check findFeatureAt doesn't return contact features except at contact
+ * points TODO:move to under the FeatureRendererModel test suite
+ */
+ @Test(groups = { "Functional" })
+ public void testFindFeatureAt_PointFeature() throws Exception
+ {
+ String alignment = "a CCCCCCGGGGGGCCCCCC\n" + "b CCCCCCGGGGGGCCCCCC\n"
+ + "c CCCCCCGGGGGGCCCCCC\n";
+ AlignFrame af = new jalview.io.FileLoader(false)
+ .LoadFileWaitTillLoaded(alignment, FormatAdapter.PASTE);
+ SequenceI aseq = af.getViewport().getAlignment().getSequenceAt(0);
+ SequenceFeature sf = null;
+ sf = new SequenceFeature("disulphide bond", "", 2, 5, Float.NaN, "");
+ aseq.addSequenceFeature(sf);
+ Assert.assertTrue(sf.isContactFeature());
+ af.refreshFeatureUI(true);
+ af.getFeatureRenderer().setAllVisible(Arrays.asList("disulphide bond"));
+ Assert.assertEquals(af.getFeatureRenderer().getDisplayedFeatureTypes()
+ .size(), 1, "Should be just one feature type displayed");
+ // step through and check for pointwise feature presence/absence
+ Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 1)
+ .size(), 0);
+ // step through and check for pointwise feature presence/absence
+ Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 2)
+ .size(), 1);
+ // step through and check for pointwise feature presence/absence
+ Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 3)
+ .size(), 0);
+ // step through and check for pointwise feature presence/absence
+ Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 4)
+ .size(), 0);
+ // step through and check for pointwise feature presence/absence
+ Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 5)
+ .size(), 1);
+ // step through and check for pointwise feature presence/absence
+ Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 6)
+ .size(), 0);
+ }
+
}
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.analysis.Finder;
+import jalview.api.AlignViewControllerI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.io.FileLoader;
+import jalview.io.FormatAdapter;
+import java.util.Arrays;
import java.util.BitSet;
import org.testng.annotations.Test;
@Test(groups = "Functional")
public void testFindColumnsWithFeature()
{
- SequenceI seq1 = new Sequence("seq1", "aMMMaaaaaaaaaaaaaaaa");
- SequenceI seq2 = new Sequence("seq2", "aaaMMMMMMMaaaaaaaaaa");
- SequenceI seq3 = new Sequence("seq3", "aaaaaaaaaaMMMMMaaaaa");
- SequenceI seq4 = new Sequence("seq3", "aaaaaaaaaaaaaaaaaaaa");
+ SequenceI seq1 = new Sequence("seq1", "-a-MMMaaaaaaaaaaaaaaaa");
+ SequenceI seq2 = new Sequence("seq2", "aa--aMM-MMMMMaaaaaaaaaa");
+ SequenceI seq3 = new Sequence("seq3", "abcab-caD-aaMMMMMaaaaa");
+ SequenceI seq4 = new Sequence("seq4", "abc--abcaaaaaaaaaaaaaa");
/*
* features start/end are base 1
null));
seq3.addSequenceFeature(new SequenceFeature("Metal", "desc", 11, 15,
0f, null));
+ // disulfide bond is a 'contact feature' - only select its 'start' and 'end'
+ seq3.addSequenceFeature(new SequenceFeature("disulfide bond", "desc", 8, 12,
+ 0f, null));
/*
- * select the first three columns --> Metal in seq1 2-3
+ * select the first five columns --> Metal in seq1 cols 4-5
*/
SequenceGroup sg = new SequenceGroup();
sg.setStartRes(0); // base 0
- sg.setEndRes(2);
+ sg.setEndRes(4);
sg.addSequence(seq1, false);
sg.addSequence(seq2, false);
sg.addSequence(seq3, false);
bs);
assertEquals(1, seqCount);
assertEquals(2, bs.cardinality());
- assertTrue(bs.get(1));
- assertTrue(bs.get(2));
+ assertTrue(bs.get(3)); // base 0
+ assertTrue(bs.get(4));
/*
- * select the first four columns: Metal in seq1 2:4, seq2 4:4
+ * select the first seven columns: Metal in seq1 cols 4-6, seq2 cols 6-7
*/
- sg.setEndRes(3);
+ sg.setEndRes(6);
bs.clear();
seqCount = AlignViewController.findColumnsWithFeature("Metal", sg, bs);
assertEquals(2, seqCount);
- assertEquals(3, bs.cardinality());
- assertTrue(bs.get(1));
- assertTrue(bs.get(2));
+ assertEquals(4, bs.cardinality());
assertTrue(bs.get(3));
+ assertTrue(bs.get(4));
+ assertTrue(bs.get(5));
+ assertTrue(bs.get(6));
/*
- * select column 11: Metal in seq3 only
+ * select column 14: Metal in seq3 only
*/
- sg.setStartRes(10);
- sg.setEndRes(10);
+ sg.setStartRes(13);
+ sg.setEndRes(13);
bs.clear();
seqCount = AlignViewController.findColumnsWithFeature("Metal", sg, bs);
assertEquals(1, seqCount);
assertEquals(1, bs.cardinality());
- assertTrue(bs.get(10));
+ assertTrue(bs.get(13));
/*
- * select columns 16-20: no Metal feature
+ * select columns 18-20: no Metal feature
*/
- sg.setStartRes(15);
+ sg.setStartRes(17);
sg.setEndRes(19);
bs.clear();
seqCount = AlignViewController.findColumnsWithFeature("Metal", sg, bs);
assertEquals(0, bs.cardinality());
/*
+ * columns 11-13 should not match disulfide bond at 8/12
+ */
+ sg.setStartRes(10);
+ sg.setEndRes(12);
+ bs.clear();
+ seqCount = AlignViewController.findColumnsWithFeature("disulfide bond",
+ sg, bs);
+ assertEquals(0, seqCount);
+ assertEquals(0, bs.cardinality());
+
+ /*
+ * columns 6-18 should match disulfide bond at columns 9, 14
+ */
+ sg.setStartRes(5);
+ sg.setEndRes(17);
+ bs.clear();
+ seqCount = AlignViewController.findColumnsWithFeature("disulfide bond",
+ sg, bs);
+ assertEquals(1, seqCount);
+ assertEquals(2, bs.cardinality());
+ assertTrue(bs.get(8));
+ assertTrue(bs.get(13));
+
+ /*
* look for a feature that isn't there
*/
sg.setStartRes(0);
assertEquals(0, seqCount);
assertEquals(0, bs.cardinality());
}
+
+ /**
+ * shameless copy of test data from findFeature for testing mark columns from
+ * highlight
+ */
+ @Test(groups = "Functional")
+ public void testSelectColumnsWithHighlight()
+ {
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "seq1 aMMMaaaaaaaaaaaaaaaa\n" + "seq2 aaaMMMMMMMaaaaaaaaaa\n"
+ + "seq3 aaaaaaaaaaMMMMMaaaaa\n"
+ + "seq4 aaaaaaaaaaaaaaaaaaaa\n", FormatAdapter.PASTE);
+
+ SearchResultsI sr = new SearchResults();
+ SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray();
+ SequenceI seq1 = sqs[0];
+ SequenceI seq2 = sqs[1];
+ SequenceI seq3 = sqs[2];
+ SequenceI seq4 = sqs[3];
+
+ /*
+ * features start/end are base 1
+ */
+ sr.addResult(seq1, 2, 4);
+ sr.addResult(seq2, 4, 10);
+ sr.addResult(seq3, 11, 15);
+
+ /*
+ * test Match/Find works first
+ */
+ Finder f = new Finder(af.getViewport().getAlignment(), null);
+ f.setFindAll(true);
+ f.setCaseSensitive(true);
+ f.find("M+");
+ assertEquals(
+ "Finder found different set of results to manually created SearchResults",
+ sr, f.getSearchResults());
+
+ /*
+ * now check simple mark columns from find operation
+ */
+ af.getViewport().setSearchResults(sr);
+ AlignViewControllerI avc = af.avc;
+
+ avc.markHighlightedColumns(false, false, false);
+ assertTrue("Didn't select highlighted columns", Arrays.deepEquals(af
+ .getViewport().getColumnSelection().getSelectedRanges()
+ .toArray(), new int[][] { { 1, 14 } }));
+ }
}
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
-import jalview.datamodel.SearchResults.Match;
-
import org.testng.annotations.Test;
public class MatchTest
@Test(groups = { "Functional" })
public void testToString()
{
- SequenceI seq = new Sequence("", "abcdefghijklm");
- Match m = new SearchResults().new Match(seq, 3, 5);
- assertEquals("2cde", m.toString());
- }
-
- @Test(groups = { "Functional" })
- public void testGetCharacters()
- {
- SequenceI seq = new Sequence("", "abcdefghijklm");
- Match m = new SearchResults().new Match(seq, 3, 5);
- assertEquals("cde", m.getCharacters());
+ SequenceI seq = new Sequence("Seq1", "abcdefghijklm");
+ SearchResultMatchI m = new SearchResults().new Match(seq, 3, 5);
+ assertEquals("Seq1/3-5", m.toString());
}
@Test(groups = { "Functional" })
{
SequenceI seq1 = new Sequence("", "abcdefghijklm");
SequenceI seq2 = new Sequence("", "abcdefghijklm");
- SearchResults sr1 = new SearchResults();
- SearchResults sr2 = new SearchResults();
+ SearchResultsI sr1 = new SearchResults();
+ SearchResultsI sr2 = new SearchResults();
assertFalse(sr1.equals(null));
assertFalse(sr1.equals(seq1));
/*
* same match but on different sequences - not equal
*/
- SearchResults sr3 = new SearchResults();
+ SearchResultsI sr3 = new SearchResults();
sr3.addResult(seq2, 1, 1);
assertFalse(sr1.equals(sr3));
assertFalse(sr3.equals(sr1));
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import jalview.datamodel.SearchResults.Match;
+import java.util.BitSet;
+import org.junit.Assert;
import org.testng.annotations.Test;
public class SearchResultsTest
@Test(groups = { "Functional" })
public void testToString()
{
- SequenceI seq = new Sequence("", "abcdefghijklm");
- SearchResults sr = new SearchResults();
+ SequenceI seq = new Sequence("Seq1", "abcdefghijklm");
+ SearchResultsI sr = new SearchResults();
sr.addResult(seq, 1, 1);
- assertEquals("0a", sr.toString());
+ assertEquals("[Seq1/1-1]", sr.toString());
sr.addResult(seq, 3, 5);
- assertEquals("0a2cde", sr.toString());
+ assertEquals("[Seq1/1-1, Seq1/3-5]", sr.toString());
- seq = new Sequence("", "pqrstuvwxy");
+ seq = new Sequence("Seq2", "pqrstuvwxy");
sr.addResult(seq, 6, 7);
- assertEquals("0a2cde5uv", sr.toString());
- }
-
- @Test(groups = { "Functional" })
- public void testGetCharacters()
- {
- SequenceI seq = new Sequence("", "abcdefghijklm");
- SearchResults sr = new SearchResults();
- sr.addResult(seq, 1, 1);
- assertEquals("a", sr.getCharacters());
- sr.addResult(seq, 3, 5);
- assertEquals("acde", sr.getCharacters());
-
- seq = new Sequence("", "pqrstuvwxy");
- sr.addResult(seq, 6, 7);
- assertEquals("acdeuv", sr.getCharacters());
+ assertEquals("[Seq1/1-1, Seq1/3-5, Seq2/6-7]", sr.toString());
}
@Test(groups = { "Functional" })
public void testEquals()
{
SequenceI seq1 = new Sequence("", "abcdefghijklm");
- SearchResults sr1 = new SearchResults();
- SearchResults sr2 = new SearchResults();
+ SearchResultsI sr1 = new SearchResults();
+ SearchResultsI sr2 = new SearchResults();
assertFalse(sr1.equals(null)); // null object
assertFalse(sr1.equals(seq1)); // wrong type
assertTrue(sr2.equals(sr1)); // reflexive
/*
- * only one result is not empty
+ * if only one result is not empty
*/
sr1.addResult(seq1, 1, 1);
assertTrue(sr1.equals(sr1));
{
SequenceI seq1 = new Sequence("", "abcdefghijklm");
SequenceI seq2 = new Sequence("", "abcdefghijklm");
- SearchResults sr1 = new SearchResults();
- SearchResults sr2 = new SearchResults();
+ SearchResultsI sr1 = new SearchResults();
+ SearchResultsI sr2 = new SearchResults();
sr1.addResult(seq1, 1, 1);
sr2.addResult(seq2, 1, 1);
public void testEquals_orderDiffers()
{
SequenceI seq1 = new Sequence("", "abcdefghijklm");
- SearchResults sr1 = new SearchResults();
- SearchResults sr2 = new SearchResults();
+ SearchResultsI sr1 = new SearchResults();
+ SearchResultsI sr2 = new SearchResults();
sr1.addResult(seq1, 1, 1);
sr1.addResult(seq1, 2, 2);
public void testHashcode()
{
SequenceI seq1 = new Sequence("", "abcdefghijklm");
- SearchResults sr1 = new SearchResults();
- SearchResults sr2 = new SearchResults();
+ SearchResultsI sr1 = new SearchResults();
+ SearchResultsI sr2 = new SearchResults();
/*
* both empty
public void testMatchConstructor()
{
SequenceI seq1 = new Sequence("", "abcdefghijklm");
- Match m = new SearchResults().new Match(seq1, 2, 5);
+ SearchResultMatchI m = new SearchResults().new Match(seq1, 2, 5);
assertSame(seq1, m.getSequence());
assertEquals(2, m.getStart());
assertEquals(5, m.getEnd());
assertEquals(2, m.getStart());
assertEquals(5, m.getEnd());
}
+
+ /**
+ * test markColumns for creating column selections
+ */
+ @Test(groups = { "Functional" })
+ public void testMarkColumns()
+ {
+ int marked = 0;
+ SequenceI seq1 = new Sequence("", "abcdefghijklm");
+ SequenceI seq2 = new Sequence("", "abcdefghijklm");
+ SequenceGroup s1g=new SequenceGroup(), s2g=new SequenceGroup(), sallg=new SequenceGroup();
+ s1g.addSequence(seq1, false);
+ s2g.addSequence(seq2, false);
+ sallg.addSequence(seq1, false);
+ sallg.addSequence(seq2, false);
+
+ SearchResultsI sr = new SearchResults();
+ BitSet bs = new BitSet();
+
+ SearchResultMatchI srm = null;
+ srm = sr.addResult(seq1, 1, 1);
+ Assert.assertNotNull("addResult didn't return Match", srm);
+ srm = sr.addResult(seq2, 1, 2);
+ assertEquals("Sequence reference not set", seq2, srm.getSequence());
+ assertEquals("match start incorrect", 1, srm.getStart());
+ assertEquals("match end incorrect", 2, srm.getEnd());
+
+ // set start/end range for groups to cover matches
+
+ s1g.setStartRes(0);
+ s1g.setEndRes(5);
+ s2g.setStartRes(0);
+ s2g.setEndRes(5);
+ sallg.setStartRes(0);
+ sallg.setEndRes(5);
+
+ /*
+ * just seq1
+ */
+ marked = sr.markColumns(s1g, bs);
+ // check the bitset cardinality before checking the return value
+ assertEquals("Didn't mark expected number", 1, bs.cardinality());
+ assertEquals("Didn't return count of number of bits marked", 1, marked);
+ assertTrue("Didn't mark expected position", bs.get(0));
+ // now check return value for marking the same again
+ assertEquals(
+ "Didn't count number of bits marked for existing marked set",
+ 0,
+ sr.markColumns(s1g, bs));
+ bs.clear();
+
+ /*
+ * just seq2
+ */
+ marked = sr.markColumns(s2g, bs);
+ assertEquals("Didn't mark expected number", 2, bs.cardinality());
+ assertEquals("Didn't return count of number of bits marked", 2, marked);
+ assertTrue("Didn't mark expected position (1)", bs.get(0));
+ assertTrue("Didn't mark expected position (2)", bs.get(1));
+
+ /*
+ * both seq1 and seq2
+ * should be same as seq2
+ */
+ BitSet allbs = new BitSet();
+ assertEquals(2, sr.markColumns(sallg, allbs));
+ assertEquals(bs, allbs);
+
+ // now check range selection
+
+ /*
+ * limit s2g to just the second column, sallg to the first column
+ */
+ s2g.setStartRes(1);
+ s2g.setEndRes(1);
+ sallg.setEndRes(0);
+ BitSet tbs = new BitSet();
+ assertEquals("Group start/end didn't select columns to mark",1, sr.markColumns(s2g, tbs));
+ assertEquals("Group start/end didn't select columns to mark", 1, sr.markColumns(sallg, tbs));
+ assertEquals(
+ "Didn't set expected number of columns in total for two successive marks",
+ 2, tbs.cardinality());
+ }
}
sf1.setStatus("new");
assertTrue(sf1.equals(sf2));
}
+
+ @Test(groups = { "Functional" })
+ public void testIsContactFeature()
+ {
+ SequenceFeature sf = new SequenceFeature("type", "desc", 22, 33, 12.5f,
+ "group");
+ assertFalse(sf.isContactFeature());
+ sf.setType("");
+ assertFalse(sf.isContactFeature());
+ sf.setType(null);
+ assertFalse(sf.isContactFeature());
+ sf.setType("Disulfide Bond");
+ assertTrue(sf.isContactFeature());
+ sf.setType("disulfide bond");
+ assertTrue(sf.isContactFeature());
+ sf.setType("Disulphide Bond");
+ assertTrue(sf.isContactFeature());
+ sf.setType("disulphide bond");
+ assertTrue(sf.isContactFeature());
+ }
}
import jalview.datamodel.Annotation;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.PDBEntry.Type;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.io.FileLoader;
af.getViewport().setGlobalColourScheme(cs);
assertFalse(cs.conservationApplied());
}
+
+ @Test(groups = { "Functional" })
+ public void testSetGetHasSearchResults()
+ {
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", FormatAdapter.FILE);
+ SearchResultsI sr = new SearchResults();
+ SequenceI s1 = af.getViewport().getAlignment().getSequenceAt(0);
+
+ // create arbitrary range on first sequence
+ sr.addResult(s1, s1.getStart() + 10, s1.getStart() + 15);
+
+ // test set
+ af.getViewport().setSearchResults(sr);
+ // has -> true
+ assertTrue(af.getViewport().hasSearchResults());
+ // get == original
+ assertEquals(sr, af.getViewport().getSearchResults());
+
+ // set(null) results in has -> false
+
+ af.getViewport().setSearchResults(null);
+ assertFalse(af.getViewport().hasSearchResults());
+ }
}
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.SearchResults;
-import jalview.datamodel.SearchResults.Match;
+import jalview.datamodel.SearchResultMatchI;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
/*
* Check protein residue 12 maps to codon 5-7, 13 to codon 8-10
*/
- SearchResults sr = MappingUtils.buildSearchResults(aseq1, 12, acfList);
+ SearchResultsI sr = MappingUtils.buildSearchResults(aseq1, 12, acfList);
assertEquals(1, sr.getResults().size());
- Match m = sr.getResults().get(0);
+ SearchResultMatchI m = sr.getResults().get(0);
assertEquals(seq1.getDatasetSequence(), m.getSequence());
assertEquals(5, m.getStart());
assertEquals(7, m.getEnd());
/*
* Check protein residue 8 maps to [6, 8, 9]
*/
- SearchResults sr = MappingUtils.buildSearchResults(aseq1, 8, acfList);
+ SearchResultsI sr = MappingUtils.buildSearchResults(aseq1, 8, acfList);
assertEquals(2, sr.getResults().size());
- Match m = sr.getResults().get(0);
+ SearchResultMatchI m = sr.getResults().get(0);
assertEquals(seq1.getDatasetSequence(), m.getSequence());
assertEquals(6, m.getStart());
assertEquals(6, m.getEnd());
<string><![CDATA[664]]></string>
</property>
<property name="sourceName">
- <string><![CDATA[Jmol-14.2.14_2015.06.11.jar]]></string>
+ <string><![CDATA[Jmol-14.6.4_2016.10.26.jar]]></string>
</property>
<property name="overrideUnixPermissions">
<boolean>false</boolean>
<boolean>true</boolean>
</property>
<property name="destinationName">
- <string><![CDATA[Jmol-14.2.14_2015.06.11.jar]]></string>
+ <string><![CDATA[Jmol-14.6.4_2016.10.26.jar]]></string>
</property>
<property name="fileSize">
<long>5417196</long>