Merge branch 'releases/Release_2_11_1_Branch'
authorJim Procter <jprocter@issues.jalview.org>
Thu, 29 Oct 2020 21:34:35 +0000 (21:34 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 29 Oct 2020 21:34:35 +0000 (21:34 +0000)
42 files changed:
RELEASE
doc/building.html
doc/building.md
examples/testdata/MN908947.jvp [new file with mode: 0644]
help/help/html/releases.html
help/help/html/whatsNew.html
src/jalview/analysis/AlignmentUtils.java
src/jalview/analysis/Finder.java
src/jalview/analysis/Grouping.java
src/jalview/analysis/SeqsetUtils.java
src/jalview/api/AlignViewportI.java
src/jalview/controller/AlignViewController.java
src/jalview/datamodel/AlignedCodonFrame.java
src/jalview/datamodel/AlignmentView.java
src/jalview/datamodel/MappedFeatures.java
src/jalview/datamodel/SearchResults.java
src/jalview/datamodel/SeqCigar.java
src/jalview/datamodel/SequenceFeature.java
src/jalview/gui/PopupMenu.java
src/jalview/io/EmblFlatFile.java
src/jalview/io/SequenceAnnotationReport.java
src/jalview/util/Comparison.java
src/jalview/util/MapList.java
src/jalview/util/MappingUtils.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java
src/jalview/ws/dbsources/EmblXmlSource.java
src/jalview/ws/jws2/MsaWSThread.java
test/jalview/analysis/AlignmentUtilsTests.java
test/jalview/analysis/FinderTest.java
test/jalview/analysis/GroupingTest.java
test/jalview/datamodel/AlignedCodonFrameTest.java
test/jalview/datamodel/SeqCigarTest.java
test/jalview/datamodel/SequenceFeatureTest.java
test/jalview/gui/SplitFrameTest.java [new file with mode: 0644]
test/jalview/io/EmblFlatFileTest.java
test/jalview/structure/Mapping.java
test/jalview/util/ComparisonTest.java
test/jalview/util/MapListTest.java
test/jalview/util/MappingUtilsTest.java
test/jalview/ws/dbsources/EmblXmlSourceTest.java
utils/install4j/install4j8_template.install4j

diff --git a/RELEASE b/RELEASE
index 90eaa35..b5ce6d5 100644 (file)
--- a/RELEASE
+++ b/RELEASE
@@ -1,2 +1,2 @@
 jalview.release=releases/Release_2_11_1_Branch
-jalview.version=2.11.1.2
+jalview.version=2.11.1.3
index cc5eb30..28206a6 100644 (file)
@@ -1,47 +1,78 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-  <meta http-equiv="Content-Style-Type" content="text/css" />
+  <meta charset="utf-8" />
   <meta name="generator" content="pandoc" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
   <title>Building Jalview from Source</title>
-  <style type="text/css">code{white-space: pre;}</style>
   <style type="text/css">
-div.sourceCode { overflow-x: auto; }
-table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
-  margin: 0; padding: 0; vertical-align: baseline; border: none; }
-table.sourceCode { width: 100%; line-height: 100%; }
-td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
-td.sourceCode { padding-left: 5px; }
-code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
-code > span.dt { color: #902000; } /* DataType */
-code > span.dv { color: #40a070; } /* DecVal */
-code > span.bn { color: #40a070; } /* BaseN */
-code > span.fl { color: #40a070; } /* Float */
-code > span.ch { color: #4070a0; } /* Char */
-code > span.st { color: #4070a0; } /* String */
-code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
-code > span.ot { color: #007020; } /* Other */
-code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
-code > span.fu { color: #06287e; } /* Function */
-code > span.er { color: #ff0000; font-weight: bold; } /* Error */
-code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
-code > span.cn { color: #880000; } /* Constant */
-code > span.sc { color: #4070a0; } /* SpecialChar */
-code > span.vs { color: #4070a0; } /* VerbatimString */
-code > span.ss { color: #bb6688; } /* SpecialString */
-code > span.im { } /* Import */
-code > span.va { color: #19177c; } /* Variable */
-code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
-code > span.op { color: #666666; } /* Operator */
-code > span.bu { } /* BuiltIn */
-code > span.ex { } /* Extension */
-code > span.pp { color: #bc7a00; } /* Preprocessor */
-code > span.at { color: #7d9029; } /* Attribute */
-code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
-code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
-code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
-code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
+      code{white-space: pre-wrap;}
+      span.smallcaps{font-variant: small-caps;}
+      span.underline{text-decoration: underline;}
+      div.column{display: inline-block; vertical-align: top; width: 50%;}
+  </style>
+  <style type="text/css">
+a.sourceLine { display: inline-block; line-height: 1.25; }
+a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
+a.sourceLine:empty { height: 1.2em; }
+.sourceCode { overflow: visible; }
+code.sourceCode { white-space: pre; position: relative; }
+div.sourceCode { margin: 1em 0; }
+pre.sourceCode { margin: 0; }
+@media screen {
+div.sourceCode { overflow: auto; }
+}
+@media print {
+code.sourceCode { white-space: pre-wrap; }
+a.sourceLine { text-indent: -1em; padding-left: 1em; }
+}
+pre.numberSource a.sourceLine
+  { position: relative; left: -4em; }
+pre.numberSource a.sourceLine::before
+  { content: attr(title);
+    position: relative; left: -1em; text-align: right; vertical-align: baseline;
+    border: none; pointer-events: all; display: inline-block;
+    -webkit-touch-callout: none; -webkit-user-select: none;
+    -khtml-user-select: none; -moz-user-select: none;
+    -ms-user-select: none; user-select: none;
+    padding: 0 4px; width: 4em;
+    color: #aaaaaa;
+  }
+pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
+div.sourceCode
+  {  }
+@media screen {
+a.sourceLine::before { text-decoration: underline; }
+}
+code span.al { color: #ff0000; font-weight: bold; } /* Alert */
+code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
+code span.at { color: #7d9029; } /* Attribute */
+code span.bn { color: #40a070; } /* BaseN */
+code span.bu { } /* BuiltIn */
+code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
+code span.ch { color: #4070a0; } /* Char */
+code span.cn { color: #880000; } /* Constant */
+code span.co { color: #60a0b0; font-style: italic; } /* Comment */
+code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
+code span.do { color: #ba2121; font-style: italic; } /* Documentation */
+code span.dt { color: #902000; } /* DataType */
+code span.dv { color: #40a070; } /* DecVal */
+code span.er { color: #ff0000; font-weight: bold; } /* Error */
+code span.ex { } /* Extension */
+code span.fl { color: #40a070; } /* Float */
+code span.fu { color: #06287e; } /* Function */
+code span.im { } /* Import */
+code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
+code span.kw { color: #007020; font-weight: bold; } /* Keyword */
+code span.op { color: #666666; } /* Operator */
+code span.ot { color: #007020; } /* Other */
+code span.pp { color: #bc7a00; } /* Preprocessor */
+code span.sc { color: #4070a0; } /* SpecialChar */
+code span.ss { color: #bb6688; } /* SpecialString */
+code span.st { color: #4070a0; } /* String */
+code span.va { color: #19177c; } /* Variable */
+code span.vs { color: #4070a0; } /* VerbatimString */
+code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
   </style>
   <style>
   @font-face {
@@ -707,7 +738,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
   </style>
 </head>
 <body>
-<div id="TOC">
+<nav id="TOC">
 <ul>
 <li><a href="#building-jalview-from-source">Building Jalview from Source</a><ul>
 <li><a href="#tldr">tl;dr</a></li>
@@ -716,7 +747,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 <li><a href="#gradle-and-git">gradle and git</a></li>
 </ul></li>
 <li><a href="#downloading-the-jalview-source-tree">Downloading the Jalview source tree</a><ul>
-<li><a href="#whats-in-the-source-tree">What's in the source tree?</a></li>
+<li><a href="#whats-in-the-source-tree">What’s in the source tree?</a></li>
 </ul></li>
 <li><a href="#building-jalview">Building Jalview</a><ul>
 <li><a href="#minimal-jalview-build">Minimal Jalview Build</a></li>
@@ -735,7 +766,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
 </ul></li>
 </ul></li>
 </ul>
-</div>
+</nav>
 <h1 id="building-jalview-from-source">Building Jalview from Source</h1>
 <h2 id="tldr">tl;dr</h2>
 <pre><code># download
@@ -744,7 +775,7 @@ git clone http://source.jalview.org/git/jalview.git
 cd jalview
 gradle shadowJar
 # run
-java -jar build/libs/jalview-all-11.jar
+java -jar build/libs/jalview-all-*-j11.jar
 
 # and/or create launcher
 gradle getdown
@@ -758,15 +789,15 @@ java -jar getdown-launcher.jar . jalview</code></pre>
 <p>The method here is described in terms of using a command line. You can easily do this on linux or in a Terminal window in macOS. You can do it in Windows.</p>
 <ul>
 <li>Java 11 compliant JDK</li>
-<li>gradle 5.2 or above</li>
+<li>gradle 5.2 or above <em>(NB gradle 6.6 and above currently produces NullPointerExceptions during the build. This is non-fatal and does not affect the build. Use gradle 6.5.1 to avoid this)</em></li>
 <li>git</li>
 </ul>
 <blockquote>
-<p>The versions and installation methods here are just suggestions (which we have tested so are known to work). If you need or wish to use different implementations (particularly you might need a bespoke JDK if you are on an exotic architecture) then the general build instructions should work with any gradle 5+. You should be able to compile the bytecode with any JDK Java 11+. The resulting bytecode (in particular the shadow jar) should be runnable in any JRE Java 1.8+. Remember that because Jalview and the getdown launcher are Java bytecode you can build on one system where you might have gradle, and run on another where you don't (JRE 1.8+ required).</p>
+<p>The versions and installation methods here are just suggestions (which we have tested so are known to work). If you need or wish to use different implementations (particularly you might need a bespoke JDK if you are on an exotic architecture) then the general build instructions should work with any gradle 5+. You should be able to compile the bytecode with any JDK Java 11+. The resulting bytecode (in particular the shadow jar) should be runnable in any JRE Java 1.8+. Remember that because Jalview and the getdown launcher are Java bytecode you can build on one system where you might have gradle, and run on another where you don’t (JRE 1.8+ required).</p>
 </blockquote>
 <h3 id="java-11-compliant-jdk">Java 11 compliant JDK</h3>
 <h4 id="all-platforms">All platforms</h4>
-<p>We recommend obtaining an OpenJDK JDK 11 (since 11 is the long term support release) from AdoptOpenJDK: <a href="https://adoptopenjdk.net/?variant=openjdk11&amp;jvmVariant=hotspot" class="uri">https://adoptopenjdk.net/?variant=openjdk11&amp;jvmVariant=hotspot</a>, either the <em>Installer</em> or <code>.zip</code>/<code>.tar.gz</code> variants whichever you prefer (if you're not sure, choose the <em>Installer</em>).</p>
+<p>We recommend obtaining an OpenJDK JDK 11 (since 11 is the long term support release) from AdoptOpenJDK: <a href="https://adoptopenjdk.net/?variant=openjdk11&amp;jvmVariant=hotspot" class="uri">https://adoptopenjdk.net/?variant=openjdk11&amp;jvmVariant=hotspot</a>, either the <em>Installer</em> or <code>.zip</code>/<code>.tar.gz</code> variants whichever you prefer (if you’re not sure, choose the <em>Installer</em>).</p>
 <blockquote>
 <h5 id="alternativecli-install-of-adoptopenjdk-11">Alternative/CLI install of AdoptOpenJDK 11</h5>
 <p>You can also install adoptopenjdk11 using either <code>brew</code> (macOS), <code>choco</code> (Windows) (see the section on <code>gradle</code> and <code>git</code> for more informaiton on <code>brew</code> and <code>choco</code>) or <code>yum</code> or <code>apt</code> (Linux):</p>
@@ -782,35 +813,35 @@ brew cask install adoptopenjdk11</code></pre>
 <p>You should be able to install the latest (or sufficiently recent) versions of gradle and git using your OS package manager.</p>
 <h4 id="macos">MacOS</h4>
 <p>we recommend using <code>brew</code>, which can be installed following the instructions at <a href="https://brew.sh/" class="uri">https://brew.sh/</a>. After installing <code>brew</code>, open a Terminal window and type in (using an Administrator privileged user):</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">brew</span> install gradle git</code></pre></div>
+<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb4-1" title="1"><span class="ex">brew</span> install gradle git</a></code></pre></div>
 <p>or if you aready have them installed but need to upgrade the version:</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">brew</span> upgrade gradle git</code></pre></div>
+<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb5-1" title="1"><span class="ex">brew</span> upgrade gradle git</a></code></pre></div>
 <h4 id="windows">Windows</h4>
 <p>we suggest using the <strong>Chocolatey</strong> package manager. See install instructions at <a href="https://chocolatey.org/" class="uri">https://chocolatey.org/</a>, and you will just need</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">choco</span> install gradle
-<span class="ex">choco</span> install git</code></pre></div>
+<div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb6-1" title="1"><span class="ex">choco</span> install gradle</a>
+<a class="sourceLine" id="cb6-2" title="2"><span class="ex">choco</span> install git</a></code></pre></div>
 <p>Alternatively, you could install a real <code>bash</code> shell and install both <code>gradle</code> and <code>git</code> through <code>apt-get</code>. See <a href="https://devblogs.microsoft.com/commandline/bash-on-ubuntu-on-windows-download-now-3/" class="uri">https://devblogs.microsoft.com/commandline/bash-on-ubuntu-on-windows-download-now-3/</a> for how to install the ubuntu bash shell in Windows 10.</p>
 <p>Another alternative would be to install them separately. For <code>gradle</code> follow the instructions at <a href="https://gradle.org/install/" class="uri">https://gradle.org/install/</a>, and for <code>git</code> here are a couple of suggestions: Git for Windows <a href="https://gitforwindows.org/" class="uri">https://gitforwindows.org/</a>. Getting the individual installs working together on the command line will be trickier so we recommend using Chocolatey or bash.</p>
 <h4 id="linux">Linux</h4>
-<p>this will depend on which distribution you're using.</p>
-<h5 id="for-debian-based-distributions-e.g.-mint-ubuntu-debian">For <em>Debian</em> based distributions (e.g. Mint, Ubuntu, Debian)</h5>
+<p>this will depend on which distribution you’re using.</p>
+<h5 id="for-debian-based-distributions-e.g.-mint-ubuntu-debian">For <em>Debian</em> based distributions (e.g. Mint, Ubuntu, Debian)</h5>
 <p>run</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"> <span class="fu">sudo</span> apt-get install gradle git</code></pre></div>
-<h5 id="for-rpm-based-distributions-e.g.-fedora-centos-redhat">for RPM-based distributions (e.g. Fedora, CentOS, RedHat)</h5>
+<div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb7-1" title="1"> <span class="fu">sudo</span> apt-get install gradle git</a></code></pre></div>
+<h5 id="for-rpm-based-distributions-e.g.-fedora-centos-redhat">for RPM-based distributions (e.g. Fedora, CentOS, RedHat)</h5>
 <p>run</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="fu">sudo</span> yum install gradle git</code></pre></div>
-<p>If you have some other version of linux you'll probably be able to work it out!</p>
+<div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb8-1" title="1"><span class="fu">sudo</span> yum install gradle git</a></code></pre></div>
+<p>If you have some other version of linux you’ll probably be able to work it out!</p>
 <h2 id="downloading-the-jalview-source-tree">Downloading the Jalview source tree</h2>
-<p>This can be done with <code>git</code>. On the command line, change directory to where you want to download Jalview's build-tree top level directory. Then run</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="fu">git</span> clone http://source.jalview.org/git/jalview.git</code></pre></div>
-<p>You'll get some progress output and after a minute or two you should have the full Jalview build-tree in the folder <code>jalview</code>.</p>
-<h3 id="whats-in-the-source-tree">What's in the source tree?</h3>
-<p>Jalview is a mature product with its codebase going back many years. As such it doesn't have a folder structure that most new gradle projects would have, so you might not find everything in the place you might expect. Here's a brief description of what you might find in the main folders under the <code>jalview</code> tree.</p>
+<p>This can be done with <code>git</code>. On the command line, change directory to where you want to download Jalview’s build-tree top level directory. Then run</p>
+<div class="sourceCode" id="cb9"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb9-1" title="1"><span class="fu">git</span> clone http://source.jalview.org/git/jalview.git</a></code></pre></div>
+<p>You’ll get some progress output and after a minute or two you should have the full Jalview build-tree in the folder <code>jalview</code>.</p>
+<h3 id="whats-in-the-source-tree">What’s in the source tree?</h3>
+<p>Jalview is a mature product with its codebase going back many years. As such it doesn’t have a folder structure that most new gradle projects would have, so you might not find everything in the place you might expect. Here’s a brief description of what you might find in the main folders under the <code>jalview</code> tree.</p>
 <p>Within the <code>jalview</code> folder you will find (of possible interest):</p>
 <table>
 <colgroup>
-<col width="16%" />
-<col width="83%" />
+<col style="width: 15%" />
+<col style="width: 84%" />
 </colgroup>
 <thead>
 <tr class="header">
@@ -821,7 +852,7 @@ brew cask install adoptopenjdk11</code></pre>
 <tbody>
 <tr class="odd">
 <td><code>bin/</code></td>
-<td>used by eclipse for compiled classes -- no need to touch this</td>
+<td>used by eclipse for compiled classes – no need to touch this</td>
 </tr>
 <tr class="even">
 <td><code>build/</code></td>
@@ -849,7 +880,7 @@ brew cask install adoptopenjdk11</code></pre>
 </tr>
 <tr class="even">
 <td><code>getdown/website/</code></td>
-<td>the assembled &quot;download&quot; folder used by getdown for downloads/upgrades</td>
+<td>the assembled “download” folder used by getdown for downloads/upgrades</td>
 </tr>
 <tr class="odd">
 <td><code>getdown/files/</code></td>
@@ -895,6 +926,10 @@ brew cask install adoptopenjdk11</code></pre>
 <td><code>gradle.properties</code></td>
 <td>configurable properties for the build process</td>
 </tr>
+<tr class="even">
+<td><code>RELEASE</code></td>
+<td>propertyfile configuring JALVIEW_VERSION (from jalview.version) and the release branch (from jalview.release). An alternative file can be specified via JALVIEW_RELEASE_FILE property</td>
+</tr>
 </tbody>
 </table>
 <p>Note that you need a Java 11 JDK to compile Jalview whether your target build is Java 1.8 or Java 11.</p>
@@ -907,33 +942,34 @@ brew cask install adoptopenjdk11</code></pre>
 </blockquote>
 <h3 id="minimal-jalview-build">Minimal Jalview Build</h3>
 <p>To compile the necessary class files, just run</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> compileJava</code></pre></div>
+<div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb11-1" title="1"><span class="ex">gradle</span> compileJava</a></code></pre></div>
 <p>to compile the classes into the <code>classes</code> folder. You should now be able to run the Jalview application directly with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">java</span> -cp <span class="st">&quot;classes:resources:help:j11lib/*&quot;</span> jalview.bin.Jalview</code></pre></div>
+<div class="sourceCode" id="cb12"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb12-1" title="1"><span class="ex">java</span> -cp <span class="st">&quot;classes:resources:help:j11lib/*&quot;</span> jalview.bin.Jalview</a></code></pre></div>
 <p>You can also run with an automatic large memory setting (which will set the maximum memory heap of the Jalview JVM to 90% of your local physical memory) and docked icon setting (if possible in your OS) with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">java</span> -cp <span class="st">&quot;classes:resources:help:j11lib/*&quot;</span> jalview.bin.Launcher</code></pre></div>
+<div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb13-1" title="1"><span class="ex">java</span> -cp <span class="st">&quot;classes:resources:help:j11lib/*&quot;</span> jalview.bin.Launcher</a></code></pre></div>
 <blockquote>
-<p><em>You must use just &quot;<code>j11lib/*</code>&quot; and not &quot;<code>j11lib/*.jar</code>&quot; as this is a special Java classpath argument wildcard interpreted by <code>java</code>, <strong>not</strong> a shell expansion wildcard interpreted by the shell.</em></p>
+<p><em>You must use just “<code>j11lib/*</code>” and not “<code>j11lib/*.jar</code>” as this is a special Java classpath argument wildcard interpreted by <code>java</code>, <strong>not</strong> a shell expansion wildcard interpreted by the shell.</em></p>
 </blockquote>
-<p>Note that <code>jalview.bin.Launcher</code> is a simplified launcher class that re-launches <code>jalview.bin.Jalview</code> with the same JRE (<em>not</em> the same JVM instance), classpath and arguments, but with an automatically determined <code>-Xmx...</code> memory setting if one hasn't been provided.</p>
+<p>Note that <code>jalview.bin.Launcher</code> is a simplified launcher class that re-launches <code>jalview.bin.Jalview</code> with the same JRE (<em>not</em> the same JVM instance), classpath and arguments, but with an automatically determined <code>-Xmx...</code> memory setting if one hasn’t been provided.</p>
 <h3 id="jalview-in-a-jar-file">Jalview in a Jar File</h3>
 <p>To package the <code>classes</code>, <code>resources</code>, and <code>help</code> into one jar, you can run</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> jar</code></pre></div>
+<div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb14-1" title="1"><span class="ex">gradle</span> jar</a></code></pre></div>
 <p>which assembles the Jalview classes and resources into <code>dist/jalview.jar</code></p>
 <p>To run this, use</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">java</span> -cp <span class="st">&quot;dist/jalview.jar:j11lib/*&quot;</span> jalview.bin.Jalview</code></pre></div>
+<div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb15-1" title="1"><span class="ex">java</span> -cp <span class="st">&quot;dist/jalview.jar:j11lib/*&quot;</span> jalview.bin.Jalview</a></code></pre></div>
 <h3 id="distributed-jar-files">Distributed Jar Files</h3>
 <p>To simplify this, all required <code>.jar</code> files can be assembled into the <code>dist</code> folder using</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> makeDist</code></pre></div>
+<div class="sourceCode" id="cb16"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb16-1" title="1"><span class="ex">gradle</span> makeDist</a></code></pre></div>
 <p>which puts all required jar files into <code>dist</code> so you can run with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">java</span> -cp <span class="st">&quot;dist/*&quot;</span> jalview.bin.Jalview</code></pre></div>
+<div class="sourceCode" id="cb17"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb17-1" title="1"><span class="ex">java</span> -cp <span class="st">&quot;dist/*&quot;</span> jalview.bin.Jalview</a></code></pre></div>
 <h3 id="single-shadow-jar-file">Single <em>shadow</em> Jar File</h3>
-<p>The shadow jar file is a single <code>.jar</code> that contains all required classes and resources from <code>jalview.jar</code> and all of the supporting libraries in <code>j11lib/*.jar</code> merged into one <code>.jar</code> archive file. A default launching class (<code>MAIN-CLASS: jalview.bin.Launcher</code>) is specified in the <code>.jar</code> manifest file (<code>META/MANIFEST.MF</code>) so a start class doesn't need to be specified.</p>
-<p>Build the shadow jar file in <code>build/lib/jalview-all-11.jar</code> with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> shadowJar</code></pre></div>
-<p>and run it with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">java</span> -jar build/lib/jalview-all-11.jar</code></pre></div>
-<p>Because no arguments are required, most OSes will associate a <code>.jar</code> file with the <code>java</code> application (if this has been installed through the OS and not just a local unzip) as a <code>-jar</code> argument so you may find you can launch <code>jalview-all-11.jar</code> just by double-clicking on it)!</p>
+<p>The shadow jar file is a single <code>.jar</code> that contains all required classes and resources from <code>jalview.jar</code> and all of the supporting libraries in <code>j11lib/*.jar</code> merged into one <code>.jar</code> archive file. A default launching class (<code>MAIN-CLASS: jalview.bin.Launcher</code>) is specified in the <code>.jar</code> manifest file (<code>META/MANIFEST.MF</code>) so a start class doesn’t need to be specified.</p>
+<p>Build the shadow jar file in <code>build/libs/jalview-all-VERSION-j11.jar</code> with</p>
+<div class="sourceCode" id="cb18"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb18-1" title="1"><span class="ex">gradle</span> shadowJar</a></code></pre></div>
+<p><strong>NB</strong> <code>VERSION</code> will be replaced with a version number or “<code>DEVELOPMENT</code>” depending on how the branch is set up.</p>
+<p>Run it with</p>
+<div class="sourceCode" id="cb19"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb19-1" title="1"><span class="ex">java</span> -jar build/libs/jalview-all-VERSION-j11.jar</a></code></pre></div>
+<p>Because no arguments are required, most OSes will associate a <code>.jar</code> file with the <code>java</code> application (if this has been installed through the OS and not just a local unzip) as a <code>-jar</code> argument so you may find you can launch <code>jalview-all-VERSION-j11.jar</code> just by double-clicking on it)!</p>
 <blockquote>
 <p>The <code>shadowJar</code> task is not a requirement for any other task, so to build the shadow jar file you must specify the <code>shadowJar</code> task.</p>
 </blockquote>
@@ -943,38 +979,39 @@ brew cask install adoptopenjdk11</code></pre>
 <h3 id="building-the-getdown-launcher">Building the <code>getdown</code> launcher</h3>
 <p>We have made significant customisations to the <code>getdown</code> launcher which you can find in <code>getdown/src/getdown</code>.</p>
 <blockquote>
-<p>You don't need to build this afresh as the required <code>gradle-core.jar</code> and <code>gradle-launcher.jar</code> files are already distributed in <code>j11lib</code> and <code>getdown/lib</code> but if you want to, then you'll need a working Maven and also a Java 8 JDK. Ensure the Java 8 <code>javac</code> is forefront in your path and do</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="bu">cd</span> getdown/src/getdown
-<span class="ex">mvn</span> clean package -Dgetdown.host.whitelist=<span class="st">&quot;jalview.org,*.jalview.org&quot;</span></code></pre></div>
-<p>and you will find the required <code>.jar</code> files in <code>core/target/gradle-core-XXX.jar</code> and <code>launcher/target/gradle-launcher-XXX.jar</code>. The <code>gradle-core.jar</code> should then be copied to all three of the <code>j8lib</code>, <code>j11lib</code> and <code>getdown/lib</code> folders, whilst the <code>gradle-launcher.jar</code> only needs to be copied to <code>getdown/lib</code>.</p>
+<p>You don’t need to build this afresh as the required <code>getdown-core.jar</code> and <code>getdown-launcher.jar</code> files are already distributed in <code>j11lib</code> and <code>getdown/lib</code> but if you want to, then you’ll need a working Maven and also a Java 8 JDK. Ensure the Java 8 <code>javac</code> is forefront in your path and do</p>
+<div class="sourceCode" id="cb20"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb20-1" title="1"><span class="bu">cd</span> getdown/src/getdown</a>
+<a class="sourceLine" id="cb20-2" title="2"><span class="ex">mvn</span> clean package -Dgetdown.host.whitelist=<span class="st">&quot;jalview.org,*.jalview.org&quot;</span></a></code></pre></div>
+<p>and you will find the required <code>.jar</code> files in <code>core/target/getdown-core-XXX.jar</code> and <code>launcher/target/getdown-launcher-XXX.jar</code>. The <code>getdown-core.jar</code> should then be copied to all three of the <code>j8lib</code>, <code>j11lib</code> and <code>getdown/lib</code> folders, whilst the <code>getdown-launcher.jar</code> only needs to be copied to <code>getdown/lib</code>.</p>
 <p>The <code>mvn</code> command should ideally include the <code>-Dgetdown.host.whitelist=*.jalview.org</code> setting. This, and the necessary file copying commands, can be found in <code>getdown/src/getdown/mvn_cmd</code>.</p>
 </blockquote>
 <p>To assemble Jalview with <code>getdown</code> use the following gradle task:</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> getdown</code></pre></div>
-<p>This puts all the necessary files to launch Jalview with <code>getdown</code> into <code>getdown/website/11/</code>. This could be treated as the reference folder for <code>getdown</code>, which is where a getdown launcher will check to see if the Jalview application files it has are up to date, and download if they aren't or it simply doesn't have them.</p>
+<div class="sourceCode" id="cb21"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb21-1" title="1"><span class="ex">gradle</span> getdown</a></code></pre></div>
+<p>This puts all the necessary files to launch Jalview with <code>getdown</code> into <code>getdown/website/11/</code>. This could be treated as the reference folder for <code>getdown</code>, which is where a getdown launcher will check to see if the Jalview application files it has are up to date, and download if they aren’t or it simply doesn’t have them.</p>
 <p>A minimal getdown-launcher can be found in <code>getdown/files/11/</code> which checks its up-to-date status with (the absolute path to) <code>getdown/website/11/</code>.</p>
 <p>This can be launched with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">java</span> -jar getdown/files/11/getdown-launcher.jar getdown/files/11/ jalview</code></pre></div>
+<div class="sourceCode" id="cb22"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb22-1" title="1"><span class="ex">java</span> -jar getdown/files/11/getdown-launcher.jar getdown/files/11/ jalview</a></code></pre></div>
 <blockquote>
-<p>We've already met the <code>-jar file.jar</code> arguments. The next argument is the working folder for getdown, and the final argument, &quot;<code>jalview</code>&quot;, is a getdown application id (only &quot;<code>jalview</code>&quot; is defined here).</p>
+<p>We’ve already met the <code>-jar file.jar</code> arguments. The next argument is the working folder for getdown, and the final argument, “<code>jalview</code>”, is a getdown application id (only “<code>jalview</code>” is defined here).</p>
 </blockquote>
+<p>The command line sequence for building and relocating the getdown artifacts can be executed as a script via <code>getdown/src/getdown/mvn_cmd</code>. Please make sure this script is kept up to date should the getdown build instructions change.</p>
 <h3 id="running-tests">Running tests</h3>
 <p>There are substantial tests written for Jalview that use TestNG, which you can run with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> test</code></pre></div>
+<div class="sourceCode" id="cb23"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb23-1" title="1"><span class="ex">gradle</span> test</a></code></pre></div>
 <p>These normally take around 5 - 10 minutes to complete and outputs its full results into the <code>tests/</code> folder. A summary of results should appear in your console.</p>
 <p>You can run different defined groups of tests with</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> test -PtestngGroups=Network</code></pre></div>
+<div class="sourceCode" id="cb24"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb24-1" title="1"><span class="ex">gradle</span> test -PtestngGroups=Network</a></code></pre></div>
 <p>Available groups include Functional (default), Network, External.</p>
 <h4 id="excluding-some-tests">Excluding some tests</h4>
-<p>Some of Jalview's Functional tests don't pass reliably in all environments. We tag these tests with a group like 'Not-bamboo' to mark them for exclusion when we run tests as part of continuous integration.</p>
+<p>Some of Jalview’s Functional tests don’t pass reliably in all environments. We tag these tests with a group like ‘Not-bamboo’ to mark them for exclusion when we run tests as part of continuous integration.</p>
 <p>To exclude one or more groups of tests, add them as a comma separated list in testngExcludedGroups.</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> test -PtestngExcludedGroups=Not-bamboo</code></pre></div>
+<div class="sourceCode" id="cb25"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb25-1" title="1"><span class="ex">gradle</span> test -PtestngExcludedGroups=Not-bamboo</a></code></pre></div>
 <h3 id="installer-packaging-with-install4j">Installer packaging with <em>install4j</em></h3>
 <p>Jalview is currently using <em>install4j</em> <a href="https://www.ej-technologies.com/products/install4j/overview.html" class="uri">https://www.ej-technologies.com/products/install4j/overview.html</a> as its installer packaging tool.</p>
 <p>If you have a licensed installation of <em>install4j</em> you can build Jalview installers by running</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> installers</code></pre></div>
+<div class="sourceCode" id="cb26"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb26-1" title="1"><span class="ex">gradle</span> installers</a></code></pre></div>
 <p>though you may need to fiddle with the <code>install4j</code> and <code>copyInstall4jTemplate</code> tasks in <code>build.gradle</code> file to point to your installation of <em>install4j</em> and also to bundled JREs if you want to bundle those into the installers.</p>
-<p>If you want more details, get in touch on our development mailing list <a href="mailto:jalview-dev@jalview.org">jalview-dev@jalview.org</a>. Sign up at <a href="http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-dev" class="uri">http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-dev</a>.</p>
+<p>If you want more details, get in touch on our development mailing list <a href="mailto:jalview-dev@jalview.org" class="email">jalview-dev@jalview.org</a>. Sign up at <a href="http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-dev" class="uri">http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-dev</a>.</p>
 <h2 id="gradle-properties">Gradle properties</h2>
 <p>There are a lot of properties configured in <code>gradle.properties</code> which we strongly recommend being left as they are unless you have a specific problem with the build process.</p>
 <p>There are a few gradle properties you might want to set on the command line with the <code>-P</code> flag when building a version of Jalview with specific requirements:</p>
@@ -982,19 +1019,19 @@ brew cask install adoptopenjdk11</code></pre>
 <p>This changes the <em>target</em> java bytecode version &gt; NOTE that you will need to use a Java 11 (or greater) JDK Java compiler to build Jalview for any byte-code target version.</p>
 <p>Valid values are <code>11</code> and <code>1.8</code>.</p>
 <p>e.g.</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> shadowJar -PJAVA_VERSION=1.8</code></pre></div>
+<div class="sourceCode" id="cb27"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb27-1" title="1"><span class="ex">gradle</span> shadowJar -PJAVA_VERSION=1.8</a></code></pre></div>
 <p>When using <code>-PJAVA_VERSION=1.8</code> the libraries from <code>j8lib</code> (instead of <code>j11lib</code>) will be used in the compile<br />
 and runtime classpath and also used in the <code>makeDist</code> build step. Where a Java version of <code>11</code> is used in folder and file names, it will instead use <code>1.8</code>. Also if you are building installer packages with <em>install4j</em> the package builder will look for JRE 1.8 bundles to package in the installers.</p>
 <blockquote>
 <p>Note that continued development of Jalview will assume a Java 11+ runtime environment, the 2.11.0 release will run under a Java 1.8 JRE with a few minor features disabled.</p>
 </blockquote>
 <h4 id="channel"><code>CHANNEL</code></h4>
-<p>This changes the <code>appbase</code> setting in <code>getdown.txt</code> (<code>appbase</code> is where the getdown launcher looks to see if there's an updated file) to point to a particular Jalview channel or some other appropriate place to look for required files. If the selected channel type requires the getdown <code>appbase</code> to be a local directory on the filesystem (instead of a website URL) then a modified version of the <code>getdown-launcher.jar</code> will be used to allow this. The two versions of the <code>getdown-launcher.jar</code> can be found in <code>getdown/lib</code>. Some other variables used in the build process might also be set differently depending on the value of <code>CHANNEL</code> to allow smooth operation of getdown in the given context.</p>
-<p>There are several values of <code>CHANNEL</code> that can be chosen, with a default of <code>LOCAL</code>. Here's what they're for and what they do:</p>
+<p>This changes the <code>appbase</code> setting in <code>getdown.txt</code> (<code>appbase</code> is where the getdown launcher looks to see if there’s an updated file) to point to a particular Jalview channel or some other appropriate place to look for required files. If the selected channel type requires the getdown <code>appbase</code> to be a local directory on the filesystem (instead of a website URL) then a modified version of the <code>getdown-launcher.jar</code> will be used to allow this. The two versions of the <code>getdown-launcher.jar</code> can be found in <code>getdown/lib</code>. Some other variables used in the build process might also be set differently depending on the value of <code>CHANNEL</code> to allow smooth operation of getdown in the given context.</p>
+<p>There are several values of <code>CHANNEL</code> that can be chosen, with a default of <code>LOCAL</code>. Here’s what they’re for and what they do:</p>
 <ul>
 <li><code>LOCAL</code>: This is for running the compiled application from the development directory. It will set
 <ul>
-<li><code>appbase</code> as <code>file://PATH/TO/YOUR/DEVELOPMENT/getdown/files/JAVA_VERSION</code> (e.g. <code>file://home/user/git/jalview/getdown/files/11</code>)</li>
+<li><code>appbase</code> as <code>file://PATH/TO/YOUR/DEVELOPMENT/getdown/files/JAVA_VERSION</code> (e.g. <code>file://home/user/git/jalview/getdown/files/11</code>)</li>
 <li>application subdir as <code>alt</code></li>
 <li>Getdown launcher can use a <code>file://</code> scheme appbase.</li>
 </ul></li>
@@ -1004,37 +1041,37 @@ and runtime classpath and also used in the <code>makeDist</code> build step. Whe
 <li>application subdir as <code>alt</code></li>
 <li>Getdown launcher cannot use a <code>file://</code> scheme appbase.</li>
 </ul></li>
-<li><code>DEVELOP</code>: This is for creating a <code>develop</code> appbase channel on the main web server. This won't become live until the actual getdown artefact is synced to the web server. It will set
+<li><code>DEVELOP</code>: This is for creating a <code>develop</code> appbase channel on the main web server. This won’t become live until the actual getdown artefact is synced to the web server. It will set
 <ul>
 <li><code>appbase</code> as <code>http://www.jalview.org/getdown/develop/JAVA_VERSION</code></li>
 <li>application subdir as <code>alt</code></li>
 <li>Getdown launcher cannot use a <code>file://</code> scheme appbase.</li>
 </ul></li>
-<li><code>SCRATCH-NAME</code>: This is for creating a temporary scratch appbase channel on the main web server. This won't become live until the actual getdown artefact is synced to the web server. This is meant for testing an over-the-air update without interfering with the live <code>release</code> or <code>develop</code> channels. The value of <code>NAME</code> can be any &quot;word-character&quot; [A-Za-z0-9_] It will set
+<li><code>SCRATCH-NAME</code>: This is for creating a temporary scratch appbase channel on the main web server. This won’t become live until the actual getdown artefact is synced to the web server. This is meant for testing an over-the-air update without interfering with the live <code>release</code> or <code>develop</code> channels. The value of <code>NAME</code> can be any “word-character” [A-Za-z0-9_] It will set
 <ul>
 <li><code>appbase</code> as <code>http://www.jalview.org/getdown/SCRATCH-NAME/JAVA_VERSION</code></li>
 <li>application subdir as <code>alt</code></li>
 <li>Getdown launcher cannot use a <code>file://</code> scheme appbase.</li>
 </ul></li>
-<li><code>TEST-LOCAL</code>: Like <code>SCRATCH</code> but with a specific <code>test-local</code> channel name and a local filesystem appbase. This is meant for testing an over-the-air update on the local filesystem. An extra property <code>LOCALDIR</code> must be given (e.g. <code>-PLOCALDIR=/home/user/tmp/test</code>) It will set
+<li><code>TEST-LOCAL</code>: Like <code>SCRATCH</code> but with a specific <code>test-local</code> channel name and a local filesystem appbase. This is meant for testing an over-the-air update on the local filesystem. An extra property <code>LOCALDIR</code> must be given (e.g. <code>-PLOCALDIR=/home/user/tmp/test</code>) It will set
 <ul>
 <li><code>appbase</code> as <code>file://${LOCALDIR}</code></li>
 <li>application subdir as <code>alt</code></li>
 <li>Getdown launcher can use a <code>file://</code> scheme appbase.</li>
 </ul></li>
-<li><code>TEST-RELEASE</code>: Like <code>SCRATCH</code> but with a specific <code>test-release</code> channel name. This won't become live until the actual getdown artefact is synced to the web server. This is meant for testing an over-the-air update without interfering with the live <code>release</code> or <code>develop</code> channels. It will set
+<li><code>TEST-RELEASE</code>: Like <code>SCRATCH</code> but with a specific <code>test-release</code> channel name. This won’t become live until the actual getdown artefact is synced to the web server. This is meant for testing an over-the-air update without interfering with the live <code>release</code> or <code>develop</code> channels. It will set
 <ul>
 <li><code>appbase</code> as <code>http://www.jalview.org/getdown/test-release/JAVA_VERSION</code></li>
 <li>application subdir as <code>alt</code></li>
 <li>Getdown launcher cannot use a <code>file://</code> scheme appbase.</li>
 </ul></li>
-<li><code>RELEASE</code>: This is for an actual release build, and will use an appbase on the main web server with the main <code>release</code> channel name. This won't become live until the actual getdown artefact is synced to the web server. It will set
+<li><code>RELEASE</code>: This is for an actual release build, and will use an appbase on the main web server with the main <code>release</code> channel name. This won’t become live until the actual getdown artefact is synced to the web server. It will set
 <ul>
 <li><code>appbase</code> as <code>http://www.jalview.org/getdown/release/JAVA_VERSION</code></li>
 <li>application subdir as <code>release</code></li>
 <li>Getdown launcher cannot use a <code>file://</code> scheme appbase.</li>
 </ul></li>
-<li><code>ARCHIVE</code>: This is a helper to create a channel for a specific release version, and will use an appbase on the main web server with a specific <code>archive/JALVIEW_VERSION</code> channel name. This won't become live until the actual getdown artefact is synced to the web server. You must also specify an <code>ARCHIVEDIR</code> property that points to an earlier version of Jalview with a <code>dist</code> directory containing the required jar files. This should create a getdown structure and digest with the older jar files. It will set
+<li><code>ARCHIVE</code>: This is a helper to create a channel for a specific release version, and will use an appbase on the main web server with a specific <code>archive/JALVIEW_VERSION</code> channel name. This won’t become live until the actual getdown artefact is synced to the web server. You must also specify an <code>ARCHIVEDIR</code> property that points to an earlier version of Jalview with a <code>dist</code> directory containing the required jar files. This should create a getdown structure and digest with the older jar files. It will set
 <ul>
 <li><code>appbase</code> as <code>http://www.jalview.org/getdown/archive/JALVIEW_VERSION/JAVA_VERSION</code></li>
 <li>application subdir as <code>alt</code></li>
@@ -1048,18 +1085,21 @@ and runtime classpath and also used in the <code>makeDist</code> build step. Whe
 </ul></li>
 </ul>
 <p>e.g.</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> getdown -PCHANNEL=SCRATCH-my_test_version</code></pre></div>
+<div class="sourceCode" id="cb28"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb28-1" title="1"><span class="ex">gradle</span> getdown -PCHANNEL=SCRATCH-my_test_version</a></code></pre></div>
+<h4 id="jalview_version-and-the-release-file">JALVIEW_VERSION and the RELEASE file</h4>
+<p>Any Jalview build will include the value of JALVIEW_VERSION in various places, including the ‘About’ and Jalview Desktop window title, and in filenames for the stand-alone executable jar. You can specify a custom version for a build via the JALVIEW_VERSION property, but for most situations, JALVIEW_VERSION will be automatically configured according to the value of the CHANNEL property, using the <code>jalview.version</code> property specified in the RELEASE file: - <code>CHANNEL=RELEASE</code> will set version to jalview.version - <code>CHANNEL=TEST or DEVELOP</code> will append ‘-test’ or ‘-develop’ to jalview.version</p>
+<p>It is also possible to specify a custom location for the RELEASE file via an optional JALVIEW_RELEASE_FILE property.</p>
 <h4 id="install4jmediatypes"><code>install4jMediaTypes</code></h4>
-<p>If you are building <em>install4j</em> installers (requires <em>install4j</em> to be installed) then this property specifies a comma-separated list of media types (i.e. platform specific installers) <em>install4j</em> should actually build.</p>
+<p>If you are building <em>install4j</em> installers (requires <em>install4j</em> to be installed) then this property specifies a comma-separated list of media types (i.e. platform specific installers) <em>install4j</em> should actually build.</p>
 <p>Currently the valid values are <code>linuxDeb</code>, <code>linuxRPM</code>, <code>macosArchive</code>, <code>unixArchive</code>, <code>unixInstaller</code>, <code>windows</code></p>
 <p>The default value is all of them.</p>
 <p>e.g.</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">gradle</span> installers -PJAVA_VERSION=1.8 -Pinstall4jMediaTypes=macosArchive</code></pre></div>
+<div class="sourceCode" id="cb29"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb29-1" title="1"><span class="ex">gradle</span> installers -PJAVA_VERSION=1.8 -Pinstall4jMediaTypes=macosArchive</a></code></pre></div>
 <p>To get an up-to-date list of possible values, you can run</p>
-<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="fu">perl</span> -n -e <span class="st">&#39;m/^\s*&lt;(\w+)[^&gt;]*\bmediaFileName=/ &amp;&amp; print &quot;$1\n&quot;;&#39;</span> utils/install4j/install4j_template.install4j  <span class="kw">|</span> <span class="fu">sort</span> -u</code></pre></div>
+<div class="sourceCode" id="cb30"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb30-1" title="1"><span class="fu">perl</span> -n -e <span class="st">&#39;m/^\s*&lt;(\w+)[^&gt;]*\bmediaFileName=/ &amp;&amp; print &quot;$1\n&quot;;&#39;</span> utils/install4j/install4j_template.install4j  <span class="kw">|</span> <span class="fu">sort</span> -u</a></code></pre></div>
 <p>in the <code>jalview</code> root folder.</p>
 <h2 id="enabling-code-coverage-with-openclover">Enabling Code Coverage with OpenClover</h2>
-<p>Bytecode instrumentation tasks are enabled by specifying 'true' (or just a non-whitespace non-numeric word) in the 'clover' property. This adds the 'openclover' plugin to the build script's classpath, making it possible to track code execution during test which can be viewed as an HTML report published at build/reports/clover/index.html.</p>
+<p>Bytecode instrumentation tasks are enabled by specifying ‘true’ (or just a non-whitespace non-numeric word) in the ‘clover’ property. This adds the ‘openclover’ plugin to the build script’s classpath, making it possible to track code execution during test which can be viewed as an HTML report published at build/reports/clover/index.html.</p>
 <p><code>gradle -Pclover=true test cloverReport</code></p>
 <h4 id="troubleshooting-report-generation">Troubleshooting report generation</h4>
 <p>The build forks a new JVM process to run the clover report generation tools (both XML and HTML reports are generated by default). The following properties can be used to specify additional options or adjust JVM memory settings. Default values for these options are:</p>
@@ -1075,31 +1115,28 @@ and runtime classpath and also used in the <code>makeDist</code> build step. Whe
 <h2 id="setting-up-in-eclipse-ide">Setting up in Eclipse IDE</h2>
 <h3 id="installing-eclipse-ide">Installing Eclipse IDE</h3>
 <p>We develop in Eclipse, and support settings to develop and save Jalview source code in our preferred style. We also support running the Jalview application, debugging and running tests with TestNG from within Eclipse.</p>
-<p>To get Jalview set up as a project in Eclipse, we recommend using at least the 2019-12 version of Eclipse IDE for Java Developers which you can download from the Eclipse website: <a href="https://www.eclipse.org/downloads/" class="uri">https://www.eclipse.org/downloads/</a>. Since Eclipse 2020-03 you are encouraged to use the Eclipse Installer (see the Eclipse Downloads page). In the installer, when given a choice of packages for Eclipse you should choose the &quot;Eclipse IDE for Enterprise Java Developers&quot; package.</p>
-<div class="figure">
-<img src="./images/eclipse_installer.png" title="Eclipse Installer screenshot" />
-
-</div>
+<p>To get Jalview set up as a project in Eclipse, we recommend using at least the 2020-03 version of Eclipse IDE for Java Developers which you can download from the Eclipse website: <a href="https://www.eclipse.org/downloads/" class="uri">https://www.eclipse.org/downloads/</a>. Since Eclipse 2020-03 you are encouraged to use the Eclipse Installer (see the Eclipse Downloads page). In the installer, when given a choice of packages for Eclipse you should choose the “Eclipse IDE for Enterprise Java Developers” package.</p>
+<p><img src="./images/eclipse_installer.png" title="Eclipse Installer screenshot" /></p>
 <p>Once Eclipse is installed, we also recommend installing several plugins from the Eclipse Marketplace.</p>
 <p>Some of these should already be installed with the Enterprise Java Developer package:</p>
-<ol style="list-style-type: decimal">
+<ol type="1">
 <li>Buildship Gradle Integration 3.0 (or greater)</li>
 <li>EclEmma Java Code Coverage</li>
 <li>Egit - Git Integration for Eclipse</li>
 </ol>
-<p>To install the others, launch Eclipse, and go to Help-&gt;Eclipse Marketplace...</p>
+<p>To install the others, launch Eclipse, and go to Help-&gt;Eclipse Marketplace…</p>
 <p>Search for and install:</p>
-<ol style="list-style-type: decimal">
+<ol type="1">
 <li>Groovy Development Tools 3.4.0 (or greater)</li>
 <li>Checkstyle Plug-in (optional)</li>
-<li>TestNG for Eclipse (optional -- only needed if you want to run tests from Eclipse)</li>
+<li>TestNG for Eclipse (optional – only needed if you want to run tests from Eclipse)</li>
 </ol>
 <blockquote>
-<p>At time of writing, TestNG for Eclipse does not show up in the Eclipse Marketplace as the latest released version does not install in Eclipse 2019-03. However, you can install a working release of TestNG for Eclipse by going to</p>
-<p>Help-&gt;Install New Software...</p>
+<p>At time of writing, TestNG for Eclipse does not show up in the Eclipse Marketplace as the latest released version does not install in Eclipse 2020-03. However, you can install a working release of TestNG for Eclipse by going to</p>
+<p>Help-&gt;Install New Software…</p>
 <p>and entering</p>
 <p><code>TestNG Release - https://dl.bintray.com/testng-team/testng-eclipse-release</code></p>
-<p>into the <em>Work with</em> box and click on the <em>Add...</em> button.</p>
+<p>into the <em>Work with</em> box and click on the <em>Add…</em> button.</p>
 <p>Eclipse might pause for a bit with the word <em>Pending</em> in the table below at this point, but it will eventually list TestNG with a selection box under the <em>Name</em> column.</p>
 <p>Select <em>TestNG</em> and carry on through the install process to install the TestNG plugin.</p>
 </blockquote>
@@ -1108,51 +1145,52 @@ and runtime classpath and also used in the <code>makeDist</code> build step. Whe
 <p>Java -&gt; Installed JREs</p>
 <p>If your Java 11 installation is not listed, click on</p>
 <p><em>Add</em> -&gt; Standard VM -&gt; <em>Next</em></p>
-<p>and enter the JRE home. You can browse to where it is installed. Give it a name (like &quot;AdoptOpenJDK 11&quot;). Select this JDK as the default JRE and click on <em>Apply and Close</em>.</p>
+<p>and enter the JRE home. You can browse to where it is installed. Give it a name (like “AdoptOpenJDK 11”). Select this JDK as the default JRE and click on <em>Apply and Close</em>.</p>
 <p>You can now import Jalview.</p>
 <h3 id="importing-jalview-as-an-eclipse-project">Importing Jalview as an Eclipse project</h3>
 <h4 id="importing-an-already-downloaded-git-repo">Importing an already downloaded git repo</h4>
 <p>If you have already downloaded Jalview using <code>git clone</code> then you can import this folder into Eclipse directly.</p>
+<p><strong>Before importing the cloned git repo you must create the Eclipse project files.</strong> You can do this by either running</p>
+<p><code>gradle eclipse</code></p>
+<p>or</p>
+<p>Unzipping the file <code>utils/eclipse/eclipse_startup_files.zip</code> in the base repo directory (<code>jalview</code>)</p>
 <p>It is important to import Jalview as a Gradle project (not as a Java project), so go to</p>
-<p>File-&gt;Import...</p>
+<p>File-&gt;Import…</p>
 <p>find and select</p>
 <p>Gradle-&gt;Existing Gradle Project</p>
 <p>and then click on the <em>Next</em> button.</p>
 <p>In the following options, it is the <strong>Project Root Directory</strong> you should set to be the <code>jalview</code> folder that git downloaded. Then you can click on the <em>Finish</em> button.</p>
 <h4 id="using-eclipse-ide-to-download-the-git-repo">Using Eclipse IDE to download the git repo</h4>
-<p>If you don't have git as a command line tool or would prefer to work entirely within Eclipse IDE then Eclipse's eGit plugin can set up a git repo of the jalview source. Go to</p>
-<p>File-&gt;Import...</p>
+<p>If you don’t have git as a command line tool or would prefer to work entirely within Eclipse IDE then Eclipse’s eGit plugin can set up a git repo of the jalview source. Go to</p>
+<p>File-&gt;Import…</p>
 <p>Find and select</p>
 <p>Git-&gt;Projects from Git</p>
 <p>and then click on the <em>Next</em> button.</p>
 <p>Then select Clone URI and click on <em>Next</em>.</p>
 <p>In the next window (Source Git Repository) you should put the <code>git clone</code> URL in the text box labelled <code>URI</code>. If you have a Jalview developer account (with a username and password for the Jalview git repository) then you should enter <code>https://source.jalview.org/git/jalview.git</code>. If you do not have a Jalview developer account then you should enter <code>http://source.jalview.org/git/jalview.git</code>. You will not be able to push any of your changes back to the Jalview git repository. However you can still pull all branches of the Jalview source code to your computer and develop the code there. &gt; You can sign up for a Jalview developer account at <a href="https://source.jalview.org/crucible/" class="uri">https://source.jalview.org/crucible/</a></p>
-<p>If you have a Jalview developer account, enter the username and password and decide if you want to use Eclipse's secure storage. If you don't have an account you can leave the Authentication section blank.</p>
-<div class="figure">
-<img src="./images/eclipse_egit_connection.png" alt="Eclipse eGit connection configuration" />
-<p class="caption">Eclipse eGit connection configuration</p>
-</div>
+<p>If you have a Jalview developer account, enter the username and password and decide if you want to use Eclipse’s secure storage. If you don’t have an account you can leave the Authentication section blank.</p>
+<figure>
+<img src="./images/eclipse_egit_connection.png" alt="Eclipse eGit connection configuration" /><figcaption>Eclipse eGit connection configuration</figcaption>
+</figure>
 <p>Click on the <em>Next</em> button.</p>
 <p>The next window (Branch Selection) gives a list of the many Jalview branches, which by default will be all checked. You probably only want to download one branch (you can always download others at a later time). This is likely to be the <code>develop</code> branch so you can click on the <em>Deselect All</em> button, find the <code>develop</code> branch (the filter text helps), select that, and then click on the <em>Next</em> button.</p>
 <p>Choose a directory to your copy of the git repo in, and leave the other options as they are and click on the <em>Next</em> button. The next stage may take a minute or two as it checks out the selected branch(es) from the Jalview git repository.</p>
-<p>When it has finished it is important to select <strong>Import as general project</strong> and then click on <em>Next</em>. &gt; Ideally there would be an <em>Import as gradle project</em> here but there isn't -- we'll sort that out later.</p>
-<div class="figure">
-<img src="./images/eclipse_egit_import.png" alt="Eclipse eGit import choice" />
-<p class="caption">Eclipse eGit import choice</p>
-</div>
+<p>When it has finished it is important to select <strong>Import as general project</strong> and then click on <em>Next</em>. &gt; Ideally there would be an <em>Import as gradle project</em> here but there isn’t – we’ll sort that out later.</p>
+<figure>
+<img src="./images/eclipse_egit_import.png" alt="Eclipse eGit import choice" /><figcaption>Eclipse eGit import choice</figcaption>
+</figure>
 <p>Click on the <em>Next</em> button.</p>
-<p>You can change the project name here. By default it will show as <strong>jalview</strong> which is fine unless you have another instance of the a Jalview project also called jalview, in which case you could change this project's name now to avoid a conflict within Eclipse.</p>
+<p>You can change the project name here. By default it will show as <strong>jalview</strong> which is fine unless you have another instance of the a Jalview project also called jalview, in which case you could change this project’s name now to avoid a conflict within Eclipse.</p>
 <p>Click on <em>Finish</em>!</p>
-<p>However, we haven't finished...</p>
+<p>However, we haven’t finished…</p>
 <p>You should now see, and be able to expand, the jalview project in the Project Explorer. We need to tell eclipse that this is a Gradle project, which will then allow the Eclipse Buildship plugin to automatically configure almost everything else!</p>
 <p>Right click on the project name (jalview) in the Project Explorer and find Configure towards the bottom of this long context menu, then choose Add Gradle Nature.</p>
-<div class="figure">
-<img src="./images/eclipse_add_gradle_nature.png" alt="Eclipse Add Gradle Nature" />
-<p class="caption">Eclipse Add Gradle Nature</p>
-</div>
+<figure>
+<img src="./images/eclipse_add_gradle_nature.png" alt="Eclipse Add Gradle Nature" /><figcaption>Eclipse Add Gradle Nature</figcaption>
+</figure>
 <p>The project should now reconfigure itself using the <code>build.gradle</code> file to dynamically set various aspects of the project including classpath.</p>
 <h4 id="additional-views">Additional views</h4>
-<p>Some views that are automatically added when Importing a Gradle Project are not added when simply Adding a Gradle Nature, but we can add these manually by clicking on Window-&gt;Show View-&gt;Console and Window-&gt;Show View-&gt;Other... Filter with the word &quot;gradle&quot; and choose both <strong>Gradle Executions</strong> and <strong>Gradle Tasks</strong> and then click on the <em>Open</em> button.</p>
+<p>Some views that are automatically added when Importing a Gradle Project are not added when simply Adding a Gradle Nature, but we can add these manually by clicking on Window-&gt;Show View-&gt;Console and Window-&gt;Show View-&gt;Other… Filter with the word “gradle” and choose both <strong>Gradle Executions</strong> and <strong>Gradle Tasks</strong> and then click on the <em>Open</em> button.</p>
 <p>Okay, ready to code! Use of Eclipse is beyond the scope of this document, but you can find more information about developing jalview and our developer workflow in the google doc <a href="https://docs.google.com/document/d/1lZo_pZRkazDBJGNachXr6qCVlw8ByuMYG6e9SZlPUlQ/edit?usp=sharing" class="uri">https://docs.google.com/document/d/1lZo_pZRkazDBJGNachXr6qCVlw8ByuMYG6e9SZlPUlQ/edit?usp=sharing</a></p>
 <hr />
 <p><a href="mailto:help@jalview.org">Jalview Development Team</a></p>
index 855f966..497e722 100644 (file)
@@ -9,7 +9,7 @@ git clone http://source.jalview.org/git/jalview.git
 cd jalview
 gradle shadowJar
 # run
-java -jar build/libs/jalview-all-11.jar
+java -jar build/libs/jalview-all-*-j11.jar
 
 # and/or create launcher
 gradle getdown
@@ -26,7 +26,7 @@ java -jar getdown-launcher.jar . jalview
 The method here is described in terms of using a command line.  You can easily do this on linux or in a Terminal window in macOS.  You can do it in Windows.
 
 * Java 11 compliant JDK
-* gradle 5.2 or above
+* gradle 5.2 or above *(NB gradle 6.6 and above currently produces NullPointerExceptions during the build. This is non-fatal and does not affect the build. Use gradle 6.5.1 to avoid this)*
 * git
 
 > The versions and installation methods here are just suggestions (which we have tested 
@@ -248,20 +248,23 @@ and all of the supporting libraries in `j11lib/*.jar` merged into one `.jar` arc
 file.  A default launching class (`MAIN-CLASS: jalview.bin.Launcher`) is specified in the `.jar` 
 manifest file (`META/MANIFEST.MF`) so a start class doesn't need to be specified.
 
-Build the shadow jar file in `build/lib/jalview-all-11.jar` with
+Build the shadow jar file in `build/libs/jalview-all-VERSION-j11.jar` with
 
 ```bash
 gradle shadowJar
 ```
-and run it with
+
+__NB__ `VERSION` will be replaced with a version number or "`DEVELOPMENT`" depending on how the branch is set up.
+
+Run it with
 
 ```bash
-java -jar build/lib/jalview-all-11.jar
+java -jar build/libs/jalview-all-VERSION-j11.jar
 ```
 
 Because no arguments are required, most OSes will associate a `.jar` file with the 
 `java` application (if this has been installed through the OS and not just a local 
-unzip) as a `-jar` argument so you may find you can launch `jalview-all-11.jar` 
+unzip) as a `-jar` argument so you may find you can launch `jalview-all-VERSION-j11.jar` 
 just by double-clicking on it)!
 
 > The `shadowJar` task is not a requirement for any other task, so to build the shadow 
@@ -537,7 +540,7 @@ We develop in Eclipse, and support settings to develop and save Jalview source c
 in our preferred style.  We also support running the Jalview application, debugging 
 and running tests with TestNG from within Eclipse.
 
-To get Jalview set up as a project in Eclipse, we recommend using at least the 2019-12 
+To get Jalview set up as a project in Eclipse, we recommend using at least the 2020-03
 version of Eclipse IDE for Java Developers which you can download from the Eclipse 
 website: <https://www.eclipse.org/downloads/>.  Since Eclipse 2020-03 you are encouraged to use the Eclipse Installer (see the Eclipse Downloads page).
 In the installer, when given a choice of packages for Eclipse you should choose the "Eclipse IDE for Enterprise Java Developers" package.
@@ -561,7 +564,7 @@ Search for and install:
 1. TestNG for Eclipse (optional -- only needed if you want to run tests from Eclipse)
 
 > At time of writing, TestNG for Eclipse does not show up in the Eclipse Marketplace 
-as the latest released version does not install in Eclipse 2019-03.
+as the latest released version does not install in Eclipse 2020-03.
 However, you can install a working release of TestNG for Eclipse by going to
 >
 Help->Install New Software...
@@ -601,6 +604,14 @@ You can now import Jalview.
 
 If you have already downloaded Jalview using `git clone` then you can import this folder into Eclipse directly.
 
+__Before importing the cloned git repo you must create the Eclipse project files.__ You can do this by either running
+
+`gradle eclipse`
+
+or
+
+Unzipping the file `utils/eclipse/eclipse_startup_files.zip` in the base repo directory (`jalview`)
+
 It is important to import 
 Jalview as a Gradle project (not as a Java project), so go to
 
diff --git a/examples/testdata/MN908947.jvp b/examples/testdata/MN908947.jvp
new file mode 100644 (file)
index 0000000..c5cd2ec
Binary files /dev/null and b/examples/testdata/MN908947.jvp differ
index 9d3c0d2..ec4f041 100755 (executable)
@@ -57,6 +57,66 @@ li:before {
     </tr>
     <tr>
       <td width="60" align="center" nowrap><strong><a
+          id="Jalview.2.11.1">2.11.1</a><a id="Jalview.2.11.1.3">.3</a><br />
+          <em>29/10/2020</em></strong></td>
+      <td align="left" valign="top">
+        <ul>
+
+        </ul>
+      </td>
+      <td align="left" valign="top">
+        <ul>
+          <li>
+            <!-- JAL-3765 -->Find doesn't always highlight all matching
+            positions in a sequence (bug introduced in 2.11.1.2)
+          </li>
+          <li>
+            <!-- JAL-3760 -->Alignments containing one or more protein
+            sequences can be classed as nucleotide
+          </li>
+          <li>
+            <!-- JAL-3748 -->CDS alignment doesn't match original CDS
+            sequences after alignment of protein products (known defect
+            first reported for 2.11.1.0)
+          </li>
+          <li>
+            <!-- JAL-3725 -->No tooltip or popup menu for genomic
+            features outwith CDS shown overlaid on protein
+          </li>
+          <li>
+            <!-- JAL-3751 -->Overlapping CDS in ENA accessions are not
+            correctly mapped by Jalview (e.g. affects viral CDS with
+            ribosomal slippage, since 2.9.0)
+          </li>
+          <li>
+            <!-- JAL-3763 -->Spliced transcript CDS sequences don't show
+            CDS features
+          </li>
+          <li>
+            <!-- JAL-3700 -->Selections in CDS sequence panel don't
+            always select corresponding protein sequences
+          </li>
+          <li>
+            <!-- JAL-3759 --> <em>Make groups from selection</em> for a
+            column selection doesn't always ignore hidden columns
+          </li>
+        </ul> <em>Installer</em>
+        <ul>
+          <li>
+            <!-- JAL-3611 -->Space character in Jalview install path on
+            Windows prevents install4j launching getdown
+          </li>
+        </ul> <em>Development</em>
+        <ul>
+          <li>
+            <!-- JAL-3248 -->Fixed typos and specified compatible gradle
+            version numbers in doc/building.md
+          </li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td width="60" align="center" nowrap><strong><a
           id="Jalview.2.11.1">2.11.1</a><a id="Jalview.2.11.1.2">.2</a><br />
           <em>25/09/2020</em></strong></td>
       <td align="left" valign="top">
@@ -255,6 +315,11 @@ li:before {
             <!-- JAL-3127 -->Sequence ID colourscheme not re-applied
             when alignment view restored from project (since Jalview 2.11.0)
           </li>
+          <li>
+            <!-- JAL-3749 -->Duplicate CDS sequences are generated when
+            protein products for certain ENA records are repeatedly
+            shown via Calculate-&gt;Show Cross Refs
+          </li>
         </ul>
       </td>
     </tr>
index cc91c62..bee8380 100755 (executable)
 </head>
 <body>
   <p>
-    <strong>Jalview 2.11.1.2</strong>
+    <strong>Jalview 2.11.1.3</strong>
   </p>
-  <p>Jalview 2.11.1.2 is the second patch release, fixing a bug
-    introduced in last weeks Jalview 2.11.1.1 release affecting display
-    of Jalview's example project for some users. Together, these
-    releases include fixes for a number of critical bugs, and also contains a
-    handful of new features suggested by the Jalview community.</p>
+  <p>Jalview 2.11.1.3 is the third patch release in the 2.11.1
+    series. Critical bugs resolved in this release include:</p>
   <ul>
-    <li>Shift+arrow keys navigate to next gap or residue in cursor
-      mode (enable with F2)</li>
-    <li>Support import of VCF 4.3 by updating HTSJDK from 2.12 to
-      2.23</li>
-    <li>Improved recognition of GZipped files from local disk or
-      retrieved via the web</li>
-    <li>EMBL and EMBL CDS database records retrieved from the
-      European Nucleotide Archive's Data API as 'EMBL Flatfile' records</li>
-    <li>Improved <a href="logging.html">Java Console and
-        logging</a> to help track down problems
-    </li>
-    <li>Improved support for Hi-DPI (4K) screens when running on
-      Linux (Requires Java 11+)</li>
-  </ul>
-  <p>Critical bug fixes include</p>
-  <ul>
-    <li>Jalview runs correctly when launched with Turkish language
-      settings</li>
-    <li>Peptide-to-CDS tracking broken when multiple EMBL gene
-      products shown for a single contig (such as viral genomes)</li>
-    <li>Errors encountered when processing variants from VCF files
-      yield "Error processing VCF: Format specifier '%s'" on the console</li>
-    <li>Count of features not shown can be wrong when there are
-      both DNA and Protein features mapped to the position under
-      the cursor</li>
-    <li>Sequence ID for reference sequence is clipped when Right
-      align Sequence IDs enabled</li>
-    <li>Find doesn't report matches that span hidden gapped columns</li>
-    <li>Jalview ignores file format parameter specifying output
-      format when exporting an alignment via the command line</li>
+    <li>Find doesn't highlight all motif matches for a sequence.</li>
+    <li>Mouse over highlighting, CDS reconstruction and problems
+      with virtual feature popups when working with linked CDS/Protein
+      alignments.</li>
+    <li>Result of aligning protein sequences linked to CDS results
+      in incorrect CDS alignment.</li>
+    <li>Jalview installer doesn't correctly install Jalview on
+      paths containing spaces.</li>
   </ul>
   <p>
-    For the full release notes, see <a href="releases.html#Jalview.2.11.1.1">the
-      Jalview 2.11.1.1 release notes</a>.
+    For the full release notes, see <a
+      href="releases.html#Jalview.2.11.1.3">the Jalview 2.11.1.3
+      release notes</a>.
   </p>
   <p>
     <strong>Known Issues</strong>
@@ -80,7 +56,7 @@
       v2.11.1.0)</li>
     <li>Drag and drop of alignment file onto alignment window when
       in a HiDPI scaled mode in Linux only works for the top left
-      quadrant of the alignment window</li>
+      quadrant of the alignment window.</li>
   </ul>
 </body>
 </html>
index 2b88cb0..d04d810 100644 (file)
  */
 package jalview.analysis;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import jalview.bin.Cache;
 import jalview.commands.RemoveGapColCommand;
 import jalview.datamodel.AlignedCodon;
 import jalview.datamodel.AlignedCodonFrame;
@@ -44,22 +61,6 @@ import jalview.util.IntRangeComparator;
 import jalview.util.MapList;
 import jalview.util.MappingUtils;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
 /**
  * grab bag of useful alignment manipulation operations Expect these to be
  * refactored elsewhere at some point.
@@ -960,11 +961,12 @@ public class AlignmentUtils
             .findMappingsForSequence(cdsSeq, mappings);
     for (AlignedCodonFrame mapping : dnaMappings)
     {
-      SequenceI peptide = mapping.findAlignedSequence(cdsSeq, protein);
+      List<SequenceToSequenceMapping> foundMap=new ArrayList<>();
+      SequenceI peptide = mapping.findAlignedSequence(cdsSeq, protein,foundMap);
       if (peptide != null)
       {
         final int peptideLength = peptide.getLength();
-        Mapping map = mapping.getMappingBetween(cdsSeq, peptide);
+        Mapping map = foundMap.get(0).getMapping();
         if (map != null)
         {
           MapList mapList = map.getMap();
@@ -977,10 +979,10 @@ public class AlignmentUtils
                   .getFromRanges());
           int mappedToLength = MappingUtils
                   .getLength(mapList.getToRanges());
-          boolean addStopCodon = (cdsLength == mappedFromLength
+          boolean addStopCodon = peptide.getDatasetSequence().getEnd()==peptide.getEnd() && ((cdsLength == mappedFromLength
                   * CODON_LENGTH + CODON_LENGTH)
                   || (peptide.getDatasetSequence()
-                          .getLength() == mappedFromLength - 1);
+                          .getLength() == mappedFromLength - 1));
           if (cdsLength != mappedToLength && !addStopCodon)
           {
             System.err.println(String.format(
@@ -1994,45 +1996,31 @@ public class AlignmentUtils
 
     SequenceI newSeq = null;
 
-    final MapList maplist = mapping.getMap();
-    if (maplist.isContiguous() && maplist.isFromForwardStrand())
-    {
-      /*
-       * just a subsequence, keep same dataset sequence
-       */
-      int start = maplist.getFromLowest();
-      int end = maplist.getFromHighest();
-      newSeq = seq.getSubSequence(start - 1, end);
-      newSeq.setName(seqId);
-    }
-    else
-    {
-      /*
-       * construct by splicing mapped from ranges
-       */
-      char[] seqChars = seq.getSequence();
-      List<int[]> fromRanges = maplist.getFromRanges();
-      int cdsWidth = MappingUtils.getLength(fromRanges);
-      char[] newSeqChars = new char[cdsWidth];
+    /*
+     * construct CDS sequence by splicing mapped from ranges
+     */
+    char[] seqChars = seq.getSequence();
+    List<int[]> fromRanges = mapping.getMap().getFromRanges();
+    int cdsWidth = MappingUtils.getLength(fromRanges);
+    char[] newSeqChars = new char[cdsWidth];
 
-      int newPos = 0;
-      for (int[] range : fromRanges)
+    int newPos = 0;
+    for (int[] range : fromRanges)
+    {
+      if (range[0] <= range[1])
       {
-        if (range[0] <= range[1])
-        {
-          // forward strand mapping - just copy the range
-          int length = range[1] - range[0] + 1;
-          System.arraycopy(seqChars, range[0] - 1, newSeqChars, newPos,
-                  length);
-          newPos += length;
-        }
-        else
+        // forward strand mapping - just copy the range
+        int length = range[1] - range[0] + 1;
+        System.arraycopy(seqChars, range[0] - 1, newSeqChars, newPos,
+                length);
+        newPos += length;
+      }
+      else
+      {
+        // reverse strand mapping - copy and complement one by one
+        for (int i = range[0]; i >= range[1]; i--)
         {
-          // reverse strand mapping - copy and complement one by one
-          for (int i = range[0]; i >= range[1]; i--)
-          {
-            newSeqChars[newPos++] = Dna.getComplement(seqChars[i - 1]);
-          }
+          newSeqChars[newPos++] = Dna.getComplement(seqChars[i - 1]);
         }
       }
 
@@ -2066,9 +2054,8 @@ public class AlignmentUtils
           }
           else
           {
-            System.err.println(
-                    "JAL-2154 regression: warning - found (and ignnored a duplicate CDS sequence):"
-                            + mtch.toString());
+            Cache.log.error(
+                    "JAL-2154 regression: warning - found (and ignored) a duplicate CDS sequence:" + mtch.toString());
           }
         }
       }
index c545c7f..d52e42a 100644 (file)
@@ -417,7 +417,7 @@ public class Finder implements FinderI
      * update residueIndex to next position after the start of the match
      * (findIndex returns a value base 1, columnIndex is held base 0)
      */
-    residueIndex += offset + 1;
+    residueIndex = searchPattern.matchedFrom()+1;
 
     /*
      * return false if the match is entirely in a hidden region
index 066814e..88d3525 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.analysis;
 
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 
@@ -109,10 +110,12 @@ public class Grouping
    * @param sequences
    * @param columnSelection
    * @param list
+   * @param hiddenColumns
    * @return
    */
   public static SequenceGroup[] makeGroupsFromCols(SequenceI[] sequences,
-          ColumnSelection cs, List<SequenceGroup> list)
+          ColumnSelection cs, List<SequenceGroup> list,
+          HiddenColumns hiddenColumns)
   {
     // TODO: determine how to get/recover input data for group generation
     Map<String, List<SequenceI>> gps = new HashMap<String, List<SequenceI>>();
@@ -137,9 +140,17 @@ public class Grouping
     int i = 0;
     for (Integer pos : cs.getSelected())
     {
-      spos[i++] = pos.intValue();
+      if (hiddenColumns == null || hiddenColumns.isVisible(pos.intValue()))
+      {
+        spos[i++] = pos.intValue();
+      }
     }
-
+    if (i < spos.length)
+    {
+      // mark end of visible column position
+      spos[i] = -1;
+    }
+    // actual number of visible columns
     for (i = 0; i < sequences.length; i++)
     {
       int slen = sequences[i].getLength();
@@ -156,6 +167,10 @@ public class Grouping
       }
       for (int p : spos)
       {
+        if (p < 0)
+        {
+          break;
+        }
         if (p >= slen)
         {
           schar.append("~");
index fdca89d..891e295 100755 (executable)
@@ -84,6 +84,20 @@ public class SeqsetUtils
    */
   public static boolean SeqCharacterUnhash(SequenceI sq, Hashtable sqinfo)
   {
+    return SeqCharacterUnhash(sq, sqinfo, false, false);
+  }
+
+  /**
+   * restore some characteristics for a sequence from its hash
+   * @param sq
+   * @param sqinfo
+   * @param excludeLimits - when true, start/end is left unmodified
+   * @param excludeFeatures - when true, features are not restored from stashed vector
+   * @return true if sequence's name was modified
+   */
+          
+  public static boolean SeqCharacterUnhash(SequenceI sq, Hashtable sqinfo, boolean excludeLimits,boolean excludeFeatures)
+  {
     boolean namePresent = true;
     if (sqinfo == null)
     {
@@ -110,13 +124,13 @@ public class SeqsetUtils
       sq.setPDBId(pdbid);
     }
 
-    if ((start != null) && (end != null))
+    if (!excludeLimits && (start != null) && (end != null))
     {
       sq.setStart(start.intValue());
       sq.setEnd(end.intValue());
     }
-
-    if (sfeatures != null && !sfeatures.isEmpty())
+    // TODO: drop this completely since we should not manipulate sequenceFeatures as a vector any more
+    if (!excludeFeatures && sfeatures != null && !sfeatures.isEmpty())
     {
       sq.setSequenceFeatures(sfeatures);
     }
index 56d25d5..2a82a32 100644 (file)
@@ -268,6 +268,15 @@ public interface AlignViewportI extends ViewStyleI
   AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
 
   /**
+   * @return an alignment view, optionally without a complement view
+   * @param selectedOnly
+   * @param markGroups
+   * @param withComplement - false if no complement view required
+   */
+  AlignmentView getAlignmentViewWithComplement(boolean selectedOnly,
+          boolean markGroups, boolean withComplement);
+
+  /**
    * This method returns the visible alignment as text, as seen on the GUI, ie
    * if columns are hidden they will not be returned in the result. Use this for
    * calculating trees, PCA, redundancy etc on views which contain hidden
index 0bb2d03..1fc1946 100644 (file)
@@ -90,7 +90,8 @@ public class AlignViewController implements AlignViewControllerI
         gps = jalview.analysis.Grouping.makeGroupsFromCols(
                 (sg == null) ? viewport.getAlignment().getSequencesArray()
                         : sg.getSequences().toArray(new SequenceI[0]),
-                cs, viewport.getAlignment().getGroups());
+                cs, viewport.getAlignment().getGroups(),
+                viewport.getAlignment().getHiddenColumns());
       }
     }
     if (gps != null)
index fffa137..6faf7a6 100644 (file)
  */
 package jalview.datamodel;
 
-import jalview.util.MapList;
-import jalview.util.MappingUtils;
-
 import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.List;
 
+import jalview.util.MapList;
+import jalview.util.MappingUtils;
+
 /**
  * Stores mapping between the columns of a protein alignment and a DNA alignment
  * and a list of individual codon to amino acid mappings between sequences.
@@ -107,6 +107,143 @@ public class AlignedCodonFrame
     {
       return mapping;
     }
+
+    /**
+     * Returns true if the mapping covers the full length of the given sequence.
+     * This allows us to distinguish the CDS that codes for a protein from
+     * another overlapping CDS in the parent dna sequence.
+     * 
+     * @param seq
+     * @return
+     */
+    public boolean covers(SequenceI seq)
+    {
+      return covers(seq,false,false);
+    }
+    /**
+     * 
+     * @param seq
+     * @param localCover - when true - compare extent of seq's dataset sequence rather than the local extent
+     * @param either - when true coverage is required for either seq or the mapped sequence 
+     * @return true if mapping covers full length of given sequence (or the other if either==true)
+     */
+    public boolean covers(SequenceI seq, boolean localCover,boolean either)
+    {
+      List<int[]> mappedRanges = null,otherRanges=null;
+      MapList mapList = mapping.getMap();
+      int mstart=seq.getStart(),mend=seq.getEnd(),ostart,oend;
+              ;
+      if (fromSeq == seq || fromSeq == seq.getDatasetSequence())
+      {
+        if (localCover && fromSeq !=seq)
+        {
+          mstart=fromSeq.getStart();
+          mend=fromSeq.getEnd();
+        }
+        mappedRanges = mapList.getFromRanges();
+        otherRanges=mapList.getToRanges();
+        ostart=mapping.to.getStart();
+        oend=mapping.to.getEnd();
+      }
+      else if (mapping.to == seq || mapping.to == seq.getDatasetSequence())
+      {
+        if (localCover && mapping.to !=seq)
+        {
+          mstart=mapping.to.getStart();
+          mend=mapping.to.getEnd();
+        }
+        mappedRanges = mapList.getToRanges();
+        otherRanges=mapList.getFromRanges();
+        ostart=fromSeq.getStart();
+        oend=fromSeq.getEnd();
+      }
+      else
+      {
+        return false;
+      }
+
+      /*
+       * check that each mapped range lies within the sequence range
+       * (necessary for circular CDS - example EMBL:J03321:AAA91567)
+       * and mapped length covers (at least) sequence length
+       */
+      int length = countRange(mappedRanges,mstart,mend);
+
+      if (length != -1)
+      {
+        // add 1 to mapped length to allow for a mapped stop codon
+        if (length + 1 >= (mend - mstart + 1))
+        {
+          return true;
+        }
+      }
+      if (either)
+      {
+        // also check coverage of the other range
+        length = countRange(otherRanges, ostart, oend);
+        if (length != -1)
+        {
+          if (length + 1 >= (oend - ostart + 1))
+          {
+            return true;
+          }
+        }
+      }
+      return false;
+    }
+    private int countRange(List<int[]> mappedRanges,int mstart,int mend)
+    {
+      int length=0;
+      for (int[] range : mappedRanges)
+      {
+        int from = Math.min(range[0], range[1]);
+        int to = Math.max(range[0], range[1]);
+        if (from < mstart || to > mend)
+        {
+          return -1;
+        }
+        length += (to - from + 1);
+      }
+      return length;
+    }
+
+    /**
+     * Adds any regions mapped to or from position {@code pos} in sequence
+     * {@code seq} to the given search results
+     * 
+     * @param seq
+     * @param pos
+     * @param sr
+     */
+    public void markMappedRegion(SequenceI seq, int pos, SearchResultsI sr)
+    {
+      int[] codon = null;
+      SequenceI mappedSeq = null;
+      SequenceI ds = seq.getDatasetSequence();
+      if (ds == null)
+      {
+        ds = seq;
+      }
+      
+      if (this.fromSeq == seq || this.fromSeq == ds)
+      {
+        codon = this.mapping.map.locateInTo(pos, pos);
+        mappedSeq = this.mapping.to;
+      }
+      else if (this.mapping.to == seq || this.mapping.to == ds)
+      {
+        codon = this.mapping.map.locateInFrom(pos, pos);
+        mappedSeq = this.fromSeq;
+      }
+
+      if (codon != null)
+      {
+        for (int i = 0; i < codon.length; i += 2)
+        {
+          sr.addResult(mappedSeq, codon[i], codon[i + 1]);
+        }
+      }
+    }
   }
 
   private List<SequenceToSequenceMapping> mappings;
@@ -261,9 +398,12 @@ public class AlignedCodonFrame
   }
 
   /**
+   * Return the corresponding aligned or dataset dna sequence for given amino
+   * acid sequence, or null if not found. returns the sequence from the first
+   * mapping found that involves the protein sequence.
    * 
-   * @param sequenceRef
-   * @return null or corresponding aaSeq entry for dnaSeq entry
+   * @param aaSeqRef
+   * @return
    */
   public SequenceI getDnaForAaSeq(SequenceI aaSeqRef)
   {
@@ -293,7 +433,8 @@ public class AlignedCodonFrame
 
   /**
    * Add search results for regions in other sequences that translate or are
-   * translated from a particular position in seq
+   * translated from a particular position in seq (which may be an aligned or
+   * dataset sequence)
    * 
    * @param seq
    * @param index
@@ -304,34 +445,14 @@ public class AlignedCodonFrame
   public void markMappedRegion(SequenceI seq, int index,
           SearchResultsI results)
   {
-    int[] codon;
     SequenceI ds = seq.getDatasetSequence();
+    if (ds == null)
+    {
+      ds = seq;
+    }
     for (SequenceToSequenceMapping ssm : mappings)
     {
-      if (ssm.fromSeq == seq || ssm.fromSeq == ds)
-      {
-        codon = ssm.mapping.map.locateInTo(index, index);
-        if (codon != null)
-        {
-          for (int i = 0; i < codon.length; i += 2)
-          {
-            results.addResult(ssm.mapping.to, codon[i], codon[i + 1]);
-          }
-        }
-      }
-      else if (ssm.mapping.to == seq || ssm.mapping.to == ds)
-      {
-        {
-          codon = ssm.mapping.map.locateInFrom(index, index);
-          if (codon != null)
-          {
-            for (int i = 0; i < codon.length; i += 2)
-            {
-              results.addResult(ssm.fromSeq, codon[i], codon[i + 1]);
-            }
-          }
-        }
-      }
+      ssm.markMappedRegion(ds, index, results);
     }
   }
 
@@ -381,18 +502,39 @@ public class AlignedCodonFrame
    */
   public SequenceI findAlignedSequence(SequenceI seq, AlignmentI al)
   {
+    return findAlignedSequence(seq, al, null);
+  }
+  /**
+   * Convenience method to return the first aligned sequence in the given
+   * alignment whose dataset has a mapping with the given (aligned or dataset)
+   * sequence, and optionally the mapping that relates them 
+   * 
+   * @param seq
+   * @param al
+   * @param map - list to add the mapping to
+   * @return sequence from al that maps to seq
+   */
+  public SequenceI findAlignedSequence(SequenceI seq, AlignmentI al,List<SequenceToSequenceMapping> map)
+  {
     /*
      * Search mapped protein ('to') sequences first.
      */
     for (SequenceToSequenceMapping ssm : mappings)
     {
-      if (ssm.fromSeq == seq || ssm.fromSeq == seq.getDatasetSequence())
+      int mStart=ssm.getMapping().getMap().getFromLowest(),mEnd=ssm.getMapping().map.getFromHighest();
+      if ((ssm.fromSeq == seq || ssm.fromSeq == seq.getDatasetSequence())
+              // here AlignmentUtilsTest. testAlignProteinAsDna_incompleteStartCodon fails because mStart/mEnd is contained by seq
+              // without this filter, we don't get the correct mapping, however
+           )//   && seq.getStart()>=mStart && seq.getEnd()<=mEnd)
       {
         for (SequenceI sourceAligned : al.getSequences())
         {
-          if (ssm.mapping.to == sourceAligned.getDatasetSequence()
-                  || ssm.mapping.to == sourceAligned)
+          if (ssm.covers(sourceAligned,true,false))
           {
+            if (map != null)
+            {
+              map.add(ssm);
+            }
             return sourceAligned;
           }
         }
@@ -404,13 +546,19 @@ public class AlignedCodonFrame
      */
     for (SequenceToSequenceMapping ssm : mappings)
     {
-      if (ssm.mapping.to == seq
+      int mStart=ssm.getMapping().getMap().getToLowest(),mEnd=ssm.getMapping().map.getToHighest();
+      if ((ssm.mapping.to == seq
               || ssm.mapping.to == seq.getDatasetSequence())
+              && seq.getStart()>=mStart && seq.getEnd()<=mEnd)
       {
         for (SequenceI sourceAligned : al.getSequences())
         {
-          if (ssm.fromSeq == sourceAligned.getDatasetSequence())
+          if (ssm.covers(sourceAligned,true,true))
           {
+            if (map != null)
+            {
+              map.add(ssm);
+            }
             return sourceAligned;
           }
         }
@@ -767,7 +915,7 @@ public class AlignedCodonFrame
    * Two AlignedCodonFrame objects are equal if they hold the same ordered list
    * of mappings
    * 
-   * @see SequenceToSequenceMapping#
+   * @see SequenceToSequenceMapping#equals
    */
   @Override
   public boolean equals(Object obj)
@@ -783,4 +931,55 @@ public class AlignedCodonFrame
   {
     return mappings;
   }
+
+  /**
+   * Returns the first mapping found which is between the two given sequences,
+   * and covers the full extent of both.
+   * 
+   * @param seq1
+   * @param seq2
+   * @return
+   */
+  public SequenceToSequenceMapping getCoveringMapping(SequenceI seq1,
+          SequenceI seq2)
+  {
+    for (SequenceToSequenceMapping mapping : mappings)
+    {
+      if (mapping.covers(seq2) && mapping.covers(seq1))
+      {
+        return mapping;
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Returns the first mapping found which is between the given dataset sequence
+   * and another, is a triplet mapping (3:1 or 1:3), and covers the full extent
+   * of both sequences involved
+   * 
+   * @param seq
+   * @return
+   */
+  public SequenceToSequenceMapping getCoveringCodonMapping(SequenceI seq)
+  {
+    for (SequenceToSequenceMapping mapping : mappings)
+    {
+      if (mapping.getMapping().getMap().isTripletMap()
+              && mapping.covers(seq))
+      {
+        if (mapping.fromSeq == seq
+                && mapping.covers(mapping.getMapping().getTo()))
+        {
+          return mapping;
+        }
+        else if (mapping.getMapping().getTo() == seq
+                && mapping.covers(mapping.fromSeq))
+        {
+          return mapping;
+        }
+      }
+    }
+    return null;
+  }
 }
index e6604d1..6d6d4c3 100644 (file)
@@ -51,6 +51,37 @@ public class AlignmentView
   private boolean isNa = false;
 
   /**
+   * reference to the complementary CDS/Protein alignment for this alignment, if available
+   */
+  private AlignmentView complementView=null;
+  
+  /**
+   * setter for 
+   * @param complementView
+   */
+  public void setComplement(AlignmentView complementView)
+  {
+    this.complementView = complementView;
+    
+  }
+  /**
+   * 
+   * @return true if a complement is available
+   */
+  public boolean hasComplementView()
+  {
+    return complementView!=null;
+  }
+  /**
+   * 
+   * @return the complement view or null
+   */
+  public AlignmentView getComplementView()
+  {
+    return complementView;
+  }
+  
+  /**
    * false if the view concerns peptides
    * 
    * @return
index d652a97..57c8c37 100644 (file)
@@ -294,8 +294,8 @@ public class MappedFeatures
   public int[] getMappedPositions(int begin, int end)
   {
     MapList map = mapping.getMap();
-    return mapping.to == featureSequence ? map.locateInFrom(begin, end)
-            : map.locateInTo(begin, end);
+    return mapping.to == featureSequence ? map.getOverlapsInFrom(begin, end)
+            : map.getOverlapsInTo(begin, end);
   }
 
   /**
index 7c3bba7..5c929fc 100755 (executable)
@@ -349,8 +349,10 @@ public class SearchResults implements SearchResultsI
   }
 
   /**
-   * Two SearchResults are considered equal if they contain the same matches in
-   * the same order.
+   * Two SearchResults are considered equal if they contain the same matches
+   * (Sequence, start position, end position) in the same order
+   * 
+   * @see Match#equals(Object)
    */
   @Override
   public boolean equals(Object obj)
index c2a6a9c..34697b3 100644 (file)
@@ -587,6 +587,7 @@ public class SeqCigar extends CigarSimple
                       + (bounds[2] == 0 ? -1 : bounds[2]));
       seqs[i].setDatasetSequence(ref);
       seqs[i].setDescription(ref.getDescription());
+      SeqsetUtils.SeqCharacterUnhash(seqs[i],alseqs[i].seqProps,true,true);
     }
     if (segments != null)
     {
index 6eeba2f..bbf1b45 100755 (executable)
@@ -612,10 +612,9 @@ public class SequenceFeature implements FeatureLocationI
     String consequence = "";
     if (mf != null)
     {
-      int[] beginRange = mf.getMappedPositions(begin, begin);
-      int[] endRange = mf.getMappedPositions(end, end);
-      int from = beginRange[0];
-      int to = endRange[endRange.length - 1];
+      int[] localRange = mf.getMappedPositions(begin, end);
+      int from = localRange[0];
+      int to = localRange[localRange.length - 1];
       String s = mf.isFromCds() ? "Peptide Location" : "Coding location";
       sb.append(String.format(ROW_DATA, s, seqName, from == to ? from
               : from + (isContactFeature() ? ":" : "-") + to));
index 568f7f1..abe9835 100644 (file)
@@ -832,9 +832,21 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
        * show local rather than linked feature coordinates
        */
       int[] beginRange = mf.getMappedPositions(start, start);
-      start = beginRange[0];
       int[] endRange = mf.getMappedPositions(end, end);
+      if (beginRange == null || endRange == null)
+      {
+        // e.g. variant extending to stop codon so not mappable
+        return;
+      }
+      start = beginRange[0];
       end = endRange[endRange.length - 1];
+      int[] localRange = mf.getMappedPositions(start, end);
+      if (localRange == null)
+      {
+        return;
+      }
+      start = localRange[0];
+      end = localRange[localRange.length - 1];
     }
     StringBuilder desc = new StringBuilder();
     desc.append(sf.getType()).append(" ").append(String.valueOf(start));
index bfae4ed..21e66d2 100644 (file)
@@ -841,11 +841,9 @@ public class EmblFlatFile extends AlignFile // FileParse
     int exonLength = MappingUtils.getLength(Arrays.asList(exon));
 
     /*
-     * if exon length matches protein, or is shorter, or longer by the 
-     * length of a stop codon (3 bases), then leave it unchanged
+     * if exon length matches protein, or is shorter, then leave it unchanged
      */
-    if (expectedCdsLength >= exonLength
-            || expectedCdsLength == exonLength - 3)
+    if (expectedCdsLength >= exonLength)
     {
       return exon;
     }
index 27c1652..a4c4895 100644 (file)
@@ -210,12 +210,27 @@ public class SequenceAnnotationReport
      * if this is a virtual features, convert begin/end to the
      * coordinates of the sequence it is mapped to
      */
-    int[] beginRange = null;
-    int[] endRange = null;
+    int[] beginRange = null; // feature start in local coordinates
+    int[] endRange = null; // feature end in local coordinates
     if (mf != null)
     {
-      beginRange = mf.getMappedPositions(begin, begin);
-      endRange = mf.getMappedPositions(end, end);
+      if (feature.isContactFeature())
+      {
+        /*
+         * map start and end points individually
+         */
+        beginRange = mf.getMappedPositions(begin, begin);
+        endRange = begin == end ? beginRange
+                : mf.getMappedPositions(end, end);
+      }
+      else
+      {
+        /*
+         * map the feature extent
+         */
+        beginRange = mf.getMappedPositions(begin, end);
+        endRange = beginRange;
+      }
       if (beginRange == null || endRange == null)
       {
         // something went wrong
index d4fc233..286bfb2 100644 (file)
@@ -268,7 +268,38 @@ public class Comparison
    */
   public static final boolean isNucleotide(SequenceI seq)
   {
-    return isNucleotide(new SequenceI[] { seq });
+    if (seq==null)
+    {
+      return false;
+    }
+    long ntCount = 0;
+    long aaCount = 0;
+
+    int len = seq.getLength();
+    for (int i = 0; i < len; i++)
+    {
+      char c = seq.getCharAt(i);
+      if (isNucleotide(c))
+      {
+        ntCount++;
+      }
+      else if (!isGap(c))
+      {
+        aaCount++;
+      }
+    }
+    /*
+     * Check for nucleotide count > 85% of total count (in a form that evades
+     * int / float conversion or divide by zero).
+     */
+    if (ntCount * 100 > EIGHTY_FIVE * (ntCount + aaCount))
+    {
+      return true;
+    }
+    else
+    {
+      return false;
+    }
   }
 
   /**
@@ -285,45 +316,23 @@ public class Comparison
     {
       return false;
     }
-
-    int ntCount = 0;
-    int aaCount = 0;
+    // true if we have seen a nucleotide sequence
+    boolean na=false;
     for (SequenceI seq : seqs)
     {
       if (seq == null)
       {
         continue;
       }
+      na=true;
       // TODO could possibly make an informed guess just from the first sequence
       // to save a lengthy calculation
-      int len = seq.getLength();
-      for (int i = 0; i < len; i++)
-      {
-        char c = seq.getCharAt(i);
-        if (isNucleotide(c))
-        {
-          ntCount++;
-        }
-        else if (!isGap(c))
-        {
-          aaCount++;
-        }
+      if (seq.isProtein()) {
+        // if even one looks like protein, the alignment is protein
+        return false;
       }
     }
-
-    /*
-     * Check for nucleotide count > 85% of total count (in a form that evades
-     * int / float conversion or divide by zero).
-     */
-    if (ntCount * 100 > EIGHTY_FIVE * (ntCount + aaCount))
-    {
-      return true;
-    }
-    else
-    {
-      return false;
-    }
-
+    return na;
   }
 
   /**
index 731e976..c5654fb 100644 (file)
@@ -24,6 +24,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import jalview.bin.Cache;
+
 /**
  * A simple way of bijectively mapping a non-contiguous linear range to another
  * non-contiguous linear range.
@@ -209,8 +211,7 @@ public class MapList
 
   /**
    * Constructor given from and to ranges as [start1, end1, start2, end2,...].
-   * If any end is equal to the next start, the ranges will be merged. There is
-   * no validation check that the ranges do not overlap each other.
+   * There is no validation check that the ranges do not overlap each other.
    * 
    * @param from
    *          contiguous regions as [start1, end1, start2, end2, ...]
@@ -228,7 +229,6 @@ public class MapList
     this.toRatio = toRatio;
     fromLowest = Integer.MAX_VALUE;
     fromHighest = Integer.MIN_VALUE;
-    int added = 0;
 
     for (int i = 0; i < from.length; i += 2)
     {
@@ -238,36 +238,16 @@ public class MapList
        */
       fromLowest = Math.min(fromLowest, Math.min(from[i], from[i + 1]));
       fromHighest = Math.max(fromHighest, Math.max(from[i], from[i + 1]));
-      if (added > 0 && from[i] == fromShifts.get(added - 1)[1])
-      {
-        /*
-         * this range starts where the last ended - just extend it
-         */
-        fromShifts.get(added - 1)[1] = from[i + 1];
-      }
-      else
-      {
-        fromShifts.add(new int[] { from[i], from[i + 1] });
-        added++;
-      }
+      fromShifts.add(new int[] { from[i], from[i + 1] });
     }
 
     toLowest = Integer.MAX_VALUE;
     toHighest = Integer.MIN_VALUE;
-    added = 0;
     for (int i = 0; i < to.length; i += 2)
     {
       toLowest = Math.min(toLowest, Math.min(to[i], to[i + 1]));
       toHighest = Math.max(toHighest, Math.max(to[i], to[i + 1]));
-      if (added > 0 && to[i] == toShifts.get(added - 1)[1])
-      {
-        toShifts.get(added - 1)[1] = to[i + 1];
-      }
-      else
-      {
-        toShifts.add(new int[] { to[i], to[i + 1] });
-        added++;
-      }
+      toShifts.add(new int[] { to[i], to[i + 1] });
     }
   }
 
@@ -330,9 +310,8 @@ public class MapList
       if (range.length != 2)
       {
         // throw new IllegalArgumentException(range);
-        System.err.println(
-                "Invalid format for fromRange " + Arrays.toString(range)
-                + " may cause errors");
+        Cache.log.error("Invalid format for fromRange "
+                + Arrays.toString(range) + " may cause errors");
       }
       fromLowest = Math.min(fromLowest, Math.min(range[0], range[1]));
       fromHighest = Math.max(fromHighest, Math.max(range[0], range[1]));
@@ -345,9 +324,8 @@ public class MapList
       if (range.length != 2)
       {
         // throw new IllegalArgumentException(range);
-        System.err.println("Invalid format for toRange "
-                + Arrays.toString(range)
-                + " may cause errors");
+        Cache.log.error("Invalid format for toRange "
+                + Arrays.toString(range) + " may cause errors");
       }
       toLowest = Math.min(toLowest, Math.min(range[0], range[1]));
       toHighest = Math.max(toHighest, Math.max(range[0], range[1]));
@@ -357,6 +335,16 @@ public class MapList
   /**
    * Consolidates a list of ranges so that any contiguous ranges are merged.
    * This assumes the ranges are already in start order (does not sort them).
+   * <p>
+   * The main use case for this method is when mapping cDNA sequence to its
+   * protein product, based on CDS feature ranges which derive from spliced
+   * exons, but are contiguous on the cDNA sequence. For example 
+   * <pre>
+   *   CDS 1-20  // from exon1
+   *   CDS 21-35 // from exon2
+   *   CDS 36-71 // from exon3
+   * 'coalesce' to range 1-71
+   * </pre>
    * 
    * @param ranges
    * @return the same list (if unchanged), else a new merged list, leaving the
@@ -384,27 +372,6 @@ public class MapList
         first = false;
         continue;
       }
-      if (range[0] == lastRange[0] && range[1] == lastRange[1])
-      {
-        // drop duplicate range
-        changed = true;
-        continue;
-      }
-
-      /*
-       * drop this range if it lies within the last range
-       */
-      if ((lastDirection == 1 && range[0] >= lastRange[0]
-              && range[0] <= lastRange[1] && range[1] >= lastRange[0]
-              && range[1] <= lastRange[1])
-              || (lastDirection == -1 && range[0] <= lastRange[0]
-                      && range[0] >= lastRange[1]
-                      && range[1] <= lastRange[0]
-                      && range[1] >= lastRange[1]))
-      {
-        changed = true;
-        continue;
-      }
 
       int direction = range[1] >= range[0] ? 1 : -1;
 
@@ -415,11 +382,7 @@ public class MapList
       boolean sameDirection = range[1] == range[0]
               || direction == lastDirection;
       boolean extending = range[0] == lastRange[1] + lastDirection;
-      boolean overlapping = (lastDirection == 1 && range[0] >= lastRange[0]
-              && range[0] <= lastRange[1])
-              || (lastDirection == -1 && range[0] <= lastRange[0]
-                      && range[0] >= lastRange[1]);
-      if (sameDirection && (overlapping || extending))
+      if (sameDirection && extending)
       {
         lastRange[1] = range[1];
         changed = true;
@@ -1134,8 +1097,8 @@ public class MapList
   }
 
   /**
-   * A helper method that returns true unless at least one range has start > end.
-   * Behaviour is undefined for a mixture of forward and reverse ranges.
+   * A helper method that returns true unless at least one range has start >
+   * end. Behaviour is undefined for a mixture of forward and reverse ranges.
    * 
    * @param ranges
    * @return
@@ -1246,4 +1209,36 @@ public class MapList
   {
     return fromShifts.size() == 1 && toShifts.size() == 1;
   }
+
+  /**
+   * Returns the [start, end...] positions in the range mapped from, that are
+   * mapped to by part or all of the given begin-end of the range mapped to.
+   * Returns null if begin-end does not overlap any position mapped to.
+   * 
+   * @param begin
+   * @param end
+   * @return
+   */
+  public int[] getOverlapsInFrom(final int begin, final int end)
+  {
+    int[] overlaps = MappingUtils.findOverlap(toShifts, begin, end);
+
+    return overlaps == null ? null : locateInFrom(overlaps[0], overlaps[1]);
+  }
+
+  /**
+   * Returns the [start, end...] positions in the range mapped to, that are
+   * mapped to by part or all of the given begin-end of the range mapped from.
+   * Returns null if begin-end does not overlap any position mapped from.
+   * 
+   * @param begin
+   * @param end
+   * @return
+   */
+  public int[] getOverlapsInTo(final int begin, final int end)
+  {
+    int[] overlaps = MappingUtils.findOverlap(fromShifts, begin, end);
+
+    return overlaps == null ? null : locateInTo(overlaps[0], overlaps[1]);
+  }
 }
index 915293e..177c54d 100644 (file)
  */
 package jalview.util;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import jalview.analysis.AlignmentSorter;
 import jalview.api.AlignViewportI;
+import jalview.bin.Cache;
 import jalview.commands.CommandI;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
 import jalview.commands.EditCommand.Edit;
 import jalview.commands.OrderCommand;
 import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.ColumnSelection;
@@ -39,13 +48,6 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * Helper methods for manipulations involving sequence mappings.
  * 
@@ -78,7 +80,7 @@ public final class MappingUtils
       action = action.getUndoAction();
     }
     // TODO write this
-    System.err.println("MappingUtils.mapCutOrPaste not yet implemented");
+    Cache.log.error("MappingUtils.mapCutOrPaste not yet implemented");
   }
 
   /**
@@ -341,75 +343,72 @@ public final class MappingUtils
         firstUngappedPos++;
       }
 
-      /*
-       * If this sequence is only gaps in the selected range, skip it
-       */
-      if (firstUngappedPos > selectionEndRes)
-      {
-        continue;
-      }
+      boolean allGapped = (firstUngappedPos > selectionEndRes);
 
       int lastUngappedPos = selectionEndRes;
-      while (lastUngappedPos >= selectionStartRes
-              && Comparison.isGap(selected.getCharAt(lastUngappedPos)))
+      if (!allGapped)
       {
-        lastUngappedPos--;
+        while (lastUngappedPos >= selectionStartRes
+                && Comparison.isGap(selected.getCharAt(lastUngappedPos)))
+        {
+          lastUngappedPos--;
+        }
       }
 
       /*
        * Find the selected start/end residue positions in sequence
        */
-      int startResiduePos = selected.findPosition(firstUngappedPos);
-      int endResiduePos = selected.findPosition(lastUngappedPos);
+      int startResiduePos = allGapped ? 0 : selected.findPosition(firstUngappedPos);
+      int endResiduePos = allGapped ? 0 : selected.findPosition(lastUngappedPos);
 
       for (AlignedCodonFrame acf : codonFrames)
       {
-        SequenceI mappedSequence = targetIsNucleotide
-                ? acf.getDnaForAaSeq(selected)
-                : acf.getAaForDnaSeq(selected);
-        if (mappedSequence != null)
+        for (SequenceI seq : mapTo.getAlignment().getSequences())
         {
-          for (SequenceI seq : mapTo.getAlignment().getSequences())
+          SequenceI peptide = targetIsNucleotide ? selected : seq;
+          SequenceI cds = targetIsNucleotide ? seq : selected;
+          SequenceToSequenceMapping s2s = acf.getCoveringMapping(cds,
+                  peptide);
+          if (s2s == null)
           {
-            int mappedStartResidue = 0;
-            int mappedEndResidue = 0;
-            if (seq.getDatasetSequence() == mappedSequence)
-            {
-              /*
-               * Found a sequence mapping. Locate the start/end mapped residues.
-               */
-              List<AlignedCodonFrame> mapping = Arrays
-                      .asList(new AlignedCodonFrame[]
-                      { acf });
-              SearchResultsI sr = buildSearchResults(selected,
-                      startResiduePos, mapping);
-              for (SearchResultMatchI m : sr.getResults())
-              {
-                mappedStartResidue = m.getStart();
-                mappedEndResidue = m.getEnd();
-              }
-              sr = buildSearchResults(selected, endResiduePos, mapping);
-              for (SearchResultMatchI m : sr.getResults())
-              {
-                mappedStartResidue = Math.min(mappedStartResidue,
-                        m.getStart());
-                mappedEndResidue = Math.max(mappedEndResidue, m.getEnd());
-              }
-
-              /*
-               * Find the mapped aligned columns, save the range. Note findIndex
-               * returns a base 1 position, SequenceGroup uses base 0
-               */
-              int mappedStartCol = seq.findIndex(mappedStartResidue) - 1;
-              minStartCol = minStartCol == -1 ? mappedStartCol
-                      : Math.min(minStartCol, mappedStartCol);
-              int mappedEndCol = seq.findIndex(mappedEndResidue) - 1;
-              maxEndCol = maxEndCol == -1 ? mappedEndCol
-                      : Math.max(maxEndCol, mappedEndCol);
-              mappedGroup.addSequence(seq, false);
-              break;
-            }
+            continue;
           }
+          mappedGroup.addSequence(seq, false);
+          if (allGapped)
+          {
+            /*
+             * sequence is mapped but includes no mapped residues
+             */
+            continue;
+          }
+          int mappedStartResidue = 0;
+          int mappedEndResidue = 0;
+          List<AlignedCodonFrame> mapping = Arrays.asList(acf);
+          SearchResultsI sr = buildSearchResults(selected, startResiduePos,
+                  mapping);
+          for (SearchResultMatchI m : sr.getResults())
+          {
+            mappedStartResidue = m.getStart();
+            mappedEndResidue = m.getEnd();
+          }
+          sr = buildSearchResults(selected, endResiduePos, mapping);
+          for (SearchResultMatchI m : sr.getResults())
+          {
+            mappedStartResidue = Math.min(mappedStartResidue, m.getStart());
+            mappedEndResidue = Math.max(mappedEndResidue, m.getEnd());
+          }
+
+          /*
+           * Find the mapped aligned columns, save the range. Note findIndex
+           * returns a base 1 position, SequenceGroup uses base 0
+           */
+          int mappedStartCol = seq.findIndex(mappedStartResidue) - 1;
+          minStartCol = minStartCol == -1 ? mappedStartCol
+                  : Math.min(minStartCol, mappedStartCol);
+          int mappedEndCol = seq.findIndex(mappedEndResidue) - 1;
+          maxEndCol = maxEndCol == -1 ? mappedEndCol
+                  : Math.max(maxEndCol, mappedEndCol);
+          break;
         }
       }
     }
@@ -449,20 +448,23 @@ public final class MappingUtils
     {
       for (AlignedCodonFrame acf : mappings)
       {
-        SequenceI mappedSeq = mappingToNucleotide ? acf.getDnaForAaSeq(seq)
-                : acf.getAaForDnaSeq(seq);
-        if (mappedSeq != null)
-        {
           for (SequenceI seq2 : mapTo.getSequences())
           {
-            if (seq2.getDatasetSequence() == mappedSeq)
+            /*
+             * the corresponding peptide / CDS is the one for which there is
+             * a complete ('covering') mapping to 'seq'
+             */
+            SequenceI peptide = mappingToNucleotide ? seq2 : seq;
+            SequenceI cds = mappingToNucleotide ? seq : seq2;
+            SequenceToSequenceMapping s2s = acf.getCoveringMapping(cds,
+                    peptide);
+            if (s2s != null)
             {
               mappedOrder.add(seq2);
               j++;
               break;
             }
           }
-        }
       }
     }
 
@@ -524,7 +526,7 @@ public final class MappingUtils
 
     if (colsel == null)
     {
-      return; // mappedColumns;
+      return; 
     }
 
     char fromGapChar = mapFrom.getAlignment().getGapCharacter();
@@ -546,10 +548,9 @@ public final class MappingUtils
     while (regions.hasNext())
     {
       mapHiddenColumns(regions.next(), codonFrames, newHidden,
-              fromSequences,
-              toSequences, fromGapChar);
+              fromSequences, toSequences, fromGapChar);
     }
-    return; // mappedColumns;
+    return; 
   }
 
   /**
@@ -667,7 +668,9 @@ public final class MappingUtils
          */
         for (SequenceI toSeq : toSequences)
         {
-          if (toSeq.getDatasetSequence() == mappedSeq)
+          if (toSeq.getDatasetSequence() == mappedSeq
+                  && mappedStartResidue >= toSeq.getStart()
+                  && mappedEndResidue <= toSeq.getEnd())
           {
             int mappedStartCol = toSeq.findIndex(mappedStartResidue);
             int mappedEndCol = toSeq.findIndex(mappedEndResidue);
@@ -836,7 +839,7 @@ public final class MappingUtils
     {
       if (range.length % 2 != 0)
       {
-        System.err.println(
+        Cache.log.error(
                 "Error unbalance start/end ranges: " + ranges.toString());
         return 0;
       }
@@ -965,7 +968,7 @@ public final class MappingUtils
 
     int min = Math.min(range[0], range[1]);
     int max = Math.max(range[0], range[1]);
-  
+
     return (min <= queryRange[0] && max >= queryRange[0]
             && min <= queryRange[1] && max >= queryRange[1]);
   }
@@ -980,8 +983,7 @@ public final class MappingUtils
    *          a list of (single) [start, end] ranges
    * @return
    */
-  public static void removeEndPositions(int positions,
-          List<int[]> ranges)
+  public static void removeEndPositions(int positions, List<int[]> ranges)
   {
     int toRemove = positions;
     Iterator<int[]> it = new ReverseListIterator<>(ranges);
@@ -993,8 +995,8 @@ public final class MappingUtils
         /*
          * not coded for [start1, end1, start2, end2, ...]
          */
-        System.err
-                .println("MappingUtils.removeEndPositions doesn't handle multiple  ranges");
+        Cache.log.error(
+                "MappingUtils.removeEndPositions doesn't handle multiple  ranges");
         return;
       }
 
@@ -1004,8 +1006,8 @@ public final class MappingUtils
         /*
          * not coded for a reverse strand range (end < start)
          */
-        System.err
-                .println("MappingUtils.removeEndPositions doesn't handle reverse strand");
+        Cache.log.error(
+                "MappingUtils.removeEndPositions doesn't handle reverse strand");
         return;
       }
       if (length > toRemove)
@@ -1039,4 +1041,66 @@ public final class MappingUtils
     }
     return result;
   }
+
+  /**
+   * Returns the maximal start-end positions in the given (ordered) list of
+   * ranges which is overlapped by the given begin-end range, or null if there
+   * is no overlap.
+   * 
+   * <pre>
+   * Examples:
+   *   if ranges is {[4, 8], [10, 12], [16, 19]}
+   * then
+   *   findOverlap(ranges, 1, 20) == [4, 19]
+   *   findOverlap(ranges, 6, 11) == [6, 11]
+   *   findOverlap(ranges, 9, 15) == [10, 12]
+   *   findOverlap(ranges, 13, 15) == null
+   * </pre>
+   * 
+   * @param ranges
+   * @param begin
+   * @param end
+   * @return
+   */
+  protected static int[] findOverlap(List<int[]> ranges, final int begin,
+          final int end)
+  {
+    boolean foundStart = false;
+    int from = 0;
+    int to = 0;
+
+    /*
+     * traverse the ranges to find the first position (if any) >= begin,
+     * and the last position (if any) <= end
+     */
+    for (int[] range : ranges)
+    {
+      if (!foundStart)
+      {
+        if (range[0] >= begin)
+        {
+          /*
+           * first range that starts with, or follows, begin
+           */
+          foundStart = true;
+          from = Math.max(range[0], begin);
+        }
+        else if (range[1] >= begin)
+        {
+          /*
+           * first range that contains begin
+           */
+          foundStart = true;
+          from = begin;
+        }
+      }
+
+      if (range[0] <= end)
+      {
+        to = Math.min(end, range[1]);
+      }
+    }
+
+    return foundStart && to >= from ? new int[] { from, to } : null;
+  }
 }
index c9a3a80..cbc2189 100644 (file)
@@ -1694,11 +1694,29 @@ public abstract class AlignmentViewport
   public jalview.datamodel.AlignmentView getAlignmentView(
           boolean selectedOnly, boolean markGroups)
   {
-    return new AlignmentView(alignment, alignment.getHiddenColumns(),
-            selectionGroup,
+    return getAlignmentViewWithComplement(selectedOnly,markGroups,true);
+  }
+  
+  @Override
+  public jalview.datamodel.AlignmentView getAlignmentViewWithComplement(
+          boolean selectedOnly, boolean markGroups,boolean withComplment)
+  {
+    AlignmentView complementView = null;
+    if (withComplment)
+    {
+      if (codingComplement != null)
+      {
+        complementView = codingComplement.getAlignmentViewWithComplement(
+                selectedOnly, markGroups, false);
+      }
+    }
+    AlignmentView thisView = new AlignmentView(alignment,
+            alignment.getHiddenColumns(), selectionGroup,
             alignment.getHiddenColumns() != null
                     && alignment.getHiddenColumns().hasHiddenColumns(),
             selectedOnly, markGroups);
+    thisView.setComplement(complementView);
+    return thisView;
   }
 
   @Override
index b348766..8f513c9 100644 (file)
@@ -38,9 +38,9 @@ import jalview.api.AlignViewportI;
 import jalview.api.FeatureColourI;
 import jalview.api.FeaturesDisplayedI;
 import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.MappedFeatures;
-import jalview.datamodel.Mapping;
 import jalview.datamodel.SearchResultMatchI;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.SearchResultsI;
@@ -1196,18 +1196,18 @@ public abstract class FeatureRendererModel
      * todo: direct lookup of CDS for peptide and vice-versa; for now,
      * have to search through an unordered list of mappings for a candidate
      */
-    Mapping mapping = null;
+    SequenceToSequenceMapping mapping = null;
     SequenceI mapFrom = null;
 
     for (AlignedCodonFrame acf : mappings)
     {
-      mapping = acf.getMappingForSequence(sequence);
-      if (mapping == null || !mapping.getMap().isTripletMap())
+      mapping = acf.getCoveringCodonMapping(ds);
+      if (mapping == null)
       {
-        continue; // we are only looking for 3:1 or 1:3 mappings
+        continue;
       }
       SearchResultsI sr = new SearchResults();
-      acf.markMappedRegion(ds, pos, sr);
+      mapping.markMappedRegion(ds, pos, sr);
       for (SearchResultMatchI match : sr.getResults())
       {
         int fromRes = match.getStart();
@@ -1260,7 +1260,7 @@ public abstract class FeatureRendererModel
       }
     }
     
-    return new MappedFeatures(mapping, mapFrom, pos, residue, result);
+    return new MappedFeatures(mapping.getMapping(), mapFrom, pos, residue, result);
   }
 
   @Override
index 97d7c9f..c5532f5 100644 (file)
@@ -69,6 +69,7 @@ import jalview.xml.binding.embl.XrefType;
  * 
  * @deprecated endpoint withdrawn August 2020 (JAL-3692), use EmblFlatfileSource
  */
+
 public abstract class EmblXmlSource extends EbiFileRetrievedProxy
 {
   private static final Regex ACCESSION_REGEX = new Regex("^[A-Z]+[0-9]+");
@@ -453,9 +454,9 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
         else
         {
           // final product length truncation check
-          int[] cdsRanges = adjustForProteinLength(translationLength,
+          int [] exons2 = adjustForProteinLength(translationLength,
                   exons);
-          dnaToProteinMapping = new Mapping(product, cdsRanges,
+          dnaToProteinMapping = new Mapping(product, exons2,
                   new int[]
                   { 1, translationLength }, 3, 1);
           if (product != null)
@@ -757,8 +758,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
 
   /**
    * Truncates (if necessary) the exon intervals to match 3 times the length of
-   * the protein; also accepts 3 bases longer (for stop codon not included in
-   * protein)
+   * the protein (including truncation for stop codon included in exon)
    * 
    * @param proteinLength
    * @param exon
@@ -775,11 +775,9 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
     int exonLength = MappingUtils.getLength(Arrays.asList(exon));
 
     /*
-     * if exon length matches protein, or is shorter, or longer by the 
-     * length of a stop codon (3 bases), then leave it unchanged
+     * if exon length matches protein, or is shorter, then leave it unchanged
      */
-    if (expectedCdsLength >= exonLength
-            || expectedCdsLength == exonLength - 3)
+    if (expectedCdsLength >= exonLength)
     {
       return exon;
     }
index db6e03f..89cf024 100644 (file)
@@ -974,13 +974,24 @@ class MsaWSThread extends AWS2Thread implements WSClientI
     {
       al.setDataset(dataset);
     }
-
     propagateDatasetMappings(al);
+    Alignment complement=null;
+    if (input.hasComplementView())
+    {
+      Object[] newcompl = input
+              .getComplementView()
+              .getAlignmentAndHiddenColumns(getRequestingAlignFrame()
+                      .getViewport().getCodingComplement().getGapCharacter());
+      complement = new Alignment((SequenceI[])newcompl[0]);
+      complement.setHiddenColumns((HiddenColumns) newcompl[1]);
+      complement.setDataset(dataset);
+      complement.alignAs(al);
+    }
     // JBNote- TODO: warn user if a block is input rather than aligned data ?
 
     if (newFrame)
     {
-      displayInNewFrame(al, alorders, hidden);
+      displayInNewFrame(al, alorders, hidden, complement);
 
     }
     else
@@ -998,10 +1009,11 @@ class MsaWSThread extends AWS2Thread implements WSClientI
    * 
    * @param al
    * @param alorders
+   * @param complement2 
    * @param columnselection
    */
   protected void displayInNewFrame(AlignmentI al,
-          List<AlignmentOrder> alorders, HiddenColumns hidden)
+          List<AlignmentOrder> alorders, HiddenColumns hidden, AlignmentI complement)
   {
     AlignFrame af = new AlignFrame(al, hidden, AlignFrame.DEFAULT_WIDTH,
             AlignFrame.DEFAULT_HEIGHT);
@@ -1021,26 +1033,18 @@ class MsaWSThread extends AWS2Thread implements WSClientI
      * SplitFrame with the other pane similarly aligned.
      */
     AlignFrame requestedBy = getRequestingAlignFrame();
-    if (requestedBy != null && requestedBy.getSplitViewContainer() != null
+    if (complement!=null && requestedBy != null && requestedBy.getSplitViewContainer() != null
             && requestedBy.getSplitViewContainer()
                     .getComplement(requestedBy) != null)
     {
-      AlignmentI complement = requestedBy.getSplitViewContainer()
-              .getComplement(requestedBy);
       String complementTitle = requestedBy.getSplitViewContainer()
               .getComplementTitle(requestedBy);
       // becomes null if the alignment window was closed before the alignment
       // job finished.
-      AlignmentI copyComplement = new Alignment(complement);
-      // todo should this be done by copy constructor?
-      copyComplement.setGapCharacter(complement.getGapCharacter());
-      // share the same dataset (and the mappings it holds)
-      copyComplement.setDataset(complement.getDataset());
-      copyComplement.alignAs(al);
-      if (copyComplement.getHeight() > 0)
+      if (complement.getHeight() > 0)
       {
         af.setTitle(alTitle);
-        AlignFrame af2 = new AlignFrame(copyComplement,
+        AlignFrame af2 = new AlignFrame(complement,
                 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
         af2.setTitle(complementTitle);
         String linkedTitle = MessageManager
index 128bc5c..cf6ef13 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.analysis;
 
+import static org.junit.Assert.assertNotEquals;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
 import static org.testng.AssertJUnit.assertNotNull;
@@ -41,6 +42,7 @@ import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.datamodel.features.SequenceFeatures;
 import jalview.gui.JvOptionPane;
 import jalview.io.AppletFormatAdapter;
@@ -55,6 +57,7 @@ import jalview.util.MappingUtils;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -1787,7 +1790,10 @@ public class AlignmentUtilsTests
     ArrayList<AlignedCodonFrame> acfs = new ArrayList<>();
     acfs.add(acf);
     protein.setCodonFrames(acfs);
-
+    Iterator<SequenceI> protseq = protein.getSequences().iterator();
+    for (SequenceI dnaseq:dna.getSequences()) {
+      assertCanResolveProteinCDS(dnaseq,protseq.next(),protein);
+    }
     /*
      * verify X is included in the aligned proteins, and placed just
      * before the first mapped residue 
@@ -1800,6 +1806,43 @@ public class AlignmentUtilsTests
   }
 
   /**
+   * assert that we can resolve the protein product in the given alignment given a DNA sequence with CDS mapping 
+   * @param dnaseq
+   * @param protein
+   */
+  private void assertCanResolveProteinCDS(SequenceI dnaseq, SequenceI expProtein, AlignmentI protein)
+  {
+    // try a few different methods to check all work
+    SequenceI aprot=null;
+    for (AlignedCodonFrame cf:protein.getCodonFrame(dnaseq))
+    {
+      aprot=cf.getAaForDnaSeq(dnaseq);
+      if (aprot!=null)
+      {
+        assertTrue("getAaForDnaSeq didn't return expected protein sequence",aprot!=expProtein);
+        break;
+      }
+    }
+    assertNotNull("Didn't locate any proteins via AlignmentI.getCodonFrame .. AlignCodonFrame.getAaForDnaSeq", aprot);
+    // try mapping utils - 
+    List<AlignedCodonFrame> mu_mappings=MappingUtils.findMappingsForSequence(dnaseq, protein.getCodonFrames());
+    assertNotNull("No mappings found for dnaseq in protein alignment via MappingUtils.findMappingsForSequence",mu_mappings);
+    assertNotEquals("No mappings found for dnaseq in protein alignment via MappingUtils.findMappingsForSequence",0,mu_mappings.size());
+    SequenceI mu_alignedprot=null;
+    List<SequenceToSequenceMapping> foundMap=null;
+    for (AlignedCodonFrame cf:mu_mappings)
+    {
+      foundMap=new ArrayList<>();
+      mu_alignedprot = cf.findAlignedSequence(dnaseq, protein,foundMap);
+      if (mu_alignedprot!=null) {
+        break;
+      }
+    }
+    assertNotNull("Didn't locate proteins via MappingUtils.findMappingsForSequence",mu_alignedprot);
+    assertTrue("findAlignedSequence didn't return expected protein sequence",mu_alignedprot==expProtein);
+  }
+
+  /**
    * Tests for the method that maps the subset of a dna sequence that has CDS
    * (or subtype) feature - case where the start codon is incomplete.
    */
index 95e6c0d..1f45f70 100644 (file)
@@ -123,6 +123,19 @@ public class FinderTest
     assertEquals(matches.get(1).getEnd(), 6);
   }
 
+  @Test(groups = "Functional")
+  public void testFind_findAll()
+  {
+    /*
+     * simple JAL-3765 test
+     * single symbol should find *all* matching symbols 
+     */
+    Finder f = new Finder(av);
+    f.findAll("M", false,false,false);
+    SearchResultsI sr = f.getSearchResults();
+    assertEquals(sr.getCount(),5);
+    
+  }
   /**
    * Test for (undocumented) find residue by position
    */
index 184f9fb..87ca53e 100644 (file)
@@ -93,7 +93,7 @@ public class GroupingTest
     }
     SequenceGroup[] seqgroupsColSel = Grouping.makeGroupsFromCols(
             alignment.getSequencesArray(), cs,
-            Arrays.asList(new SequenceGroup[] { sg_12, sg_345 }));
+            Arrays.asList(new SequenceGroup[] { sg_12, sg_345 }),null);
     AssertJUnit
             .assertEquals(seqgroupsString.length, seqgroupsColSel.length);
     for (int p = 0; p < seqgroupsString.length; p++)
index fb4073a..337ac1a 100644 (file)
@@ -22,20 +22,22 @@ package jalview.datamodel;
 
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
 
-import jalview.gui.JvOptionPane;
-import jalview.util.MapList;
-
 import java.util.Arrays;
 import java.util.List;
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
+import jalview.gui.JvOptionPane;
+import jalview.util.MapList;
+
 public class AlignedCodonFrameTest
 {
 
@@ -98,52 +100,67 @@ public class AlignedCodonFrameTest
   public void testGetMappedRegion()
   {
     // introns lower case, exons upper case
-    final Sequence seq1 = new Sequence("Seq1", "c-G-TA-gC-gT-T");
-    seq1.createDatasetSequence();
-    final Sequence seq2 = new Sequence("Seq2", "-TA-gG-Gg-CG-a");
-    seq2.createDatasetSequence();
+    final Sequence dna1 = new Sequence("Seq1/10-18", "c-G-TA-gC-gT-T");
+    dna1.createDatasetSequence();
+    final Sequence dna2 = new Sequence("Seq2/20-28", "-TA-gG-Gg-CG-a");
+    dna2.createDatasetSequence();
 
-    final Sequence aseq1 = new Sequence("Seq1", "-P-R");
-    aseq1.createDatasetSequence();
-    final Sequence aseq2 = new Sequence("Seq2", "-LY-Q");
-    aseq2.createDatasetSequence();
+    final Sequence pep1 = new Sequence("Seq1/3-4", "-P-R");
+    pep1.createDatasetSequence();
+    final Sequence pep2 = new Sequence("Seq2/7-9", "-LY-Q");
+    pep2.createDatasetSequence();
 
     /*
      * First with no mappings
      */
     AlignedCodonFrame acf = new AlignedCodonFrame();
 
-    assertNull(acf.getMappedRegion(seq1, aseq1, 1));
+    assertNull(acf.getMappedRegion(dna1, pep1, 3));
 
     /*
      * Set up the mappings for the exons (upper-case bases)
      * Note residue Q is unmapped
      */
-    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 }, new int[] {
-        1, 2 }, 3, 1);
-    acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
-    map = new MapList(new int[] { 1, 2, 4, 5, 7, 8 }, new int[] { 1, 2 },
+    MapList map1 = new MapList(new int[] { 11, 13, 15, 15, 17, 18 }, new int[] {
+        3, 4 }, 3, 1);
+    acf.addMap(dna1.getDatasetSequence(), pep1.getDatasetSequence(), map1);
+    MapList map2 = new MapList(new int[] { 20, 21, 23, 24, 26, 27 }, new int[] { 7, 9 },
             3, 1);
-    acf.addMap(seq2.getDatasetSequence(), aseq2.getDatasetSequence(), map);
+    acf.addMap(dna2.getDatasetSequence(), pep2.getDatasetSequence(), map2);
 
-    assertArrayEquals(new int[] { 2, 4 },
-            acf.getMappedRegion(seq1, aseq1, 1));
-    assertArrayEquals(new int[] { 6, 6, 8, 9 },
-            acf.getMappedRegion(seq1, aseq1, 2));
-    assertArrayEquals(new int[] { 1, 2, 4, 4 },
-            acf.getMappedRegion(seq2, aseq2, 1));
-    assertArrayEquals(new int[] { 5, 5, 7, 8 },
-            acf.getMappedRegion(seq2, aseq2, 2));
+    /*
+     * get codon positions for peptide position
+     */
+    assertArrayEquals(new int[] { 11, 13 },
+            acf.getMappedRegion(dna1, pep1, 3));
+    assertArrayEquals(new int[] { 15, 15, 17, 18 },
+            acf.getMappedRegion(dna1, pep1, 4));
+    assertArrayEquals(new int[] { 20, 21, 23, 23 },
+            acf.getMappedRegion(dna2, pep2, 7));
+    assertArrayEquals(new int[] { 24, 24, 26, 27 },
+            acf.getMappedRegion(dna2, pep2, 8));
 
     /*
-     * No mapping from seq2 to Q
+     * No mapping from dna2 to Q
      */
-    assertNull(acf.getMappedRegion(seq2, aseq2, 3));
+    assertNull(acf.getMappedRegion(dna2, pep2, 9));
 
     /*
-     * No mapping from sequence 1 to sequence 2
+     * No mapping from dna1 to pep2
      */
-    assertNull(acf.getMappedRegion(seq1, aseq2, 1));
+    assertNull(acf.getMappedRegion(dna1, pep2, 7));
+    
+    /*
+     * get peptide position for codon position
+     */
+    assertArrayEquals(new int[] { 3, 3 },
+            acf.getMappedRegion(pep1, dna1, 11));
+    assertArrayEquals(new int[] { 3, 3 },
+            acf.getMappedRegion(pep1, dna1, 12));
+    assertArrayEquals(new int[] { 3, 3 },
+            acf.getMappedRegion(pep1, dna1, 13));
+    assertNull(acf.getMappedRegion(pep1, dna1, 14)); // intron base, not mapped
+
   }
 
   @Test(groups = { "Functional" })
@@ -486,4 +503,212 @@ public class AlignedCodonFrameTest
     assertEquals(1, acf.getMappingsFromSequence(seq1).size());
     assertSame(before, acf.getMappingsFromSequence(seq1).get(0));
   }
+  
+  @Test(groups = { "Functional" })
+  public void testGetCoveringMapping()
+  {
+    SequenceI dna = new Sequence("dna", "acttcaATGGCGGACtaattt");
+    SequenceI cds = new Sequence("cds/7-15", "ATGGCGGAC");
+    cds.setDatasetSequence(dna);
+    SequenceI pep = new Sequence("pep", "MAD");
+    
+    /*
+     * with null argument or no mappings
+     */
+    AlignedCodonFrame acf = new AlignedCodonFrame();
+    assertNull(acf.getCoveringMapping(null,  null));
+    assertNull(acf.getCoveringMapping(dna,  null));
+    assertNull(acf.getCoveringMapping(null,  pep));
+    assertNull(acf.getCoveringMapping(dna,  pep));
+
+    /*
+     * with a non-covering mapping e.g. overlapping exon
+     */
+    MapList map = new MapList(new int[] { 7, 9 }, new int[] {
+        1, 1 }, 3, 1);
+    acf.addMap(dna, pep, map);
+    assertNull(acf.getCoveringMapping(dna,  pep));
+    
+    acf = new AlignedCodonFrame();
+    MapList map2 = new MapList(new int[] { 13, 18 }, new int[] {
+        2, 2 }, 3, 1);
+    acf.addMap(dna, pep, map2);
+    assertNull(acf.getCoveringMapping(dna,  pep));
+    
+    /*
+     * with a covering mapping from CDS (dataset) to protein
+     */
+    acf = new AlignedCodonFrame();
+    MapList map3 = new MapList(new int[] { 7, 15 }, new int[] {
+        1, 3 }, 3, 1);
+    acf.addMap(dna, pep, map3);
+    assertNull(acf.getCoveringMapping(dna,  pep));
+    SequenceToSequenceMapping mapping = acf.getCoveringMapping(cds,  pep);
+    assertNotNull(mapping);
+    
+    /*
+     * with a mapping that extends to stop codon
+     */
+    acf = new AlignedCodonFrame();
+    MapList map4 = new MapList(new int[] { 7, 18 }, new int[] {
+        1, 3 }, 3, 1);
+    acf.addMap(dna, pep, map4);
+    assertNull(acf.getCoveringMapping(dna,  pep));
+    assertNull(acf.getCoveringMapping(cds,  pep));
+    SequenceI cds2 = new Sequence("cds/7-18", "ATGGCGGACtaa");
+    cds2.setDatasetSequence(dna);
+    mapping = acf.getCoveringMapping(cds2,  pep);
+    assertNotNull(mapping);
+  }
+
+  /**
+   * Test the method that adds mapped positions to SearchResults
+   */
+  @Test(groups = { "Functional" })
+  public void testMarkMappedRegion()
+  {
+    // introns lower case, exons upper case
+    final Sequence dna1 = new Sequence("Seq1/10-18", "c-G-TA-gC-gT-T");
+    dna1.createDatasetSequence();
+    final Sequence dna2 = new Sequence("Seq2/20-28", "-TA-gG-Gg-CG-a");
+    dna2.createDatasetSequence();
+  
+    final Sequence pep1 = new Sequence("Seq1/3-4", "-P-R");
+    pep1.createDatasetSequence();
+    final Sequence pep2 = new Sequence("Seq2/7-9", "-LY-Q");
+    pep2.createDatasetSequence();
+  
+    /*
+     * First with no mappings
+     */
+    AlignedCodonFrame acf = new AlignedCodonFrame();
+    SearchResults sr = new SearchResults();
+    acf.markMappedRegion(dna1, 12, sr);
+    assertTrue(sr.isEmpty());
+  
+    /*
+     * Set up the mappings for the exons (upper-case bases)
+     * Note residue Q is unmapped
+     */
+    MapList map1 = new MapList(new int[] { 11, 13, 15, 15, 17, 18 }, new int[] {
+        3, 4 }, 3, 1);
+    acf.addMap(dna1.getDatasetSequence(), pep1.getDatasetSequence(), map1);
+    MapList map2 = new MapList(new int[] { 20, 21, 23, 24, 26, 27 }, new int[] { 7, 8 },
+            3, 1);
+    acf.addMap(dna2.getDatasetSequence(), pep2.getDatasetSequence(), map2);
+    
+    /*
+     * intron bases are not mapped
+     */
+    acf.markMappedRegion(dna1, 10, sr);
+    assertTrue(sr.isEmpty());
+  
+    /*
+     * Q is not mapped
+     */
+    acf.markMappedRegion(pep2, 9, sr);
+    assertTrue(sr.isEmpty());
+
+    /*
+     * mark peptide position for exon position (of aligned sequence)
+     */
+    acf.markMappedRegion(dna1, 11, sr);
+    SearchResults expected = new SearchResults();
+    expected.addResult(pep1.getDatasetSequence(),  3, 3);
+    assertEquals(sr, expected);
+
+    /*
+     * mark peptide position for exon position of dataset sequence - same result
+     */
+    sr = new SearchResults();
+    acf.markMappedRegion(dna1.getDatasetSequence(), 11, sr);
+    assertEquals(sr, expected);
+    
+    /*
+     * marking the same position a second time should not create a duplicate match
+     */
+    acf.markMappedRegion(dna1.getDatasetSequence(), 12, sr);
+    assertEquals(sr, expected);
+    
+    /*
+     * mark exon positions for peptide position (of aligned sequence)
+     */
+    sr = new SearchResults();
+    acf.markMappedRegion(pep2, 7, sr); // codon positions 20, 21, 23
+    expected = new SearchResults();
+    expected.addResult(dna2.getDatasetSequence(),  20, 21);
+    expected.addResult(dna2.getDatasetSequence(),  23, 23);
+    assertEquals(sr, expected);
+    
+    /*
+     * add another codon to the same SearchResults
+     */
+    acf.markMappedRegion(pep1.getDatasetSequence(), 4, sr); // codon positions 15, 17, 18
+    expected.addResult(dna1.getDatasetSequence(),  15, 15);
+    expected.addResult(dna1.getDatasetSequence(),  17, 18);
+    assertEquals(sr, expected);
+  }
+
+  @Test(groups = { "Functional" })
+  public void testGetCoveringCodonMapping()
+  {
+    SequenceI dna = new Sequence("dna/10-30", "acttcaATGGCGGACtaattt");
+    // CDS sequence with its own dataset sequence (JAL-3763)
+    SequenceI cds = new Sequence("cds/1-9", "-A--TGGC-GGAC");
+    cds.createDatasetSequence();
+    SequenceI pep = new Sequence("pep/1-3", "MAD");
+    
+    /*
+     * with null argument or no mappings
+     */
+    AlignedCodonFrame acf = new AlignedCodonFrame();
+    assertNull(acf.getCoveringCodonMapping(null));
+    assertNull(acf.getCoveringCodonMapping(dna));
+    assertNull(acf.getCoveringCodonMapping(pep));
+  
+    /*
+     * with a non-covering mapping e.g. overlapping exon
+     */
+    MapList map = new MapList(new int[] { 16, 18 }, new int[] {
+        1, 1 }, 3, 1);
+    acf.addMap(dna, pep, map);
+    assertNull(acf.getCoveringCodonMapping(dna));
+    assertNull(acf.getCoveringCodonMapping(pep));
+    
+    acf = new AlignedCodonFrame();
+    MapList map2 = new MapList(new int[] { 13, 18 }, new int[] {
+        2, 2 }, 3, 1);
+    acf.addMap(dna, pep, map2);
+    assertNull(acf.getCoveringCodonMapping(dna));
+    assertNull(acf.getCoveringCodonMapping(pep));
+    
+    /*
+     * with a covering mapping from CDS (dataset) to protein
+     */
+    acf = new AlignedCodonFrame();
+    MapList map3 = new MapList(new int[] { 1, 9 }, new int[] {
+        1, 3 }, 3, 1);
+    acf.addMap(cds.getDatasetSequence(), pep, map3);
+    assertNull(acf.getCoveringCodonMapping(dna));
+    SequenceToSequenceMapping mapping = acf.getCoveringCodonMapping(pep);
+    assertNotNull(mapping);
+    SequenceToSequenceMapping mapping2 = acf.getCoveringCodonMapping(cds.getDatasetSequence());
+    assertSame(mapping, mapping2);
+    
+    /*
+     * with a mapping that extends to stop codon
+     * (EMBL CDS location often includes the stop codon)
+     * - getCoveringCodonMapping is lenient (doesn't require exact length match)
+     */
+    SequenceI cds2 = new Sequence("cds/1-12", "-A--TGGC-GGACTAA");
+    cds2.createDatasetSequence();
+    acf = new AlignedCodonFrame();
+    MapList map4 = new MapList(new int[] { 1, 12 }, new int[] {
+        1, 3 }, 3, 1);
+    acf.addMap(cds2, pep, map4);
+    mapping = acf.getCoveringCodonMapping(cds2.getDatasetSequence());
+    assertNotNull(mapping);
+    mapping2 = acf.getCoveringCodonMapping(pep);
+    assertSame(mapping, mapping2);
+  }
 }
index 89169d6..761835d 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.datamodel;
 
+import static org.testng.Assert.assertTrue;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
 
@@ -66,6 +67,29 @@ public class SeqCigarTest
     }
   }
 
+  @Test(groups= {"Functional"})
+  public void testReconstructSeq()
+  {
+    String o_seq = "asdfktryasdtqwrtsaslldddptyipqqwaslchvhttt";
+    SequenceI s = new Sequence("MySeq", o_seq, 39, 80);
+    String orig_gapped = "----asdf------ktryas---dtqwrtsasll----dddptyipqqwa----slchvhttt";
+    // name of sequence in a particular alignment should be recovered
+    SequenceI s_gapped = new Sequence("MySeqAlign", orig_gapped, 39, 80);
+    s_gapped.setDatasetSequence(s);
+    SeqCigar cg_sgapped = new SeqCigar(s_gapped);
+    assertTrue(testSeqRecovery(cg_sgapped,s_gapped,true));
+    SequenceI subseq_gapped = s_gapped.getSubSequence(44, 60);
+    SeqCigar subseq_cg_range=new SeqCigar(s_gapped,44,59);
+    assertTrue(testSeqRecovery(subseq_cg_range, subseq_gapped, true),"SeqCigar created on range of sequence failed");
+
+    // test another way of reconstructing a sequence from seqCigar
+    SequenceI[] sqs=SeqCigar.createAlignmentSequences(new SeqCigar[] {subseq_cg_range}, '-', new HiddenColumns(), null);
+    assertTrue(testSeqRecovery(subseq_cg_range, sqs[0], true),"createAlignmentSequences didn't reconstruct same sequence as for SeqCigar created on range of sequence failed (used by AlignmentView for selections)");
+
+    subseq_gapped.setName("SubSeqMySeqAlign"); // name of sequence in a particular alignment should be recovered
+    SeqCigar subseq_cg = new SeqCigar(subseq_gapped);
+    assertTrue(testSeqRecovery(subseq_cg,subseq_gapped,true));
+  }
   /*
    * refactored 'as is' from main method
    * 
@@ -94,13 +118,13 @@ public class SeqCigarTest
     assertEquals("Failed parseCigar", ex_cs_gapped,
             gen_sgapped.getCigarstring());
 
-    testSeqRecovery(gen_sgapped, s_gapped);
+    assertTrue(testSeqRecovery(gen_sgapped, s_gapped,true));
 
     /*
      * Test dataset resolution
      */
     SeqCigar sub_gapped = new SeqCigar(s_subsequence_gapped);
-    testSeqRecovery(sub_gapped, s_subsequence_gapped);
+    assertTrue(testSeqRecovery(sub_gapped, s_subsequence_gapped,true));
 
     /*
      * Test width functions
@@ -187,7 +211,7 @@ public class SeqCigarTest
     assertEquals("Failed getCigarstring", ex_cs_gapped, cs_gapped);
   }
 
-  protected void testSeqRecovery(SeqCigar gen_sgapped, SequenceI s_gapped)
+  protected boolean testSeqRecovery(SeqCigar gen_sgapped, SequenceI s_gapped,boolean startEndCheck)
   {
     // this is non-rigorous - start and end recovery is not tested.
     SequenceI gen_sgapped_s = gen_sgapped.getSeq('-');
@@ -201,7 +225,14 @@ public class SeqCigarTest
       System.err.println("Couldn't reconstruct sequence.\n"
               + gen_sgapped_s.getSequenceAsString() + "\n"
               + s_gapped.getSequenceAsString());
+      return false;
+    }
+    if (startEndCheck)
+    {
+      assertEquals("Start not conserved in reconstructed sequence",s_gapped.getStart(),gen_sgapped_s.getStart());
+      assertEquals("End not conserved in reconstructed sequence",s_gapped.getEnd(),gen_sgapped_s.getEnd());
     }
+    return true;
   }
 
 }
index f8479a3..bd5e9ac 100644 (file)
@@ -48,8 +48,8 @@ public class SequenceFeatureTest
   @Test(groups = { "Functional" })
   public void testCopyConstructors()
   {
-    SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33,
-            12.5f, "group");
+    SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33, 12.5f,
+            "group");
     sf1.setValue("STRAND", "+");
     sf1.setValue("Note", "Testing");
     Integer count = Integer.valueOf(7);
@@ -83,8 +83,8 @@ public class SequenceFeatureTest
     /*
      * copy constructor modifying type/begin/end/group/score
      */
-    SequenceFeature sf4 = new SequenceFeature(sf1, "Disulfide bond", 12,
-            15, "group3", -9.1f);
+    SequenceFeature sf4 = new SequenceFeature(sf1, "Disulfide bond", 12, 15,
+            "group3", -9.1f);
     assertEquals("Disulfide bond", sf4.getType());
     assertTrue(sf4.isContactFeature());
     assertEquals("desc", sf4.getDescription());
@@ -104,8 +104,8 @@ public class SequenceFeatureTest
   @Test(groups = { "Functional" })
   public void testGetValue()
   {
-    SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33,
-            12.5f, "group");
+    SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33, 12.5f,
+            "group");
     sf1.setValue("STRAND", "+");
     assertEquals("+", sf1.getValue("STRAND"));
     assertNull(sf1.getValue("strand")); // case-sensitive
@@ -137,15 +137,15 @@ public class SequenceFeatureTest
   @Test(groups = { "Functional" })
   public void testEqualsAndHashCode()
   {
-    SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33,
-            12.5f, "group");
+    SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33, 12.5f,
+            "group");
     sf1.setValue("ID", "id");
     sf1.setValue("Name", "name");
     sf1.setValue("Parent", "parent");
     sf1.setStrand("+");
     sf1.setPhase("1");
-    SequenceFeature sf2 = new SequenceFeature("type", "desc", 22, 33,
-            12.5f, "group");
+    SequenceFeature sf2 = new SequenceFeature("type", "desc", 22, 33, 12.5f,
+            "group");
     sf2.setValue("ID", "id");
     sf2.setValue("Name", "name");
     sf2.setValue("Parent", "parent");
@@ -158,10 +158,10 @@ public class SequenceFeatureTest
     assertEquals(sf1.hashCode(), sf2.hashCode());
 
     // changing type breaks equals:
-    SequenceFeature sf3 = new SequenceFeature("type", "desc", 22, 33,
-            12.5f, "group");
-    SequenceFeature sf4 = new SequenceFeature("Type", "desc", 22, 33,
-            12.5f, "group");
+    SequenceFeature sf3 = new SequenceFeature("type", "desc", 22, 33, 12.5f,
+            "group");
+    SequenceFeature sf4 = new SequenceFeature("Type", "desc", 22, 33, 12.5f,
+            "group");
     assertFalse(sf3.equals(sf4));
 
     // changing description breaks equals:
@@ -195,7 +195,8 @@ public class SequenceFeatureTest
 
     // changing start position breaks equals:
     int restorei = sf2.getBegin();
-    sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup(), sf2.getScore());
+    sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup(),
+            sf2.getScore());
     assertFalse(sf1.equals(sf2));
     sf2 = new SequenceFeature(sf2, restorei, sf2.getEnd(),
             sf2.getFeatureGroup(), sf2.getScore());
@@ -210,9 +211,11 @@ public class SequenceFeatureTest
 
     // changing feature group breaks equals:
     restores = sf2.getFeatureGroup();
-    sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group", sf2.getScore());
+    sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group",
+            sf2.getScore());
     assertFalse(sf1.equals(sf2));
-    sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores, sf2.getScore());
+    sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores,
+            sf2.getScore());
 
     // changing ID breaks equals:
     restores = (String) sf2.getValue("ID");
@@ -285,7 +288,8 @@ public class SequenceFeatureTest
     String seqName = seq.getName();
 
     // single locus, no group, no score
-    SequenceFeature sf = new SequenceFeature("variant", "G,C", 22, 22, null);
+    SequenceFeature sf = new SequenceFeature("variant", "G,C", 22, 22,
+            null);
     String expected = "<br><table><tr><td>Location</td><td>TestSeq</td><td>22</td></tr>"
             + "<tr><td>Type</td><td>variant</td><td></td></tr>"
             + "<tr><td>Description</td><td>G,C</td><td></td></tr></table>";
@@ -299,8 +303,7 @@ public class SequenceFeatureTest
             + "<tr><td>Description</td><td>a description</td><td></td></tr></table>";
     assertEquals(expected, sf.getDetailsReport(seqName, null));
 
-    sf = new SequenceFeature("variant", "G,C", 22, 33,
-            12.5f, "group");
+    sf = new SequenceFeature("variant", "G,C", 22, 33, 12.5f, "group");
     sf.setValue("Parent", "ENSG001");
     sf.setValue("Child", "ENSP002");
     expected = "<br><table><tr><td>Location</td><td>TestSeq</td><td>22-33</td></tr>"
@@ -351,9 +354,23 @@ public class SequenceFeatureTest
             + "<tr><td>Type</td><td>variant</td><td></td></tr>"
             + "<tr><td>Description</td><td>G,C</td><td></td></tr>"
             + "<tr><td>Consequence</td><td><i>Translated by Jalview</i></td><td>p.Leu9Phe</td></tr>"
-            + "<tr><td>alleles</td><td></td><td>G,C</td></tr>"
+            + "<tr><td>alleles</td><td></td><td>G,C</td></tr>" 
             + "</table>";
 
     assertEquals(expected, sf.getDetailsReport(seq.getName(), mf));
+    
+
+    /*
+     * exon feature extending beyond mapped range; mapped location should be
+     * restricted to peptide mapped range limit i.e. 10-13
+     */
+    SequenceFeature sf2 = new SequenceFeature("exon", "exon 1", 109, 230, null);
+    features.add(sf2);
+    expected = "<br><table><tr><td>Location</td><td>Cds</td><td>109-230</td></tr>"
+            + "<tr><td>Peptide Location</td><td>TestSeq</td><td>10-13</td></tr>"
+            + "<tr><td>Type</td><td>exon</td><td></td></tr>"
+            + "<tr><td>Description</td><td>exon 1</td><td></td></tr>"
+            + "</table>";
+    assertEquals(expected, sf2.getDetailsReport(seq.getName(), mf));
   }
 }
diff --git a/test/jalview/gui/SplitFrameTest.java b/test/jalview/gui/SplitFrameTest.java
new file mode 100644 (file)
index 0000000..7420e71
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import static org.junit.Assert.assertNotEquals;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import jalview.api.FeatureColourI;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
+import jalview.project.Jalview2xmlTests;
+import jalview.renderer.ResidueShaderI;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.FeatureColour;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.JalviewColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.util.MessageManager;
+
+import java.awt.Color;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class SplitFrameTest
+{
+  AlignFrame dnaAf, proteinAf;
+
+  SplitFrame testSplitFrame;
+
+  @BeforeClass(alwaysRun = true)
+  public static void setUpBeforeClass() throws Exception
+  {
+    setUpJvOptionPane();
+    /*
+     * use read-only test properties file
+     */
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Jalview.main(new String[] { "-nonews" });
+  }
+
+  @AfterMethod(alwaysRun = true)
+  public void tearDown()
+  {
+    Desktop.instance.closeAll_actionPerformed(null);
+  }
+
+  /**
+   * configure (read-only) properties for test to ensure Consensus is computed
+   * for colour Above PID testing
+   */
+  @BeforeMethod(alwaysRun = true)
+  public void setUp()
+  {
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+            Boolean.TRUE.toString());
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/testdata/MN908947.jvp", DataSourceType.FILE);
+
+    /*
+     * wait for Consensus thread to complete
+     */
+    synchronized (this)
+    {
+      while (af.getViewport().getConsensusSeq() == null)
+      {
+        try
+        {
+          wait(50);
+        } catch (InterruptedException e)
+        {
+        }
+      }
+    }
+    testSplitFrame = (SplitFrame) af.getSplitViewContainer();
+    proteinAf=af.getViewport().getAlignment().isNucleotide() ? testSplitFrame.getComplementAlignFrame(af) : af;
+    dnaAf=testSplitFrame.getComplementAlignFrame(proteinAf);
+  }
+
+  public static void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
+  @Test(groups= {"Functional"})
+  public void testAlignAsSplitFrame()
+  {
+
+    /*
+     * If alignment was requested from one half of a SplitFrame, show in a
+     * SplitFrame with the other pane similarly aligned.
+     */
+    AlignFrame requestedBy = proteinAf;
+    AlignmentI wholeProteinAl = proteinAf.getViewport().getAlignment();
+    SequenceI[] sel = wholeProteinAl.getSequencesArray();
+    // Select 3 sequences, from columns 3-7 inclusive
+    SequenceGroup selRegion = new SequenceGroup(
+            Arrays.asList(sel[0], sel[1], sel[3]));
+    selRegion.setStartRes(3);
+    selRegion.setEndRes(7);
+    proteinAf.getViewport().setSelectionGroup(selRegion);
+    proteinAf.getViewport().sendSelection();
+    assertNotNull(dnaAf.getViewport().getSelectionGroup());
+    AlignmentView inputView = proteinAf.gatherSequencesForAlignment();
+    assertEquals(inputView.getSequences().length, 3);
+    assertEquals(inputView.getWidth(), 5);
+    assertNotNull(inputView.getComplementView());
+
+    Object alAndHidden[] = inputView.getAlignmentAndHiddenColumns(
+            proteinAf.getViewport().getGapCharacter());
+    AlignmentI result = new Alignment((SequenceI[]) alAndHidden[0]);
+    result.setHiddenColumns((HiddenColumns) alAndHidden[1]);
+    // check we are referring to the expected alignment
+    assertEquals(
+            requestedBy.getSplitViewContainer().getComplement(requestedBy),
+            dnaAf.getCurrentView().getAlignment());
+    // and that datasets are consistent (if not, there's a problem elsewhere in
+    // splitframe construction
+    AlignmentI complementDs = requestedBy.getSplitViewContainer()
+            .getComplement(requestedBy).getDataset();
+    assertTrue(complementDs == dnaAf
+            .getViewport().getAlignment().getDataset());
+    assertTrue(complementDs == proteinAf.getViewport().getAlignment()
+            .getDataset());
+
+    char gc = requestedBy.getSplitViewContainer().getComplement(requestedBy)
+            .getGapCharacter();
+
+    AlignmentI complement = inputView.getComplementView()
+            .getVisibleAlignment(gc);
+    String complementTitle = requestedBy.getSplitViewContainer()
+            .getComplementTitle(requestedBy);
+    // becomes null if the alignment window was closed before the alignment
+    // job finished.
+    AlignmentI copyComplement = new Alignment(complement);
+    // todo should this be done by copy constructor?
+    copyComplement.setGapCharacter(complement.getGapCharacter());
+    // share the same dataset (and the mappings it holds)
+    copyComplement.setDataset(complementDs);
+    copyComplement.alignAs(result);
+    // check shape is as expected
+    assertEquals(copyComplement.getWidth(), result.getWidth() * 3);
+    assertEquals(copyComplement.getHeight(), result.getHeight());
+    // specific bug with this set - see same CDS for all distinct products
+    assertTrue(
+            !copyComplement.getSequenceAt(0).getSequenceAsString().equals(
+                    copyComplement.getSequenceAt(1).getSequenceAsString()),
+            "Didn't reconstruct CDS correctly");
+    // now get the result again, do some edits and reconstruct again
+    alAndHidden = inputView.getAlignmentAndHiddenColumns(
+            proteinAf.getViewport().getGapCharacter());
+    AlignmentI newresult = new Alignment((SequenceI[]) alAndHidden[0]);
+    newresult.setHiddenColumns((HiddenColumns) alAndHidden[1]);
+    newresult.setDataset(complementDs);
+    newresult.getSequenceAt(0).insertCharAt(3, 3, '-');
+    newresult.getSequenceAt(1).insertCharAt(0, 3, '-');
+    newresult.padGaps();
+    AlignmentI newcomplement = inputView.getComplementView()
+            .getVisibleAlignment('-');
+    newcomplement.alignAs(newresult);
+    assertEquals(newcomplement.getWidth(), newresult.getWidth() * 3);
+    assertEquals(newcomplement.getHeight(), newresult.getHeight());
+    // if reconstruction worked, the first sequence should not equal the first
+    // sequence in the original CDS 'alignAs'
+    for (int sq = 0; sq < 3; sq++)
+    {
+      // check same CDS in same position
+      assertTrue(newcomplement.getSequenceAt(sq)
+              .getDatasetSequence() == newcomplement.getSequenceAt(sq)
+                      .getDatasetSequence());
+      // verify that sequence strings are different
+      assertTrue(!newcomplement.getSequenceAt(sq).getSequenceAsString()
+              .equals(copyComplement.getSequenceAt(sq)
+                      .getSequenceAsString()));
+    }
+    // JAL-3748 bug manifests as duplicated CDS sequence content, so need to
+    // also check each CDS is distinct.
+    assertTrue(
+            !newcomplement.getSequenceAt(0).getSequenceAsString().equals(
+                    newcomplement.getSequenceAt(1).getSequenceAsString()),
+            "Didn't reconstruct CDS correctly");
+
+  }
+}
index 5d8ef21..2465f27 100644 (file)
@@ -173,7 +173,7 @@ public class EmblFlatFileTest
         {
           assertEquals((ranges = map.getFromRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1579);
-          assertEquals(ranges.get(0)[1], 2934);
+          assertEquals(ranges.get(0)[1], 2931);
           assertEquals((ranges = map.getToRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1);
           assertEquals(ranges.get(0)[1], 451);
@@ -185,7 +185,7 @@ public class EmblFlatFileTest
         {
           assertEquals((ranges = map.getFromRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 2928);
-          assertEquals(ranges.get(0)[1], 3992);
+          assertEquals(ranges.get(0)[1], 3989);
           assertEquals((ranges = map.getToRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1);
           assertEquals(ranges.get(0)[1], 354);
@@ -194,7 +194,7 @@ public class EmblFlatFileTest
         {
           assertEquals((ranges = map.getFromRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 4054);
-          assertEquals(ranges.get(0)[1], 4848);
+          assertEquals(ranges.get(0)[1], 4845);
           assertEquals((ranges = map.getToRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1);
           assertEquals(ranges.get(0)[1], 264);
@@ -206,7 +206,7 @@ public class EmblFlatFileTest
           assertEquals(ranges.get(0)[0], 7022);
           assertEquals(ranges.get(0)[1], 7502);
           assertEquals(ranges.get(1)[0], 1);
-          assertEquals(ranges.get(1)[1], 437);
+          assertEquals(ranges.get(1)[1], 434);
           assertEquals((ranges = map.getToRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1);
           assertEquals(ranges.get(0)[1], 305);
@@ -216,7 +216,7 @@ public class EmblFlatFileTest
           // complement(488..1480)
           assertEquals((ranges = map.getFromRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1480);
-          assertEquals(ranges.get(0)[1], 488);
+          assertEquals(ranges.get(0)[1], 491);
           assertEquals((ranges = map.getToRanges()).size(), 1);
           assertEquals(ranges.get(0)[0], 1);
           assertEquals(ranges.get(0)[1], 330);
@@ -312,11 +312,12 @@ public class EmblFlatFileTest
   {
     int[] exons = new int[] { 11, 15, 21, 25, 31, 38 }; // 18 bp
 
+    int[] exons_nostop = new int[] { 11, 15, 21, 25, 31, 35 }; // 15 bp
     // exact length match:
     assertSame(exons, EmblFlatFile.adjustForProteinLength(6, exons));
 
-    // match if we assume exons include stop codon not in protein:
-    assertSame(exons, EmblFlatFile.adjustForProteinLength(5, exons));
+    // trimmed if we assume exons include stop codon not in protein:
+    assertEquals(Arrays.toString(exons_nostop), Arrays.toString(EmblFlatFile.adjustForProteinLength(5, exons)));
 
     // truncate last exon by 6bp
     int[] truncated = EmblFlatFile.adjustForProteinLength(4, exons);
index 4bee3f5..fe8a4c6 100644 (file)
@@ -260,6 +260,8 @@ public class Mapping
   @Test(groups = { "Functional" })
   public void compareTransferredToRefPDBAnnot() throws Exception
   {
+    // JBPNote this has failed when run on OSX via gradle clean test
+    // possible race condition ?
     StructureImportSettings.setProcessSecondaryStructure(true);
     StructureImportSettings.setVisibleChainAnnotation(true);
     StructureImportSettings.setShowSeqFeatures(true);
index 6f6841d..2e646f5 100644 (file)
@@ -85,15 +85,15 @@ public class ComparisonTest
     seq = new Sequence("DNA", "ACTugGCCAG");
     SequenceI seq2 = new Sequence("Protein", "FLIMVSPTYW");
     /*
-     * 90% DNA:
+     * 90% DNA but one protein sequence - expect false
      */
-    assertTrue(Comparison.isNucleotide(new SequenceI[] { seq, seq, seq,
+    assertFalse(Comparison.isNucleotide(new SequenceI[] { seq, seq, seq,
         seq, seq, seq, seq, seq, seq, seq2 }));
-    assertTrue(Comparison.isNucleotide(new SequenceI[][] {
+    assertFalse(Comparison.isNucleotide(new SequenceI[][] {
         new SequenceI[] { seq }, new SequenceI[] { seq, seq, seq },
         new SequenceI[] { seq, seq, seq, seq, seq, seq2 } }));
     /*
-     * 80% DNA:
+     * 80% DNA but one protein sequence - Expect false
      */
     assertFalse(Comparison.isNucleotide(new SequenceI[] { seq, seq, seq,
         seq, seq, seq, seq, seq, seq2, seq2 }));
index 86dcc39..6bbda78 100644 (file)
@@ -27,8 +27,6 @@ import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
 
-import jalview.gui.JvOptionPane;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -36,8 +34,16 @@ import java.util.List;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import jalview.bin.Cache;
+import jalview.gui.JvOptionPane;
+
 public class MapListTest
 {
+  @BeforeClass(alwaysRun = true)
+  public void setUp()
+  {
+    Cache.initLogger();
+  }
 
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
@@ -49,17 +55,20 @@ public class MapListTest
   @Test(groups = { "Functional" })
   public void testSomething()
   {
-    MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 }, new int[] {
-        51, 1 }, 1, 3);
+    MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 },
+            new int[]
+            { 51, 1 }, 1, 3);
     MapList ml1 = new MapList(new int[] { 1, 3, 17, 4 },
-            new int[] { 51, 1 }, 1, 3);
+            new int[]
+            { 51, 1 }, 1, 3);
     MapList ml2 = new MapList(new int[] { 1, 60 }, new int[] { 1, 20 }, 3,
             1);
     // test internal consistency
     int to[] = new int[51];
     testMap(ml, 1, 60);
-    MapList mldna = new MapList(new int[] { 2, 2, 6, 8, 12, 16 }, new int[]
-    { 1, 3 }, 3, 1);
+    MapList mldna = new MapList(new int[] { 2, 2, 6, 8, 12, 16 },
+            new int[]
+            { 1, 3 }, 3, 1);
     int[] frm = mldna.locateInFrom(1, 1);
     testLocateFrom(mldna, 1, 1, new int[] { 2, 2, 6, 7 });
     testMap(mldna, 1, 3);
@@ -294,6 +303,85 @@ public class MapListTest
   }
 
   /**
+   * Tests for method that locates the overlap of the ranges in the 'from' map
+   * for given range in the 'to' map
+   */
+  @Test(groups = { "Functional" })
+  public void testGetOverlapsInFrom_withIntrons()
+  {
+    /*
+     * Exons at positions [2, 3, 5] [6, 7, 9] [10, 12, 14] [16, 17, 18] i.e.
+     * 2-3, 5-7, 9-10, 12-12, 14-14, 16-18
+     */
+    int[] codons = { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
+    int[] protein = { 11, 14 };
+    MapList ml = new MapList(codons, protein, 3, 1);
+
+    assertEquals("[2, 3, 5, 5]",
+            Arrays.toString(ml.getOverlapsInFrom(11, 11)));
+    assertEquals("[2, 3, 5, 7, 9, 9]",
+            Arrays.toString(ml.getOverlapsInFrom(11, 12)));
+    // out of range 5' :
+    assertEquals("[2, 3, 5, 7, 9, 9]",
+            Arrays.toString(ml.getOverlapsInFrom(8, 12)));
+    // out of range 3' :
+    assertEquals("[10, 10, 12, 12, 14, 14, 16, 18]",
+            Arrays.toString(ml.getOverlapsInFrom(13, 16)));
+    // out of range both :
+    assertEquals("[2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18]",
+            Arrays.toString(ml.getOverlapsInFrom(1, 16)));
+    // no overlap:
+    assertNull(ml.getOverlapsInFrom(20, 25));
+  }
+
+  /**
+   * Tests for method that locates the overlap of the ranges in the 'to' map
+   * for given range in the 'from' map
+   */
+  @Test(groups = { "Functional" })
+  public void testGetOverlapsInTo_withIntrons()
+  {
+    /*
+     * Exons at positions [2, 3, 5] [6, 7, 9] [10, 12, 14] [17, 18, 19] i.e.
+     * 2-3, 5-7, 9-10, 12-12, 14-14, 17-19
+     */
+    int[] codons = { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 17, 19 };
+    /*
+     * Mapped proteins at positions 1, 3, 4, 6 in the sequence
+     */
+    int[] protein = { 1, 1, 3, 4, 6, 6 };
+    MapList ml = new MapList(codons, protein, 3, 1);
+
+    /*
+     * Can't map from an unmapped position
+     */
+    assertNull(ml.getOverlapsInTo(1, 1));
+    assertNull(ml.getOverlapsInTo(4, 4));
+    assertNull(ml.getOverlapsInTo(15, 16));
+    
+    /*
+     * nor from a range that includes no mapped position (exon)
+     */
+    assertNull(ml.getOverlapsInTo(15, 16));
+
+    // end of codon 1 maps to first peptide
+    assertEquals("[1, 1]", Arrays.toString(ml.getOverlapsInTo(2, 2)));
+    // end of codon 1 and start of codon 2 maps to first 2 peptides
+    assertEquals("[1, 1, 3, 3]", Arrays.toString(ml.getOverlapsInTo(3, 7)));
+
+    // range overlaps 5' end of dna:
+    assertEquals("[1, 1, 3, 3]", Arrays.toString(ml.getOverlapsInTo(1, 6)));
+   assertEquals("[1, 1, 3, 3]", Arrays.toString(ml.getOverlapsInTo(1, 8)));
+
+    // range overlaps 3' end of dna:
+    assertEquals("[6, 6]", Arrays.toString(ml.getOverlapsInTo(17, 24)));
+    assertEquals("[6, 6]", Arrays.toString(ml.getOverlapsInTo(16, 24)));
+    
+    // dna positions 8, 11 are intron but include end of exon 2 and start of exon 3
+    assertEquals("[3, 4]", Arrays.toString(ml.getOverlapsInTo(8, 11)));
+  }
+
+  /**
    * Tests for method that locates ranges in the 'to' map for given range in the
    * 'from' map.
    */
@@ -431,7 +519,8 @@ public class MapListTest
     List<int[]> ranges = new ArrayList<>();
     ranges.add(new int[] { 2, 3 });
     ranges.add(new int[] { 5, 6 });
-    assertEquals("[2, 3, 5, 6]", Arrays.toString(MapList.getRanges(ranges)));
+    assertEquals("[2, 3, 5, 6]",
+            Arrays.toString(MapList.getRanges(ranges)));
   }
 
   /**
@@ -463,7 +552,8 @@ public class MapListTest
     assertEquals(6, ml2.getToHighest());
     assertEquals("{[2, 3], [5, 7], [9, 10], [12, 12], [14, 14], [16, 18]}",
             prettyPrint(ml2.getFromRanges()));
-    assertEquals("{[1, 1], [3, 4], [6, 6]}", prettyPrint(ml2.getToRanges()));
+    assertEquals("{[1, 1], [3, 4], [6, 6]}",
+            prettyPrint(ml2.getToRanges()));
 
     /*
      * reverse direction
@@ -478,22 +568,23 @@ public class MapListTest
   }
 
   /**
-   * Test constructor can merge consecutive ranges
+   * Test constructor used to merge consecutive ranges but now just leaves them
+   * as supplied (JAL-3751)
    */
   @Test(groups = { "Functional" })
   public void testConstructor_mergeRanges()
   {
-    int[] codons = { 2, 3, 3, 7, 9, 10, 12, 12, 14, 14, 16, 17 };
-    int[] protein = { 1, 1, 1, 3, 6, 6 };
+    int[] codons = { 2, 3, 3, 7, 9, 10, 12, 12, 13, 14, 16, 17 };
+    int[] protein = { 1, 1, 2, 3, 6, 6 };
     MapList ml = new MapList(codons, protein, 3, 1);
     assertEquals(3, ml.getFromRatio());
     assertEquals(2, ml.getFromLowest());
     assertEquals(17, ml.getFromHighest());
     assertEquals(1, ml.getToLowest());
     assertEquals(6, ml.getToHighest());
-    assertEquals("{[2, 7], [9, 10], [12, 12], [14, 14], [16, 17]}",
+    assertEquals("{[2, 3], [3, 7], [9, 10], [12, 12], [13, 14], [16, 17]}",
             prettyPrint(ml.getFromRanges()));
-    assertEquals("{[1, 3], [6, 6]}", prettyPrint(ml.getToRanges()));
+    assertEquals("{[1, 1], [2, 3], [6, 6]}", prettyPrint(ml.getToRanges()));
   }
 
   /**
@@ -544,8 +635,9 @@ public class MapListTest
   @Test(groups = { "Functional" })
   public void testToString()
   {
-    MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 }, new int[] {
-        51, 1 }, 1, 3);
+    MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 },
+            new int[]
+            { 51, 1 }, 1, 3);
     String s = ml.toString();
     assertEquals("[ [1, 5] [10, 15] [25, 20] ] 1:3 to [ [51, 1] ]", s);
   }
@@ -554,14 +646,16 @@ public class MapListTest
   public void testAddMapList()
   {
     MapList ml = new MapList(new int[] { 11, 15, 20, 25, 35, 30 },
-            new int[] { 72, 22 }, 1, 3);
+            new int[]
+            { 72, 22 }, 1, 3);
     assertEquals(11, ml.getFromLowest());
     assertEquals(35, ml.getFromHighest());
     assertEquals(22, ml.getToLowest());
     assertEquals(72, ml.getToHighest());
 
-    MapList ml2 = new MapList(new int[] { 2, 4, 37, 40 }, new int[] { 12,
-        17, 78, 83, 88, 96 }, 1, 3);
+    MapList ml2 = new MapList(new int[] { 2, 4, 37, 40 },
+            new int[]
+            { 12, 17, 78, 83, 88, 96 }, 1, 3);
     ml.addMapList(ml2);
     assertEquals(2, ml.getFromLowest());
     assertEquals(40, ml.getFromHighest());
@@ -581,7 +675,8 @@ public class MapListTest
   public void testAddMapList_sameMap()
   {
     MapList ml = new MapList(new int[] { 11, 15, 20, 25, 35, 30 },
-            new int[] { 72, 22 }, 1, 3);
+            new int[]
+            { 72, 22 }, 1, 3);
     String before = ml.toString();
     ml.addMapList(ml);
     assertEquals(before, ml.toString());
@@ -595,8 +690,8 @@ public class MapListTest
     MapList ml = new MapList(new int[] { 11, 15 }, new int[] { 72, 58 }, 1,
             3);
 
-    MapList ml2 = new MapList(new int[] { 15, 16 }, new int[] { 58, 53 },
-            1, 3);
+    MapList ml2 = new MapList(new int[] { 15, 16 }, new int[] { 58, 53 }, 1,
+            3);
     ml.addMapList(ml2);
     assertEquals("[ [11, 16] ] 1:3 to [ [72, 53] ]", ml.toString());
   }
@@ -682,13 +777,15 @@ public class MapListTest
   public void testIsFromForwardStrand()
   {
     // [3-9] declares forward strand
-    MapList ml = new MapList(new int[] { 2, 2, 3, 9, 12, 11 }, new int[] {
-        20, 11 }, 1, 1);
+    MapList ml = new MapList(new int[] { 2, 2, 3, 9, 12, 11 },
+            new int[]
+            { 20, 11 }, 1, 1);
     assertTrue(ml.isFromForwardStrand());
 
     // [11-5] declares reverse strand ([13-14] is ignored)
     ml = new MapList(new int[] { 2, 2, 11, 5, 13, 14 },
-            new int[] { 20, 11 }, 1, 1);
+            new int[]
+            { 20, 11 }, 1, 1);
     assertFalse(ml.isFromForwardStrand());
 
     // all single position ranges - defaults to forward strand
@@ -698,7 +795,7 @@ public class MapListTest
   }
 
   /**
-   * Test the method that merges a list of ranges where possible
+   * Test the method that merges contiguous ranges
    */
   @Test(groups = { "Functional" })
   public void testCoalesceRanges()
@@ -720,101 +817,57 @@ public class MapListTest
     // merging in forward direction:
     ranges.clear();
     ranges.add(new int[] { 1, 3 });
-    ranges.add(new int[] { 4, 5 });
-    ranges.add(new int[] { 5, 5 });
-    ranges.add(new int[] { 5, 7 });
+    ranges.add(new int[] { 4, 5 }); // contiguous
+    ranges.add(new int[] { 5, 5 }); // overlap!
+    ranges.add(new int[] { 6, 7 }); // contiguous
     List<int[]> merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
-    assertArrayEquals(new int[] { 1, 7 }, merged.get(0));
+    assertEquals(2, merged.size());
+    assertArrayEquals(new int[] { 1, 5 }, merged.get(0));
+    assertArrayEquals(new int[] { 5, 7 }, merged.get(1));
     // verify input list is unchanged
     assertEquals(4, ranges.size());
     assertArrayEquals(new int[] { 1, 3 }, ranges.get(0));
     assertArrayEquals(new int[] { 4, 5 }, ranges.get(1));
     assertArrayEquals(new int[] { 5, 5 }, ranges.get(2));
-    assertArrayEquals(new int[] { 5, 7 }, ranges.get(3));
+    assertArrayEquals(new int[] { 6, 7 }, ranges.get(3));
 
     // merging in reverse direction:
     ranges.clear();
     ranges.add(new int[] { 7, 5 });
-    ranges.add(new int[] { 5, 4 });
-    ranges.add(new int[] { 4, 4 });
-    ranges.add(new int[] { 3, 1 });
+    ranges.add(new int[] { 5, 4 }); // overlap
+    ranges.add(new int[] { 4, 4 }); // overlap
+    ranges.add(new int[] { 3, 1 }); // contiguous
     merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
-    assertArrayEquals(new int[] { 7, 1 }, merged.get(0));
+    assertEquals(3, merged.size());
+    assertArrayEquals(new int[] { 7, 5 }, merged.get(0));
+    assertArrayEquals(new int[] { 5, 4 }, merged.get(1));
+    assertArrayEquals(new int[] { 4, 1 }, merged.get(2));
 
     // merging with switches of direction:
     ranges.clear();
     ranges.add(new int[] { 1, 3 });
-    ranges.add(new int[] { 4, 5 });
-    ranges.add(new int[] { 5, 5 });
-    ranges.add(new int[] { 6, 6 });
+    ranges.add(new int[] { 4, 5 }); // contiguous
+    ranges.add(new int[] { 5, 5 }); // overlap
+    ranges.add(new int[] { 6, 6 }); // contiguous
     ranges.add(new int[] { 12, 10 });
-    ranges.add(new int[] { 9, 8 });
-    ranges.add(new int[] { 8, 8 });
-    ranges.add(new int[] { 7, 7 });
+    ranges.add(new int[] { 9, 8 }); // contiguous
+    ranges.add(new int[] { 8, 8 }); // overlap
+    ranges.add(new int[] { 7, 7 }); // contiguous
     merged = MapList.coalesceRanges(ranges);
-    assertEquals(2, merged.size());
-    assertArrayEquals(new int[] { 1, 6 }, merged.get(0));
-    assertArrayEquals(new int[] { 12, 7 }, merged.get(1));
-  }
-
-  /**
-   * Test the method that merges a list of ranges where possible
-   */
-  @Test(groups = { "Functional" })
-  public void testCoalesceRanges_withOverlap()
-  {
-    List<int[]> ranges = new ArrayList<>();
-    ranges.add(new int[] { 1, 3 });
-    ranges.add(new int[] { 2, 5 });
-
-    /*
-     * [2, 5] should extend [1, 3]
-     */
-    List<int[]> merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
+    assertEquals(4, merged.size());
     assertArrayEquals(new int[] { 1, 5 }, merged.get(0));
-
-    /*
-     * a subsumed interval should be dropped
-     */
-    ranges.clear();
-    ranges.add(new int[] { 1, 6 });
-    ranges.add(new int[] { 2, 4 });
-    merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
-    assertArrayEquals(new int[] { 1, 6 }, merged.get(0));
-
-    ranges.clear();
-    ranges.add(new int[] { 1, 5 });
-    ranges.add(new int[] { 1, 6 });
-    merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
-    assertArrayEquals(new int[] { 1, 6 }, merged.get(0));
-
-    /*
-     * merge duplicate ranges
-     */
+    assertArrayEquals(new int[] { 5, 6 }, merged.get(1));
+    assertArrayEquals(new int[] { 12, 8 }, merged.get(2));
+    assertArrayEquals(new int[] { 8, 7 }, merged.get(3));
+    
+    // 'subsumed' ranges are preserved
     ranges.clear();
-    ranges.add(new int[] { 1, 3 });
-    ranges.add(new int[] { 1, 3 });
+    ranges.add(new int[] { 10, 30 });
+    ranges.add(new int[] { 15, 25 }); 
     merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
-    assertArrayEquals(new int[] { 1, 3 }, merged.get(0));
-
-    /*
-     * reverse direction
-     */
-    ranges.clear();
-    ranges.add(new int[] { 9, 5 });
-    ranges.add(new int[] { 9, 4 });
-    ranges.add(new int[] { 8, 3 });
-    ranges.add(new int[] { 3, 2 });
-    ranges.add(new int[] { 1, 0 });
-    merged = MapList.coalesceRanges(ranges);
-    assertEquals(1, merged.size());
-    assertArrayEquals(new int[] { 9, 0 }, merged.get(0));
+    assertEquals(2, merged.size());
+    assertArrayEquals(new int[] { 10, 30 }, merged.get(0));
+    assertArrayEquals(new int[] { 15, 25 }, merged.get(1));
   }
 
   /**
@@ -826,13 +879,15 @@ public class MapListTest
     /*
      * simple 1:1 plus 1:1 forwards
      */
-    MapList ml1 = new MapList(new int[] { 3, 4, 8, 12 }, new int[] { 5, 8,
-        11, 13 }, 1, 1);
+    MapList ml1 = new MapList(new int[] { 3, 4, 8, 12 },
+            new int[]
+            { 5, 8, 11, 13 }, 1, 1);
     assertEquals("{[3, 4], [8, 12]}", prettyPrint(ml1.getFromRanges()));
     assertEquals("{[5, 8], [11, 13]}", prettyPrint(ml1.getToRanges()));
 
-    MapList ml2 = new MapList(new int[] { 1, 50 }, new int[] { 40, 45, 70,
-        75, 90, 127 }, 1, 1);
+    MapList ml2 = new MapList(new int[] { 1, 50 },
+            new int[]
+            { 40, 45, 70, 75, 90, 127 }, 1, 1);
     assertEquals("{[1, 50]}", prettyPrint(ml2.getFromRanges()));
     assertEquals("{[40, 45], [70, 75], [90, 127]}",
             prettyPrint(ml2.getToRanges()));
@@ -859,7 +914,8 @@ public class MapListTest
      */
     ml1 = new MapList(new int[] { 1, 50 }, new int[] { 70, 119 }, 1, 1);
     ml2 = new MapList(new int[] { 1, 500 },
-            new int[] { 1000, 901, 600, 201 }, 1, 1);
+            new int[]
+            { 1000, 901, 600, 201 }, 1, 1);
     compound = ml1.traverse(ml2);
 
     assertEquals(1, compound.getFromRatio());
@@ -876,8 +932,8 @@ public class MapListTest
      * 1:1 plus 1:3 should result in 1:3
      */
     ml1 = new MapList(new int[] { 1, 30 }, new int[] { 11, 40 }, 1, 1);
-    ml2 = new MapList(new int[] { 1, 100 }, new int[] { 1, 50, 91, 340 },
-            1, 3);
+    ml2 = new MapList(new int[] { 1, 100 }, new int[] { 1, 50, 91, 340 }, 1,
+            3);
     compound = ml1.traverse(ml2);
 
     assertEquals(1, compound.getFromRatio());
@@ -895,8 +951,8 @@ public class MapListTest
      * 3:1 plus 1:1 should result in 3:1
      */
     ml1 = new MapList(new int[] { 1, 30 }, new int[] { 11, 20 }, 3, 1);
-    ml2 = new MapList(new int[] { 1, 100 }, new int[] { 1, 15, 91, 175 },
-            1, 1);
+    ml2 = new MapList(new int[] { 1, 100 }, new int[] { 1, 15, 91, 175 }, 1,
+            1);
     compound = ml1.traverse(ml2);
 
     assertEquals(3, compound.getFromRatio());
@@ -958,8 +1014,8 @@ public class MapListTest
   }
 
   /**
-   * Test that method that inspects for the (first) forward or reverse 'to' range.
-   * Single position ranges are ignored.
+   * Test that method that inspects for the (first) forward or reverse 'to'
+   * range. Single position ranges are ignored.
    */
   @Test(groups = { "Functional" })
   public void testIsToForwardsStrand()
index dd789d6..08673ae 100644 (file)
@@ -22,11 +22,24 @@ package jalview.util;
 
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 import static org.testng.AssertJUnit.fail;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+
+import java.awt.Color;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
 
 import jalview.api.AlignViewportI;
+import jalview.bin.Cache;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
 import jalview.commands.EditCommand.Edit;
@@ -47,19 +60,14 @@ import jalview.io.FileFormat;
 import jalview.io.FileFormatI;
 import jalview.io.FormatAdapter;
 
-import java.awt.Color;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
 public class MappingUtilsTest
 {
-
+  @BeforeClass(alwaysRun = true)
+  public void setUp()
+  {
+    Cache.initLogger();
+  }
+  
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
   {
@@ -90,8 +98,9 @@ public class MappingUtilsTest
     MapList map = new MapList(new int[] { 5, 10 }, new int[] { 12, 13 }, 3,
             1);
     acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
-    List<AlignedCodonFrame> acfList = Arrays.asList(new AlignedCodonFrame[]
-    { acf });
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
 
     /*
      * Check protein residue 12 maps to codon 5-7, 13 to codon 8-10
@@ -140,11 +149,14 @@ public class MappingUtilsTest
      * Map dna bases [6, 8, 9], [11, 13, 115] to protein residues 8 and 9
      */
     AlignedCodonFrame acf = new AlignedCodonFrame();
-    MapList map = new MapList(new int[] { 6, 6, 8, 9, 11, 11, 13, 13, 15,
-        15 }, new int[] { 8, 9 }, 3, 1);
+    MapList map = new MapList(
+            new int[]
+            { 6, 6, 8, 9, 11, 11, 13, 13, 15, 15 }, new int[] { 8, 9 }, 3,
+            1);
     acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
-    List<AlignedCodonFrame> acfList = Arrays.asList(new AlignedCodonFrame[]
-    { acf });
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
 
     /*
      * Check protein residue 8 maps to [6, 8, 9]
@@ -184,8 +196,8 @@ public class MappingUtilsTest
     for (int i = 5; i < 18; i++)
     {
       sr = MappingUtils.buildSearchResults(seq1, i, acfList);
-      int residue = (i == 6 || i == 8 || i == 9) ? 8 : (i == 11 || i == 13
-              || i == 15 ? 9 : 0);
+      int residue = (i == 6 || i == 8 || i == 9) ? 8
+              : (i == 11 || i == 13 || i == 15 ? 9 : 0);
       if (residue == 0)
       {
         assertEquals(0, sr.getResults().size());
@@ -221,18 +233,19 @@ public class MappingUtilsTest
     MapList map = new MapList(new int[] { 1, 3 }, new int[] { 1, 1 }, 3, 1);
     for (int seq = 0; seq < 3; seq++)
     {
-      acf.addMap(cdna.getSequenceAt(seq).getDatasetSequence(), protein
-              .getSequenceAt(seq).getDatasetSequence(), map);
+      acf.addMap(cdna.getSequenceAt(seq).getDatasetSequence(),
+              protein.getSequenceAt(seq).getDatasetSequence(), map);
     }
-    List<AlignedCodonFrame> acfList = Arrays.asList(new AlignedCodonFrame[]
-    { acf });
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
 
-    AlignViewportI dnaView = new AlignViewport(cdna);
-    AlignViewportI proteinView = new AlignViewport(protein);
+    AlignViewportI theDnaView = new AlignViewport(cdna);
+    AlignViewportI theProteinView = new AlignViewport(protein);
     protein.setCodonFrames(acfList);
 
     /*
-     * Select Seq1 and Seq3 in the protein (startRes=endRes=0)
+     * Select Seq1 and Seq3 in the protein
      */
     SequenceGroup sg = new SequenceGroup();
     sg.setColourText(true);
@@ -240,12 +253,13 @@ public class MappingUtilsTest
     sg.setOutlineColour(Color.LIGHT_GRAY);
     sg.addSequence(protein.getSequenceAt(0), false);
     sg.addSequence(protein.getSequenceAt(2), false);
+    sg.setEndRes(protein.getWidth() - 1);
 
     /*
      * Verify the mapped sequence group in dna
      */
     SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg,
-            proteinView, dnaView);
+            theProteinView, theDnaView);
     assertTrue(mappedGroup.getColourText());
     assertSame(sg.getIdColour(), mappedGroup.getIdColour());
     assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
@@ -253,7 +267,7 @@ public class MappingUtilsTest
     assertSame(cdna.getSequenceAt(0), mappedGroup.getSequences().get(0));
     assertSame(cdna.getSequenceAt(2), mappedGroup.getSequences().get(1));
     assertEquals(0, mappedGroup.getStartRes());
-    assertEquals(2, mappedGroup.getEndRes());
+    assertEquals(2, mappedGroup.getEndRes()); // 3 columns (1 codon)
 
     /*
      * Verify mapping sequence group from dna to protein
@@ -263,7 +277,7 @@ public class MappingUtilsTest
     sg.addSequence(cdna.getSequenceAt(0), false);
     sg.setStartRes(0);
     sg.setEndRes(2);
-    mappedGroup = MappingUtils.mapSequenceGroup(sg, dnaView, proteinView);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, theDnaView, theProteinView);
     assertTrue(mappedGroup.getColourText());
     assertSame(sg.getIdColour(), mappedGroup.getIdColour());
     assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
@@ -286,8 +300,8 @@ public class MappingUtilsTest
   protected AlignmentI loadAlignment(final String data, FileFormatI format)
           throws IOException
   {
-    AlignmentI a = new FormatAdapter().readFile(data,
-            DataSourceType.PASTE, format);
+    AlignmentI a = new FormatAdapter().readFile(data, DataSourceType.PASTE,
+            format);
     a.setDataset(null);
     return a;
   }
@@ -332,8 +346,8 @@ public class MappingUtilsTest
     cs.clear();
     colsel.clear();
     colsel.addElement(2);
-    MappingUtils.mapColumnSelection(colsel, hidden, proteinView,
-            dnaView, cs, hs);
+    MappingUtils.mapColumnSelection(colsel, hidden, proteinView, dnaView,
+            cs, hs);
     assertEquals("[]", cs.getSelected().toString());
 
     /*
@@ -343,8 +357,8 @@ public class MappingUtilsTest
     cs.clear();
     colsel.clear();
     colsel.addElement(3);
-    MappingUtils.mapColumnSelection(colsel, hidden, proteinView,
-            dnaView, cs, hs);
+    MappingUtils.mapColumnSelection(colsel, hidden, proteinView, dnaView,
+            cs, hs);
     assertEquals("[5, 6, 7, 8, 9, 10]", cs.getSelected().toString());
 
     /*
@@ -355,10 +369,10 @@ public class MappingUtilsTest
     colsel.clear();
     colsel.addElement(1);
     colsel.addElement(3);
-    MappingUtils.mapColumnSelection(colsel, hidden, proteinView,
-            dnaView, cs, hs);
-    assertEquals("[0, 1, 2, 3, 5, 6, 7, 8, 9, 10]", cs.getSelected()
-            .toString());
+    MappingUtils.mapColumnSelection(colsel, hidden, proteinView, dnaView,
+            cs, hs);
+    assertEquals("[0, 1, 2, 3, 5, 6, 7, 8, 9, 10]",
+            cs.getSelected().toString());
   }
 
   /**
@@ -387,23 +401,27 @@ public class MappingUtilsTest
     // map first dna to first protein seq
     AlignedCodonFrame acf = new AlignedCodonFrame();
     MapList map = new MapList(new int[] { 10, 12, 15, 15, 17, 18 },
-            new int[] { 40, 41 }, 3, 1);
-    acf.addMap(cdna.getSequenceAt(0).getDatasetSequence(), protein
-            .getSequenceAt(0).getDatasetSequence(), map);
+            new int[]
+            { 40, 41 }, 3, 1);
+    acf.addMap(cdna.getSequenceAt(0).getDatasetSequence(),
+            protein.getSequenceAt(0).getDatasetSequence(), map);
 
     // map second dna to second protein seq
-    map = new MapList(new int[] { 20, 20, 22, 23, 24, 26 }, new int[] { 50,
-        51 }, 3, 1);
-    acf.addMap(cdna.getSequenceAt(1).getDatasetSequence(), protein
-            .getSequenceAt(1).getDatasetSequence(), map);
+    map = new MapList(new int[] { 20, 20, 22, 23, 24, 26 },
+            new int[]
+            { 50, 51 }, 3, 1);
+    acf.addMap(cdna.getSequenceAt(1).getDatasetSequence(),
+            protein.getSequenceAt(1).getDatasetSequence(), map);
 
     // map third dna to third protein seq
-    map = new MapList(new int[] { 30, 30, 32, 34, 36, 37 }, new int[] { 60,
-        61 }, 3, 1);
-    acf.addMap(cdna.getSequenceAt(2).getDatasetSequence(), protein
-            .getSequenceAt(2).getDatasetSequence(), map);
-    List<AlignedCodonFrame> acfList = Arrays.asList(new AlignedCodonFrame[]
-    { acf });
+    map = new MapList(new int[] { 30, 30, 32, 34, 36, 37 },
+            new int[]
+            { 60, 61 }, 3, 1);
+    acf.addMap(cdna.getSequenceAt(2).getDatasetSequence(),
+            protein.getSequenceAt(2).getDatasetSequence(), map);
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
 
     dnaView = new AlignViewport(cdna);
     proteinView = new AlignViewport(protein);
@@ -466,24 +484,21 @@ public class MappingUtilsTest
   public void testFlattenRanges()
   {
     assertEquals("[1, 2, 3, 4]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 1, 4 })));
-    assertEquals(
-            "[1, 2, 3, 4]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 1, 2, 3,
-                4 })));
-    assertEquals(
-            "[1, 2, 3, 4]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 1, 1, 2,
-                2, 3, 3, 4, 4 })));
-    assertEquals(
-            "[1, 2, 3, 4, 7, 8, 9, 12]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 1, 4, 7,
-                9, 12, 12 })));
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 1, 4 })));
+    assertEquals("[1, 2, 3, 4]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 1, 2, 3, 4 })));
+    assertEquals("[1, 2, 3, 4]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 1, 1, 2, 2, 3, 3, 4, 4 })));
+    assertEquals("[1, 2, 3, 4, 7, 8, 9, 12]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 1, 4, 7, 9, 12, 12 })));
     // trailing unpaired start position is ignored:
-    assertEquals(
-            "[1, 2, 3, 4, 7, 8, 9, 12]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 1, 4, 7,
-                9, 12, 12, 15 })));
+    assertEquals("[1, 2, 3, 4, 7, 8, 9, 12]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 1, 4, 7, 9, 12, 12, 15 })));
   }
 
   /**
@@ -509,14 +524,15 @@ public class MappingUtilsTest
     MapList map = new MapList(new int[] { 1, 6 }, new int[] { 1, 2 }, 3, 1);
     for (int seq = 0; seq < 3; seq++)
     {
-      acf.addMap(cdna.getSequenceAt(seq).getDatasetSequence(), protein
-              .getSequenceAt(seq).getDatasetSequence(), map);
+      acf.addMap(cdna.getSequenceAt(seq).getDatasetSequence(),
+              protein.getSequenceAt(seq).getDatasetSequence(), map);
     }
-    List<AlignedCodonFrame> acfList = Arrays.asList(new AlignedCodonFrame[]
-    { acf });
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
 
-    AlignViewportI dnaView = new AlignViewport(cdna);
-    AlignViewportI proteinView = new AlignViewport(protein);
+    AlignViewportI theDnaView = new AlignViewport(cdna);
+    AlignViewportI theProteinView = new AlignViewport(protein);
     protein.setCodonFrames(acfList);
 
     /*
@@ -536,7 +552,7 @@ public class MappingUtilsTest
      * Verify the mapped sequence group in dna
      */
     SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg,
-            proteinView, dnaView);
+            theProteinView, theDnaView);
     assertTrue(mappedGroup.getColourText());
     assertSame(sg.getIdColour(), mappedGroup.getIdColour());
     assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
@@ -557,7 +573,7 @@ public class MappingUtilsTest
     // select columns 2 and 3 in DNA which span protein columns 0 and 1
     sg.setStartRes(2);
     sg.setEndRes(3);
-    mappedGroup = MappingUtils.mapSequenceGroup(sg, dnaView, proteinView);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, theDnaView, theProteinView);
     assertTrue(mappedGroup.getColourText());
     assertSame(sg.getIdColour(), mappedGroup.getIdColour());
     assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
@@ -582,31 +598,32 @@ public class MappingUtilsTest
      * viewport).
      */
     AlignmentI cdna = loadAlignment(
-            ">Seq1\nA-CG-GC--AT-CA\n>Seq2\n-TG-AC-AG-T-AT\n>Seq3\n-T--ACG-TAAT-G\n",
+            ">Cds11\nA-CG-GC--AT-CA\n>Cds2\n-TG-AC-AG-T-AT\n>Cds3\n-T--ACG-TAAT-G\n",
             FileFormat.Fasta);
     cdna.setDataset(null);
     AlignmentI protein = loadAlignment(
-            ">Seq1\n-KA-S\n>Seq2\n--L-QY\n>Seq3\nQ-V-M\n", FileFormat.Fasta);
+            ">Pep1\n-KA-S\n>Pep2\n--L-QY\n>Pep3\nQ-V-M\n",
+            FileFormat.Fasta);
     protein.setDataset(null);
     AlignedCodonFrame acf = new AlignedCodonFrame();
     MapList map = new MapList(new int[] { 1, 9 }, new int[] { 1, 3 }, 3, 1);
     for (int seq = 0; seq < 3; seq++)
     {
-      acf.addMap(cdna.getSequenceAt(seq).getDatasetSequence(), protein
-              .getSequenceAt(seq).getDatasetSequence(), map);
+      acf.addMap(cdna.getSequenceAt(seq).getDatasetSequence(),
+              protein.getSequenceAt(seq).getDatasetSequence(), map);
     }
-    List<AlignedCodonFrame> acfList = Arrays.asList(new AlignedCodonFrame[]
-    { acf });
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
 
-    AlignViewportI dnaView = new AlignViewport(cdna);
-    AlignViewportI proteinView = new AlignViewport(protein);
+    AlignViewportI theDnaView = new AlignViewport(cdna);
+    AlignViewportI theProteinView = new AlignViewport(protein);
     protein.setCodonFrames(acfList);
 
     /*
-     * Select Seq1 and Seq2 in the protein, column 1 (K/-). Expect mapped
-     * sequence group to cover Seq1, columns 0-3 (ACG). Because the selection
-     * only includes a gap in Seq2 there is no mappable selection region in the
-     * corresponding DNA.
+     * Select Pep1 and Pep2 in the protein, column 1 (K/-). Expect mapped
+     * sequence group to cover Cds1, columns 0-3 (ACG). Although the selection
+     * only includes a gap in Cds2, mapped Cds2 is included with 'no columns'
      */
     SequenceGroup sg = new SequenceGroup();
     sg.setColourText(true);
@@ -621,14 +638,15 @@ public class MappingUtilsTest
      * Verify the mapped sequence group in dna
      */
     SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg,
-            proteinView, dnaView);
+            theProteinView, theDnaView);
     assertTrue(mappedGroup.getColourText());
     assertSame(sg.getIdColour(), mappedGroup.getIdColour());
     assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
-    assertEquals(1, mappedGroup.getSequences().size());
+    assertEquals(2, mappedGroup.getSequences().size());
     assertSame(cdna.getSequenceAt(0), mappedGroup.getSequences().get(0));
-    // Seq2 in protein has a gap in column 1 - ignored
-    // Seq1 has K which should map to columns 0-3 in Seq1
+    assertSame(cdna.getSequenceAt(1), mappedGroup.getSequences().get(1));
+    // Pep2 in protein has a gap in column 1 - doesn't map to any column
+    // Pep1 has K which should map to columns 0-3 in Cds1
     assertEquals(0, mappedGroup.getStartRes());
     assertEquals(3, mappedGroup.getEndRes());
 
@@ -638,7 +656,7 @@ public class MappingUtilsTest
      */
     sg.setStartRes(2);
     sg.setEndRes(4);
-    mappedGroup = MappingUtils.mapSequenceGroup(sg, proteinView, dnaView);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, theProteinView, theDnaView);
     assertEquals(1, mappedGroup.getStartRes());
     assertEquals(13, mappedGroup.getEndRes());
 
@@ -651,19 +669,19 @@ public class MappingUtilsTest
     // select columns 4,5 - includes Seq1:codon2 (A) only
     sg.setStartRes(4);
     sg.setEndRes(5);
-    mappedGroup = MappingUtils.mapSequenceGroup(sg, dnaView, proteinView);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, theDnaView, theProteinView);
     assertEquals(2, mappedGroup.getStartRes());
     assertEquals(2, mappedGroup.getEndRes());
 
     // add Seq2 to dna selection cols 4-5 include codons 1 and 2 (LQ)
     sg.addSequence(cdna.getSequenceAt(1), false);
-    mappedGroup = MappingUtils.mapSequenceGroup(sg, dnaView, proteinView);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, theDnaView, theProteinView);
     assertEquals(2, mappedGroup.getStartRes());
     assertEquals(4, mappedGroup.getEndRes());
 
     // add Seq3 to dna selection cols 4-5 include codon 1 (Q)
     sg.addSequence(cdna.getSequenceAt(2), false);
-    mappedGroup = MappingUtils.mapSequenceGroup(sg, dnaView, proteinView);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, theDnaView, theProteinView);
     assertEquals(0, mappedGroup.getStartRes());
     assertEquals(4, mappedGroup.getEndRes());
   }
@@ -699,8 +717,8 @@ public class MappingUtilsTest
     /*
      * Seq1 has three mappings
      */
-    List<AlignedCodonFrame> result = MappingUtils.findMappingsForSequence(
-            seq1, mappings);
+    List<AlignedCodonFrame> result = MappingUtils
+            .findMappingsForSequence(seq1, mappings);
     assertEquals(3, result.size());
     assertTrue(result.contains(acf1));
     assertTrue(result.contains(acf2));
@@ -777,22 +795,22 @@ public class MappingUtilsTest
      */
     List<AlignedCodonFrame> result = MappingUtils
             .findMappingsForSequenceAndOthers(null, mappings,
-                    Arrays.asList(new SequenceI[] { seq1, seq2 }));
+                    Arrays.asList(new SequenceI[]
+                    { seq1, seq2 }));
     assertTrue(result.isEmpty());
 
     result = MappingUtils.findMappingsForSequenceAndOthers(seq1, null,
-            Arrays.asList(new SequenceI[] { seq1, seq2 }));
+            Arrays.asList(new SequenceI[]
+            { seq1, seq2 }));
     assertTrue(result.isEmpty());
 
     /*
      * Seq1 has three mappings, but filter argument will only accept
      * those to seq2
      */
-    result = MappingUtils.findMappingsForSequenceAndOthers(
-            seq1,
-            mappings,
-            Arrays.asList(new SequenceI[] { seq1, seq2,
-                seq1.getDatasetSequence() }));
+    result = MappingUtils.findMappingsForSequenceAndOthers(seq1, mappings,
+            Arrays.asList(new SequenceI[]
+            { seq1, seq2, seq1.getDatasetSequence() }));
     assertEquals(2, result.size());
     assertTrue(result.contains(acf1));
     assertTrue(result.contains(acf2));
@@ -821,7 +839,8 @@ public class MappingUtilsTest
     dna.createDatasetSequence();
     protein.createDatasetSequence();
     AlignedCodonFrame acf = new AlignedCodonFrame();
-    MapList map = new MapList(new int[] { 8, 16 }, new int[] { 5, 7 }, 3, 1);
+    MapList map = new MapList(new int[] { 8, 16 }, new int[] { 5, 7 }, 3,
+            1);
     acf.addMap(dna.getDatasetSequence(), protein.getDatasetSequence(), map);
     List<AlignedCodonFrame> mappings = new ArrayList<>();
     mappings.add(acf);
@@ -836,7 +855,8 @@ public class MappingUtilsTest
      */
     EditCommand ec = new EditCommand();
     final Edit edit = ec.new Edit(Action.INSERT_GAP,
-            new SequenceI[] { protein }, 4, 2, '-');
+            new SequenceI[]
+            { protein }, 4, 2, '-');
     ec.appendEdit(edit, prot, true, null);
 
     /*
@@ -862,34 +882,29 @@ public class MappingUtilsTest
   public void testFlattenRanges_reverseStrand()
   {
     assertEquals("[4, 3, 2, 1]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 4, 1 })));
-    assertEquals(
-            "[4, 3, 2, 1]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 4, 3, 2,
-                1 })));
-    assertEquals(
-            "[4, 3, 2, 1]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 4, 4, 3,
-                3, 2, 2, 1, 1 })));
-    assertEquals(
-            "[12, 9, 8, 7, 4, 3, 2, 1]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 12, 12,
-                9, 7, 4, 1 })));
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 4, 1 })));
+    assertEquals("[4, 3, 2, 1]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 4, 3, 2, 1 })));
+    assertEquals("[4, 3, 2, 1]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 4, 4, 3, 3, 2, 2, 1, 1 })));
+    assertEquals("[12, 9, 8, 7, 4, 3, 2, 1]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 12, 12, 9, 7, 4, 1 })));
     // forwards and backwards anyone?
-    assertEquals(
-            "[4, 5, 6, 3, 2, 1]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 4, 6, 3,
-                1 })));
+    assertEquals("[4, 5, 6, 3, 2, 1]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 4, 6, 3, 1 })));
     // backwards and forwards
-    assertEquals(
-            "[3, 2, 1, 4, 5, 6]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 3, 1, 4,
-                6 })));
+    assertEquals("[3, 2, 1, 4, 5, 6]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 3, 1, 4, 6 })));
     // trailing unpaired start position is ignored:
-    assertEquals(
-            "[12, 9, 8, 7, 4, 3, 2]",
-            Arrays.toString(MappingUtils.flattenRanges(new int[] { 12, 12,
-                9, 7, 4, 2, 1 })));
+    assertEquals("[12, 9, 8, 7, 4, 3, 2]",
+            Arrays.toString(MappingUtils.flattenRanges(new int[]
+            { 12, 12, 9, 7, 4, 2, 1 })));
   }
 
   /**
@@ -1157,85 +1172,115 @@ public class MappingUtilsTest
     /*
      * both forward ranges
      */
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        1, 10 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        2, 10 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        1, 9 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        4, 5 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        0, 9 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        -10, -9 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        1, 11 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        11, 12 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 1, 10 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 2, 10 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 1, 9 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 4, 5 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 0, 9 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { -10, -9 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 1, 11 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 11, 12 }));
 
     /*
      * forward range, reverse query
      */
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        10, 1 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        9, 1 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        10, 2 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        5, 5 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        11, 1 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, new int[] {
-        10, 0 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 10, 1 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 9, 1 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 10, 2 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 5, 5 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 11, 1 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 10, 0 }));
 
     /*
      * reverse range, forward query
      */
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        1, 10 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        1, 9 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        2, 10 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        6, 6 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        6, 11 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        11, 20 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        -3, -2 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 1, 10 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 1, 9 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 2, 10 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 6, 6 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 6, 11 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 11, 20 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { -3, -2 }));
 
     /*
      * both reverse
      */
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        10, 1 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        9, 1 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        10, 2 }));
-    assertTrue(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        3, 3 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        11, 1 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        10, 0 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        12, 11 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 10, 1 }, new int[] {
-        -5, -8 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 10, 1 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 9, 1 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 10, 2 }));
+    assertTrue(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 3, 3 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 11, 1 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 10, 0 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { 12, 11 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 10, 1 }, new int[] { -5, -8 }));
 
     /*
      * bad arguments
      */
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10, 12 },
-            new int[] {
-        1, 10 }));
-    assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 },
-            new int[] { 1 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10, 12 }, new int[] { 1, 10 }));
+    assertFalse(
+            MappingUtils.rangeContains(new int[]
+            { 1, 10 }, new int[] { 1 }));
     assertFalse(MappingUtils.rangeContains(new int[] { 1, 10 }, null));
     assertFalse(MappingUtils.rangeContains(null, new int[] { 1, 10 }));
   }
@@ -1314,4 +1359,123 @@ public class MappingUtilsTest
       // expected
     }
   }
+
+  /**
+   * Test mapping a sequence group where sequences in and outside the group
+   * share a dataset sequence (e.g. alternative CDS for the same gene)
+   * <p>
+   * This scenario doesn't arise after JAL-3763 changes, but test left as still valid
+   * @throws IOException
+   */
+  @Test(groups = { "Functional" })
+  public void testMapSequenceGroup_sharedDataset() throws IOException
+  {
+    /*
+     * Set up dna and protein Seq1/2/3 with mappings (held on the protein
+     * viewport). CDS sequences share the same 'gene' dataset sequence.
+     */
+    SequenceI dna = new Sequence("dna", "aaatttgggcccaaatttgggccc");
+    SequenceI cds1 = new Sequence("cds1/1-6", "aaattt");
+    SequenceI cds2 = new Sequence("cds1/4-9", "tttggg");
+    SequenceI cds3 = new Sequence("cds1/19-24", "gggccc");
+
+    cds1.setDatasetSequence(dna);
+    cds2.setDatasetSequence(dna);
+    cds3.setDatasetSequence(dna);
+
+    SequenceI pep1 = new Sequence("pep1", "KF");
+    SequenceI pep2 = new Sequence("pep2", "FG");
+    SequenceI pep3 = new Sequence("pep3", "GP");
+    pep1.createDatasetSequence();
+    pep2.createDatasetSequence();
+    pep3.createDatasetSequence();
+
+    /*
+     * add mappings from coding positions of dna to respective peptides
+     */
+    AlignedCodonFrame acf = new AlignedCodonFrame();
+    acf.addMap(dna, pep1,
+            new MapList(new int[]
+            { 1, 6 }, new int[] { 1, 2 }, 3, 1));
+    acf.addMap(dna, pep2,
+            new MapList(new int[]
+            { 4, 9 }, new int[] { 1, 2 }, 3, 1));
+    acf.addMap(dna, pep3,
+            new MapList(new int[]
+            { 19, 24 }, new int[] { 1, 2 }, 3, 1));
+
+    List<AlignedCodonFrame> acfList = Arrays
+            .asList(new AlignedCodonFrame[]
+            { acf });
+
+    AlignmentI cdna = new Alignment(new SequenceI[] { cds1, cds2, cds3 });
+    AlignmentI protein = new Alignment(
+            new SequenceI[]
+            { pep1, pep2, pep3 });
+    AlignViewportI cdnaView = new AlignViewport(cdna);
+    AlignViewportI peptideView = new AlignViewport(protein);
+    protein.setCodonFrames(acfList);
+
+    /*
+     * Select pep1 and pep3 in the protein alignment
+     */
+    SequenceGroup sg = new SequenceGroup();
+    sg.setColourText(true);
+    sg.setIdColour(Color.GREEN);
+    sg.setOutlineColour(Color.LIGHT_GRAY);
+    sg.addSequence(pep1, false);
+    sg.addSequence(pep3, false);
+    sg.setEndRes(protein.getWidth() - 1);
+
+    /*
+     * Verify the mapped sequence group in dna is cds1 and cds3
+     */
+    SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg,
+            peptideView, cdnaView);
+    assertTrue(mappedGroup.getColourText());
+    assertSame(sg.getIdColour(), mappedGroup.getIdColour());
+    assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
+    assertEquals(2, mappedGroup.getSequences().size());
+    assertSame(cds1, mappedGroup.getSequences().get(0));
+    assertSame(cds3, mappedGroup.getSequences().get(1));
+    // columns 1-6 selected (0-5 base zero)
+    assertEquals(0, mappedGroup.getStartRes());
+    assertEquals(5, mappedGroup.getEndRes());
+
+    /*
+     * Select mapping sequence group from dna to protein
+     */
+    sg.clear();
+    sg.addSequence(cds2, false);
+    sg.addSequence(cds1, false);
+    sg.setStartRes(0);
+    sg.setEndRes(cdna.getWidth() - 1);
+    mappedGroup = MappingUtils.mapSequenceGroup(sg, cdnaView, peptideView);
+    assertTrue(mappedGroup.getColourText());
+    assertSame(sg.getIdColour(), mappedGroup.getIdColour());
+    assertSame(sg.getOutlineColour(), mappedGroup.getOutlineColour());
+    assertEquals(2, mappedGroup.getSequences().size());
+    assertSame(protein.getSequenceAt(1), mappedGroup.getSequences().get(0));
+    assertSame(protein.getSequenceAt(0), mappedGroup.getSequences().get(1));
+    assertEquals(0, mappedGroup.getStartRes());
+    assertEquals(1, mappedGroup.getEndRes()); // two columns
+  }
+
+  @Test(groups = "Functional")
+  public void testFindOverlap()
+  {
+    List<int[]> ranges = new ArrayList<>();
+    ranges.add(new int[] {4, 8});
+    ranges.add(new int[] {10, 12});
+    ranges.add(new int[] {16, 19});
+    
+    int[] overlap = MappingUtils.findOverlap(ranges, 5,  13);
+    assertArrayEquals(overlap, new int[] {5, 12});
+    overlap = MappingUtils.findOverlap(ranges, -100, 100);
+    assertArrayEquals(overlap, new int[] {4, 19});
+    overlap = MappingUtils.findOverlap(ranges, 7, 17);
+    assertArrayEquals(overlap, new int[] {7, 17});
+    overlap = MappingUtils.findOverlap(ranges, 13, 15);
+    assertNull(overlap);
+  }
 }
index 5f288a8..51d50f5 100644 (file)
@@ -26,6 +26,14 @@ import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
@@ -36,14 +44,6 @@ import jalview.xml.binding.embl.EntryType.Feature;
 import jalview.xml.binding.embl.EntryType.Feature.Qualifier;
 import jalview.xml.binding.embl.XrefType;
 
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
 public class EmblXmlSourceTest
 {
 
@@ -352,11 +352,12 @@ public class EmblXmlSourceTest
     // exact length match:
     assertSame(exons, EmblXmlSource.adjustForProteinLength(6, exons));
 
-    // match if we assume exons include stop codon not in protein:
-    assertSame(exons, EmblXmlSource.adjustForProteinLength(5, exons));
+    // truncate last exon by 3bp (e.g. stop codon)
+    int[] truncated = EmblXmlSource.adjustForProteinLength(5, exons);
+    assertEquals("[11, 15, 21, 25, 31, 35]", Arrays.toString(truncated));
 
     // truncate last exon by 6bp
-    int[] truncated = EmblXmlSource.adjustForProteinLength(4, exons);
+    truncated = EmblXmlSource.adjustForProteinLength(4, exons);
     assertEquals("[11, 15, 21, 25, 31, 32]", Arrays.toString(truncated));
 
     // remove last exon and truncate preceding by 1bp
index a02cd6d..d540935 100644 (file)
           <versionLine x="85" y="109" text="version ${compiler:sys.version}" />
         </text>
       </splashScreen>
-      <java mainClass="com.threerings.getdown.launcher.GetdownApp" vmParameters="-Dinstaller_template_version=${compiler:INSTALLER_TEMPLATE_VERSION}" arguments="${launcher:sys.launcherDirectory} jalview">
+      <java mainClass="com.threerings.getdown.launcher.GetdownApp" vmParameters="-Dinstaller_template_version=${compiler:INSTALLER_TEMPLATE_VERSION}" arguments="&quot;${launcher:sys.launcherDirectory}&quot; jalview">
         <classPath>
           <archive location="getdown-launcher.jar" />
           <archive location="${compiler:GETDOWN_INSTALL_DIR}/getdown-launcher.jar" failOnError="false" />