-build
-buildPropertiesFile
-buildTests
-buildextclients
-buildindices
-castorbinding
-clean
-compileApplet
-distclean
help
-init
-linkcheck
-makeApplet
-makedist
-makefulldist
-obfuscate
-packageApplet
-prepare
-prepareTests
-preparejnlp
-prepubapplet_1
-pubapplet
-runenv
-signApplet
-sourcedist
-sourcedoc
-sourcescrub
-testclean
-testng
usage
-writejnlpf
<classpathentry kind="lib" path="lib/jfreesvg-2.1.jar"/>
<classpathentry kind="lib" path="lib/quaqua-filechooser-only-8.0.jar"/>
<classpathentry kind="lib" path="lib/htsjdk-1.133.jar"/>
+ <classpathentry kind="lib" path="lib/VAqua4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Plugin.jar"/>
<classpathentry kind="lib" path="lib/jersey-client-1.19.jar"/>
<classpathentry kind="lib" path="lib/jersey-core-1.19.jar"/>
<classpathentry kind="lib" path="lib/biojava-core-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/biojava-ontology-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/groovy-all-2.4.12-indy.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="classes"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=52
quaqua: v.8.0 (latest stable) by Randel S Hofer. LGPL and BSD Modified license: downloaded from http://www.randelshofer.ch/quaqua/
+vaqua: v4 (latest stable) by Alan Snyder et al. GPLv2 with Classpathe xception, also includes contributions from Quaqua: ownloaded from http://violetlib.org/vaqua/overview.html
+
lib/htsjdk-1.120-SNAPSHOT.jar: (currently not required for 2.10) built from maven master at https://github.com/samtools/htsjdk MIT License to Broad Institute
lib/biojava-core-4.1.0.jar LGPLv2.1 - latest license at https://github.com/biojava/biojava/blob/master/LICENSE
To get JSON output instead use:
java -jar target/benchmarks.jar -rf json
+ To run a specific benchmark file use:
+ java -jar target/benchmarks.jar <Benchmark class name>
+
JSON output can be viewed quickly by drag-dropping on http://jmh.morethan.io/
To get help use the standard -h option:
6. If you make changes to the Jalview code everything will need to be refreshed, by performing steps 3-5 again.
+
--- /dev/null
+/*
+ * 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 org.jalview;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Param;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+
+/*
+ * A class to benchmark hidden columns performance
+ */
+@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
+@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
+@Fork(1)
+public class HiddenColsIteratorsBenchmark {
+ /*
+ * State with multiple hidden columns and a start position set
+ */
+ @State(Scope.Thread)
+ public static class HiddenColsAndStartState
+ {
+ @Param({"300", "10000", "100000"})
+ public int maxcols;
+
+ @Param({"1", "50", "90"})
+ public int startpcnt; // position as percentage of maxcols
+
+ @Param({"1","15","100"})
+ public int hide;
+
+ HiddenColumns h = new HiddenColumns();
+ Random rand = new Random();
+
+ public int hiddenColumn;
+ public int visibleColumn;
+
+ @Setup
+ public void setup()
+ {
+ rand.setSeed(1234);
+ int lastcol = 0;
+ while (lastcol < maxcols)
+ {
+ int count = rand.nextInt(100);
+ lastcol += count;
+ h.hideColumns(lastcol, lastcol+hide);
+ lastcol+=hide;
+ }
+
+ // make sure column at start is hidden
+ hiddenColumn = (int)(maxcols * startpcnt/100.0);
+ h.hideColumns(hiddenColumn, hiddenColumn);
+
+ // and column <hide> after start is visible
+ ColumnSelection sel = new ColumnSelection();
+ h.revealHiddenColumns(hiddenColumn+hide, sel);
+ visibleColumn = hiddenColumn+hide;
+
+ System.out.println("Maxcols: " + maxcols + " HiddenCol: " + hiddenColumn + " Hide: " + hide);
+ System.out.println("Number of hidden columns: " + h.getSize());
+ }
+ }
+
+ /* Convention: functions in alphabetical order */
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public int benchStartIterator(HiddenColsAndStartState tstate)
+ {
+ int res = 0;
+ int startx = tstate.visibleColumn;
+ Iterator<Integer> it = tstate.h.getStartRegionIterator(startx,
+ startx+60);
+ while (it.hasNext())
+ {
+ res = it.next() - startx;
+ Blackhole.consumeCPU(5);
+ }
+ return res;
+ }
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public int benchBoundedIterator(HiddenColsAndStartState tstate)
+ {
+ int startx = tstate.visibleColumn;
+ int blockStart = startx;
+ int blockEnd;
+ int screenY = 0;
+ Iterator<int[]> it = tstate.h.getBoundedIterator(startx,
+ startx+60);
+ while (it.hasNext())
+ {
+ int[] region = it.next();
+
+ blockEnd = Math.min(region[0] - 1, blockStart + 60 - screenY);
+
+ screenY += blockEnd - blockStart + 1;
+ blockStart = region[1] + 1;
+
+ Blackhole.consumeCPU(5);
+ }
+ return blockStart;
+ }
+}
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public class HiddenColumnsBenchmark
-{
- /*
- * State with multiple hidden columns and a start position set
- */
- @State(Scope.Thread)
- public static class HiddenColsAndStartState
- {
- @Param({ "300", "10000", "100000" })
- public int maxcols;
-
- @Param({ "1", "50", "90" })
- public int startpcnt; // position as percentage of maxcols
-
- @Param({ "1", "15", "100" })
- public int hide;
-
- HiddenColumns h = new HiddenColumns();
-
- Random rand = new Random();
-
- public int hiddenColumn;
-
- public int visibleColumn;
-
- @Setup
- public void setup()
+{
+ /*
+ * State with multiple hidden columns and a start position set
+ */
+ @State(Scope.Thread)
+ public static class HiddenColsAndStartState
+ {
+ @Param({"100", "1000", "10000", "100000", "1000000"})
+ public int maxcols;
+
+ @Param({"1", "50", "90"})
+ public int startpcnt; // position as percentage of maxcols
+
+ @Param({"1","15","100"})
+ public int hide;
+
+ HiddenColumns h = new HiddenColumns();
+ Random rand = new Random();
+
+ public int hiddenColumn;
+ public int visibleColumn;
+
+ @Setup
+ public void setup()
+ {
+ rand.setSeed(1234);
+ int lastcol = 0;
+ while (lastcol < maxcols)
+ {
+ int count = rand.nextInt(100);
+ lastcol += count;
+ h.hideColumns(lastcol, lastcol+hide);
+ lastcol+=hide;
+ }
+
+ // make sure column at start is hidden
+ hiddenColumn = (int)(maxcols * startpcnt/100.0);
+ h.hideColumns(hiddenColumn, hiddenColumn);
+
+ // and column <hide> after start is visible
+ ColumnSelection sel = new ColumnSelection();
+ h.revealHiddenColumns(hiddenColumn+hide, sel);
+ visibleColumn = hiddenColumn+hide;
+
+ System.out.println("Maxcols: " + maxcols + " HiddenCol: " + hiddenColumn + " Hide: " + hide);
+ System.out.println("Number of hidden columns: " + h.getSize());
+ }
+ }
+
+ /* Convention: functions in alphabetical order */
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public int benchAdjustForHiddenColumns(HiddenColsAndStartState tstate)
+ {
+ return tstate.h.visibleToAbsoluteColumn(tstate.visibleColumn);
+ }
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public int benchFindColumnPosition(HiddenColsAndStartState tstate)
+ {
+ return tstate.h.absoluteToVisibleColumn(tstate.visibleColumn);
+ }
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public int benchGetSize(HiddenColsAndStartState tstate)
{
- rand.setSeed(1234);
- int lastcol = 0;
- while (lastcol < maxcols)
- {
- int count = rand.nextInt(100);
- lastcol += count;
- h.hideColumns(lastcol, lastcol + hide);
- lastcol += hide;
- }
-
- // make sure column at start is hidden
- hiddenColumn = (int) (maxcols * startpcnt / 100.0);
- h.hideColumns(hiddenColumn, hiddenColumn);
-
- // and column <hide> after start is visible
- ColumnSelection sel = new ColumnSelection();
- h.revealHiddenColumns(hiddenColumn + hide, sel);
- visibleColumn = hiddenColumn + hide;
-
- System.out.println("Maxcols: " + maxcols + " HiddenCol: "
- + hiddenColumn + " Hide: " + hide);
- System.out.println("Number of hidden columns: " + h.getSize());
+ return tstate.h.getSize();
}
- }
-
- /* Convention: functions in alphabetical order */
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public int benchAdjustForHiddenColumns(HiddenColsAndStartState tstate)
- {
- return tstate.h.adjustForHiddenColumns(tstate.visibleColumn);
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public int benchFindColumnPosition(HiddenColsAndStartState tstate)
- {
- return tstate.h.findColumnPosition(tstate.visibleColumn);
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public List<Integer> benchFindHiddenRegionPositions(
- HiddenColsAndStartState tstate)
- {
- return tstate.h.findHiddenRegionPositions();
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public ArrayList<int[]> benchGetHiddenColumnsCopy(
- HiddenColsAndStartState tstate)
- {
- return tstate.h.getHiddenColumnsCopy();
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public int benchGetSize(HiddenColsAndStartState tstate)
- {
- return tstate.h.getSize();
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public HiddenColumns benchHideCols(HiddenColsAndStartState tstate)
- {
- tstate.h.hideColumns(tstate.visibleColumn, tstate.visibleColumn + 2000);
- return tstate.h;
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public boolean benchIsVisible(HiddenColsAndStartState tstate)
- {
- return tstate.h.isVisible(tstate.hiddenColumn);
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public HiddenColumns benchReveal(HiddenColsAndStartState tstate)
- {
- ColumnSelection sel = new ColumnSelection();
- tstate.h.revealHiddenColumns(tstate.hiddenColumn, sel);
- return tstate.h;
- }
-
- @Benchmark
- @BenchmarkMode({ Mode.Throughput })
- public HiddenColumns benchRevealAll(HiddenColsAndStartState tstate)
- {
- ColumnSelection sel = new ColumnSelection();
- tstate.h.revealAllHiddenColumns(sel);
- return tstate.h;
- }
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public HiddenColumns benchHideCols(HiddenColsAndStartState tstate)
+ {
+ tstate.h.hideColumns(tstate.visibleColumn,
+ tstate.visibleColumn+2000);
+ return tstate.h;
+ }
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public boolean benchIsVisible(HiddenColsAndStartState tstate)
+ {
+ return tstate.h.isVisible(tstate.hiddenColumn);
+ }
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public HiddenColumns benchReveal(HiddenColsAndStartState tstate)
+ {
+ ColumnSelection sel = new ColumnSelection();
+ tstate.h.revealHiddenColumns(tstate.hiddenColumn, sel);
+ return tstate.h;
+ }
+
+ @Benchmark
+ @BenchmarkMode({Mode.Throughput})
+ public HiddenColumns benchRevealAll(HiddenColsAndStartState tstate)
+ {
+ ColumnSelection sel = new ColumnSelection();
+ tstate.h.revealAllHiddenColumns(sel);
+ return tstate.h;
+ }
+
+
}
\ No newline at end of file
<echo message="testng - run jalview's tests via testNG. Default group is '${testng-groups}'" />
<echo message=" you can specify particular test groups as a list via -Dtestng-groups=" />
<echo message="See docs/building.html and the comments in build file for other targets." />
- <echo message="note: compile and makeApplet require the property java118.home to be set to point to a java 1.1.8 jdk." />
+ <echo message="note: compile and makeApplet optionally compile/obfuscate applet against a different Java version by specifying -Djava118.home=PathtoJDK/lib which is the lib directory in the JDK install that contains rt.jar " />
<echo message="Useful -D flags: -Ddonotobfuscate will prevent applet obfuscation" />
</target>
<!-- Anne's version needs 1.7 - should rebuild VARNA to java 1.6 for release -->
<property name="j2sev" value="1.7+" />
<!-- Java Compilation settings - source and target javac version -->
- <property name="javac.source" value="1.7" />
- <property name="javac.target" value="1.7" />
+ <property name="javac.source" value="1.8" />
+ <property name="javac.target" value="1.8" />
<!-- Permissions for running Java applets and applications. -->
<!-- Defaults are those suitable for deploying jalview webstart www.jalview.org -->
</path>
<property name="source.dist.name" value="${basedir}/jalview-src.tar.gz" />
<!-- The Location of the java 1.1.8 jdk -->
- <!--<property name="java118.home" value="C:\Sun\jdk1.1.8" /> -->
<property name="java118.home" value="${java.home}" />
- <!-- <property name="applet.jre.tools" value="${java118.home}/lib/classes.zip" />
- -->
<!-- jre for 1.4 version -->
- <property name="applet.jre.tools" value="${java.home}/lib/rt.jar" />
+ <property name="applet.jre.tools" value="${java118.home}/lib/rt.jar" />
<!-- the classpath for building the 1.1 applet -->
<path id="jalviewlite.deps">
<fileset dir="${java118.home}">
- <include name="lib/classes.zip" />
+ <include name="lib/rt.jar" />
</fileset>
<fileset dir="${java.home}/lib">
<include name="plugin.jar" />
<offline_allowed />
</information>
<resources>
- <j2se version="1.7+" />
+ <j2se version="1.8+" />
<jar main="true" href="jalview.jar"/>
<fileset dir="${packageDir}">
<exclude name="jalview.jar" />
<jnlpf toFile="${jnlpFile}" />
<!-- add the add-modules j2se attribute for java 9 -->
- <replace file="${jnlpFile}" value="j2se version="1.7+" initial-heap-size="${inih}" max-heap-size="${maxh}" java-vm-args="--add-modules=java.se.ee --illegal-access=warn"">
- <replacetoken>j2se version="1.7+"</replacetoken>
+ <replace file="${jnlpFile}" value="j2se version="1.8+" initial-heap-size="${inih}" max-heap-size="${maxh}" java-vm-args="--add-modules=java.se.ee --illegal-access=warn"">
+ <replacetoken>j2se version="1.8+"</replacetoken>
</replace>
</target>
<include name="plugin.jar" />
</fileset>
</path>
- <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
+ <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard_5.3.3.jar" />
<proguard verbose="true" >
<injar file="in.jar" />
<mapID target="pdbmcviewer" url="html/features/pdbviewer.html"/>
<mapID target="pdbjmol" url="html/features/jmol.html"/>
<mapID target="chimera" url="html/features/chimera.html"/>
+ <mapID target="chimera.annotxfer" url="html/features/chimera.html#annotxfer"/>
<mapID target="varna" url="html/features/varna.html"/>
<mapID target="xsspannotation" url="html/features/xsspannotation.html"/>
<mapID target="preferences" url="html/features/preferences.html"/>
<tocitem text="Jalview Documentation" target="home" expand="true">
<tocitem text="What's new" target="new" expand="true">
<tocitem text="Latest Release Notes" target="release"/>
+ <tocitem text="Structure Chooser" target="pdbchooser"/>
+ <tocitem text="Chimera Annotation Exchange" target="chimera.annotxfer"/>
</tocitem>
<tocitem text="Editing Alignments" target="edit" />
structure in the alignment. The regions used to calculate
the superposition will be highlighted using the 'Cartoon'
rendering style, and the remaining data shown as a chain
- trace.<br/><br/>
+ trace.<br />
+ <br />
</em></li>
- <li><strong><a name="experimental">EXPERIMENTAL FEATURES</a></strong><br/>
- <em>
- These are only available if the <strong>Tools→Enable
- Experimental Features</strong> option is enabled. (Since Jalview 2.10.2)</em>
- <ul>
- <li><strong>Write Jalview features</strong><br /> <em>Selecting
- this option will create new residue attributes for any
- features currently visible in the associated alignment
- views, allowing those positions to be selected and
- analysed with via Chimera's 'Render by Attribute' tool
- (found in the Tools submenu called Structure Analysis).<br />
- <br />If you use this option, please remember to select
- the <em>Refresh Menus</em> option in Chimera's Render by
- Attribute dialog box in order to see the attributes
- derived from Jalview sequence features.
- </em><br />
- <a href="https://issues.jalview.org/browse/JAL-2295">View
- this function's issue in Jalview's bug tracker</a></li>
- <li><strong>Fetch Chimera Attributes</strong><br /> <em>This
- submenu lists available Chimera residue attributes that
- can be imported as Jalview features on associated
- sequences.<br />This is particularly useful for
- transferring quantitative positional annotation. For
- example, structure similarity for an alignment can be
- visualised by transferring the local RMSD attributes
- generated by Chimera's Match->Align tool onto aligned
- sequences and displayed with a <a
- href="featureschemes.html">Graduated feature colour
- scheme</a>.
- </em><a href="https://issues.jalview.org/browse/JAL-2296">View
- this function's issue in Jalview's bug tracker</a></li>
- </ul></li>
- <li><strong>Help<br>
+ <li><a name="annotxfer"><strong>Write Jalview
+ features</strong></a><br /> <em>Selecting this option will create
+ new residue attributes for any features currently visible in
+ the associated alignment views, allowing those positions to
+ be selected and analysed with via Chimera's 'Render by
+ Attribute' tool (found in the Tools submenu called Structure
+ Analysis).<br /> <br />If you use this option, please
+ remember to select the <em>Refresh Menus</em> option in
+ Chimera's Render by Attribute dialog box in order to see the
+ attributes derived from Jalview sequence features.
+ </em></li>
+ <li><strong>Fetch Chimera Attributes</strong><br /> <em>This
+ submenu lists available Chimera residue attributes that can
+ be imported as Jalview features on associated sequences.<br />This
+ is particularly useful for transferring quantitative
+ positional annotation. For example, structure similarity for
+ an alignment can be visualised by transferring the local
+ RMSD attributes generated by Chimera's Match->Align tool
+ onto aligned sequences and displayed with a <a
+ href="featureschemes.html">Graduated feature colour
+ scheme</a>. </li>
+ </ul></li>
+ <li><strong>Help<br>
</strong>
<ul>
<li><strong>Chimera Help<br>
</p> -->
<p>
<a name="align"><strong>Superposing structures based on
- their aligned sequences</strong></a><br> If several structures are
- available on the alignment, you may add additional structures to an
- existing Jmol view by selecting their entry in the appropriate
- pop-up menu. Jalview will ask you if you wish to add the structure
- to the existing alignment, and if you do, it will import and
- superimpose the new PDB file using the corresponding positions from
- the alignment. If the alignment is subsequently edited, you can use
- the <a href="#sAlign"><em>Jmol→Align</em></a> menu option from
- the menu bar of the structure view window to superpose the
- structures using the updated alignment.<br> <em>Sequence
+ their aligned sequences</strong></a><br> If several structures are shown
+ in a view, you can superimpose them using the corresponding
+ positions from the alignment via the <a href="#sAlign"><em>Jmol→Align</em></a>
+ menu option from the menu bar of the structure view window. <br> <em>Sequence
based structure superposition was added in Jalview 2.6</em>
</p>
<p>
and PDB file association (if available). The Jalview id/start-end
option is ignored if Modeller output is selected.
<p>
- <a name="editing"><strong>e"Editinge" Preferences tab</strong></a>
+ <a name="editing"><strong>"Editing" Preferences tab</strong></a>
</p>
<p>There are currently three options available which can be
selected / deselected.</p>
<body>
<p>
- <strong>Structure Chooser</strong>
+ <strong>Structure Chooser Dialog Box</strong>
</p>
<p>
- The Structure Chooser interface allows you to interactively select
- which PDB structures to view for the currently selected set of
+ The Structure Chooser allows you to select
+ 3D structures to view for the currently selected set of
sequences. It is opened by selecting the <strong>"3D
- Structure Data.."</strong> option from the Sequence ID panel's <a
+ Structure Data..."</strong> option from the Sequence ID panel's <a
href="../menus/popupMenu.html">pop-up menu</a>. The dialog
provides:
</p>
<p>
<strong>Selecting and Viewing Structures</strong>
</p>
+ <p>The drop-down menu offers different options for structure
+ discovery; the 'Cached' view is shown automatically if existing
+ structure data has been imported for the selected sequences, and if
+ none is available, the import PDB/mmCIF file options are shown.</p>
<p>
Once one or more structures have been selected, pressing the <strong>View</strong>
- button will import them into <a
+ or <strong>Add</strong> button will import them <a
href="viewingpdbs.html#afterviewbutton">a new or existing
- structure view</a>.
+ structure view</a>. When multiple views are available, use the
+ drop-down menu to pick the target viewer for the structures.
</p>
<p>
<strong>Automated discovery of structure data</strong>
criteria (e.g. worst quality rather than best).</p>
<p>
- <img src="schooser_main.png" style="width: 464px; height: 369px;">
+ <img src="schooser_main.png" style="width: 499px; height: 437px;">
<!-- <p><img src="schooser_config.png" style="width: 463px; height: 369px; ">
<p><img src="schooser_drop-down.png" style="width: 464px; height: 368px; ">
<p><img src="schooser_enter-id.png" style="width: 467px; height: 373px; ">
<p><img src="schooser_from-file.png" style="width: 468px; height: 370px; ">
<p><img src="schooser_cached.png"> -->
- <br>The screenshot above shows the Structure Chooser interface
- along with the meta-data of auto-discovered structures for the
- sample alignment. If no structures were
- auto-discovered, options for manually associating PDB records will be shown (see below).
- <p>
+ <br>The screenshot above shows the Structure Chooser displayed after
+ selecting all the sequences in the Jalview example project. If no
+ structures were auto-discovered, options for manually associating
+ PDB records will be shown (see below).<p>
<strong>Exploration of meta-data for available structures</strong>
</p>
<p>Information on each structure available is displayed in columns
Columns' tab and tick the columns which you want to see.</p>
<p>
<img src="schooser_enter-id.png"
- style="width: 464px; height: 369px;">
+ style="width: 464px; height: 173px;">
<br/>
<strong>Manual selection/association of PDB files with
Sequences</strong>
provided it is installed and can be launched by Jalview. The default
viewer can be configured in the <a href="preferences.html#structure">Structure
tab</a> in the <strong>Tools→Preferences</strong> dialog box.
+
<p>
Structure data imported into Jalview can also be processed to
display secondary structure and temperature factor annotation. See
for more information.
</p>
<p>
- <strong><a name="afterviewbutton">After pressing the
- 'View' button in the Structure Chooser</a></strong><br /> The behaviour of
- the 'View' button depends on the number of structures selected, and
- whether structure views already exist for the selected structures or
- aligned sequences.
+ <img src="schooser_viewbutton.png"
+ style="width: 465px; height: 81px" /><br/> <strong><a
+ name="afterviewbutton">Controlling where the new structures
+ will be shown</a></strong>
+ <br />The Structure Chooser offers several options
+ for viewing a structure. <br/><strong>New View</strong> will open a new
+ structure viewer for the selected structures, but if there are views
+ already open, you can select which one to use, and press the <strong>Add</strong>
+ button. Jalview can automatically superimpose new structures based
+ on the linked alignments - but if this is not desirable, simple
+ un-tick the <strong>Superpose Structures</strong> checkbox.
+
</p>
- <p>If multiple structures are selected, then Jalview will always
- create a new structure view. The selected structures will be
- imported into this view, and superposed with the matched positions
- from the aligned sequences. A message in the structure viewer's
- status bar will be shown if not enough aligned columns were
- available to perform a superposition.</p>
<p>
- If a <strong>single</strong> PDB structure is selected, one of the
- following will happen:
+ <em>Superposing structures</em><br/>Jalview superposes structures using
+ the visible portions of any associated sequence alignments. A
+ message in the structure viewer's status bar will be shown if not
+ enough aligned columns were available to perform a superposition.
</p>
-
- <ul>
- <li>If no structures are open, then an interactive display of
- the structure will be opened in a new window.</li>
-
- <li>If another structure is already shown for the current
- alignment, then you will be asked if you want to add and <a
- href="jmol.html#align"></a> to the structure in the existing view.
- (<em>new feature in Jalview 2.6</em>).
- </li>
-
- <li>If the structure is already shown, then you will be
- prompted to associate the sequence with an existing view of the
- selected structure. This is useful when working with multi-domain
- or multi-chain PDB files.</li>
-
- <li style="list-style: none">See the <a href="jmol.html">Jmol
- </a> and <a href="chimera.html">Chimera</a> PDB viewer help pages for
- more information about the display.
- </li>
- </ul>
-
+ <p>
+ See the <a href="jmol.html">Jmol
+ </a> and <a href="chimera.html">Chimera</a> help pages for
+ more information about their capabilities.</p>
+
<p>
<strong>Retrieving sequences from the PDB</strong><br>You can
the <a href="../features/groovy.html">Groovy Console</a> for
interactive scripting.
</em><strong><br></strong></li>
- <li><strong>Enable Experimental Features</strong> <em>Enable or disable <a href="../whatsNew.html#experimental">features still under development</a> in Jalview's user interface. This setting is remembered in your preferences.</em>
+ <!-- <li><strong>Enable Experimental Features</strong> <em>Enable or disable <a href="../whatsNew.html#experimental">features still under development</a> in Jalview's user interface. This setting is remembered in your preferences.</em> -->
</ul></li>
<li><strong>Vamsas</strong> <em>For more details, read the
<tr>
<td width="60" nowrap>
<div align="center">
- <strong><a name="Jalview.2.10.4">2.10.4</a><br /> <em>27/02/2018</em></strong>
+ <strong><a name="Jalview.2.10.4">2.10.4</a><br /> <em>10/05/2018</em></strong>
</div>
</td>
<td><div align="left">
<em></em>
<ul>
<li>
- <!-- JAL-984 -->Mouse cursor changes to indicate Sequence ID and annotation area margins can be click-dragged to adjust them.</li>
+ <!-- JAL-1847 JAL-2944 -->New Structure Chooser control
+ for disabling automatic superposition of multiple
+ structures and open structures in existing views
+ </li>
+ <li>
+ <!-- JAL-984 -->Mouse cursor changes to indicate Sequence
+ ID and annotation area margins can be click-dragged to
+ adjust them.
+ </li>
+ <li>
+ <!-- JAL-2885 -->Jalview uses HTTPS for Uniprot, Xfam and
+ Ensembl services
+ </li>
+ <li>
+ <!-- JAL-2759 -->Improved performance for large alignments
+ and lots of hidden columns
+ </li>
<li>
- <!-- JAL-2885 -->Jalview uses HTTPS for Uniprot, Xfam and Ensembl services
+ <!-- JAL-2593 -->Improved performance when rendering lots
+ of features (particularly when transparency is disabled)
</li>
</ul>
</div>
<td><div align="left">
<ul>
<li>
- <!-- JAL-2778 -->Slow redraw when Overview panel shown overlapping alignment panel
+ <!-- JAL-2899 -->Structure and Overview aren't updated
+ when Colour By Annotation threshold slider is adjusted
+ </li>
+ <li>
+ <!-- JAL-2778 -->Slow redraw when Overview panel shown
+ overlapping alignment panel
+ </li>
+ <li>
+ <!-- JAL-2929 -->Overview doesn't show end of unpadded
+ sequence as gaps
+ </li>
+ <li>
+ <!-- JAL-2789, JAL-2893 -->Cross-reference handling
+ improved: CDS not handled correctly if transcript has no
+ UTR
+ </li>
+ <li>
+ <!-- JAL-2321 -->Secondary structure and temperature
+ factor annotation not added to sequence when local PDB
+ file associated with it by drag'n'drop or structure
+ chooser
+ </li>
+ <li>
+ <!-- JAL-2984 -->Answering 'No' to PDB Autoassociate
+ dialog doesn't import PDB files dropped on an alignment
+ </li>
+ <li>
+ <!-- JAL-2666 -->Linked scrolling via protein horizontal
+ scroll bar doesn't work for some CDS/Protein views
+ </li>
+ <li>
+ <!-- JAL-2930 -->Trackpad scrolling is broken on OSX on
+ Java 1.8u153 onwards and Java 1.9u4+.
+ </li>
+ <li>
+ <!-- JAL-2924 -->Tooltip shouldn't be displayed for empty
+ columns in annotation row
+ </li>
+ <li>
+ <!-- JAL-2913 -->Preferences panel's ID Width control is not
+ honored in batch mode
+ </li>
+ <li>
+ <!-- JAL-2945 -->Linked sequence highlighting doesn't work
+ for structures added to existing Jmol view
+ </li>
+ <li>
+ <!-- JAL-2223 -->'View Mappings' includes duplicate
+ entries after importing project with multiple views
+ </li>
+ <li>
+ <!-- JAL-2781 JAL-2780 -->Viewing or annotating Uniprot
+ protein sequences via SIFTS from associated PDB entries
+ with negative residue numbers or missing residues fails
</li>
<li>
- <!-- JAL-2666 -->Linked scrolling via protein horizontal scroll bar doesn't work for some CDS/Protein views
+ <!-- JAL-2952 -->Exception when shading sequence with negative
+ Temperature Factor values from annotated PDB files (e.g.
+ as generated by CONSURF)
+ </li>
+ <li>
+ <!-- JAL-2922 -->Invert displayed features very slow when
+ structure and/or overview windows are also shown
+ </li>
+ <li>
+ <!-- JAL-2954 -->Selecting columns from highlighted regions
+ very slow for alignments with large numbers of sequences
+ </li>
+ <li>
+ <!-- JAL-2925 -->Copy Consensus fails for group consensus
+ with 'StringIndexOutOfBounds'
+ </li>
+ <li>
+ <!-- JAL-2976 -->VAqua(4) provided as fallback Look and Feel for OSX
+ platforms running Java 10
+ </li>
+ <li>
+ <!-- JAL-2960 -->Adding a structure to existing structure
+ view appears to do nothing because the view is hidden behind the alignment view
</li>
</ul>
- </div>
- </td>
+ <em>Applet</em>
+ <ul>
+ <li>
+ <!-- JAL-2926 -->Copy consensus sequence option in applet
+ should copy the group consensus when popup is opened on it
+ </li>
+ </ul>
+ <em>Batch Mode</em>
+ <ul>
+ <li>
+ <!-- JAL-2913 -->Fixed ID width preference is not respected
+ </li>
+ </ul>
+ <em>New Known Defects</em>
+ <ul>
+ <li>
+ <!-- JAL-2973 --> Exceptions occasionally raised when
+ editing a large alignment and overview is displayed
+ </li>
+ <li>
+ <!-- JAL-2974 -->'Overview updating' progress bar is shown
+ repeatedly after a series of edits even when the overview
+ is no longer reflecting updates
+ </li>
+ <li>
+ <!-- JAL-2946 -->'SIFTS Mapping Error' when viewing
+ structures for protein subsequence (if 'Trim Retrieved
+ Sequences' enabled) or Ensembl isoforms (Workaround in
+ 2.10.4 is to fail back to N&W mapping)
+ </li>
+ </ul>
+ </div>
+ </td>
</tr>
<tr>
<td width="60" nowrap>
<strong>What's new in Jalview 2.10.4 ?</strong>
</p>
<p>
- This is the February 2018 release of Jalview, with several minor bug fixes and enhanvements.
- The full list bugs fixed in this release can be found in the <a href="releases.html#Jalview.2.10.4">2.10.4
- Release Notes</a>. In addition, Jalview 2.10.4 provides:
+ This is the May 2018 release of Jalview, and the last in the 2.10.x series. Jalview 2.10.4 includes:
</p>
<ul>
- <li></li>
+ <li>Numerous efficiency improvements in the renderer and overview when working with large alignments with lots of hidden columns</li>
+ <li>Use of HTTPS when connecting to Uniprot, Ensembl and other EBI web services</li>
+ <li>Critical patches for running Jalview on OSX with Java 10</li>
+ <li>Easier adjustment of the Alignment ID panel and Annotation panel</li>
+ <li>Improved support for mapping between 3D Structures and Uniprot Protein Sequences</li>
+ <li>Improved support for discovering CDS and transcripts for Proteins and Ensembl gene IDs</li>
+ <li>New buttons on the Structure Chooser for adding structures
+ to an existing view, and disabling automatic superposition
+ according to linked alignments</li>
+ <li>Annotation transfer between Chimera and Jalview <em>(formerly only
+ available in 'Experimental' mode)</em></li>
</ul>
<p>
- <strong><a name="experimental">Experimental Features</a></strong>
+ The full list of bugs fixed in this release can be found in the <a href="releases.html#Jalview.2.10.4">2.10.4
+ Release Notes</a>.
</p>
- <p>
- Remember, please enable the <em>Experimental Features</em> option in
- the Jalview Desktop's <em>Tools</em> menu, and then restart Jalview
- if you want to try out features below:
- </p>
- <ul>
- <li><em>Annotation transfer between Chimera and Jalview</em><br />Two
- <a href="features/chimera.html#experimental">new entries in
- the Chimera viewer's Chimera menu</a> allow positional annotation to
- be exchanged between Chimera and Jalview.</li>
- </ul>
-
</body>
</html>
label.enter_view_name = Enter View Name
label.enter_label = Enter label
label.enter_label_for_the_structure = Enter a label for the structure
-label.pdb_entry_is_already_displayed = {0} is already displayed.\nDo you want to re-use this viewer ?
-label.map_sequences_to_visible_window = Map Sequences to Visible Window: {0}
-label.add_pdbentry_to_view = Do you want to add {0} to the view called\n{1}\n
-label.align_to_existing_structure_view = Align to existing structure view
label.pdb_entries_couldnt_be_retrieved = The following pdb entries could not be retrieved from the PDB\:\n{0}\nPlease retry, or try downloading them manually.
label.couldnt_load_file = Couldn't load file
label.couldnt_find_pdb_id_in_file = Couldn't find a PDB id in the file supplied. Please enter an Id to identify this structure.
label.result = result
label.results = results
label.structure_chooser = Structure Chooser
-label.select = Select :
label.invert = Invert
label.select_pdb_file = Select PDB File
info.select_filter_option = Select Filter Option/Manual Entry
label.enter_view_name = Introduzca un nombre para la vista
label.enter_label = Introducir etiqueta
label.enter_label_for_the_structure = Introducir una etiqueta para la estructura
-label.pdb_entry_is_already_displayed = {0} Ya est\u00E1 mostrado.\nQuieres volver a usar este visor?
-label.map_sequences_to_visible_window = Mapa de secuencias en ventana visible: {0}
-label.add_pdbentry_to_view = Quieres a\u00F1adir {0} a la vista llamada\n{1}\n
-label.align_to_existing_structure_view = Alinear a una estructura ya existente
label.pdb_entries_couldnt_be_retrieved = Las siguientes entradas pdb no pueden ser extra\u00EDdas del PDB\:\n{0}\nPor favor, prueba descarg\u00E1ndolas manualmente.
label.couldnt_load_file = No se pudo cargar el fichero
label.couldnt_find_pdb_id_in_file = No se pudo encontrar un Id PDB en el fichero suministrado. Por favor, introduzca un Id para identificar esta estructura.
label.scale_protein_to_cdna=Adaptar proteÃna a cDNA
label.scale_protein_to_cdna_tip=Hacer a los residuos de proteÃnas de la misma anchura que los codones en ventanas divididas
status.loading_cached_pdb_entries=Cargando Entradas PDB en Caché
-label.select=Seleccionar :
label.select_by_annotation=Seleccionar/Ocultar Columnas por Anotación
action.select_by_annotation=Seleccionar/Ocultar Columnas por Anotación...
action.export_features=Exportar CaracterÃsticas
public String id;
- public Vector<Bond> bonds = new Vector<Bond>();
+ public Vector<Bond> bonds = new Vector<>();
- public Vector<Atom> atoms = new Vector<Atom>();
+ public Vector<Atom> atoms = new Vector<>();
- public Vector<Residue> residues = new Vector<Residue>();
+ public Vector<Residue> residues = new Vector<>();
public int offset;
boolean deoxyn = false;
boolean nucleotide = false;
StringBuilder seq = new StringBuilder(256);
- Vector<SequenceFeature> resFeatures = new Vector<SequenceFeature>();
- Vector<Annotation> resAnnotation = new Vector<Annotation>();
- int i, iSize = atoms.size() - 1;
+ Vector<SequenceFeature> resFeatures = new Vector<>();
+ Vector<Annotation> resAnnotation = new Vector<>();
+ int iSize = atoms.size() - 1;
int resNumber = -1;
char insCode = ' ';
- for (i = 0; i <= iSize; i++)
+
+ for (int i = 0; i <= iSize; i++)
{
Atom tmp = atoms.elementAt(i);
resNumber = tmp.resNumber;
offset = resNumber;
}
- Vector<Atom> resAtoms = new Vector<Atom>();
+ Vector<Atom> resAtoms = new Vector<>();
// Add atoms to a vector while the residue number
// remains the same as the first atom's resNumber (res)
while ((resNumber == res) && (ins == insCode) && (i < atoms.size()))
if (StructureImportSettings.isShowSeqFeatures())
{
- for (i = 0, iSize = resFeatures.size(); i < iSize; i++)
+ iSize = resFeatures.size();
+ for (int i = 0; i < iSize; i++)
{
sequence.addSequenceFeature(resFeatures.elementAt(i));
resFeatures.setElementAt(null, i);
if (visibleChainAnnotation)
{
Annotation[] annots = new Annotation[resAnnotation.size()];
- float max = 0;
- for (i = 0, iSize = annots.length; i < iSize; i++)
+ float max = 0f;
+ float min = 0f;
+ iSize = annots.length;
+ for (int i = 0; i < iSize; i++)
{
annots[i] = resAnnotation.elementAt(i);
- if (annots[i].value > max)
- {
- max = annots[i].value;
- }
+ max = Math.max(max, annots[i].value);
+ min = Math.min(min, annots[i].value);
resAnnotation.setElementAt(null, i);
}
AlignmentAnnotation tfactorann = new AlignmentAnnotation(
"Temperature Factor", "Temperature Factor for " + pdbid + id,
- annots, 0, max, AlignmentAnnotation.LINE_GRAPH);
+ annots, min, max, AlignmentAnnotation.LINE_GRAPH);
tfactorann.setSequenceRef(sequence);
sequence.addAlignmentAnnotation(tfactorann);
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
public class Dna
* 'final' variables describe the inputs to the translation, which should not
* be modified.
*/
- final private List<SequenceI> selection;
+ private final List<SequenceI> selection;
- final private String[] seqstring;
+ private final String[] seqstring;
- final private int[] contigs;
+ private final Iterator<int[]> contigs;
- final private char gapChar;
+ private final char gapChar;
- final private AlignmentAnnotation[] annotations;
+ private final AlignmentAnnotation[] annotations;
- final private int dnaWidth;
+ private final int dnaWidth;
- final private AlignmentI dataset;
+ private final AlignmentI dataset;
+
+ private ShiftList vismapping;
+
+ private int[] startcontigs;
/*
* Working variables for the translation.
* @param viewport
* @param visibleContigs
*/
- public Dna(AlignViewportI viewport, int[] visibleContigs)
+ public Dna(AlignViewportI viewport, Iterator<int[]> visibleContigs)
{
this.selection = Arrays.asList(viewport.getSequenceSelection());
this.seqstring = viewport.getViewAsString(true);
this.annotations = viewport.getAlignment().getAlignmentAnnotation();
this.dnaWidth = viewport.getAlignment().getWidth();
this.dataset = viewport.getAlignment().getDataset();
+ initContigs();
+ }
+
+ /**
+ * Initialise contigs used as starting point for translateCodingRegion
+ */
+ private void initContigs()
+ {
+ vismapping = new ShiftList(); // map from viscontigs to seqstring
+ // intervals
+
+ int npos = 0;
+ int[] lastregion = null;
+ ArrayList<Integer> tempcontigs = new ArrayList<>();
+ while (contigs.hasNext())
+ {
+ int[] region = contigs.next();
+ if (lastregion == null)
+ {
+ vismapping.addShift(npos, region[0]);
+ }
+ else
+ {
+ // hidden region
+ vismapping.addShift(npos, region[0] - lastregion[1] + 1);
+ }
+ lastregion = region;
+ tempcontigs.add(region[0]);
+ tempcontigs.add(region[1]);
+ }
+
+ startcontigs = new int[tempcontigs.size()];
+ int i = 0;
+ for (Integer val : tempcontigs)
+ {
+ startcontigs[i] = val;
+ i++;
+ }
+ tempcontigs = null;
}
/**
int s;
int sSize = selection.size();
- List<SequenceI> pepseqs = new ArrayList<SequenceI>();
+ List<SequenceI> pepseqs = new ArrayList<>();
for (s = 0; s < sSize; s++)
{
SequenceI newseq = translateCodingRegion(selection.get(s),
if (dnarefs != null)
{
// intersect with pep
- List<DBRefEntry> mappedrefs = new ArrayList<DBRefEntry>();
+ List<DBRefEntry> mappedrefs = new ArrayList<>();
DBRefEntry[] refs = dna.getDBRefs();
for (int d = 0; d < refs.length; d++)
{
String seqstring, AlignedCodonFrame acf,
List<SequenceI> proteinSeqs)
{
- List<int[]> skip = new ArrayList<int[]>();
- int skipint[] = null;
- ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring
- // intervals
- int vc;
- int[] scontigs = new int[contigs.length];
+ List<int[]> skip = new ArrayList<>();
+ int[] skipint = null;
int npos = 0;
- for (vc = 0; vc < contigs.length; vc += 2)
- {
- if (vc == 0)
- {
- vismapping.addShift(npos, contigs[vc]);
- }
- else
- {
- // hidden region
- vismapping.addShift(npos, contigs[vc] - contigs[vc - 1] + 1);
- }
- scontigs[vc] = contigs[vc];
- scontigs[vc + 1] = contigs[vc + 1];
- }
+ int vc = 0;
+
+ int[] scontigs = new int[startcontigs.length];
+ System.arraycopy(startcontigs, 0, scontigs, 0, startcontigs.length);
// allocate a roughly sized buffer for the protein sequence
StringBuilder protein = new StringBuilder(seqstring.length() / 2);
public AlignmentI reverseCdna(boolean complement)
{
int sSize = selection.size();
- List<SequenceI> reversed = new ArrayList<SequenceI>();
+ List<SequenceI> reversed = new ArrayList<>();
for (int s = 0; s < sSize; s++)
{
SequenceI newseq = reverseSequence(selection.get(s).getName(),
*/
package jalview.api.structures;
+import jalview.api.AlignmentViewPanel;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
import jalview.schemes.ColourSchemeI;
import jalview.structures.models.AAStructureBindingModel;
*/
boolean hasMapping();
+ /**
+ * Checks if the PDB file is already loaded in this viewer, if so just adds
+ * mappings as necessary and answers true, else answers false. This supports
+ * the use case of adding additional chains of the same structure to a viewer.
+ *
+ * @param seq
+ * @param chains
+ * @param apanel
+ * @param pdbId
+ * @return
+ */
+ boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains,
+ AlignmentViewPanel apanel, String pdbId);
+
+ /**
+ * Adds one or more chains (sequences) of a PDB structure to this structure
+ * viewer
+ *
+ * @param pdbentry
+ * @param seq
+ * @param chains
+ * @param apanel
+ * @param pdbId
+ * @return
+ */
+ void addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq,
+ String[] chains, AlignmentViewPanel apanel, String pdbId);
+
+ /**
+ * refresh GUI after reconfiguring structure(s) and alignment panels
+ */
+ void updateTitleAndMenus();
+
+ /**
+ * Answers true if the viewer should attempt to align any added structures,
+ * else false
+ *
+ * @return
+ */
+ boolean isAlignAddedStructures();
+
+ /**
+ * Sets the flag for whether added structures should be aligned
+ *
+ * @param alignAdded
+ */
+ void setAlignAddedStructures(boolean alignAdded);
+
+ /**
+ * Raise the panel to the top of the stack...
+ */
+ void raiseViewer();
+
}
static StringBuffer copiedSequences;
- static Vector<int[]> copiedHiddenColumns;
+ static HiddenColumns copiedHiddenColumns;
protected void copy_actionPerformed()
{
if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null)
{
- copiedHiddenColumns = new Vector<>(viewport.getAlignment()
- .getHiddenColumns().getHiddenColumnsCopy());
int hiddenOffset = viewport.getSelectionGroup().getStartRes();
- for (int[] region : copiedHiddenColumns)
- {
- region[0] = region[0] - hiddenOffset;
- region[1] = region[1] - hiddenOffset;
- }
+ int hiddenCutoff = viewport.getSelectionGroup().getEndRes();
+
+ // create new HiddenColumns object with copy of hidden regions
+ // between startRes and endRes, offset by startRes
+ copiedHiddenColumns = new HiddenColumns(
+ viewport.getAlignment().getHiddenColumns(), hiddenOffset,
+ hiddenCutoff, hiddenOffset);
}
else
{
{
try
{
-
if (copiedSequences == null)
{
return;
}
- StringTokenizer st = new StringTokenizer(copiedSequences.toString());
+ StringTokenizer st = new StringTokenizer(copiedSequences.toString(),
+ "\t");
Vector seqs = new Vector();
while (st.hasMoreElements())
{
}
AlignFrame af = new AlignFrame(new Alignment(newSeqs),
viewport.applet, newtitle, false);
- if (copiedHiddenColumns != null)
- {
- for (int i = 0; i < copiedHiddenColumns.size(); i++)
- {
- int[] region = copiedHiddenColumns.elementAt(i);
- af.viewport.hideColumns(region[0], region[1]);
- }
- }
+ af.viewport.setHiddenColumns(copiedHiddenColumns);
jalview.bin.JalviewLite.addFrame(af, newtitle, frameWidth,
frameHeight);
if (av.hasHiddenColumns())
{
AlignmentI al = av.getAlignment();
- start = al.getHiddenColumns().findColumnPosition(ostart);
- end = al.getHiddenColumns().findColumnPosition(end);
+ start = al.getHiddenColumns().absoluteToVisibleColumn(ostart);
+ end = al.getHiddenColumns().absoluteToVisibleColumn(end);
if (start == end)
{
if (!scrollToNearest && !al.getHiddenColumns().isVisible(ostart))
if (av.hasHiddenColumns())
{
width = av.getAlignment().getHiddenColumns()
- .findColumnPosition(width);
+ .absoluteToVisibleColumn(width);
}
if (x < 0)
{
import jalview.analysis.AlignmentUtils;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
import java.awt.event.MouseMotionListener;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Vector;
public class AnnotationLabels extends Panel
implements ActionListener, MouseListener, MouseMotionListener
}
else if (evt.getActionCommand().equals(COPYCONS_SEQ))
{
- SequenceI cons = av.getConsensusSeq();
+ SequenceGroup group = aa[selectedRow].groupRef;
+ SequenceI cons = group == null ? av.getConsensusSeq()
+ : group.getConsensusSeq();
if (cons != null)
{
copy_annotseqtoclipboard(cons);
+ "\t" + sq.getSequenceAsString() + "\n");
if (av.hasHiddenColumns())
{
- jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector<>(
- av.getAlignment().getHiddenColumns().getHiddenColumnsCopy());
+ jalview.appletgui.AlignFrame.copiedHiddenColumns = new HiddenColumns(
+ av.getAlignment().getHiddenColumns());
}
}
if (av.hasHiddenColumns())
{
column = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(column);
+ .visibleToAbsoluteColumn(column);
}
if (row > -1 && column < aa[row].annotations.length
public class FeatureSettings extends Panel
implements ItemListener, MouseListener, MouseMotionListener,
- ActionListener, AdjustmentListener, FeatureSettingsControllerI
+ AdjustmentListener, FeatureSettingsControllerI
{
FeatureRenderer fr;
add(scrollPane, BorderLayout.CENTER);
}
- Button invert = new Button("Invert Selection");
- invert.addActionListener(this);
+ Button invert = new Button(
+ MessageManager.getString("label.invert_selection"));
+ invert.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ invertSelection();
+ }
+ });
Panel lowerPanel = new Panel(new GridLayout(2, 1, 5, 10));
lowerPanel.add(invert);
}
}
- @Override
- public void actionPerformed(ActionEvent evt)
+ protected void invertSelection()
{
for (int i = 0; i < featurePanel.getComponentCount(); i++)
{
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int annotationHeight = 0;
{
mg.translate(0, od.getSequencesHeight());
or.drawGraph(mg, av.getAlignmentConservationAnnotation(),
- av.getCharWidth(), od.getGraphHeight(),
- od.getColumns(av.getAlignment()));
+ od.getGraphHeight(), od.getColumns(av.getAlignment()));
mg.translate(0, -od.getSequencesHeight());
}
System.gc();
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
+import java.util.Iterator;
import java.util.List;
public class ScalePanel extends Panel
if (av.hasHiddenColumns())
{
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x);
+ res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
}
else
{
});
pop.add(item);
- if (av.getAlignment().getHiddenColumns().hasManyHiddenColumns())
+ if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions())
{
item = new MenuItem(MessageManager.getString("action.reveal_all"));
item.addActionListener(new ActionListener()
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
if (!stretchingGroup)
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
res = Math.max(0, res);
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
{
if (hidden.isVisible(sel))
{
- sel = hidden.findColumnPosition(sel);
+ sel = hidden.absoluteToVisibleColumn(sel);
}
else
{
if (av.getShowHiddenMarkers())
{
int widthx = 1 + endx - startx;
- List<Integer> positions = hidden.findHiddenRegionPositions();
- for (int pos : positions)
+ Iterator<Integer> it = hidden.getStartRegionIterator(startx,
+ startx + widthx + 1);
+ while (it.hasNext())
{
-
- res = pos - startx;
-
- if (res < 0 || res > widthx)
- {
- continue;
- }
+ res = it.next() - startx;
gg.fillPolygon(
new int[]
- { -1 + res * avCharWidth - avcharHeight / 4,
- -1 + res * avCharWidth + avcharHeight / 4,
- -1 + res * avCharWidth },
- new int[]
- { y, y, y + 2 * yOf }, 3);
+ { -1 + res * avCharWidth - avcharHeight / 4, -1 + res * avCharWidth + avcharHeight / 4,
+ -1 + res * avCharWidth }, new int[]
+ { y, y, y + 2 * yOf }, 3);
}
}
}
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.VisibleContigsIterator;
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.viewmodel.AlignmentViewport;
import java.awt.Image;
import java.awt.Panel;
import java.beans.PropertyChangeEvent;
-import java.util.List;
+import java.util.Iterator;
public class SeqCanvas extends Panel implements ViewportListenerI
{
if (av.hasHiddenColumns())
{
startx = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(startx);
+ .visibleToAbsoluteColumn(startx);
endx = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(endx);
+ .visibleToAbsoluteColumn(endx);
}
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
// WEST SCALE
if (av.hasHiddenColumns())
{
endx = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(endx);
+ .visibleToAbsoluteColumn(endx);
}
SequenceI seq;
int canvasHeight, int startRes)
{
AlignmentI al = av.getAlignment();
-
+
FontMetrics fm = getFontMetrics(av.getFont());
-
+
LABEL_EAST = 0;
LABEL_WEST = 0;
-
+
if (av.getScaleRightWrapped())
{
LABEL_EAST = fm.stringWidth(getMask());
}
-
+
if (av.getScaleLeftWrapped())
{
LABEL_WEST = fm.stringWidth(getMask());
}
-
+
int hgap = avcharHeight;
if (av.getScaleAboveWrapped())
{
hgap += avcharHeight;
}
-
+
int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / avcharWidth;
int cHeight = av.getAlignment().getHeight() * avcharHeight;
-
+
av.setWrappedWidth(cWidth);
-
+
av.getRanges().setViewportStartAndWidth(startRes, cWidth);
-
+
int endx;
int ypos = hgap;
-
+
int maxwidth = av.getAlignment().getWidth();
-
+
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth);
+ .absoluteToVisibleColumn(maxwidth);
}
-
+
while ((ypos <= canvasHeight) && (startRes < maxwidth))
{
endx = startRes + cWidth - 1;
-
+
if (endx > maxwidth)
{
endx = maxwidth;
}
-
+
g.setColor(Color.black);
-
+
if (av.getScaleLeftWrapped())
{
drawWestScale(g, startRes, endx, ypos);
}
-
+
if (av.getScaleRightWrapped())
{
g.translate(canvasWidth - LABEL_EAST, 0);
drawEastScale(g, startRes, endx, ypos);
g.translate(-(canvasWidth - LABEL_EAST), 0);
}
-
+
g.translate(LABEL_WEST, 0);
-
+
if (av.getScaleAboveWrapped())
{
drawNorthScale(g, startRes, endx, ypos);
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
g.setColor(Color.blue);
int res;
- List<Integer> positions = hidden.findHiddenRegionPositions();
- for (int pos : positions)
+ Iterator<Integer> it = hidden.getStartRegionIterator(startRes,
+ endx + 1);
+ while (it.hasNext())
{
- res = pos - startRes;
-
- if (res < 0 || res > endx - startRes)
- {
- continue;
- }
-
+ res = it.next() - startRes;
gg.fillPolygon(
new int[]
- { res * avcharWidth - avcharHeight / 4,
- res * avcharWidth + avcharHeight / 4,
- res * avcharWidth },
+ { res * avcharWidth - avcharHeight / 4, res * avcharWidth + avcharHeight / 4, res * avcharWidth },
new int[]
- { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2),
- ypos - (avcharHeight / 2) + 8 },
- 3);
-
+ { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), ypos - (avcharHeight / 2) + 8 }, 3);
}
}
-
+
if (g.getClip() == null)
{
g.setClip(0, 0, cWidth * avcharWidth, canvasHeight);
}
-
+
drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos);
g.setClip(null);
-
+
if (av.isShowAnnotation())
{
g.translate(0, cHeight + ypos + 4);
{
annotations = new AnnotationPanel(av);
}
-
+
annotations.drawComponent(g, startRes, endx + 1);
g.translate(0, -cHeight - ypos - 4);
}
g.translate(-LABEL_WEST, 0);
-
+
ypos += cHeight + getAnnotationHeight() + hgap;
-
+
startRes += cWidth;
}
-
+
}
AnnotationPanel annotations;
else
{
int screenY = 0;
- final int screenYMax = endRes - startRes;
- int blockStart = startRes;
- int blockEnd = endRes;
-
- if (av.hasHiddenColumns())
- {
- HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- for (int[] region : hidden.getHiddenColumnsCopy())
- {
- int hideStart = region[0];
- int hideEnd = region[1];
-
- if (hideStart <= blockStart)
- {
- blockStart += (hideEnd - hideStart) + 1;
- continue;
- }
-
- /*
- * draw up to just before the next hidden region, or the end of
- * the visible region, whichever comes first
- */
- blockEnd = Math.min(hideStart - 1, blockStart + screenYMax
- - screenY);
-
- g1.translate(screenY * avcharWidth, 0);
+ int blockStart;
+ int blockEnd;
- draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ VisibleContigsIterator regions = (VisibleContigsIterator) hidden
+ .getVisContigsIterator(startRes, endRes + 1, true);
- /*
- * draw the downline of the hidden column marker (ScalePanel draws the
- * triangle on top) if we reached it
- */
- if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1)
- {
- g1.setColor(Color.blue);
- g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1,
- 0 + offset,
- (blockEnd - blockStart + 1) * avcharWidth - 1,
- (endSeq - startSeq + 1) * avcharHeight + offset);
- }
-
- g1.translate(-screenY * avcharWidth, 0);
- screenY += blockEnd - blockStart + 1;
- blockStart = hideEnd + 1;
-
- if (screenY > screenYMax)
- {
- // already rendered last block
- return;
- }
- }
- }
- if (screenY <= screenYMax)
+ while (regions.hasNext())
{
- // remaining visible region to render
- blockEnd = blockStart + (endRes - startRes) - screenY;
+ int[] region = regions.next();
+ blockEnd = region[1];
+ blockStart = region[0];
+
+ /*
+ * draw up to just before the next hidden region, or the end of
+ * the visible region, whichever comes first
+ */
g1.translate(screenY * avcharWidth, 0);
+
draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
+ /*
+ * draw the downline of the hidden column marker (ScalePanel draws the
+ * triangle on top) if we reached it
+ */
+ if (av.getShowHiddenMarkers()
+ && (regions.hasNext() || regions.endsAtHidden()))
+ {
+ g1.setColor(Color.blue);
+ g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1,
+ 0 + offset, (blockEnd - blockStart + 1) * avcharWidth - 1,
+ (endSeq - startSeq + 1) * avcharHeight + offset);
+ }
+
g1.translate(-screenY * avcharWidth, 0);
+ screenY += blockEnd - blockStart + 1;
}
}
-
}
// int startRes, int endRes, int startSeq, int endSeq, int x, int y,
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
return res;
{
fixedColumns = true;
int y1 = av.getAlignment().getHiddenColumns()
- .getHiddenBoundaryLeft(startres);
+ .getNextHiddenBoundary(true, startres);
int y2 = av.getAlignment().getHiddenColumns()
- .getHiddenBoundaryRight(startres);
+ .getNextHiddenBoundary(false, startres);
if ((insertGap && startres > y1 && lastres < y1)
|| (!insertGap && startres < y2 && lastres > y2))
if (sg.getSize() == av.getAlignment().getHeight())
{
if ((av.hasHiddenColumns() && startres < av.getAlignment()
- .getHiddenColumns().getHiddenBoundaryRight(startres)))
+ .getHiddenColumns()
+ .getNextHiddenBoundary(false, startres)))
{
endEditing();
return;
*/
package jalview.bin;
-import groovy.lang.Binding;
-import groovy.util.GroovyScriptEngine;
-
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
import java.util.Map;
import java.util.Vector;
+import javax.swing.LookAndFeel;
import javax.swing.UIManager;
+import groovy.lang.Binding;
+import groovy.util.GroovyScriptEngine;
+
/**
* Main class for Jalview Application <br>
* <br>
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex)
{
+ System.err.println("Unexpected Look and Feel Exception");
+ ex.printStackTrace();
}
if (Platform.isAMac())
{
+
+ LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
+ .getLookAndFeel();
System.setProperty("com.apple.mrj.application.apple.menu.about.name",
"Jalview");
System.setProperty("apple.laf.useScreenMenuBar", "true");
- try
+ if (lookAndFeel != null)
{
- UIManager.setLookAndFeel(
- ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel());
- } catch (Throwable e)
+ try
+ {
+ UIManager.setLookAndFeel(lookAndFeel);
+ } catch (Throwable e)
+ {
+ System.err.println(
+ "Failed to set QuaQua look and feel: " + e.toString());
+ }
+ }
+ if (lookAndFeel == null || !(lookAndFeel.getClass()
+ .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
+ || !UIManager.getLookAndFeel().getClass().toString()
+ .toLowerCase().contains("quaqua"))
{
- System.err.println(
- "Failed to set QuaQua look and feel: " + e.toString());
+ try
+ {
+ System.err.println(
+ "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
+ UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
+ } catch (Throwable e)
+ {
+ System.err.println(
+ "Failed to reset look and feel: " + e.toString());
+ }
}
}
}
try
{
- Map<String, Object> vbinding = new HashMap<String, Object>();
+ Map<String, Object> vbinding = new HashMap<>();
vbinding.put("Jalview", this);
if (af != null)
{
+ nickname + "|" + url);
if (source == null)
{
- source = new Vector<String>();
+ source = new Vector<>();
}
source.addElement(nickname);
}
System.out.println("adding source '" + data + "'");
if (source == null)
{
- source = new Vector<String>();
+ source = new Vector<>();
}
source.addElement(data);
}
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
SequenceI rs = sel.getSequenceAt(0);
start = rs.findIndex(start);
end = rs.findIndex(end);
- List<Integer> cs = new ArrayList<Integer>(csel.getSelected());
+ List<Integer> cs = new ArrayList<>(csel.getSelected());
csel.clear();
for (Integer selectedCol : cs)
{
setMouseoverListener(currentAlignFrame, listener);
}
- private Vector<jalview.javascript.JSFunctionExec> javascriptListeners = new Vector<jalview.javascript.JSFunctionExec>();
+ private Vector<jalview.javascript.JSFunctionExec> javascriptListeners = new Vector<>();
/*
* (non-Javadoc)
else
{
param = st.nextToken();
- List<SequenceI> tmp = new ArrayList<SequenceI>();
- List<String> tmp2 = new ArrayList<String>();
+ List<SequenceI> tmp = new ArrayList<>();
+ List<String> tmp2 = new ArrayList<>();
while (st.hasMoreTokens())
{
JnetAnnotationMaker.add_annotation(predictions,
alignFrame.viewport.getAlignment(), 0, false);
// false == do not add sequence profile from concise output
- SequenceI repseq = alignFrame.viewport.getAlignment()
- .getSequenceAt(0);
- alignFrame.viewport.getAlignment().setSeqrep(repseq);
- HiddenColumns cs = new HiddenColumns();
- cs.hideInsertionsFor(repseq);
- alignFrame.viewport.getAlignment().setHiddenColumns(cs);
+
+ alignFrame.viewport.getAlignment().setupJPredAlignment();
+
alignFrame.alignPanel.fontChanged();
alignFrame.alignPanel.setScrollValues(0, 0);
result = true;
// callInitCallback();
}
- private Hashtable<String, long[]> jshashes = new Hashtable<String, long[]>();
+ private Hashtable<String, long[]> jshashes = new Hashtable<>();
- private Hashtable<String, Hashtable<String, String[]>> jsmessages = new Hashtable<String, Hashtable<String, String[]>>();
+ private Hashtable<String, Hashtable<String, String[]>> jsmessages = new Hashtable<>();
public void setJsMessageSet(String messageclass, String viewId,
String[] colcommands)
Hashtable<String, String[]> msgset = jsmessages.get(messageclass);
if (msgset == null)
{
- msgset = new Hashtable<String, String[]>();
+ msgset = new Hashtable<>();
jsmessages.put(messageclass, msgset);
}
msgset.put(viewId, colcommands);
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
{
hiddenCols = cols;
}
+
+ @Override
+ public void setupJPredAlignment()
+ {
+ SequenceI repseq = getSequenceAt(0);
+ setSeqrep(repseq);
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideList(repseq.getInsertions());
+ setHiddenColumns(cs);
+ }
+
+ @Override
+ public HiddenColumns propagateInsertions(SequenceI profileseq,
+ AlignmentView input)
+ {
+ int profsqpos = 0;
+
+ char gc = getGapCharacter();
+ Object[] alandhidden = input.getAlignmentAndHiddenColumns(gc);
+ HiddenColumns nview = (HiddenColumns) alandhidden[1];
+ SequenceI origseq = ((SequenceI[]) alandhidden[0])[profsqpos];
+ return propagateInsertions(profileseq, origseq, nview);
+ }
+
+ /**
+ *
+ * @param profileseq
+ * sequence in al which corresponds to origseq
+ * @param al
+ * alignment which is to have gaps inserted into it
+ * @param origseq
+ * sequence corresponding to profileseq which defines gap map for
+ * modifying al
+ */
+ private HiddenColumns propagateInsertions(SequenceI profileseq,
+ SequenceI origseq, HiddenColumns hc)
+ {
+ // take the set of hidden columns, and the set of gaps in origseq,
+ // and remove all the hidden gaps from hiddenColumns
+
+ // first get the gaps as a Bitset
+ // then calculate hidden ^ not(gap)
+ BitSet gaps = origseq.gapBitset();
+ hc.andNot(gaps);
+
+ // for each sequence in the alignment, except the profile sequence,
+ // insert gaps corresponding to each hidden region but where each hidden
+ // column region is shifted backwards by the number of preceding visible
+ // gaps update hidden columns at the same time
+ HiddenColumns newhidden = new HiddenColumns();
+
+ int numGapsBefore = 0;
+ int gapPosition = 0;
+ Iterator<int[]> it = hc.iterator();
+ while (it.hasNext())
+ {
+ int[] region = it.next();
+
+ // get region coordinates accounting for gaps
+ // we can rely on gaps not being *in* hidden regions because we already
+ // removed those
+ while (gapPosition < region[0])
+ {
+ gapPosition++;
+ if (gaps.get(gapPosition))
+ {
+ numGapsBefore++;
+ }
+ }
+
+ int left = region[0] - numGapsBefore;
+ int right = region[1] - numGapsBefore;
+
+ newhidden.hideColumns(left, right);
+ padGaps(left, right, profileseq);
+ }
+ return newhidden;
+ }
+
+ /**
+ * Pad gaps in all sequences in alignment except profileseq
+ *
+ * @param left
+ * position of first gap to insert
+ * @param right
+ * position of last gap to insert
+ * @param profileseq
+ * sequence not to pad
+ */
+ private void padGaps(int left, int right, SequenceI profileseq)
+ {
+ char gc = getGapCharacter();
+
+ // make a string with number of gaps = length of hidden region
+ StringBuilder sb = new StringBuilder();
+ for (int g = 0; g < right - left + 1; g++)
+ {
+ sb.append(gc);
+ }
+
+ // loop over the sequences and pad with gaps where required
+ for (int s = 0, ns = getHeight(); s < ns; s++)
+ {
+ SequenceI sqobj = getSequenceAt(s);
+ if ((sqobj != profileseq) && (sqobj.getLength() >= left))
+ {
+ String sq = sqobj.getSequenceAsString();
+ sqobj.setSequence(
+ sq.substring(0, left) + sb.toString() + sq.substring(left));
+ }
+ }
+ }
+
}
this.calcId = annotation.calcId;
if (annotation.properties != null)
{
- properties = new HashMap<String, String>();
+ properties = new HashMap<>();
for (Map.Entry<String, String> val : annotation.properties.entrySet())
{
properties.put(val.getKey(), val.getValue());
if (annotation.sequenceMapping != null)
{
Integer p = null;
- sequenceMapping = new HashMap<Integer, Annotation>();
+ sequenceMapping = new HashMap<>();
Iterator<Integer> pos = annotation.sequenceMapping.keySet()
.iterator();
while (pos.hasNext())
int epos = sequenceRef.findPosition(endRes);
if (sequenceMapping != null)
{
- Map<Integer, Annotation> newmapping = new HashMap<Integer, Annotation>();
+ Map<Integer, Annotation> newmapping = new HashMap<>();
Iterator<Integer> e = sequenceMapping.keySet().iterator();
while (e.hasNext())
{
{
return;
}
- sequenceMapping = new HashMap<Integer, Annotation>();
+ sequenceMapping = new HashMap<>();
int seqPos;
{
return;
}
- hidden.makeVisibleAnnotation(this);
+ makeVisibleAnnotation(hidden);
}
public void setPadGaps(boolean padgaps, char gapchar)
/**
* properties associated with the calcId
*/
- protected Map<String, String> properties = new HashMap<String, String>();
+ protected Map<String, String> properties = new HashMap<>();
/**
* base colour for line graphs. If null, will be set automatically by
: false;
// TODO build a better annotation element map and get rid of annotations[]
- Map<Integer, Annotation> mapForsq = new HashMap<Integer, Annotation>();
+ Map<Integer, Annotation> mapForsq = new HashMap<>();
if (sequenceMapping != null)
{
if (sp2sq != null)
if (mapping != null)
{
Map<Integer, Annotation> old = sequenceMapping;
- Map<Integer, Annotation> remap = new HashMap<Integer, Annotation>();
+ Map<Integer, Annotation> remap = new HashMap<>();
int index = -1;
for (int mp[] : mapping.values())
{
{
if (properties == null)
{
- properties = new HashMap<String, String>();
+ properties = new HashMap<>();
}
properties.put(property, value);
}
return graphMin < graphMax;
}
+ /**
+ * delete any columns in alignmentAnnotation that are hidden (including
+ * sequence associated annotation).
+ *
+ * @param hiddenColumns
+ * the set of hidden columns
+ */
+ public void makeVisibleAnnotation(HiddenColumns hiddenColumns)
+ {
+ if (annotations != null)
+ {
+ makeVisibleAnnotation(0, annotations.length, hiddenColumns);
+ }
+ }
+
+ /**
+ * delete any columns in alignmentAnnotation that are hidden (including
+ * sequence associated annotation).
+ *
+ * @param start
+ * remove any annotation to the right of this column
+ * @param end
+ * remove any annotation to the left of this column
+ * @param hiddenColumns
+ * the set of hidden columns
+ */
+ public void makeVisibleAnnotation(int start, int end,
+ HiddenColumns hiddenColumns)
+ {
+ if (annotations != null)
+ {
+ if (hiddenColumns.hasHiddenColumns())
+ {
+ removeHiddenAnnotation(start, end, hiddenColumns);
+ }
+ else
+ {
+ restrict(start, end);
+ }
+ }
+ }
+
+ /**
+ * The actual implementation of deleting hidden annotation columns
+ *
+ * @param start
+ * remove any annotation to the right of this column
+ * @param end
+ * remove any annotation to the left of this column
+ * @param hiddenColumns
+ * the set of hidden columns
+ */
+ private void removeHiddenAnnotation(int start, int end,
+ HiddenColumns hiddenColumns)
+ {
+ // mangle the alignmentAnnotation annotation array
+ ArrayList<Annotation[]> annels = new ArrayList<>();
+ Annotation[] els = null;
+
+ int w = 0;
+
+ Iterator<int[]> blocks = hiddenColumns.getVisContigsIterator(start,
+ end + 1, false);
+
+ int copylength;
+ int annotationLength;
+ while (blocks.hasNext())
+ {
+ int[] block = blocks.next();
+ annotationLength = block[1] - block[0] + 1;
+
+ if (blocks.hasNext())
+ {
+ // copy just the visible segment of the annotation row
+ copylength = annotationLength;
+ }
+ else
+ {
+ if (annotationLength + block[0] <= annotations.length)
+ {
+ // copy just the visible segment of the annotation row
+ copylength = annotationLength;
+ }
+ else
+ {
+ // copy to the end of the annotation row
+ copylength = annotations.length - block[0];
+ }
+ }
+
+ els = new Annotation[annotationLength];
+ annels.add(els);
+ System.arraycopy(annotations, block[0], els, 0, copylength);
+ w += annotationLength;
+ }
+
+ if (w != 0)
+ {
+ annotations = new Annotation[w];
+
+ w = 0;
+ for (Annotation[] chnk : annels)
+ {
+ System.arraycopy(chnk, 0, annotations, w, chnk.length);
+ w += chnk.length;
+ }
+ }
+ }
+
public static Iterable<AlignmentAnnotation> findAnnotations(
Iterable<AlignmentAnnotation> list, SequenceI seq, String calcId,
String label)
*/
AlignedCodonFrame getMapping(SequenceI mapFrom, SequenceI mapTo);
+ /**
+ * Set the hidden columns collection on the alignment
+ *
+ * @param cols
+ */
public void setHiddenColumns(HiddenColumns cols);
+ /**
+ * Set the first sequence as representative and hide its insertions. Typically
+ * used when loading JPred files.
+ */
+ public void setupJPredAlignment();
+
+ /**
+ * Add gaps into the sequences aligned to profileseq under the given
+ * AlignmentView
+ *
+ * @param profileseq
+ * sequence in al which sequences are aligned to
+ * @param input
+ * alignment view where sequence corresponding to profileseq is first
+ * entry
+ * @return new HiddenColumns for new alignment view, with insertions into
+ * profileseq marked as hidden.
+ */
+ public HiddenColumns propagateInsertions(SequenceI profileseq,
+ AlignmentView input);
+
}
*/
package jalview.datamodel;
-import java.util.List;
+import java.util.Iterator;
public class CigarArray extends CigarBase
{
SequenceGroup selectionGroup)
{
this(constructSeqCigarArray(alignment, selectionGroup));
- constructFromAlignment(alignment,
- hidden != null ? hidden.getHiddenColumnsCopy() : null,
- selectionGroup);
+ constructFromAlignment(alignment, hidden, selectionGroup);
}
private static int[] _calcStartEndBounds(AlignmentI alignment,
* @param selectionGroup
*/
private void constructFromAlignment(AlignmentI alignment,
- List<int[]> list, SequenceGroup selectionGroup)
+ HiddenColumns hidden, SequenceGroup selectionGroup)
{
int[] _startend = _calcStartEndBounds(alignment, selectionGroup);
- int start = _startend[1], end = _startend[2];
+ int start = _startend[1];
+ int end = _startend[2];
// now construct the CigarArray operations
- if (list != null)
+ if (hidden != null)
{
int[] region;
- int hideStart, hideEnd;
+ int hideStart;
+ int hideEnd;
int last = start;
- for (int j = 0; last < end & j < list.size(); j++)
+
+ Iterator<int[]> regions = hidden.getBoundedIterator(start, end);
+ while (regions.hasNext())
{
- region = list.get(j);
+ region = regions.next();
hideStart = region[0];
hideEnd = region[1];
- // edit hidden regions to selection range
-
- // just move on if hideEnd is before last
- if (hideEnd < last)
- {
- continue;
- }
- // exit if next region is after end
- if (hideStart > end)
- {
- break;
- }
// truncate region at start if last falls in region
if ((hideStart < last) && (hideEnd >= last))
addOperation(CigarArray.D, 1 + hideEnd - hideStart);
last = hideEnd + 1;
}
+
// Final match if necessary.
if (last <= end)
{
* List of databases whose sequences might have coding regions annotated
*/
public static final String[] DNACODINGDBS = { EMBL, EMBLCDS, GENEDB,
- ENSEMBL };
+ ENSEMBL, ENSEMBLGENOMES };
public static final String[] CODINGDBS = { EMBLCDS, GENEDB, ENSEMBL };
public static String[] allSources()
{
- List<String> src = new ArrayList<String>();
+ List<String> src = new ArrayList<>();
for (Field f : DBRefSource.class.getFields())
{
if (String.class.equals(f.getType()))
*/
package jalview.datamodel;
-import jalview.util.Comparison;
-import jalview.util.ShiftList;
-
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.BitSet;
-import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+/**
+ * This class manages the collection of hidden columns associated with an
+ * alignment. To iterate over the collection, or over visible columns/regions,
+ * use an iterator obtained from one of:
+ *
+ * - getBoundedIterator: iterates over the hidden regions, within some bounds,
+ * returning *absolute* positions
+ *
+ * - getBoundedStartIterator: iterates over the start positions of hidden
+ * regions, within some bounds, returning *visible* positions
+ *
+ * - getVisContigsIterator: iterates over visible regions in a range, returning
+ * *absolute* positions
+ *
+ * - getVisibleColsIterator: iterates over the visible *columns*
+ *
+ * For performance reasons, provide bounds where possible. Note that column
+ * numbering begins at 0 throughout this class.
+ *
+ * @author kmourao
+ */
+
+/* Implementation notes:
+ *
+ * Methods which change the hiddenColumns collection should use a writeLock to
+ * prevent other threads accessing the hiddenColumns collection while changes
+ * are being made. They should also reset the hidden columns cursor, and either
+ * update the hidden columns count, or set it to 0 (so that it will later be
+ * updated when needed).
+ *
+ *
+ * Methods which only need read access to the hidden columns collection should
+ * use a readLock to prevent other threads changing the hidden columns
+ * collection while it is in use.
+ */
public class HiddenColumns
{
+ private static final int HASH_MULTIPLIER = 31;
+
private static final ReentrantReadWriteLock LOCK = new ReentrantReadWriteLock();
/*
+ * Cursor which tracks the last used hidden columns region, and the number
+ * of hidden columns up to (but not including) that region.
+ */
+ private HiddenColumnsCursor cursor = new HiddenColumnsCursor();
+
+ /*
+ * cache of the number of hidden columns: must be kept up to date by methods
+ * which add or remove hidden columns
+ */
+ private int numColumns = 0;
+
+ /*
* list of hidden column [start, end] ranges; the list is maintained in
* ascending start column order
*/
- private ArrayList<int[]> hiddenColumns;
+ private List<int[]> hiddenColumns = new ArrayList<>();
/**
* Constructor
* Copy constructor
*
* @param copy
+ * the HiddenColumns object to copy from
*/
public HiddenColumns(HiddenColumns copy)
{
+ this(copy, Integer.MIN_VALUE, Integer.MAX_VALUE, 0);
+ }
+
+ /**
+ * Copy constructor within bounds and with offset. Copies hidden column
+ * regions fully contained between start and end, and offsets positions by
+ * subtracting offset.
+ *
+ * @param copy
+ * HiddenColumns instance to copy from
+ * @param start
+ * lower bound to copy from
+ * @param end
+ * upper bound to copy to
+ * @param offset
+ * offset to subtract from each region boundary position
+ *
+ */
+ public HiddenColumns(HiddenColumns copy, int start, int end, int offset)
+ {
try
{
LOCK.writeLock().lock();
if (copy != null)
{
- if (copy.hiddenColumns != null)
+ numColumns = 0;
+ Iterator<int[]> it = copy.getBoundedIterator(start, end);
+ while (it.hasNext())
+ {
+ int[] region = it.next();
+ // still need to check boundaries because iterator returns
+ // all overlapping regions and we need contained regions
+ if (region[0] >= start && region[1] <= end)
+ {
+ hiddenColumns.add(
+ new int[]
+ { region[0] - offset, region[1] - offset });
+ numColumns += region[1] - region[0] + 1;
+ }
+ }
+ cursor = new HiddenColumnsCursor(hiddenColumns);
+ }
+ } finally
+ {
+ LOCK.writeLock().unlock();
+ }
+ }
+
+ /**
+ * Adds the specified column range to the hidden columns collection
+ *
+ * @param start
+ * start of range to add (absolute position in alignment)
+ * @param end
+ * end of range to add (absolute position in alignment)
+ */
+ public void hideColumns(int start, int end)
+ {
+ try
+ {
+ LOCK.writeLock().lock();
+
+ int previndex = 0;
+ int prevHiddenCount = 0;
+ int regionindex = 0;
+ if (!hiddenColumns.isEmpty())
+ {
+ // set up cursor reset values
+ HiddenCursorPosition cursorPos = cursor.findRegionForColumn(start, false);
+ regionindex = cursorPos.getRegionIndex();
+
+ if (regionindex > 0)
+ {
+ // get previous index and hidden count for updating the cursor later
+ previndex = regionindex - 1;
+ int[] prevRegion = hiddenColumns.get(previndex);
+ prevHiddenCount = cursorPos.getHiddenSoFar()
+ - (prevRegion[1] - prevRegion[0] + 1);
+ }
+ }
+
+ // new range follows everything else; check first to avoid looping over
+ // whole hiddenColumns collection
+ if (hiddenColumns.isEmpty()
+ || start > hiddenColumns.get(hiddenColumns.size() - 1)[1])
+ {
+ hiddenColumns.add(new int[] { start, end });
+ numColumns += end - start + 1;
+ }
+ else
+ {
+ /*
+ * traverse existing hidden ranges and insert / amend / append as
+ * appropriate
+ */
+ boolean added = false;
+ if (regionindex > 0)
+ {
+ added = insertRangeAtRegion(regionindex - 1, start, end);
+ }
+ if (!added && regionindex < hiddenColumns.size())
+ {
+ insertRangeAtRegion(regionindex, start, end);
+ }
+ }
+
+ // reset the cursor to just before our insertion point: this saves
+ // a lot of reprocessing in large alignments
+ cursor = new HiddenColumnsCursor(hiddenColumns, previndex,
+ prevHiddenCount);
+ } finally
+ {
+ LOCK.writeLock().unlock();
+ }
+ }
+
+ /**
+ * Insert [start, range] at the region at index i in hiddenColumns, if
+ * feasible
+ *
+ * @param i
+ * index to insert at
+ * @param start
+ * start of range to insert
+ * @param end
+ * end of range to insert
+ * @return true if range was successfully inserted
+ */
+ private boolean insertRangeAtRegion(int i, int start, int end)
+ {
+ boolean added = false;
+
+ int[] region = hiddenColumns.get(i);
+ if (end < region[0] - 1)
+ {
+ /*
+ * insert discontiguous preceding range
+ */
+ hiddenColumns.add(i, new int[] { start, end });
+ numColumns += end - start + 1;
+ added = true;
+ }
+ else if (end <= region[1])
+ {
+ /*
+ * new range overlaps existing, or is contiguous preceding it - adjust
+ * start column
+ */
+ int oldstart = region[0];
+ region[0] = Math.min(region[0], start);
+ numColumns += oldstart - region[0]; // new columns are between old and
+ // adjusted starts
+ added = true;
+ }
+ else if (start <= region[1] + 1)
+ {
+ /*
+ * new range overlaps existing, or is contiguous following it - adjust
+ * start and end columns
+ */
+ insertRangeAtOverlap(i, start, end, region);
+ added = true;
+ }
+ return added;
+ }
+
+ /**
+ * Insert a range whose start position overlaps an existing region and/or is
+ * contiguous to the right of the region
+ *
+ * @param i
+ * index to insert at
+ * @param start
+ * start of range to insert
+ * @param end
+ * end of range to insert
+ * @param region
+ * the overlapped/continued region
+ */
+ private void insertRangeAtOverlap(int i, int start, int end, int[] region)
+ {
+ int oldstart = region[0];
+ int oldend = region[1];
+ region[0] = Math.min(region[0], start);
+ region[1] = Math.max(region[1], end);
+
+ numColumns += oldstart - region[0];
+
+ /*
+ * also update or remove any subsequent ranges
+ * that are overlapped
+ */
+ int endi = i;
+ while (endi < hiddenColumns.size() - 1)
+ {
+ int[] nextRegion = hiddenColumns.get(endi + 1);
+ if (nextRegion[0] > end + 1)
+ {
+ /*
+ * gap to next hidden range - no more to update
+ */
+ break;
+ }
+ numColumns -= nextRegion[1] - nextRegion[0] + 1;
+ region[1] = Math.max(nextRegion[1], end);
+ endi++;
+ }
+ numColumns += region[1] - oldend;
+ hiddenColumns.subList(i + 1, endi + 1).clear();
+ }
+
+ /**
+ * hide a list of ranges
+ *
+ * @param ranges
+ */
+ public void hideList(List<int[]> ranges)
+ {
+ try
+ {
+ LOCK.writeLock().lock();
+ for (int[] r : ranges)
+ {
+ hideColumns(r[0], r[1]);
+ }
+ cursor = new HiddenColumnsCursor(hiddenColumns);
+
+ } finally
+ {
+ LOCK.writeLock().unlock();
+ }
+ }
+
+ /**
+ * Unhides, and adds to the selection list, all hidden columns
+ */
+ public void revealAllHiddenColumns(ColumnSelection sel)
+ {
+ try
+ {
+ LOCK.writeLock().lock();
+
+ for (int[] region : hiddenColumns)
+ {
+ for (int j = region[0]; j < region[1] + 1; j++)
{
- hiddenColumns = copy.copyHiddenRegionsToArrayList();
+ sel.addElement(j);
}
}
+ hiddenColumns.clear();
+ cursor = new HiddenColumnsCursor(hiddenColumns);
+ numColumns = 0;
+
} finally
{
LOCK.writeLock().unlock();
}
/**
- * This method is used to return all the HiddenColumn regions and is intended
- * to remain private. External callers which need a copy of the regions can
- * call getHiddenColumnsCopyAsList.
+ * Reveals, and marks as selected, the hidden column range with the given
+ * start column
*
- * @return empty list or List of hidden column intervals
+ * @param start
+ * the start column to look for
+ * @param sel
+ * the column selection to add the hidden column range to
*/
- private List<int[]> getHiddenRegions()
+ public void revealHiddenColumns(int start, ColumnSelection sel)
{
- return hiddenColumns == null ? Collections.<int[]> emptyList()
- : hiddenColumns;
+ try
+ {
+ LOCK.writeLock().lock();
+
+ if (!hiddenColumns.isEmpty())
+ {
+ int regionIndex = cursor.findRegionForColumn(start, false)
+ .getRegionIndex();
+
+ if (regionIndex != -1 && regionIndex != hiddenColumns.size())
+ {
+ // regionIndex is the region which either contains start
+ // or lies to the right of start
+ int[] region = hiddenColumns.get(regionIndex);
+ if (start == region[0])
+ {
+ for (int j = region[0]; j < region[1] + 1; j++)
+ {
+ sel.addElement(j);
+ }
+ int colsToRemove = region[1] - region[0] + 1;
+ hiddenColumns.remove(regionIndex);
+ numColumns -= colsToRemove;
+ }
+ }
+ }
+ } finally
+ {
+ LOCK.writeLock().unlock();
+ }
}
/**
{
LOCK.readLock().lock();
StringBuilder regionBuilder = new StringBuilder();
- if (hiddenColumns != null)
+
+ boolean first = true;
+ for (int[] range : hiddenColumns)
{
- for (int[] range : hiddenColumns)
+ if (!first)
+ {
+ regionBuilder.append(delimiter);
+ }
+ else
{
- regionBuilder.append(delimiter).append(range[0]).append(between)
- .append(range[1]);
+ first = false;
}
+ regionBuilder.append(range[0]).append(between).append(range[1]);
- regionBuilder.deleteCharAt(0);
}
+
return regionBuilder.toString();
} finally
{
*/
public int getSize()
{
+ return numColumns;
+ }
+
+ /**
+ * Get the number of distinct hidden regions
+ *
+ * @return number of regions
+ */
+ public int getNumberOfRegions()
+ {
try
{
LOCK.readLock().lock();
- int size = 0;
- if (hasHiddenColumns())
- {
- for (int[] range : hiddenColumns)
- {
- size += range[1] - range[0] + 1;
- }
- }
- return size;
+ return hiddenColumns.size();
} finally
{
LOCK.readLock().unlock();
/*
* check hidden columns are either both null, or match
*/
- if (this.hiddenColumns == null)
- {
- return (that.hiddenColumns == null);
- }
- if (that.hiddenColumns == null
- || that.hiddenColumns.size() != this.hiddenColumns.size())
+
+ if (that.hiddenColumns.size() != this.hiddenColumns.size())
{
return false;
}
- int i = 0;
- for (int[] thisRange : hiddenColumns)
+
+ Iterator<int[]> it = this.iterator();
+ Iterator<int[]> thatit = that.iterator();
+ while (it.hasNext())
{
- int[] thatRange = that.hiddenColumns.get(i++);
- if (thisRange[0] != thatRange[0] || thisRange[1] != thatRange[1])
+ if (!(Arrays.equals(it.next(), thatit.next())))
{
return false;
}
}
return true;
+
} finally
{
LOCK.readLock().unlock();
* int column index in alignment view (count from zero)
* @return alignment column index for column
*/
- public int adjustForHiddenColumns(int column)
+ public int visibleToAbsoluteColumn(int column)
{
try
{
LOCK.readLock().lock();
int result = column;
- if (hiddenColumns != null)
+
+ if (!hiddenColumns.isEmpty())
{
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.get(i);
- if (result >= region[0])
- {
- result += region[1] - region[0] + 1;
- }
- }
+ result += cursor.findRegionForColumn(column, true)
+ .getHiddenSoFar();
}
+
return result;
} finally
{
/**
* Use this method to find out where a column will appear in the visible
* alignment when hidden columns exist. If the column is not visible, then the
- * left-most visible column will always be returned.
+ * index of the next visible column on the left will be returned (or 0 if
+ * there is no visible column on the left)
*
* @param hiddenColumn
* the column index in the full alignment including hidden columns
* @return the position of the column in the visible alignment
*/
- public int findColumnPosition(int hiddenColumn)
+ public int absoluteToVisibleColumn(int hiddenColumn)
{
try
{
LOCK.readLock().lock();
int result = hiddenColumn;
- if (hiddenColumns != null)
- {
- int index = 0;
- int[] region;
- do
- {
- region = hiddenColumns.get(index++);
- if (hiddenColumn > region[1])
- {
- result -= region[1] + 1 - region[0];
- }
- } while ((hiddenColumn > region[1])
- && (index < hiddenColumns.size()));
- if (hiddenColumn >= region[0] && hiddenColumn <= region[1])
+ if (!hiddenColumns.isEmpty())
+ {
+ HiddenCursorPosition cursorPos = cursor
+ .findRegionForColumn(hiddenColumn, false);
+ int index = cursorPos.getRegionIndex();
+ int hiddenBeforeCol = cursorPos.getHiddenSoFar();
+
+ // just subtract hidden cols count - this works fine if column is
+ // visible
+ result = hiddenColumn - hiddenBeforeCol;
+
+ // now check in case column is hidden - it will be in the returned
+ // hidden region
+ if (index < hiddenColumns.size())
{
- // Here the hidden column is within a region, so
- // we want to return the position of region[0]-1, adjusted for any
- // earlier hidden columns.
- // Calculate the difference between the actual hidden col position
- // and region[0]-1, and then subtract from result to convert result
- // from
- // the adjusted hiddenColumn value to the adjusted region[0]-1 value
-
- // However, if the region begins at 0 we cannot return region[0]-1
- // just return 0
- if (region[0] == 0)
- {
- return 0;
- }
- else
+ int[] region = hiddenColumns.get(index);
+ if (hiddenColumn >= region[0] && hiddenColumn <= region[1])
{
- return result - (hiddenColumn - region[0] + 1);
+ // actually col is hidden, return region[0]-1
+ // unless region[0]==0 in which case return 0
+ if (region[0] == 0)
+ {
+ result = 0;
+ }
+ else
+ {
+ result = region[0] - 1 - hiddenBeforeCol;
+ }
}
}
}
+
return result; // return the shifted position after removing hidden
// columns.
} finally
/**
* Find the visible column which is a given visible number of columns to the
- * left of another visible column. i.e. for a startColumn x, the column which
- * is distance 1 away will be column x-1.
+ * left (negative visibleDistance) or right (positive visibleDistance) of
+ * startColumn. If startColumn is not visible, we use the visible column at
+ * the left boundary of the hidden region containing startColumn.
*
* @param visibleDistance
- * the number of visible columns to offset by
+ * the number of visible columns to offset by (left offset = negative
+ * value; right offset = positive value)
* @param startColumn
- * the column to start from
- * @return the position of the column in the visible alignment
+ * the position of the column to start from (absolute position)
+ * @return the position of the column which is <visibleDistance> away
+ * (absolute position)
*/
- public int subtractVisibleColumns(int visibleDistance, int startColumn)
+ public int offsetByVisibleColumns(int visibleDistance, int startColumn)
{
try
{
-
LOCK.readLock().lock();
- int distance = visibleDistance;
-
- // in case startColumn is in a hidden region, move it to the left
- int start = adjustForHiddenColumns(findColumnPosition(startColumn));
-
- // get index of hidden region to left of start
- int index = getHiddenIndexLeft(start);
- if (index == -1)
- {
- // no hidden regions to left of startColumn
- return start - distance;
- }
-
- // walk backwards through the alignment subtracting the counts of visible
- // columns from distance
- int[] region;
- int gap = 0;
- int nextstart = start;
-
- while ((index > -1) && (distance - gap > 0))
- {
- // subtract the gap to right of region from distance
- distance -= gap;
- start = nextstart;
-
- // calculate the next gap
- region = hiddenColumns.get(index);
- gap = start - region[1];
-
- // set start to just to left of current region
- nextstart = region[0] - 1;
- index--;
- }
+ int start = absoluteToVisibleColumn(startColumn);
+ return visibleToAbsoluteColumn(start + visibleDistance);
- if (distance - gap > 0)
- {
- // fell out of loop because there are no more hidden regions
- distance -= gap;
- return nextstart - distance;
- }
- return start - distance;
} finally
{
LOCK.readLock().unlock();
}
-
}
/**
- * Use this method to determine the set of hiddenRegion start positions
+ * This method returns the rightmost limit of a region of an alignment with
+ * hidden columns. In otherwords, the next hidden column.
*
- * @return list of column number in visible view where hidden regions start
+ * @param alPos
+ * the absolute (visible) alignmentPosition to find the next hidden
+ * column for
+ * @return the index of the next hidden column, or alPos if there is no next
+ * hidden column
*/
- public List<Integer> findHiddenRegionPositions()
+ public int getNextHiddenBoundary(boolean left, int alPos)
{
try
{
LOCK.readLock().lock();
- List<Integer> positions = null;
-
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
- positions = new ArrayList<>(hiddenColumns.size());
+ int index = cursor.findRegionForColumn(alPos, false)
+ .getRegionIndex();
- positions.add(hiddenColumns.get(0)[0]);
- for (int i = 1; i < hiddenColumns.size(); ++i)
+ if (left && index > 0)
{
-
- int result = 0;
- if (hiddenColumns != null)
+ int[] region = hiddenColumns.get(index - 1);
+ return region[1];
+ }
+ else if (!left && index < hiddenColumns.size())
+ {
+ int[] region = hiddenColumns.get(index);
+ if (alPos < region[0])
{
- int index = 0;
- int gaps = 0;
- do
- {
- int[] region = hiddenColumns.get(index);
- gaps += region[1] + 1 - region[0];
- result = region[1] + 1;
- index++;
- } while (index <= i);
-
- result -= gaps;
+ return region[0];
+ }
+ else if ((alPos <= region[1])
+ && (index + 1 < hiddenColumns.size()))
+ {
+ // alPos is within a hidden region, return the next one
+ // if there is one
+ region = hiddenColumns.get(index + 1);
+ return region[0];
}
- positions.add(result);
}
}
- else
- {
- positions = new ArrayList<>();
- }
-
- return positions;
+ return alPos;
} finally
{
LOCK.readLock().unlock();
}
/**
- * This method returns the rightmost limit of a region of an alignment with
- * hidden columns. In otherwords, the next hidden column.
+ * Answers if a column in the alignment is visible
*
- * @param index
- * int
+ * @param column
+ * absolute position of column in the alignment
+ * @return true if column is visible
*/
- public int getHiddenBoundaryRight(int alPos)
+ public boolean isVisible(int column)
{
try
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
+
+ if (!hiddenColumns.isEmpty())
{
- int index = 0;
- do
+ int regionindex = cursor.findRegionForColumn(column, false)
+ .getRegionIndex();
+ if (regionindex > -1 && regionindex < hiddenColumns.size())
{
- int[] region = hiddenColumns.get(index);
- if (alPos < region[0])
+ int[] region = hiddenColumns.get(regionindex);
+ // already know that column <= region[1] as cursor returns containing
+ // region or region to right
+ if (column >= region[0])
{
- return region[0];
+ return false;
}
-
- index++;
- } while (index < hiddenColumns.size());
+ }
}
+ return true;
- return alPos;
} finally
{
LOCK.readLock().unlock();
}
-
}
/**
- * This method returns the leftmost limit of a region of an alignment with
- * hidden columns. In otherwords, the previous hidden column.
*
- * @param index
- * int
+ * @return true if there are columns hidden
*/
- public int getHiddenBoundaryLeft(int alPos)
+ public boolean hasHiddenColumns()
{
try
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
- {
- int index = hiddenColumns.size() - 1;
- do
- {
- int[] region = hiddenColumns.get(index);
- if (alPos > region[1])
- {
- return region[1];
- }
-
- index--;
- } while (index > -1);
- }
-
- return alPos;
+ // we don't use getSize()>0 here because it has to iterate over
+ // the full hiddenColumns collection and so will be much slower
+ return (!hiddenColumns.isEmpty());
} finally
{
LOCK.readLock().unlock();
}
/**
- * This method returns the index of the hidden region to the left of a column
- * position. If the column is in a hidden region it returns the index of the
- * region to the left. If there is no hidden region to the left it returns -1.
*
- * @param pos
- * int
+ * @return true if there is more than one hidden column region
*/
- private int getHiddenIndexLeft(int pos)
+ public boolean hasMultiHiddenColumnRegions()
{
try
{
-
LOCK.readLock().lock();
- if (hiddenColumns != null)
- {
- int index = hiddenColumns.size() - 1;
- do
- {
- int[] region = hiddenColumns.get(index);
- if (pos > region[1])
- {
- return index;
- }
-
- index--;
- } while (index > -1);
- }
-
- return -1;
+ return !hiddenColumns.isEmpty() && hiddenColumns.size() > 1;
} finally
{
LOCK.readLock().unlock();
}
-
}
+
/**
- * Adds the specified column range to the hidden columns
- *
- * @param start
- * @param end
+ * Returns a hashCode built from hidden column ranges
*/
- public void hideColumns(int start, int end)
+ @Override
+ public int hashCode()
{
- boolean wasAlreadyLocked = false;
try
{
- // check if the write lock was already locked by this thread,
- // as this method can be called internally in loops within HiddenColumns
- if (!LOCK.isWriteLockedByCurrentThread())
- {
- LOCK.writeLock().lock();
- }
- else
- {
- wasAlreadyLocked = true;
- }
-
- if (hiddenColumns == null)
- {
- hiddenColumns = new ArrayList<>();
- }
+ LOCK.readLock().lock();
+ int hashCode = 1;
- /*
- * traverse existing hidden ranges and insert / amend / append as
- * appropriate
- */
- for (int i = 0; i < hiddenColumns.size(); i++)
+ for (int[] hidden : hiddenColumns)
{
- int[] region = hiddenColumns.get(i);
-
- if (end < region[0] - 1)
- {
- /*
- * insert discontiguous preceding range
- */
- hiddenColumns.add(i, new int[] { start, end });
- return;
- }
-
- if (end <= region[1])
- {
- /*
- * new range overlaps existing, or is contiguous preceding it - adjust
- * start column
- */
- region[0] = Math.min(region[0], start);
- return;
- }
-
- if (start <= region[1] + 1)
- {
- /*
- * new range overlaps existing, or is contiguous following it - adjust
- * start and end columns
- */
- region[0] = Math.min(region[0], start);
- region[1] = Math.max(region[1], end);
-
- /*
- * also update or remove any subsequent ranges
- * that are overlapped
- */
- while (i < hiddenColumns.size() - 1)
- {
- int[] nextRegion = hiddenColumns.get(i + 1);
- if (nextRegion[0] > end + 1)
- {
- /*
- * gap to next hidden range - no more to update
- */
- break;
- }
- region[1] = Math.max(nextRegion[1], end);
- hiddenColumns.remove(i + 1);
- }
- return;
- }
+ hashCode = HASH_MULTIPLIER * hashCode + hidden[0];
+ hashCode = HASH_MULTIPLIER * hashCode + hidden[1];
}
-
- /*
- * remaining case is that the new range follows everything else
- */
- hiddenColumns.add(new int[] { start, end });
+ return hashCode;
} finally
{
- if (!wasAlreadyLocked)
- {
- LOCK.writeLock().unlock();
- }
+ LOCK.readLock().unlock();
}
}
- public boolean isVisible(int column)
+ /**
+ * Hide columns corresponding to the marked bits
+ *
+ * @param inserts
+ * - columns mapped to bits starting from zero
+ */
+ public void hideColumns(BitSet inserts)
+ {
+ hideColumns(inserts, 0, inserts.length() - 1);
+ }
+
+ /**
+ * Hide columns corresponding to the marked bits, within the range
+ * [start,end]. Entries in tohide which are outside [start,end] are ignored.
+ *
+ * @param tohide
+ * columns mapped to bits starting from zero
+ * @param start
+ * start of range to hide columns within
+ * @param end
+ * end of range to hide columns within
+ */
+ private void hideColumns(BitSet tohide, int start, int end)
{
try
{
- LOCK.readLock().lock();
-
- if (hiddenColumns != null)
+ LOCK.writeLock().lock();
+ for (int firstSet = tohide
+ .nextSetBit(start), lastSet = start; firstSet >= start
+ && lastSet <= end; firstSet = tohide
+ .nextSetBit(lastSet))
{
- for (int[] region : hiddenColumns)
+ lastSet = tohide.nextClearBit(firstSet);
+ if (lastSet <= end)
{
- if (column >= region[0] && column <= region[1])
- {
- return false;
- }
+ hideColumns(firstSet, lastSet - 1);
+ }
+ else if (firstSet <= end)
+ {
+ hideColumns(firstSet, end);
}
}
-
- return true;
+ cursor = new HiddenColumnsCursor(hiddenColumns);
} finally
{
- LOCK.readLock().unlock();
- }
- }
-
- private ArrayList<int[]> copyHiddenRegionsToArrayList()
- {
- int size = 0;
- if (hiddenColumns != null)
- {
- size = hiddenColumns.size();
- }
- ArrayList<int[]> copy = new ArrayList<>(size);
-
- for (int i = 0, j = size; i < j; i++)
- {
- int[] rh;
- int[] cp;
- rh = hiddenColumns.get(i);
- if (rh != null)
- {
- cp = new int[rh.length];
- System.arraycopy(rh, 0, cp, 0, rh.length);
- copy.add(cp);
- }
+ LOCK.writeLock().unlock();
}
-
- return copy;
}
/**
- * Returns a copy of the vector of hidden regions, as an ArrayList. Before
- * using this method please consider if you really need access to the hidden
- * regions - a new (or existing!) method on HiddenColumns might be more
- * appropriate.
+ * Hide columns corresponding to the marked bits, within the range
+ * [start,end]. Entries in tohide which are outside [start,end] are ignored.
+ * NB Existing entries in [start,end] are cleared.
*
- * @return hidden regions as an ArrayList of [start,end] pairs
+ * @param tohide
+ * columns mapped to bits starting from zero
+ * @param start
+ * start of range to hide columns within
+ * @param end
+ * end of range to hide columns within
*/
- public ArrayList<int[]> getHiddenColumnsCopy()
+ public void clearAndHideColumns(BitSet tohide, int start, int end)
{
- try
- {
- LOCK.readLock().lock();
- return copyHiddenRegionsToArrayList();
- } finally
- {
- LOCK.readLock().unlock();
- }
+ clearHiddenColumnsInRange(start, end);
+ hideColumns(tohide, start, end);
}
/**
- * propagate shift in alignment columns to column selection
+ * Make all columns in the range [start,end] visible
*
* @param start
- * beginning of edit
- * @param left
- * shift in edit (+ve for removal, or -ve for inserts)
+ * start of range to show columns
+ * @param end
+ * end of range to show columns
*/
- public List<int[]> compensateForEdit(int start, int change,
- ColumnSelection sel)
+ private void clearHiddenColumnsInRange(int start, int end)
{
try
{
LOCK.writeLock().lock();
- List<int[]> deletedHiddenColumns = null;
-
- if (hiddenColumns != null)
+
+ if (!hiddenColumns.isEmpty())
{
- deletedHiddenColumns = new ArrayList<>();
- int hSize = hiddenColumns.size();
- for (int i = 0; i < hSize; i++)
+ HiddenCursorPosition pos = cursor.findRegionForColumn(start, false);
+ int index = pos.getRegionIndex();
+
+ if (index != -1 && index != hiddenColumns.size())
{
- int[] region = hiddenColumns.get(i);
- if (region[0] > start && start + change > region[1])
+ // regionIndex is the region which either contains start
+ // or lies to the right of start
+ int[] region = hiddenColumns.get(index);
+ if (region[0] < start && region[1] >= start)
{
- deletedHiddenColumns.add(region);
-
- hiddenColumns.remove(i);
- i--;
- hSize--;
- continue;
+ // region contains start, truncate so that it ends just before start
+ numColumns -= region[1] - start + 1;
+ region[1] = start - 1;
+ index++;
}
- if (region[0] > start)
+ int endi = index;
+ while (endi < hiddenColumns.size())
{
- region[0] -= change;
- region[1] -= change;
- }
+ region = hiddenColumns.get(endi);
- if (region[0] < 0)
- {
- region[0] = 0;
+ if (region[1] > end)
+ {
+ if (region[0] <= end)
+ {
+ // region contains end, truncate so it starts just after end
+ numColumns -= end - region[0] + 1;
+ region[0] = end + 1;
+ }
+ break;
+ }
+
+ numColumns -= region[1] - region[0] + 1;
+ endi++;
}
+ hiddenColumns.subList(index, endi).clear();
}
- this.revealHiddenColumns(0, sel);
+ cursor = new HiddenColumnsCursor(hiddenColumns);
}
-
- return deletedHiddenColumns;
} finally
{
LOCK.writeLock().unlock();
}
/**
- * propagate shift in alignment columns to column selection special version of
- * compensateForEdit - allowing for edits within hidden regions
*
- * @param start
- * beginning of edit
- * @param left
- * shift in edit (+ve for removal, or -ve for inserts)
+ * @param updates
+ * BitSet where hidden columns will be marked
*/
- public void compensateForDelEdits(int start, int change)
+ protected void andNot(BitSet updates)
{
try
{
LOCK.writeLock().lock();
- if (hiddenColumns != null)
- {
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.get(i);
- if (region[0] >= start)
- {
- region[0] -= change;
- }
- if (region[1] >= start)
- {
- region[1] -= change;
- }
- if (region[1] < region[0])
- {
- hiddenColumns.remove(i--);
- }
- if (region[0] < 0)
- {
- region[0] = 0;
- }
- if (region[1] < 0)
- {
- region[1] = 0;
- }
- }
+ BitSet hiddenBitSet = new BitSet();
+ for (int[] range : hiddenColumns)
+ {
+ hiddenBitSet.set(range[0], range[1] + 1);
}
+ hiddenBitSet.andNot(updates);
+ hiddenColumns.clear();
+ hideColumns(hiddenBitSet);
} finally
{
LOCK.writeLock().unlock();
}
/**
- * return all visible segments between the given start and end boundaries
+ * Calculate the visible start and end index of an alignment.
*
- * @param start
- * (first column inclusive from 0)
- * @param end
- * (last column - not inclusive)
- * @return int[] {i_start, i_end, ..} where intervals lie in
- * start<=i_start<=i_end<end
+ * @param width
+ * full alignment width
+ * @return integer array where: int[0] = startIndex, and int[1] = endIndex
*/
- public int[] getVisibleContigs(int start, int end)
+ public int[] getVisibleStartAndEndIndex(int width)
{
try
{
LOCK.readLock().lock();
- if (hiddenColumns != null && hiddenColumns.size() > 0)
- {
- List<int[]> visiblecontigs = new ArrayList<>();
- List<int[]> regions = getHiddenRegions();
- int vstart = start;
- int[] region;
- int hideStart;
- int hideEnd;
+ int firstVisible = 0;
+ int lastVisible = width - 1;
- for (int j = 0; vstart < end && j < regions.size(); j++)
- {
- region = regions.get(j);
- hideStart = region[0];
- hideEnd = region[1];
-
- if (hideEnd < vstart)
- {
- continue;
- }
- if (hideStart > vstart)
- {
- visiblecontigs.add(new int[] { vstart, hideStart - 1 });
- }
- vstart = hideEnd + 1;
- }
+ if (!hiddenColumns.isEmpty())
+ {
+ // first visible col with index 0, convert to absolute index
+ firstVisible = visibleToAbsoluteColumn(0);
- if (vstart < end)
+ // last visible column is either immediately to left of
+ // last hidden region, or is just the last column in the alignment
+ int[] lastregion = hiddenColumns.get(hiddenColumns.size() - 1);
+ if (lastregion[1] == width - 1)
{
- visiblecontigs.add(new int[] { vstart, end - 1 });
+ // last region is at very end of alignment
+ // last visible column immediately precedes it
+ lastVisible = lastregion[0] - 1;
}
- int[] vcontigs = new int[visiblecontigs.size() * 2];
- for (int i = 0, j = visiblecontigs.size(); i < j; i++)
- {
- int[] vc = visiblecontigs.get(i);
- visiblecontigs.set(i, null);
- vcontigs[i * 2] = vc[0];
- vcontigs[i * 2 + 1] = vc[1];
- }
- visiblecontigs.clear();
- return vcontigs;
- }
- else
- {
- return new int[] { start, end - 1 };
}
+ return new int[] { firstVisible, lastVisible };
+
} finally
{
LOCK.readLock().unlock();
}
}
- public String[] getVisibleSequenceStrings(int start, int end,
- SequenceI[] seqs)
+ /**
+ * Finds the hidden region (if any) which starts or ends at res
+ *
+ * @param res
+ * visible residue position, unadjusted for hidden columns
+ * @return region as [start,end] or null if no matching region is found. If
+ * res is adjacent to two regions, returns the left region.
+ */
+ public int[] getRegionWithEdgeAtRes(int res)
{
try
{
LOCK.readLock().lock();
- int iSize = seqs.length;
- String[] selections = new String[iSize];
- if (hiddenColumns != null && hiddenColumns.size() > 0)
- {
- for (int i = 0; i < iSize; i++)
- {
- StringBuffer visibleSeq = new StringBuffer();
- List<int[]> regions = getHiddenRegions();
-
- int blockStart = start;
- int blockEnd = end;
- int[] region;
- int hideStart;
- int hideEnd;
+ int adjres = visibleToAbsoluteColumn(res);
- for (int j = 0; j < regions.size(); j++)
- {
- region = regions.get(j);
- hideStart = region[0];
- hideEnd = region[1];
-
- if (hideStart < start)
- {
- continue;
- }
-
- blockStart = Math.min(blockStart, hideEnd + 1);
- blockEnd = Math.min(blockEnd, hideStart);
-
- if (blockStart > blockEnd)
- {
- break;
- }
-
- visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
-
- blockStart = hideEnd + 1;
- blockEnd = end;
- }
-
- if (end > blockStart)
- {
- visibleSeq.append(seqs[i].getSequence(blockStart, end));
- }
+ int[] reveal = null;
- selections[i] = visibleSeq.toString();
- }
- }
- else
+ if (!hiddenColumns.isEmpty())
{
- for (int i = 0; i < iSize; i++)
+ // look for a region ending just before adjres
+ int regionindex = cursor.findRegionForColumn(adjres - 1, false)
+ .getRegionIndex();
+ if (regionindex < hiddenColumns.size()
+ && hiddenColumns.get(regionindex)[1] == adjres - 1)
+ {
+ reveal = hiddenColumns.get(regionindex);
+ }
+ // check if the region ends just after adjres
+ else if (regionindex < hiddenColumns.size()
+ && hiddenColumns.get(regionindex)[0] == adjres + 1)
{
- selections[i] = seqs[i].getSequenceAsString(start, end);
+ reveal = hiddenColumns.get(regionindex);
}
}
+ return reveal;
- return selections;
} finally
{
LOCK.readLock().unlock();
}
/**
- * Locate the first and last position visible for this sequence. if seq isn't
- * visible then return the position of the left and right of the hidden
- * boundary region, and the corresponding alignment column indices for the
- * extent of the sequence
- *
- * @param seq
- * @return int[] { visible start, visible end, first seqpos, last seqpos,
- * alignment index for seq start, alignment index for seq end }
+ * Return an iterator over the hidden regions
*/
- public int[] locateVisibleBoundsOfSequence(SequenceI seq)
+ public Iterator<int[]> iterator()
{
try
{
LOCK.readLock().lock();
- int fpos = seq.getStart();
- int lpos = seq.getEnd();
- int start = 0;
-
- if (hiddenColumns == null || hiddenColumns.size() == 0)
- {
- int ifpos = seq.findIndex(fpos) - 1;
- int ilpos = seq.findIndex(lpos) - 1;
- return new int[] { ifpos, ilpos, fpos, lpos, ifpos, ilpos };
- }
-
- // Simply walk along the sequence whilst watching for hidden column
- // boundaries
- List<int[]> regions = getHiddenRegions();
- int spos = fpos;
- int lastvispos = -1;
- int rcount = 0;
- int hideStart = seq.getLength();
- int hideEnd = -1;
- int visPrev = 0;
- int visNext = 0;
- int firstP = -1;
- int lastP = -1;
- boolean foundStart = false;
- for (int p = 0, pLen = seq.getLength(); spos <= seq.getEnd()
- && p < pLen; p++)
- {
- if (!Comparison.isGap(seq.getCharAt(p)))
- {
- // keep track of first/last column
- // containing sequence data regardless of visibility
- if (firstP == -1)
- {
- firstP = p;
- }
- lastP = p;
- // update hidden region start/end
- while (hideEnd < p && rcount < regions.size())
- {
- int[] region = regions.get(rcount++);
- visPrev = visNext;
- visNext += region[0] - visPrev;
- hideStart = region[0];
- hideEnd = region[1];
- }
- if (hideEnd < p)
- {
- hideStart = seq.getLength();
- }
- // update visible boundary for sequence
- if (p < hideStart)
- {
- if (!foundStart)
- {
- fpos = spos;
- start = p;
- foundStart = true;
- }
- lastvispos = p;
- lpos = spos;
- }
- // look for next sequence position
- spos++;
- }
- }
- if (foundStart)
- {
- return new int[] { findColumnPosition(start),
- findColumnPosition(lastvispos), fpos, lpos, firstP, lastP };
- }
- // otherwise, sequence was completely hidden
- return new int[] { visPrev, visNext, 0, 0, firstP, lastP };
+ return new RangeIterator(hiddenColumns);
} finally
{
LOCK.readLock().unlock();
}
/**
- * delete any columns in alignmentAnnotation that are hidden (including
- * sequence associated annotation).
+ * Return a bounded iterator over the hidden regions
*
- * @param alignmentAnnotation
+ * @param start
+ * position to start from (inclusive, absolute column position)
+ * @param end
+ * position to end at (inclusive, absolute column position)
+ * @return
*/
- public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
+ public Iterator<int[]> getBoundedIterator(int start, int end)
{
- makeVisibleAnnotation(-1, -1, alignmentAnnotation);
+ try
+ {
+ LOCK.readLock().lock();
+ return new RangeIterator(start, end, hiddenColumns);
+ } finally
+ {
+ LOCK.readLock().unlock();
+ }
}
/**
- * delete any columns in alignmentAnnotation that are hidden (including
- * sequence associated annotation).
+ * Return a bounded iterator over the *visible* start positions of hidden
+ * regions
*
* @param start
- * remove any annotation to the right of this column
+ * position to start from (inclusive, visible column position)
* @param end
- * remove any annotation to the left of this column
- * @param alignmentAnnotation
- * the annotation to operate on
+ * position to end at (inclusive, visible column position)
*/
- public void makeVisibleAnnotation(int start, int end,
- AlignmentAnnotation alignmentAnnotation)
+ public Iterator<Integer> getStartRegionIterator(int start, int end)
{
try
{
LOCK.readLock().lock();
- if (alignmentAnnotation.annotations == null)
- {
- return;
- }
- if (start == end && end == -1)
- {
- start = 0;
- end = alignmentAnnotation.annotations.length;
- }
- if (hiddenColumns != null && hiddenColumns.size() > 0)
- {
- // then mangle the alignmentAnnotation annotation array
- Vector<Annotation[]> annels = new Vector<>();
- Annotation[] els = null;
- List<int[]> regions = getHiddenRegions();
- int blockStart = start;
- int blockEnd = end;
- int[] region;
- int hideStart;
- int hideEnd;
- int w = 0;
-
- for (int j = 0; j < regions.size(); j++)
- {
- region = regions.get(j);
- hideStart = region[0];
- hideEnd = region[1];
-
- if (hideStart < start)
- {
- continue;
- }
-
- blockStart = Math.min(blockStart, hideEnd + 1);
- blockEnd = Math.min(blockEnd, hideStart);
-
- if (blockStart > blockEnd)
- {
- break;
- }
-
- annels.addElement(els = new Annotation[blockEnd - blockStart]);
- System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
- 0, els.length);
- w += els.length;
- blockStart = hideEnd + 1;
- blockEnd = end;
- }
- if (end > blockStart)
- {
- annels.addElement(els = new Annotation[end - blockStart + 1]);
- if ((els.length
- + blockStart) <= alignmentAnnotation.annotations.length)
- {
- // copy just the visible segment of the annotation row
- System.arraycopy(alignmentAnnotation.annotations, blockStart,
- els, 0, els.length);
- }
- else
- {
- // copy to the end of the annotation row
- System.arraycopy(alignmentAnnotation.annotations, blockStart,
- els, 0,
- (alignmentAnnotation.annotations.length - blockStart));
- }
- w += els.length;
- }
- if (w == 0)
- {
- return;
- }
+ // get absolute position of column in alignment
+ int absoluteStart = visibleToAbsoluteColumn(start);
- alignmentAnnotation.annotations = new Annotation[w];
- w = 0;
+ // Get cursor position and supply it to the iterator:
+ // Since we want visible region start, we look for a cursor for the
+ // (absoluteStart-1), then if absoluteStart is the start of a visible
+ // region we'll get the cursor pointing to the region before, which is
+ // what we want
+ HiddenCursorPosition pos = cursor
+ .findRegionForColumn(absoluteStart - 1, false);
- for (Annotation[] chnk : annels)
- {
- System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
- chnk.length);
- w += chnk.length;
- }
- }
- else
- {
- alignmentAnnotation.restrict(start, end);
- }
+ return new StartRegionIterator(pos, start, end,
+ hiddenColumns);
} finally
{
LOCK.readLock().unlock();
}
/**
+ * Return an iterator over visible *columns* (not regions) between the given
+ * start and end boundaries
*
- * @return true if there are columns hidden
+ * @param start
+ * first column (inclusive)
+ * @param end
+ * last column (inclusive)
*/
- public boolean hasHiddenColumns()
+ public Iterator<Integer> getVisibleColsIterator(int start, int end)
{
try
{
LOCK.readLock().lock();
- return hiddenColumns != null && hiddenColumns.size() > 0;
+ return new RangeElementsIterator(
+ new VisibleContigsIterator(start, end + 1, hiddenColumns));
} finally
{
LOCK.readLock().unlock();
}
/**
+ * return an iterator over visible segments between the given start and end
+ * boundaries
*
- * @return true if there are more than one set of columns hidden
+ * @param start
+ * first column, inclusive from 0
+ * @param end
+ * last column - not inclusive
+ * @param useVisibleCoords
+ * if true, start and end are visible column positions, not absolute
+ * positions*
*/
- public boolean hasManyHiddenColumns()
+ public VisibleContigsIterator getVisContigsIterator(int start,
+ int end,
+ boolean useVisibleCoords)
{
+ int adjstart = start;
+ int adjend = end;
+ if (useVisibleCoords)
+ {
+ adjstart = visibleToAbsoluteColumn(start);
+ adjend = visibleToAbsoluteColumn(end);
+ }
+
try
{
LOCK.readLock().lock();
- return hiddenColumns != null && hiddenColumns.size() > 1;
+ return new VisibleContigsIterator(adjstart, adjend, hiddenColumns);
} finally
{
LOCK.readLock().unlock();
}
}
-
- /**
- * mark the columns corresponding to gap characters as hidden in the column
- * selection
- *
- * @param sr
- */
- public void hideInsertionsFor(SequenceI sr)
- {
- try
- {
- LOCK.writeLock().lock();
- List<int[]> inserts = sr.getInsertions();
- for (int[] r : inserts)
- {
- hideColumns(r[0], r[1]);
- }
- } finally
- {
- LOCK.writeLock().unlock();
- }
- }
-
- /**
- * Unhides, and adds to the selection list, all hidden columns
- */
- public void revealAllHiddenColumns(ColumnSelection sel)
- {
- try
- {
- LOCK.writeLock().lock();
- if (hiddenColumns != null)
- {
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.get(i);
- for (int j = region[0]; j < region[1] + 1; j++)
- {
- sel.addElement(j);
- }
- }
- }
-
- hiddenColumns = null;
- } finally
- {
- LOCK.writeLock().unlock();
- }
- }
-
- /**
- * Reveals, and marks as selected, the hidden column range with the given
- * start column
- *
- * @param start
- */
- public void revealHiddenColumns(int start, ColumnSelection sel)
- {
- try
- {
- LOCK.writeLock().lock();
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.get(i);
- if (start == region[0])
- {
- for (int j = region[0]; j < region[1] + 1; j++)
- {
- sel.addElement(j);
- }
-
- hiddenColumns.remove(region);
- break;
- }
- }
- if (hiddenColumns.size() == 0)
- {
- hiddenColumns = null;
- }
- } finally
- {
- LOCK.writeLock().unlock();
- }
- }
-
- /**
- * removes intersection of position,length ranges in deletions from the
- * start,end regions marked in intervals.
- *
- * @param shifts
- * @param intervals
- * @return
- */
- private boolean pruneIntervalList(final List<int[]> shifts,
- ArrayList<int[]> intervals)
- {
- boolean pruned = false;
- int i = 0;
- int j = intervals.size() - 1;
- int s = 0;
- int t = shifts.size() - 1;
- int[] hr = intervals.get(i);
- int[] sr = shifts.get(s);
- while (i <= j && s <= t)
- {
- boolean trailinghn = hr[1] >= sr[0];
- if (!trailinghn)
- {
- if (i < j)
- {
- hr = intervals.get(++i);
- }
- else
- {
- i++;
- }
- continue;
- }
- int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
- if (endshift < hr[0] || endshift < sr[0])
- { // leadinghc disjoint or not a deletion
- if (s < t)
- {
- sr = shifts.get(++s);
- }
- else
- {
- s++;
- }
- continue;
- }
- boolean leadinghn = hr[0] >= sr[0];
- boolean leadinghc = hr[0] < endshift;
- boolean trailinghc = hr[1] < endshift;
- if (leadinghn)
- {
- if (trailinghc)
- { // deleted hidden region.
- intervals.remove(i);
- pruned = true;
- j--;
- if (i <= j)
- {
- hr = intervals.get(i);
- }
- continue;
- }
- if (leadinghc)
- {
- hr[0] = endshift; // clip c terminal region
- leadinghn = !leadinghn;
- pruned = true;
- }
- }
- if (!leadinghn)
- {
- if (trailinghc)
- {
- if (trailinghn)
- {
- hr[1] = sr[0] - 1;
- pruned = true;
- }
- }
- else
- {
- // sr contained in hr
- if (s < t)
- {
- sr = shifts.get(++s);
- }
- else
- {
- s++;
- }
- continue;
- }
- }
- }
- return pruned; // true if any interval was removed or modified by
- // operations.
- }
-
- /**
- * remove any hiddenColumns or selected columns and shift remaining based on a
- * series of position, range deletions.
- *
- * @param deletions
- */
- public void pruneDeletions(List<int[]> shifts)
- {
- try
- {
- LOCK.writeLock().lock();
- // delete any intervals intersecting.
- if (hiddenColumns != null)
- {
- pruneIntervalList(shifts, hiddenColumns);
- if (hiddenColumns != null && hiddenColumns.size() == 0)
- {
- hiddenColumns = null;
- }
- }
- } finally
- {
- LOCK.writeLock().unlock();
- }
- }
-
- /**
- * Add gaps into the sequences aligned to profileseq under the given
- * AlignmentView
- *
- * @param profileseq
- * @param al
- * - alignment to have gaps inserted into it
- * @param input
- * - alignment view where sequence corresponding to profileseq is
- * first entry
- * @return new HiddenColumns for new alignment view, with insertions into
- * profileseq marked as hidden.
- */
- public static HiddenColumns propagateInsertions(SequenceI profileseq,
- AlignmentI al, AlignmentView input)
- {
- int profsqpos = 0;
-
- char gc = al.getGapCharacter();
- Object[] alandhidden = input.getAlignmentAndHiddenColumns(gc);
- HiddenColumns nview = (HiddenColumns) alandhidden[1];
- SequenceI origseq = ((SequenceI[]) alandhidden[0])[profsqpos];
- nview.propagateInsertions(profileseq, al, origseq);
- return nview;
- }
-
- /**
- *
- * @param profileseq
- * - sequence in al which corresponds to origseq
- * @param al
- * - alignment which is to have gaps inserted into it
- * @param origseq
- * - sequence corresponding to profileseq which defines gap map for
- * modifying al
- */
- private void propagateInsertions(SequenceI profileseq, AlignmentI al,
- SequenceI origseq)
- {
- char gc = al.getGapCharacter();
- // recover mapping between sequence's non-gap positions and positions
- // mapping to view.
- pruneDeletions(ShiftList.parseMap(origseq.gapMap()));
- int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
- int spos = 0;
- int offset = 0;
-
- // add profile to visible contigs
- for (int v = 0; v < viscontigs.length; v += 2)
- {
- if (viscontigs[v] > spos)
- {
- StringBuffer sb = new StringBuffer();
- for (int s = 0, ns = viscontigs[v] - spos; s < ns; s++)
- {
- sb.append(gc);
- }
- for (int s = 0, ns = al.getHeight(); s < ns; s++)
- {
- SequenceI sqobj = al.getSequenceAt(s);
- if (sqobj != profileseq)
- {
- String sq = al.getSequenceAt(s).getSequenceAsString();
- if (sq.length() <= spos + offset)
- {
- // pad sequence
- int diff = spos + offset - sq.length() - 1;
- if (diff > 0)
- {
- // pad gaps
- sq = sq + sb;
- while ((diff = spos + offset - sq.length() - 1) > 0)
- {
- // sq = sq
- // + ((diff >= sb.length()) ? sb.toString() : sb
- // .substring(0, diff));
- if (diff >= sb.length())
- {
- sq += sb.toString();
- }
- else
- {
- char[] buf = new char[diff];
- sb.getChars(0, diff, buf, 0);
- sq += buf.toString();
- }
- }
- }
- sq += sb.toString();
- }
- else
- {
- al.getSequenceAt(s).setSequence(sq.substring(0, spos + offset)
- + sb.toString() + sq.substring(spos + offset));
- }
- }
- }
- // offset+=sb.length();
- }
- spos = viscontigs[v + 1] + 1;
- }
- if ((offset + spos) < profileseq.getLength())
- {
- // pad the final region with gaps.
- StringBuffer sb = new StringBuffer();
- for (int s = 0, ns = profileseq.getLength() - spos
- - offset; s < ns; s++)
- {
- sb.append(gc);
- }
- for (int s = 0, ns = al.getHeight(); s < ns; s++)
- {
- SequenceI sqobj = al.getSequenceAt(s);
- if (sqobj == profileseq)
- {
- continue;
- }
- String sq = sqobj.getSequenceAsString();
- // pad sequence
- int diff = origseq.getLength() - sq.length();
- while (diff > 0)
- {
- // sq = sq
- // + ((diff >= sb.length()) ? sb.toString() : sb
- // .substring(0, diff));
- if (diff >= sb.length())
- {
- sq += sb.toString();
- }
- else
- {
- char[] buf = new char[diff];
- sb.getChars(0, diff, buf, 0);
- sq += buf.toString();
- }
- diff = origseq.getLength() - sq.length();
- }
- }
- }
- }
-
- /**
- * remove any hiddenColumns or selected columns and shift remaining based on a
- * series of position, range deletions.
- *
- * @param deletions
- */
- private void pruneDeletions(ShiftList deletions)
- {
- if (deletions != null)
- {
- final List<int[]> shifts = deletions.getShifts();
- if (shifts != null && shifts.size() > 0)
- {
- pruneDeletions(shifts);
-
- // and shift the rest.
- this.compensateForEdits(deletions);
- }
- }
- }
-
- /**
- * Adjust hidden column boundaries based on a series of column additions or
- * deletions in visible regions.
- *
- * @param shiftrecord
- * @return
- */
- private ShiftList compensateForEdits(ShiftList shiftrecord)
- {
- if (shiftrecord != null)
- {
- final List<int[]> shifts = shiftrecord.getShifts();
- if (shifts != null && shifts.size() > 0)
- {
- int shifted = 0;
- for (int i = 0, j = shifts.size(); i < j; i++)
- {
- int[] sh = shifts.get(i);
- compensateForDelEdits(shifted + sh[0], sh[1]);
- shifted -= sh[1];
- }
- }
- return shiftrecord.getInverse();
- }
- return null;
- }
-
- /**
- * Returns a hashCode built from hidden column ranges
- */
- @Override
- public int hashCode()
- {
- try
- {
- LOCK.readLock().lock();
- int hashCode = 1;
- if (hiddenColumns != null)
- {
- for (int[] hidden : hiddenColumns)
- {
- hashCode = 31 * hashCode + hidden[0];
- hashCode = 31 * hashCode + hidden[1];
- }
- }
- return hashCode;
- } finally
- {
- LOCK.readLock().unlock();
- }
- }
-
- /**
- * Hide columns corresponding to the marked bits
- *
- * @param inserts
- * - columns map to bits starting from zero
- */
- public void hideMarkedBits(BitSet inserts)
- {
- try
- {
- LOCK.writeLock().lock();
- for (int firstSet = inserts
- .nextSetBit(0), lastSet = 0; firstSet >= 0; firstSet = inserts
- .nextSetBit(lastSet))
- {
- lastSet = inserts.nextClearBit(firstSet);
- hideColumns(firstSet, lastSet - 1);
- }
- } finally
- {
- LOCK.writeLock().unlock();
- }
- }
-
- /**
- *
- * @param inserts
- * BitSet where hidden columns will be marked
- */
- public void markHiddenRegions(BitSet inserts)
- {
- try
- {
- LOCK.readLock().lock();
- if (hiddenColumns == null)
- {
- return;
- }
- for (int[] range : hiddenColumns)
- {
- inserts.set(range[0], range[1] + 1);
- }
- } finally
- {
- LOCK.readLock().unlock();
- }
- }
-
- /**
- * Calculate the visible start and end index of an alignment.
- *
- * @param width
- * full alignment width
- * @return integer array where: int[0] = startIndex, and int[1] = endIndex
- */
- public int[] getVisibleStartAndEndIndex(int width)
- {
- try
- {
- LOCK.readLock().lock();
- int[] alignmentStartEnd = new int[] { 0, width - 1 };
- int startPos = alignmentStartEnd[0];
- int endPos = alignmentStartEnd[1];
-
- int[] lowestRange = new int[] { -1, -1 };
- int[] higestRange = new int[] { -1, -1 };
-
- if (hiddenColumns == null)
- {
- return new int[] { startPos, endPos };
- }
-
- for (int[] hiddenCol : hiddenColumns)
- {
- lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange;
- higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange;
- }
-
- if (lowestRange[0] == -1 && lowestRange[1] == -1)
- {
- startPos = alignmentStartEnd[0];
- }
- else
- {
- startPos = lowestRange[1] + 1;
- }
-
- if (higestRange[0] == -1 && higestRange[1] == -1)
- {
- endPos = alignmentStartEnd[1];
- }
- else
- {
- endPos = higestRange[0] - 1;
- }
- return new int[] { startPos, endPos };
- } finally
- {
- LOCK.readLock().unlock();
- }
-
- }
-
- /**
- * Finds the hidden region (if any) which starts or ends at res
- *
- * @param res
- * visible residue position, unadjusted for hidden columns
- * @return region as [start,end] or null if no matching region is found
- */
- public int[] getRegionWithEdgeAtRes(int res)
- {
- try
- {
- LOCK.readLock().lock();
- int adjres = adjustForHiddenColumns(res);
-
- int[] reveal = null;
- if (hiddenColumns != null)
- {
- for (int[] region : hiddenColumns)
- {
- if (adjres + 1 == region[0] || adjres - 1 == region[1])
- {
- reveal = region;
- break;
- }
- }
- }
- return reveal;
- } finally
- {
- LOCK.readLock().unlock();
- }
- }
-
}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HiddenColumnsCursor
+{
+ // absolute position of first hidden column
+ private int firstColumn;
+
+ private List<int[]> hiddenColumns = new ArrayList<>();
+
+ private HiddenCursorPosition cursorPos = new HiddenCursorPosition(0, 0);
+
+ protected HiddenColumnsCursor()
+ {
+
+ }
+
+ protected HiddenColumnsCursor(List<int[]> hiddenCols)
+ {
+ resetCursor(hiddenCols, 0, 0);
+ }
+
+ protected HiddenColumnsCursor(List<int[]> hiddenCols, int index,
+ int hiddencount)
+ {
+ resetCursor(hiddenCols, index, hiddencount);
+ }
+
+ /**
+ * Reset the cursor with a new hidden columns collection, where we know in
+ * advance the index and hidden columns count of a particular location.
+ *
+ * @param hiddenCols
+ * new hidden columns collection
+ * @param index
+ * cursor index to reset to
+ * @param hiddencount
+ * hidden columns count to reset to
+ */
+ private void resetCursor(List<int[]> hiddenCols, int index,
+ int hiddencount)
+ {
+ hiddenColumns = hiddenCols;
+ if (!hiddenCols.isEmpty())
+ {
+ firstColumn = hiddenColumns.get(0)[0];
+ cursorPos = new HiddenCursorPosition(index,
+ hiddencount);
+ }
+ }
+
+ /**
+ * Get the cursor pointing to the hidden region that column is within (if
+ * column is hidden) or which is to the right of column (if column is
+ * visible). If no hidden columns are to the right, returns a cursor pointing
+ * to an imaginary hidden region beyond the end of the hidden columns
+ * collection (this ensures the count of previous hidden columns is correct).
+ * If hidden columns is empty returns null.
+ *
+ * @param column
+ * index of column in visible or absolute coordinates
+ * @param useVisible
+ * true if column is in visible coordinates, false if absolute
+ * @return cursor pointing to hidden region containing the column (if hidden)
+ * or to the right of the column (if visible)
+ */
+ protected HiddenCursorPosition findRegionForColumn(int column,
+ boolean useVisible)
+ {
+ if (hiddenColumns.isEmpty())
+ {
+ return null;
+ }
+
+ // used to add in hiddenColumns offset when working with visible columns
+ int offset = (useVisible ? 1 : 0);
+
+ HiddenCursorPosition pos = cursorPos;
+ int index = pos.getRegionIndex();
+ int hiddenCount = pos.getHiddenSoFar();
+
+ if (column < firstColumn)
+ {
+ pos = new HiddenCursorPosition(0, 0);
+ }
+
+ // column is after current region
+ else if ((index < hiddenColumns.size())
+ && (hiddenColumns.get(index)[0] <= column
+ + offset * hiddenCount))
+ {
+ // iterate from where we are now, if we're lucky we'll be close by
+ // (but still better than iterating from 0)
+ // stop when we find the region *before* column
+ // i.e. the next region starts after column or if not, ends after column
+ pos = searchForward(pos, column, useVisible);
+ }
+
+ // column is before current region
+ else
+ {
+ pos = searchBackward(pos, column, useVisible);
+ }
+ cursorPos = pos;
+ return pos;
+ }
+
+ /**
+ * Search forwards through the hidden columns collection to find the hidden
+ * region immediately before a column
+ *
+ * @param pos
+ * current position
+ * @param column
+ * column to locate
+ * @param useVisible
+ * whether using visible or absolute coordinates
+ * @return position of region before column
+ */
+ private HiddenCursorPosition searchForward(HiddenCursorPosition pos,
+ int column, boolean useVisible)
+ {
+ HiddenCursorPosition p = pos;
+ if (useVisible)
+ {
+ while ((p.getRegionIndex() < hiddenColumns.size())
+ && hiddenColumns.get(p.getRegionIndex())[0] <= column
+ + p.getHiddenSoFar())
+ {
+ p = stepForward(p);
+ }
+ }
+ else
+ {
+ while ((p.getRegionIndex() < hiddenColumns.size())
+ && hiddenColumns.get(p.getRegionIndex())[1] < column)
+ {
+ p = stepForward(p);
+ }
+ }
+ return p;
+ }
+
+ /**
+ * Move to the next (rightwards) hidden region after a given cursor position
+ *
+ * @param p
+ * current position of cursor
+ * @return new position of cursor at next region
+ */
+ private HiddenCursorPosition stepForward(HiddenCursorPosition p)
+ {
+ int[] region = hiddenColumns.get(p.getRegionIndex());
+
+ // increment the index, and add this region's hidden columns to the hidden
+ // column count
+ return new HiddenCursorPosition(p.getRegionIndex() + 1,
+ p.getHiddenSoFar() + region[1] - region[0] + 1);
+ }
+
+ /**
+ * Search backwards through the hidden columns collection to find the hidden
+ * region immediately before (left of) a given column
+ *
+ * @param pos
+ * current position
+ * @param column
+ * column to locate
+ * @param useVisible
+ * whether using visible or absolute coordinates
+ * @return position of region immediately to left of column
+ */
+ private HiddenCursorPosition searchBackward(HiddenCursorPosition p,
+ int column, boolean useVisible)
+ {
+ int i = p.getRegionIndex();
+ int h = p.getHiddenSoFar();
+
+ // used to add in hiddenColumns offset when working with visible columns
+ int offset = (useVisible ? 1 : 0);
+
+ while ((i > 0) && (hiddenColumns.get(i - 1)[1] >= column + offset * h))
+ {
+ i--;
+ int[] region = hiddenColumns.get(i);
+ h -= region[1] - region[0] + 1;
+ }
+ return new HiddenCursorPosition(i, h);
+ }
+
+}
--- /dev/null
+/*
+ * 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.datamodel;
+
+public final class HiddenCursorPosition
+{
+ // index of last visited region
+ private final int regionIndex;
+
+ // number of hidden columns before last visited region
+ private final int hiddenSoFar;
+
+ public HiddenCursorPosition(int index, int hiddencount)
+ {
+ regionIndex = index;
+ hiddenSoFar = hiddencount;
+ }
+
+ public int getRegionIndex()
+ {
+ return regionIndex;
+ }
+
+ public int getHiddenSoFar()
+ {
+ return hiddenSoFar;
+ }
+}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Iterator over each element in a set of ranges i.e. if ranges is {[3,6],
+ * [12,15]} it will iterate over {3,4,5,6,12,13,14,15}. Uses a local copy of the
+ * set of ranges.
+ *
+ * @author kmourao
+ *
+ */
+public class RangeElementsIterator implements Iterator<Integer>
+{
+ private int last;
+
+ private int current;
+
+ private int next;
+
+ private Iterator<int[]> rangeIterator;
+
+ private int[] nextRange = null;
+
+ RangeElementsIterator(Iterator<int[]> it)
+ {
+ rangeIterator = it;
+ if (rangeIterator.hasNext())
+ {
+ nextRange = rangeIterator.next();
+ next = nextRange[0];
+ last = nextRange[1];
+ }
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return rangeIterator.hasNext() || next <= last;
+ }
+
+ @Override
+ public Integer next()
+ {
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+
+ current = next;
+
+ // recalculate next
+ next++;
+
+ // if there are more ranges need to check if next is in a range
+ checkNextRange();
+ return current;
+ }
+
+ /**
+ * Check how next position relates to next range, and update next position if
+ * necessary
+ */
+ private void checkNextRange()
+ {
+ if (nextRange != null && next > nextRange[1])
+ {
+ if (rangeIterator.hasNext())
+ {
+ nextRange = rangeIterator.next();
+ next = nextRange[0];
+ last = nextRange[1];
+ }
+ else
+ {
+ nextRange = null;
+ }
+
+ }
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * An iterator which iterates over a list of ranges. Works with a copy of the
+ * collection of ranges.
+ */
+public class RangeIterator implements Iterator<int[]>
+{
+ // current index in rangeList
+ private int currentPosition = 0;
+
+ // current range in rangeList
+ private int[] currentRange;
+
+ // local copy or reference to rangeList
+ private List<int[]> localRanges;
+
+ /**
+ * Unbounded constructor
+ *
+ * @param rangeList
+ * list of ranges to iterate over
+ */
+ RangeIterator(List<int[]> rangeList)
+ {
+ if (!rangeList.isEmpty())
+ {
+ int last = rangeList.get(rangeList.size() - 1)[1];
+ init(0, last, rangeList);
+ }
+ else
+ {
+ init(0, 0, rangeList);
+ }
+ }
+
+ /**
+ * Construct an iterator over rangeList bounded at [lowerBound,upperBound]
+ *
+ * @param lowerBound
+ * lower bound to iterate from
+ * @param upperBound
+ * upper bound to iterate to
+ * @param rangeList
+ * list of ranges to iterate over
+ */
+ RangeIterator(int lowerBound, int upperBound,
+ List<int[]> rangeList)
+ {
+ init(lowerBound, upperBound, rangeList);
+ }
+
+ /**
+ * Construct an iterator over rangeList bounded at [lowerBound,upperBound]
+ *
+ * @param lowerBound
+ * lower bound to iterate from
+ * @param upperBound
+ * upper bound to iterate to
+ */
+ private void init(int lowerBound, int upperBound,
+ List<int[]> rangeList)
+ {
+ int start = lowerBound;
+ int end = upperBound;
+
+ if (rangeList != null)
+ {
+ localRanges = new ArrayList<>();
+
+ // iterate until a range overlaps with [start,end]
+ int i = 0;
+ while ((i < rangeList.size()) && (rangeList.get(i)[1] < start))
+ {
+ i++;
+ }
+
+ // iterate from start to end, adding each range. Positions are
+ // absolute, and all ranges which *overlap* [start,end] are added.
+ while (i < rangeList.size() && (rangeList.get(i)[0] <= end))
+ {
+ int[] rh = rangeList.get(i);
+ int[] cp = new int[2];
+ System.arraycopy(rh, 0, cp, 0, rh.length);
+ localRanges.add(cp);
+ i++;
+ }
+ }
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return (localRanges != null) && (currentPosition < localRanges.size());
+ }
+
+ @Override
+ public int[] next()
+ {
+ currentRange = localRanges.get(currentPosition);
+ currentPosition++;
+ return currentRange;
+ }
+
+ @Override
+ public void remove()
+ {
+ localRanges.remove(--currentPosition);
+ }
+}
{
int count = 0;
BitSet mask = new BitSet();
+ int startRes = sqcol.getStartRes();
+ int endRes = sqcol.getEndRes();
+
for (SequenceI s : sqcol.getSequences())
{
- int[] cols = getResults(s, sqcol.getStartRes(), sqcol.getEndRes());
+ int[] cols = getResults(s, startRes, endRes);
if (cols != null)
{
for (int pair = 0; pair < cols.length; pair += 2)
import java.util.BitSet;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Vector;
{
if (pdbIds == null)
{
- pdbIds = new Vector<PDBEntry>();
+ pdbIds = new Vector<>();
pdbIds.add(entry);
return true;
}
return map;
}
+ /**
+ * Build a bitset corresponding to sequence gaps
+ *
+ * @return a BitSet where set values correspond to gaps in the sequence
+ */
+ @Override
+ public BitSet gapBitset()
+ {
+ BitSet gaps = new BitSet(sequence.length);
+ int j = 0;
+ while (j < sequence.length)
+ {
+ if (jalview.util.Comparison.isGap(sequence[j]))
+ {
+ gaps.set(j);
+ }
+ j++;
+ }
+ return gaps;
+ }
+
@Override
public int[] findPositionMap()
{
@Override
public List<int[]> getInsertions()
{
- ArrayList<int[]> map = new ArrayList<int[]>();
+ ArrayList<int[]> map = new ArrayList<>();
int lastj = -1, j = 0;
int pos = start;
int seqlen = sequence.length;
{
if (this.annotation == null)
{
- this.annotation = new Vector<AlignmentAnnotation>();
+ this.annotation = new Vector<>();
}
if (!this.annotation.contains(annotation))
{
return null;
}
- Vector<AlignmentAnnotation> subset = new Vector<AlignmentAnnotation>();
+ Vector<AlignmentAnnotation> subset = new Vector<>();
Enumeration<AlignmentAnnotation> e = annotation.elements();
while (e.hasMoreElements())
{
public List<AlignmentAnnotation> getAlignmentAnnotations(String calcId,
String label)
{
- List<AlignmentAnnotation> result = new ArrayList<AlignmentAnnotation>();
+ List<AlignmentAnnotation> result = new ArrayList<>();
if (this.annotation != null)
{
for (AlignmentAnnotation ann : annotation)
}
synchronized (dbrefs)
{
- List<DBRefEntry> primaries = new ArrayList<DBRefEntry>();
+ List<DBRefEntry> primaries = new ArrayList<>();
DBRefEntry[] tmp = new DBRefEntry[1];
for (DBRefEntry ref : dbrefs)
{
return count;
}
+
+ @Override
+ public String getSequenceStringFromIterator(Iterator<int[]> it)
+ {
+ StringBuilder newSequence = new StringBuilder();
+ while (it.hasNext())
+ {
+ int[] block = it.next();
+ if (it.hasNext())
+ {
+ newSequence.append(getSequence(block[0], block[1] + 1));
+ }
+ else
+ {
+ newSequence.append(getSequence(block[0], block[1]));
+ }
+ }
+
+ return newSequence.toString();
+ }
+
+ @Override
+ public int firstResidueOutsideIterator(Iterator<int[]> regions)
+ {
+ int start = 0;
+
+ if (!regions.hasNext())
+ {
+ return findIndex(getStart()) - 1;
+ }
+
+ // Simply walk along the sequence whilst watching for region
+ // boundaries
+ int hideStart = getLength();
+ int hideEnd = -1;
+ boolean foundStart = false;
+
+ // step through the non-gapped positions of the sequence
+ for (int i = getStart(); i <= getEnd() && (!foundStart); i++)
+ {
+ // get alignment position of this residue in the sequence
+ int p = findIndex(i) - 1;
+
+ // update region start/end
+ while (hideEnd < p && regions.hasNext())
+ {
+ int[] region = regions.next();
+ hideStart = region[0];
+ hideEnd = region[1];
+ }
+ if (hideEnd < p)
+ {
+ hideStart = getLength();
+ }
+ // update boundary for sequence
+ if (p < hideStart)
+ {
+ start = p;
+ foundStart = true;
+ }
+ }
+
+ if (foundStart)
+ {
+ return start;
+ }
+ // otherwise, sequence was completely hidden
+ return 0;
+ }
}
{
if (consensus.annotations[i] != null)
{
- if (consensus.annotations[i].description.charAt(0) == '[')
+ String desc = consensus.annotations[i].description;
+ if (desc.length() > 1 && desc.charAt(0) == '[')
{
- seqs.append(consensus.annotations[i].description.charAt(1));
+ seqs.append(desc.charAt(1));
}
else
{
import jalview.datamodel.features.SequenceFeaturesI;
import java.util.BitSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Vector;
public int[] gapMap();
/**
+ * Build a bitset corresponding to sequence gaps
+ *
+ * @return a BitSet where set values correspond to gaps in the sequence
+ */
+ public BitSet gapBitset();
+
+ /**
* Returns an int array where indices correspond to each position in sequence
* char array and the element value gives the result of findPosition for that
* index in the sequence.
* @param c2
*/
public int replace(char c1, char c2);
+
+ /**
+ * Returns the sequence string constructed from the substrings of a sequence
+ * defined by the int[] ranges provided by an iterator. E.g. the iterator
+ * could iterate over all visible regions of the alignment
+ *
+ * @param it
+ * the iterator to use
+ * @return a String corresponding to the sequence
+ */
+ public String getSequenceStringFromIterator(Iterator<int[]> it);
+
+ /**
+ * Locate the first position in this sequence which is not contained in an
+ * iterator region. If no such position exists, return 0
+ *
+ * @param it
+ * iterator over regions
+ * @return first residue not contained in regions
+ */
+ public int firstResidueOutsideIterator(Iterator<int[]> it);
}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * An iterator which iterates over visible start positions of hidden column
+ * regions in a range.
+ */
+public class StartRegionIterator implements Iterator<Integer>
+{
+ // start position to iterate from
+ private int start;
+
+ // end position to iterate to
+ private int end;
+
+ // current index in hiddenColumns
+ private int currentPosition = 0;
+
+ // local copy or reference to hiddenColumns
+ private List<Integer> positions = null;
+
+ /**
+ * Construct an iterator over hiddenColums bounded at [lowerBound,upperBound]
+ *
+ * @param lowerBound
+ * lower bound to iterate from
+ * @param upperBound
+ * upper bound to iterate to
+ * @param useCopyCols
+ * whether to make a local copy of hiddenColumns for iteration (set
+ * to true if calling from outwith the HiddenColumns class)
+ */
+ StartRegionIterator(int lowerBound, int upperBound,
+ List<int[]> hiddenColumns)
+ {
+ this(null, lowerBound, upperBound, hiddenColumns);
+ }
+
+ /**
+ * Construct an iterator over hiddenColums bounded at [lowerBound,upperBound]
+ *
+ * @param pos
+ * a hidden cursor position to start from - may be null
+ * @param lowerBound
+ * lower bound to iterate from - will be ignored if pos != null
+ * @param upperBound
+ * upper bound to iterate to
+ * @param hiddenColumns
+ * the hidden columns collection to use
+ */
+ StartRegionIterator(HiddenCursorPosition pos, int lowerBound,
+ int upperBound, List<int[]> hiddenColumns)
+ {
+ start = lowerBound;
+ end = upperBound;
+
+ if (hiddenColumns != null)
+ {
+ positions = new ArrayList<>(hiddenColumns.size());
+
+ // navigate to start, keeping count of hidden columns
+ int i = 0;
+ int hiddenSoFar = 0;
+
+ if (pos != null)
+ {
+ // use the cursor position provided
+ i = pos.getRegionIndex();
+ hiddenSoFar = pos.getHiddenSoFar();
+ }
+ else
+ {
+ // navigate to start
+ while ((i < hiddenColumns.size())
+ && (hiddenColumns.get(i)[0] < start + hiddenSoFar))
+ {
+ int[] region = hiddenColumns.get(i);
+ hiddenSoFar += region[1] - region[0] + 1;
+ i++;
+ }
+ }
+
+ // iterate from start to end, adding start positions of each
+ // hidden region. Positions are visible columns count, not absolute
+ while (i < hiddenColumns.size()
+ && (hiddenColumns.get(i)[0] <= end + hiddenSoFar))
+ {
+ int[] region = hiddenColumns.get(i);
+ positions.add(region[0] - hiddenSoFar);
+ hiddenSoFar += region[1] - region[0] + 1;
+ i++;
+ }
+ }
+ else
+ {
+ positions = new ArrayList<>();
+ }
+
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return (currentPosition < positions.size());
+ }
+
+ /**
+ * Get next hidden region start position
+ *
+ * @return the start position in *visible* coordinates
+ */
+ @Override
+ public Integer next()
+ {
+ int result = positions.get(currentPosition);
+ currentPosition++;
+ return result;
+ }
+}
+
HiddenColumns hidden;
- public VisibleColsCollection(int s, int e, AlignmentI al)
+ public VisibleColsCollection(int s, int e, HiddenColumns h)
{
start = s;
end = e;
- hidden = al.getHiddenColumns();
+ hidden = h;
}
@Override
public Iterator<Integer> iterator()
{
- return new VisibleColsIterator(start, end, hidden);
+ return hidden.getVisibleColsIterator(start, end);
}
@Override
+++ /dev/null
-/*
- * 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.datamodel;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * An iterator which iterates over all visible columns in an alignment
- *
- * @author kmourao
- *
- */
-public class VisibleColsIterator implements Iterator<Integer>
-{
- private int last;
-
- private int current;
-
- private int next;
-
- private List<int[]> hidden;
-
- private int lasthiddenregion;
-
- public VisibleColsIterator(int firstcol, int lastcol,
- HiddenColumns hiddenCols)
- {
- last = lastcol;
- current = firstcol;
- next = firstcol;
- hidden = hiddenCols.getHiddenColumnsCopy();
- lasthiddenregion = -1;
-
- if (hidden != null)
- {
- int i = 0;
- for (i = 0; i < hidden.size(); ++i)
- {
- if (current >= hidden.get(i)[0] && current <= hidden.get(i)[1])
- {
- // current is hidden, move to right
- current = hidden.get(i)[1] + 1;
- next = current;
- }
- if (current < hidden.get(i)[0])
- {
- break;
- }
- }
- lasthiddenregion = i - 1;
-
- for (i = hidden.size() - 1; i >= 0; --i)
- {
- if (last >= hidden.get(i)[0] && last <= hidden.get(i)[1])
- {
- // last is hidden, move to left
- last = hidden.get(i)[0] - 1;
- }
- if (last > hidden.get(i)[1])
- {
- break;
- }
- }
- }
- }
-
- @Override
- public boolean hasNext()
- {
- return next <= last;
- }
-
- @Override
- public Integer next()
- {
- if (next > last)
- {
- throw new NoSuchElementException();
- }
- current = next;
- if ((hidden != null) && (lasthiddenregion + 1 < hidden.size()))
- {
- // still some more hidden regions
- if (next + 1 < hidden.get(lasthiddenregion + 1)[0])
- {
- // next+1 is still before the next hidden region
- next++;
- }
- else if ((next + 1 >= hidden.get(lasthiddenregion + 1)[0])
- && (next + 1 <= hidden.get(lasthiddenregion + 1)[1]))
- {
- // next + 1 is in the next hidden region
- next = hidden.get(lasthiddenregion + 1)[1] + 1;
- lasthiddenregion++;
- }
- }
- else
- {
- // finished with hidden regions, just increment normally
- next++;
- }
- return current;
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * An iterator which iterates over visible regions in a range. Provides a
+ * special "endsAtHidden" indicator to allow callers to determine if the final
+ * visible column is adjacent to a hidden region.
+ */
+public class VisibleContigsIterator implements Iterator<int[]>
+{
+ private List<int[]> vcontigs = new ArrayList<>();
+
+ private int currentPosition = 0;
+
+ private boolean endsAtHidden = false;
+
+ VisibleContigsIterator(int start, int end,
+ List<int[]> hiddenColumns)
+ {
+ if (hiddenColumns != null && hiddenColumns.size() > 0)
+ {
+ int vstart = start;
+ int hideStart;
+ int hideEnd;
+
+ for (int[] region : hiddenColumns)
+ {
+ endsAtHidden = false;
+ hideStart = region[0];
+ hideEnd = region[1];
+
+ // navigate to start
+ if (hideEnd < vstart)
+ {
+ continue;
+ }
+ if (hideStart > vstart)
+ {
+ if (end - 1 > hideStart - 1)
+ {
+ int[] contig = new int[] { vstart, hideStart - 1 };
+ vcontigs.add(contig);
+ endsAtHidden = true;
+ }
+ else
+ {
+ int[] contig = new int[] { vstart, end - 1 };
+ vcontigs.add(contig);
+ }
+ }
+ vstart = hideEnd + 1;
+
+ // exit if we're past the end
+ if (vstart >= end)
+ {
+ break;
+ }
+ }
+
+ if (vstart < end)
+ {
+ int[] contig = new int[] { vstart, end - 1 };
+ vcontigs.add(contig);
+ endsAtHidden = false;
+ }
+ }
+ else
+ {
+ int[] contig = new int[] { start, end - 1 };
+ vcontigs.add(contig);
+ }
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return (currentPosition < vcontigs.size());
+ }
+
+ @Override
+ public int[] next()
+ {
+ int[] result = vcontigs.get(currentPosition);
+ currentPosition++;
+ return result;
+ }
+
+ public boolean endsAtHidden()
+ {
+ return endsAtHidden;
+ }
+}
+
package jalview.ext.ensembl;
import jalview.bin.Cache;
+import jalview.datamodel.DBRefSource;
/**
* A class to behave much like EnsemblGene but referencing the ensemblgenomes
@Override
public String getDbName()
{
- return "EnsemblGenomes";
+ return DBRefSource.ENSEMBLGENOMES;
}
@Override
@Override
public String getDbSource()
{
- return "EnsemblGenomes";
+ return DBRefSource.ENSEMBLGENOMES;
}
}
*/
public class EnsemblLookup extends EnsemblRestClient
{
-
- private static final String OBJECT_TYPE_TRANSLATION = "Translation";
- private static final String PARENT = "Parent";
- private static final String OBJECT_TYPE_TRANSCRIPT = "Transcript";
- private static final String ID = "id";
- private static final String OBJECT_TYPE_GENE = "Gene";
- private static final String OBJECT_TYPE = "object_type";
-
- /**
- * keep track of last identifier retrieved to break loops
- */
- private String lastId;
-
/**
* Default constructor (to use rest.ensembl.org)
*/
}
/**
- * Calls the Ensembl lookup REST endpoint and retrieves the 'Parent' for the
- * given identifier, or null if not found
+ * Returns the gene id related to the given identifier (which may be for a
+ * gene, transcript or protein)
*
* @param identifier
* @param objectType
- * (optional)
* @return
*/
public String getGeneId(String identifier, String objectType)
BufferedReader br = null;
try
{
-
URL url = getUrl(identifier, objectType);
-
- if (identifier.equals(lastId))
- {
- System.err.println("** Ensembl lookup " + url.toString()
- + " looping on Parent!");
- return null;
- }
-
- lastId = identifier;
-
if (url != null)
{
br = getHttpResponse(url, ids);
lastCommand = command;
}
+ Thread colourby = null;
/**
* Sends a set of colour commands to the structure viewer
*
*/
@Override
protected void colourBySequence(
- StructureMappingcommandSet[] colourBySequenceCommands)
+ final StructureMappingcommandSet[] colourBySequenceCommands)
{
- for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands)
+ if (colourby != null)
{
- for (String cbyseq : cpdbbyseq.commands)
+ colourby.interrupt();
+ colourby = null;
+ }
+ colourby = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
{
- executeWhenReady(cbyseq);
+ for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands)
+ {
+ for (String cbyseq : cpdbbyseq.commands)
+ {
+ executeWhenReady(cbyseq);
+ }
+ }
}
- }
+ });
+ colourby.start();
}
/**
try
{
// recover PDB filename for the model hovered over.
- int _mp = _modelFileNameMap.length - 1,
- mnumber = new Integer(mdlId).intValue() - 1;
- while (mnumber < _modelFileNameMap[_mp])
+ int mnumber = new Integer(mdlId).intValue() - 1;
+ if (_modelFileNameMap != null)
{
- _mp--;
+ int _mp = _modelFileNameMap.length - 1;
+
+ while (mnumber < _modelFileNameMap[_mp])
+ {
+ _mp--;
+ }
+ pdbfilename = modelFileNames[_mp];
}
- pdbfilename = modelFileNames[_mp];
- if (pdbfilename == null)
+ else
{
- pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
- .getAbsolutePath();
- }
+ if (mnumber >= 0 && mnumber < modelFileNames.length)
+ {
+ pdbfilename = modelFileNames[mnumber];
+ }
+ if (pdbfilename == null)
+ {
+ pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
+ .getAbsolutePath();
+ }
+ }
} catch (Exception e)
{
}
import jalview.io.FileParse;
import jalview.io.StructureFile;
import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureImportSettings;
import jalview.util.Format;
import jalview.util.MessageManager;
{
Viewer viewer = null;
+ public JmolParser(boolean immediate, String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ super(immediate, inFile, sourceType);
+ }
+
public JmolParser(String inFile, DataSourceType sourceType)
throws IOException
{
}
lastID = tmpatom.resNumIns.trim();
}
- xferSettings();
+ if (isParseImmediately())
+ {
+ // configure parsing settings from the static singleton
+ xferSettings();
+ }
makeResidueList();
makeCaBondList();
prot.add(chainseq);
}
- if (StructureImportSettings.isProcessSecondaryStructure())
+ // look at local setting for adding secondary tructure
+ if (predictSecondaryStructure)
{
createAnnotation(chainseq, chain, ms.at);
}
public boolean equals(Object otherObject)
{
FTSDataColumnI that = (FTSDataColumnI) otherObject;
- return this.getCode().equals(that.getCode())
+ return otherObject == null ? false
+ : this.getCode().equals(that.getCode())
&& this.getName().equals(that.getName())
&& this.getGroup().equals(that.getGroup());
}
return;
}
- ArrayList<int[]> hiddenColumns = null;
+ HiddenColumns hiddenColumns = null;
if (viewport.hasHiddenColumns())
{
- hiddenColumns = new ArrayList<>();
int hiddenOffset = viewport.getSelectionGroup().getStartRes();
int hiddenCutoff = viewport.getSelectionGroup().getEndRes();
- ArrayList<int[]> hiddenRegions = viewport.getAlignment()
- .getHiddenColumns().getHiddenColumnsCopy();
- for (int[] region : hiddenRegions)
- {
- if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
- {
- hiddenColumns
- .add(new int[]
- { region[0] - hiddenOffset, region[1] - hiddenOffset });
- }
- }
+
+ // create new HiddenColumns object with copy of hidden regions
+ // between startRes and endRes, offset by startRes
+ hiddenColumns = new HiddenColumns(
+ viewport.getAlignment().getHiddenColumns(), hiddenOffset,
+ hiddenCutoff, hiddenOffset);
}
Desktop.jalviewClipboard = new Object[] { seqs,
if (Desktop.jalviewClipboard != null
&& Desktop.jalviewClipboard[2] != null)
{
- List<int[]> hc = (List<int[]>) Desktop.jalviewClipboard[2];
- for (int[] region : hc)
- {
- af.viewport.hideColumns(region[0], region[1]);
- }
+ HiddenColumns hc = (HiddenColumns) Desktop.jalviewClipboard[2];
+ af.viewport.setHiddenColumns(hc);
}
// >>>This is a fix for the moment, until a better solution is
if (Desktop.jalviewClipboard != null
&& Desktop.jalviewClipboard[2] != null)
{
- List<int[]> hc = (List<int[]>) Desktop.jalviewClipboard[2];
- for (int region[] : hc)
- {
- af.viewport.hideColumns(region[0], region[1]);
- }
+ HiddenColumns hc = (HiddenColumns) Desktop.jalviewClipboard[2];
+ af.viewport.setHiddenColumns(hc);
}
// >>>This is a fix for the moment, until a better solution is
int assocfiles = 0;
if (filesmatched.size() > 0)
{
- if (Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false)
- || JvOptionPane.showConfirmDialog(thisaf,
- MessageManager.formatMessage(
- "label.automatically_associate_structure_files_with_sequences_same_name",
- new Object[]
- { Integer.valueOf(filesmatched.size())
- .toString() }),
- MessageManager.getString(
- "label.automatically_associate_structure_files_by_name"),
- JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION)
-
+ boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
+ if (!autoAssociate)
+ {
+ String msg = MessageManager.formatMessage(
+ "label.automatically_associate_structure_files_with_sequences_same_name",
+ new Object[]
+ { Integer.valueOf(filesmatched.size())
+ .toString() });
+ String ttl = MessageManager.getString(
+ "label.automatically_associate_structure_files_by_name");
+ int choice = JvOptionPane.showConfirmDialog(thisaf, msg,
+ ttl, JvOptionPane.YES_NO_OPTION);
+ autoAssociate = choice == JvOptionPane.YES_OPTION;
+ }
+ if (autoAssociate)
{
for (Object[] fm : filesmatched)
{
alignPanel.paintAlignment(true, false);
}
}
+ else
+ {
+ /*
+ * add declined structures as sequences
+ */
+ for (Object[] o : filesmatched)
+ {
+ filesnotmatched.add((String) o[0]);
+ }
+ }
}
if (filesnotmatched.size() > 0)
{
new JnetAnnotationMaker();
JnetAnnotationMaker.add_annotation(predictions,
viewport.getAlignment(), 0, false);
- SequenceI repseq = viewport.getAlignment().getSequenceAt(0);
- viewport.getAlignment().setSeqrep(repseq);
- HiddenColumns cs = new HiddenColumns();
- cs.hideInsertionsFor(repseq);
- viewport.getAlignment().setHiddenColumns(cs);
+ viewport.getAlignment().setupJPredAlignment();
isAnnotation = true;
}
// else if (IdentifyFile.FeaturesFile.equals(format))
import jalview.analysis.AlignmentUtils;
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
-import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureColourI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
-import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import javax.swing.JInternalFrame;
* area
* @return
*/
- public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
+ public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
{
- int[] viscontigs = null;
- int start = 0, end = 0;
+ int start = 0;
+ int end = 0;
if (selectedRegionOnly && selectionGroup != null)
{
start = selectionGroup.getStartRes();
{
end = alignment.getWidth();
}
- viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
- return viscontigs;
+ return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
+ false));
}
/**
return validCharWidth;
}
- private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
+ private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
public AutoCalcSetting getCalcIdSettingsFor(String calcId)
{
if (av.hasHiddenColumns())
{
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- start = hidden.findColumnPosition(start);
- end = hidden.findColumnPosition(end);
+ start = hidden.absoluteToVisibleColumn(start);
+ end = hidden.absoluteToVisibleColumn(end);
if (start == end)
{
if (!hidden.isVisible(r[0]))
{
// reset the width to exclude hidden columns
width = av.getAlignment().getHiddenColumns()
- .findColumnPosition(width);
+ .absoluteToVisibleColumn(width);
}
hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int resWidth = getSeqPanel().seqCanvas
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth);
+ .absoluteToVisibleColumn(maxwidth);
}
int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight())
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int height = ((maxwidth / chunkWidth) + 1) * cHeight;
}
}
+ @Override
+ protected void sliderDragReleased()
+ {
+ super.sliderDragReleased();
+ ap.paintAlignment(true, true);
+ }
+
}
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Iterator;
import java.util.regex.Pattern;
import javax.swing.JCheckBoxMenuItem;
Alignment ds = new Alignment(dseqs);
if (av.hasHiddenColumns())
{
- omitHidden = av.getAlignment().getHiddenColumns()
- .getVisibleSequenceStrings(0, sq.getLength(), seqs);
+ Iterator<int[]> it = av.getAlignment().getHiddenColumns()
+ .getVisContigsIterator(0, sq.getLength(), false);
+ omitHidden = new String[] { sq.getSequenceStringFromIterator(it) };
}
int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 };
Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(new StringSelection(output), Desktop.instance);
- ArrayList<int[]> hiddenColumns = null;
+ HiddenColumns hiddenColumns = null;
if (av.hasHiddenColumns())
{
- hiddenColumns = av.getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy();
+ hiddenColumns = new HiddenColumns(
+ av.getAlignment().getHiddenColumns());
}
Desktop.jalviewClipboard = new Object[] { seqs, ds, // what is the dataset
if (e.isShiftDown())
{
e.consume();
- if (e.getWheelRotation() > 0)
+ double wheelRotation = e.getPreciseWheelRotation();
+ if (wheelRotation > 0)
{
av.getRanges().scrollRight(true);
}
- else
+ else if (wheelRotation < 0)
{
av.getRanges().scrollRight(false);
}
if (av.hasHiddenColumns())
{
column = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(column);
+ .visibleToAbsoluteColumn(column);
}
AlignmentAnnotation ann = aa[row];
{
this.setToolTipText(JvSwingUtils.wrapTooltip(true, description));
}
+ else
+ {
+ this.setToolTipText(null); // no tooltip if null or empty description
+ }
}
else
{
@Override
public void mouseReleased(MouseEvent evt)
{
- if (sliderDragging)
- {
- sliderDragging = false;
- valueChanged(true);
- }
+ sliderDragReleased();
}
});
}
{
this.annotations = anns;
}
+
+ protected void sliderDragReleased()
+ {
+ if (sliderDragging)
+ {
+ sliderDragging = false;
+ valueChanged(true);
+ }
+ }
}
import java.util.Vector;
import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
private static final String SPACE = " ";
- private static final String BACKSLASH = "\"";
+ private static final String QUOTE = "\"";
AppJmolBinding jmb;
{
return progressBar;
}
+
/**
- * add a single PDB structure to a new or existing Jmol view
+ * display a single PDB structure in a new Jmol view
*
* @param pdbentry
* @param seq
final AlignmentPanel ap)
{
progressBar = ap.alignFrame;
- String pdbId = pdbentry.getId();
- /*
- * If the PDB file is already loaded, the user may just choose to add to an
- * existing viewer (or cancel)
- */
- if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
- {
- return;
- }
-
- /*
- * Check if there are other Jmol views involving this alignment and prompt
- * user about adding this molecule to one of them
- */
- if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
- {
- return;
- }
-
- /*
- * If the options above are declined or do not apply, open a new viewer
- */
- openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
+ openNewJmol(ap, alignAddedStructures, new PDBEntry[] { pdbentry },
+ new SequenceI[][]
+ { seq });
}
- private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
+ private void openNewJmol(AlignmentPanel ap, boolean alignAdded,
+ PDBEntry[] pdbentrys,
SequenceI[][] seqs)
{
progressBar = ap.alignFrame;
addAlignmentPanel(ap);
useAlignmentPanelForColourbyseq(ap);
- if (pdbentrys.length > 1)
- {
- alignAddedStructures = true;
- useAlignmentPanelForSuperposition(ap);
- }
+ alignAddedStructures = alignAdded;
+ useAlignmentPanelForSuperposition(ap);
+
jmb.setColourBySequence(true);
setSize(400, 400); // probably should be a configurable/dynamic default here
initMenus();
}
/**
- * create a new Jmol containing several structures superimposed using the
- * given alignPanel.
+ * create a new Jmol containing several structures optionally superimposed
+ * using the given alignPanel.
*
* @param ap
+ * @param alignAdded
+ * - true to superimpose
* @param pe
* @param seqs
*/
- public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
+ public AppJmol(AlignmentPanel ap, boolean alignAdded, PDBEntry[] pe,
+ SequenceI[][] seqs)
{
- openNewJmol(ap, pe, seqs);
+ openNewJmol(ap, alignAdded, pe, seqs);
}
- /**
- * Returns a list of any Jmol viewers. The list is restricted to those linked
- * to the given alignment panel if it is not null.
- */
- @Override
- protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
- {
- List<StructureViewerBase> result = new ArrayList<>();
- JInternalFrame[] frames = Desktop.instance.getAllFrames();
-
- for (JInternalFrame frame : frames)
- {
- if (frame instanceof AppJmol)
- {
- if (apanel == null
- || ((StructureViewerBase) frame).isLinkedWith(apanel))
- {
- result.add((StructureViewerBase) frame);
- }
- }
- }
- return result;
- }
void initJmol(String command)
{
jmb.setFinishedInit(true);
}
- boolean allChainsSelected = false;
-
@Override
void showSelectedChains()
{
StringBuilder fileList = new StringBuilder();
for (String s : files)
{
- fileList.append(SPACE).append(BACKSLASH)
- .append(Platform.escapeString(s)).append(BACKSLASH);
+ fileList.append(SPACE).append(QUOTE)
+ .append(Platform.escapeString(s)).append(QUOTE);
}
String filesString = fileList.toString();
jmb.updateColours(ap);
}
// do superposition if asked to
- if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
+ if (alignAddedStructures)
{
alignAddedStructures();
}
}
}
});
- alignAddedStructures = false;
+
}
/**
String file = jmb.getPdbEntry(pi).getFile();
if (file == null)
{
+ // todo: extract block as method and pull up (also ChimeraViewFrame)
// retrieve the pdb and store it locally
AlignmentI pdbseq = null;
pdbid = jmb.getPdbEntry(pi).getId();
* around to the bottom of the window stack (as the original implementation
* does)
*
- * @see com.sun.java.swing.plaf.windows.WindowsDesktopManager
+ * see com.sun.java.swing.plaf.windows.WindowsDesktopManager
*/
public class AquaInternalFrameManager extends DefaultDesktopManager
{
savemenu.setVisible(false); // not yet implemented
viewMenu.add(fitToWindow);
- /*
- * exchange of Jalview features and Chimera attributes is for now
- * an optionally enabled experimental feature
- */
- if (Desktop.instance.showExperimental())
+ JMenuItem writeFeatures = new JMenuItem(
+ MessageManager.getString("label.create_chimera_attributes"));
+ writeFeatures.setToolTipText(MessageManager
+ .getString("label.create_chimera_attributes_tip"));
+ writeFeatures.addActionListener(new ActionListener()
{
- JMenuItem writeFeatures = new JMenuItem(
- MessageManager.getString("label.create_chimera_attributes"));
- writeFeatures.setToolTipText(MessageManager
- .getString("label.create_chimera_attributes_tip"));
- writeFeatures.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- sendFeaturesToChimera();
- }
- });
- viewerActionMenu.add(writeFeatures);
-
- final JMenu fetchAttributes = new JMenu(
- MessageManager.getString("label.fetch_chimera_attributes"));
- fetchAttributes.setToolTipText(MessageManager
- .getString("label.fetch_chimera_attributes_tip"));
- fetchAttributes.addMouseListener(new MouseAdapter()
+ @Override
+ public void actionPerformed(ActionEvent e)
{
+ sendFeaturesToChimera();
+ }
+ });
+ viewerActionMenu.add(writeFeatures);
- @Override
- public void mouseEntered(MouseEvent e)
- {
- buildAttributesMenu(fetchAttributes);
- }
- });
- viewerActionMenu.add(fetchAttributes);
- }
+ final JMenu fetchAttributes = new JMenu(
+ MessageManager.getString("label.fetch_chimera_attributes"));
+ fetchAttributes.setToolTipText(
+ MessageManager.getString("label.fetch_chimera_attributes_tip"));
+ fetchAttributes.addMouseListener(new MouseAdapter()
+ {
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ buildAttributesMenu(fetchAttributes);
+ }
+ });
+ viewerActionMenu.add(fetchAttributes);
}
/**
}
/**
- * add a single PDB structure to a new or existing Chimera view
+ * open a single PDB structure in a new Chimera view
*
* @param pdbentry
* @param seq
String[] chains, final AlignmentPanel ap)
{
this();
- String pdbId = pdbentry.getId();
-
- /*
- * If the PDB file is already loaded, the user may just choose to add to an
- * existing viewer (or cancel)
- */
- if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
- {
- return;
- }
- /*
- * Check if there are other Chimera views involving this alignment and give
- * user the option to add and align this molecule to one of them (or cancel)
- */
- if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
- {
- return;
- }
-
- /*
- * If the options above are declined or do not apply, show the structure in
- * a new viewer
- */
openNewChimera(ap, new PDBEntry[] { pdbentry },
new SequenceI[][]
{ seq });
if (pdbentrys.length > 1)
{
- alignAddedStructures = true;
useAlignmentPanelForSuperposition(ap);
}
jmb.setColourBySequence(true);
}
/**
- * create a new viewer containing several structures superimposed using the
- * given alignPanel.
+ * create a new viewer containing several structures, optionally superimposed
+ * using the given alignPanel.
*
* @param pe
* @param seqs
* @param ap
*/
- public ChimeraViewFrame(PDBEntry[] pe, SequenceI[][] seqs,
+ public ChimeraViewFrame(PDBEntry[] pe, boolean alignAdded,
+ SequenceI[][] seqs,
AlignmentPanel ap)
{
this();
+ setAlignAddedStructures(alignAdded);
openNewChimera(ap, pe, seqs);
}
}
/**
- * Returns a list of any Chimera viewers in the desktop. The list is
- * restricted to those linked to the given alignment panel if it is not null.
- */
- @Override
- protected List<StructureViewerBase> getViewersFor(AlignmentPanel ap)
- {
- List<StructureViewerBase> result = new ArrayList<>();
- JInternalFrame[] frames = Desktop.instance.getAllFrames();
-
- for (JInternalFrame frame : frames)
- {
- if (frame instanceof ChimeraViewFrame)
- {
- if (ap == null || ((StructureViewerBase) frame).isLinkedWith(ap))
- {
- result.add((StructureViewerBase) frame);
- }
- }
- }
- return result;
- }
-
- /**
* Launch Chimera. If we have a chimera session file name, send Chimera the
* command to open its saved session file.
*/
jmb.updateColours(ap);
}
// do superposition if asked to
- if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
+ if (alignAddedStructures)
{
new Thread(new Runnable()
{
alignStructs_withAllAlignPanels();
}
}).start();
- alignAddedStructures = false;
}
addingStructures = false;
}
private String fetchPdbFile(PDBEntry processingEntry) throws Exception
{
- // FIXME: this is duplicated code with Jmol frame ?
String filePath = null;
Pdb pdbclient = new Pdb();
AlignmentI pdbseq = null;
{
Cache.setProperty(EXPERIMENTAL_FEATURES, Boolean.toString(selected));
}
+
+ /**
+ * Answers a (possibly empty) list of any structure viewer frames (currently
+ * for either Jmol or Chimera) which are currently open. This may optionally
+ * be restricted to viewers of a specified class, or viewers linked to a
+ * specified alignment panel.
+ *
+ * @param apanel
+ * if not null, only return viewers linked to this panel
+ * @param structureViewerClass
+ * if not null, only return viewers of this class
+ * @return
+ */
+ public List<StructureViewerBase> getStructureViewers(
+ AlignmentPanel apanel,
+ Class<? extends StructureViewerBase> structureViewerClass)
+ {
+ List<StructureViewerBase> result = new ArrayList<>();
+ JInternalFrame[] frames = Desktop.instance.getAllFrames();
+
+ for (JInternalFrame frame : frames)
+ {
+ if (frame instanceof StructureViewerBase)
+ {
+ if (structureViewerClass == null
+ || structureViewerClass.isInstance(frame))
+ {
+ if (apanel == null
+ || ((StructureViewerBase) frame).isLinkedWith(apanel))
+ {
+ result.add((StructureViewerBase) frame);
+ }
+ }
+ }
+ }
+ return result;
+ }
}
public void invertSelection()
{
- for (int i = 0; i < table.getRowCount(); i++)
+ Object[][] data = ((FeatureTableModel) table.getModel()).getData();
+ for (int i = 0; i < data.length; i++)
{
- Boolean value = (Boolean) table.getValueAt(i, 2);
-
- table.setValueAt(new Boolean(!value.booleanValue()), i, 2);
+ data[i][2] = !(Boolean) data[i][2];
}
+ updateFeatureRenderer(data, true);
+ table.repaint();
}
public void orderByAvWidth()
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth) - 1;
+ .absoluteToVisibleColumn(maxwidth) - 1;
}
int annotationHeight = 0;
public void mouseWheelMoved(MouseWheelEvent e)
{
e.consume();
- if (e.getWheelRotation() > 0)
+ double wheelRotation = e.getPreciseWheelRotation();
+ if (wheelRotation > 0)
{
if (e.isShiftDown())
{
av.getRanges().scrollUp(false);
}
}
- else
+ else if (wheelRotation < 0)
{
if (e.isShiftDown())
{
* identical DB sources, and should be collapsed.
*/
DefaultMutableTreeNode tn = null, root = new DefaultMutableTreeNode();
- Hashtable<String, DefaultMutableTreeNode> source = new Hashtable<String, DefaultMutableTreeNode>();
+ Hashtable<String, DefaultMutableTreeNode> source = new Hashtable<>();
sfetcher = sfetch;
String dbs[] = sfetch.getSupportedDb();
- Hashtable<String, String> ht = new Hashtable<String, String>();
+ Hashtable<String, String> ht = new Hashtable<>();
for (int i = 0; i < dbs.length; i++)
{
tn = source.get(dbs[i]);
tsel = dbviews.getSelectionPaths();
boolean forcedFirstChild = false;
- List<DbSourceProxy> srcs = new ArrayList<DbSourceProxy>();
+ List<DbSourceProxy> srcs = new ArrayList<>();
if (tsel != null)
{
for (TreePath tp : tsel)
return null;
}
StringBuffer sb = new StringBuffer();
- HashSet<String> hs = new HashSet<String>();
+ HashSet<String> hs = new HashSet<>();
for (DbSourceProxy dbs : getSelectedSources())
{
String tq = dbs.getTestQuery();
return sb.toString();
}
- List<ActionListener> lstners = new Vector<ActionListener>();
+ List<ActionListener> lstners = new Vector<>();
public void addActionListener(ActionListener actionListener)
{
// TODO Auto-generated method stub
}
+
+ @Override
+ public void setVisible(boolean arg0)
+ {
+ System.out.println("setVisible: " + arg0);
+ super.setVisible(arg0);
+ }
}
}
else
{
- ArrayList<int[]> hiddenRegions = hidden.getHiddenColumnsCopy();
- for (int[] region : hiddenRegions)
+ Iterator<int[]> hiddenRegions = hidden.iterator();
+ while (hiddenRegions.hasNext())
{
+ int[] region = hiddenRegions.next();
HiddenColumns hc = new HiddenColumns();
hc.setStart(region[0]);
hc.setEnd(region[1]);
{
mg.translate(0, od.getSequencesHeight());
or.drawGraph(mg, av.getAlignmentConservationAnnotation(),
- av.getCharWidth(), od.getGraphHeight(),
- od.getColumns(av.getAlignment()));
+ od.getGraphHeight(), od.getColumns(av.getAlignment()));
mg.translate(0, -od.getSequencesHeight());
}
System.gc();
protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
{
-
- HiddenColumns hidden = new HiddenColumns();
- BitSet inserts = new BitSet(), mask = new BitSet();
-
- // set mask to preserve existing hidden columns outside selected group
- if (ap.av.hasHiddenColumns())
- {
- ap.av.getAlignment().getHiddenColumns().markHiddenRegions(mask);
- }
+ HiddenColumns hidden = ap.av.getAlignment().getHiddenColumns();
+ BitSet inserts = new BitSet();
boolean markedPopup = false;
// mark inserts in current selection
{
// mark just the columns in the selection group to be hidden
inserts.set(ap.av.getSelectionGroup().getStartRes(),
- ap.av.getSelectionGroup().getEndRes() + 1);
-
- // and clear that part of the mask
- mask.andNot(inserts);
+ ap.av.getSelectionGroup().getEndRes() + 1); // TODO why +1?
// now clear columns without gaps
for (SequenceI sq : ap.av.getSelectionGroup().getSequences())
}
inserts.and(sq.getInsertionsAsBits());
}
- }
- else
- {
- // initially, mark all columns to be hidden
- inserts.set(0, ap.av.getAlignment().getWidth());
-
- // and clear out old hidden regions completely
- mask.clear();
+ hidden.clearAndHideColumns(inserts, ap.av.getSelectionGroup().getStartRes(),
+ ap.av.getSelectionGroup().getEndRes());
}
// now mark for sequence under popup if we haven't already done it
- if (!markedPopup && sequence != null)
+ else if (!markedPopup && sequence != null)
{
- inserts.and(sequence.getInsertionsAsBits());
- }
+ inserts.or(sequence.getInsertionsAsBits());
- // finally, preserve hidden regions outside selection
- inserts.or(mask);
-
- // and set hidden columns accordingly
- hidden.hideMarkedBits(inserts);
-
- ap.av.getAlignment().setHiddenColumns(hidden);
+ // and set hidden columns accordingly
+ hidden.hideColumns(inserts);
+ }
refresh();
}
autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
userIdWidth.setEnabled(!autoIdWidth.isSelected());
userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
- Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
+ Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");
userIdWidth.setText(wi == null ? "" : wi.toString());
// TODO: refactor to use common enum via FormatAdapter and allow extension
// for new flat file formats
Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
Boolean.toString(autoIdWidth.isSelected()));
userIdWidth_actionPerformed();
- Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
+ Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
userIdWidth.getText());
/*
boolean applyToAllViews = false;
- // Controller controller;
public RotatableCanvas(AlignmentPanel ap)
{
this.av = ap.av;
addMouseWheelListener(new MouseWheelListener()
{
+ @Override
public void mouseWheelMoved(MouseWheelEvent e)
{
- if (e.getWheelRotation() > 0)
+ double wheelRotation = e.getPreciseWheelRotation();
+ if (wheelRotation > 0)
{
+ /*
+ * zoom in
+ */
scale = (float) (scale * 1.1);
repaint();
}
-
- else
+ else if (wheelRotation < 0)
{
+ /*
+ * zoom out
+ */
scale = (float) (scale * 0.9);
repaint();
}
boolean first = true;
+ @Override
public void setPoints(Vector points, int npoint)
{
this.points = points;
dim = height;
}
- return (float) ((dim * scalefactor) / (2 * maxwidth));
+ return (dim * scalefactor) / (2 * maxwidth);
}
/**
*
* @return DOCUMENT ME!
*/
+ @Override
public Dimension getPreferredSize()
{
if (prefsize != null)
*
* @return DOCUMENT ME!
*/
+ @Override
public Dimension getMinimumSize()
{
return getPreferredSize();
* @param g
* DOCUMENT ME!
*/
+ @Override
public void paintComponent(Graphics g1)
{
for (int i = 0; i < npoint; i++)
{
SequencePoint sp = (SequencePoint) points.elementAt(i);
- int x = (int) ((float) (sp.coord[0] - centre[0]) * scale) + halfwidth;
- int y = (int) ((float) (sp.coord[1] - centre[1]) * scale)
+ int x = (int) ((sp.coord[0] - centre[0]) * scale) + halfwidth;
+ int y = (int) ((sp.coord[1] - centre[1]) * scale)
+ halfheight;
float z = sp.coord[1] - centre[2];
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void keyTyped(KeyEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void keyReleased(KeyEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void keyPressed(KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_UP)
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseClicked(MouseEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseEntered(MouseEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseExited(MouseEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseReleased(MouseEvent evt)
{
}
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mousePressed(MouseEvent evt)
{
int x = evt.getX();
// controller.handleSequenceSelectionEvent(new
// SequenceSelectionEvent(this,sel));
// }
+ @Override
public void mouseMoved(MouseEvent evt)
{
SequenceI found = findPoint(evt.getX(), evt.getY());
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseDragged(MouseEvent evt)
{
mx = evt.getX();
{
rotmat.setIdentity();
- rotmat.rotate((float) (my - omy), 'x');
- rotmat.rotate((float) (mx - omx), 'y');
+ rotmat.rotate(my - omy, 'x');
+ rotmat.rotate(mx - omx, 'y');
for (int i = 0; i < npoint; i++)
{
{
SequencePoint sp = (SequencePoint) points.elementAt(i);
int tmp1 = (int) (((sp.coord[0] - centre[0]) * scale)
- + ((float) getWidth() / 2.0));
+ + (getWidth() / 2.0));
int tmp2 = (int) (((sp.coord[1] - centre[1]) * scale)
- + ((float) getHeight() / 2.0));
+ + (getHeight() / 2.0));
if ((tmp1 > x1) && (tmp1 < x2) && (tmp2 > y1) && (tmp2 < y2))
{
for (int i = 0; i < npoint; i++)
{
SequencePoint sp = (SequencePoint) points.elementAt(i);
- int px = (int) ((float) (sp.coord[0] - centre[0]) * scale)
+ int px = (int) ((sp.coord[0] - centre[0]) * scale)
+ halfwidth;
- int py = (int) ((float) (sp.coord[1] - centre[1]) * scale)
+ int py = (int) ((sp.coord[1] - centre[1]) * scale)
+ halfheight;
if ((Math.abs(px - x) < 3) && (Math.abs(py - y) < 3))
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
+import java.util.Iterator;
import java.util.List;
import javax.swing.JMenuItem;
if (av.hasHiddenColumns())
{
- x = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x);
+ x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
}
if (x >= av.getAlignment().getWidth())
});
pop.add(item);
- if (av.getAlignment().getHiddenColumns().hasHiddenColumns())
+ if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions())
{
item = new JMenuItem(MessageManager.getString("action.reveal_all"));
item.addActionListener(new ActionListener()
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
if (res >= av.getAlignment().getWidth())
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
res = Math.max(0, res);
- res = hidden.adjustForHiddenColumns(res);
+ res = hidden.visibleToAbsoluteColumn(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
reveal = av.getAlignment().getHiddenColumns()
.getRegionWithEdgeAtRes(res);
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res);
ToolTipManager.sharedInstance().registerComponent(this);
this.setToolTipText(
{
if (hidden.isVisible(sel))
{
- sel = hidden.findColumnPosition(sel);
+ sel = hidden.absoluteToVisibleColumn(sel);
}
else
{
if (av.getShowHiddenMarkers())
{
- List<Integer> positions = hidden.findHiddenRegionPositions();
- for (int pos : positions)
+ Iterator<Integer> it = hidden.getStartRegionIterator(startx,
+ startx + widthx + 1);
+ while (it.hasNext())
{
- res = pos - startx;
-
- if (res < 0 || res > widthx)
- {
- continue;
- }
+ res = it.next() - startx;
gg.fillPolygon(
new int[]
- { -1 + res * avCharWidth - avCharHeight / 4,
- -1 + res * avCharWidth + avCharHeight / 4,
- -1 + res * avCharWidth },
- new int[]
- { y, y, y + 2 * yOf }, 3);
+ { -1 + res * avCharWidth - avCharHeight / 4,
+ -1 + res * avCharWidth + avCharHeight / 4,
+ -1 + res * avCharWidth }, new int[]
+ { y, y, y + 2 * yOf }, 3);
}
}
}
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.VisibleContigsIterator;
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.util.Comparison;
import java.awt.Shape;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
+import java.util.Iterator;
import java.util.List;
import javax.swing.JComponent;
if (av.hasHiddenColumns())
{
HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns();
- startX = hiddenColumns.adjustForHiddenColumns(startx);
- endX = hiddenColumns.adjustForHiddenColumns(endx);
+ startX = hiddenColumns.visibleToAbsoluteColumn(startx);
+ endX = hiddenColumns.visibleToAbsoluteColumn(endx);
}
FontMetrics fm = getFontMetrics(av.getFont());
int charWidth = av.getCharWidth();
g.setColor(Color.blue);
+ int res;
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- List<Integer> positions = hidden.findHiddenRegionPositions();
- for (int pos : positions)
+
+ Iterator<Integer> it = hidden.getStartRegionIterator(startColumn,
+ endColumn);
+ while (it.hasNext())
{
- int res = pos - startColumn;
+ res = it.next() - startColumn;
if (res < 0 || res > endColumn - startColumn + 1)
{
if (av.hasHiddenColumns())
{
maxwidth = av.getAlignment().getHiddenColumns()
- .findColumnPosition(maxwidth);
+ .absoluteToVisibleColumn(maxwidth);
}
// chop the wrapped alignment extent up into panel-sized blocks and treat
else
{
int screenY = 0;
- final int screenYMax = endRes - startRes;
- int blockStart = startRes;
- int blockEnd = endRes;
+ int blockStart;
+ int blockEnd;
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy())
- {
- int hideStart = region[0];
- int hideEnd = region[1];
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ VisibleContigsIterator regions = hidden
+ .getVisContigsIterator(startRes, endRes + 1, true);
- if (hideStart <= blockStart)
- {
- blockStart += (hideEnd - hideStart) + 1;
- continue;
- }
+ while (regions.hasNext())
+ {
+ int[] region = regions.next();
+ blockEnd = region[1];
+ blockStart = region[0];
/*
* draw up to just before the next hidden region, or the end of
* the visible region, whichever comes first
*/
- blockEnd = Math.min(hideStart - 1, blockStart + screenYMax
- - screenY);
-
g1.translate(screenY * charWidth, 0);
draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset);
* draw the downline of the hidden column marker (ScalePanel draws the
* triangle on top) if we reached it
*/
- if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1)
+ if (av.getShowHiddenMarkers()
+ && (regions.hasNext() || regions.endsAtHidden()))
{
g1.setColor(Color.blue);
g1.translate(-screenY * charWidth, 0);
screenY += blockEnd - blockStart + 1;
- blockStart = hideEnd + 1;
-
- if (screenY > screenYMax)
- {
- // already rendered last block
- return;
- }
- }
-
- if (screenY <= screenYMax)
- {
- // remaining visible region to render
- blockEnd = blockStart + screenYMax - screenY;
- g1.translate(screenY * charWidth, 0);
- draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset);
-
- g1.translate(-screenY * charWidth, 0);
}
}
// convert the cursorX into a position on the visible alignment
int cursor_xpos = av.getAlignment().getHiddenColumns()
- .findColumnPosition(cursorX);
+ .absoluteToVisibleColumn(cursorX);
if (av.getAlignment().getHiddenColumns().isVisible(cursorX))
{
{
// package into blocks of visible columns
int screenY = 0;
- int blockStart = startRes;
- int blockEnd = endRes;
+ int blockStart;
+ int blockEnd;
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy())
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ VisibleContigsIterator regions = hidden
+ .getVisContigsIterator(startRes, endRes + 1, true);
+ while (regions.hasNext())
{
- int hideStart = region[0];
- int hideEnd = region[1];
-
- if (hideStart <= blockStart)
- {
- blockStart += (hideEnd - hideStart) + 1;
- continue;
- }
-
- blockEnd = hideStart - 1;
+ int[] region = regions.next();
+ blockEnd = region[1];
+ blockStart = region[0];
g.translate(screenY * charWidth, 0);
drawPartialGroupOutline(g, group,
g.translate(-screenY * charWidth, 0);
screenY += blockEnd - blockStart + 1;
- blockStart = hideEnd + 1;
-
- if (screenY > (endRes - startRes))
- {
- // already rendered last block
- break;
- }
- }
-
- if (screenY <= (endRes - startRes))
- {
- // remaining visible region to render
- blockEnd = blockStart + (endRes - startRes) - screenY;
- g.translate(screenY * charWidth, 0);
- drawPartialGroupOutline(g, group,
- blockStart, blockEnd, startSeq, endSeq, offset);
-
- g.translate(-screenY * charWidth, 0);
}
}
}
if (av.hasHiddenColumns())
{
firstVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(firstVisibleColumn);
+ .visibleToAbsoluteColumn(firstVisibleColumn);
lastVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(lastVisibleColumn);
+ .visibleToAbsoluteColumn(lastVisibleColumn);
}
for (int seqNo = ranges.getStartSeq(); seqNo <= ranges
if (av.hasHiddenColumns())
{
firstCol = alignment.getHiddenColumns()
- .findColumnPosition(firstCol);
- lastCol = alignment.getHiddenColumns().findColumnPosition(lastCol);
+ .absoluteToVisibleColumn(firstCol);
+ lastCol = alignment.getHiddenColumns().absoluteToVisibleColumn(lastCol);
}
int transX = (firstCol - ranges.getStartRes()) * av.getCharWidth();
int transY = (firstSeq - ranges.getStartSeq()) * av.getCharHeight();
scrollX = -range;
}
}
- // Both scrolling and resizing change viewport ranges: scrolling changes
- // both start and end points, but resize only changes end values.
- // Here we only want to fastpaint on a scroll, with resize using a normal
- // paint, so scroll events are identified as changes to the horizontal or
- // vertical start value.
- if (eventName.equals(ViewportRanges.STARTRES))
- {
- if (av.getWrapAlignment())
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (eventName.equals(ViewportRanges.STARTRES))
+ {
+ if (av.getWrapAlignment())
+ {
+ fastPaintWrapped(scrollX);
+ }
+ else
+ {
+ fastPaint(scrollX, 0);
+ }
+ }
+ else if (eventName.equals(ViewportRanges.STARTSEQ))
+ {
+ // scroll
+ fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
+ }
+ else if (eventName.equals(ViewportRanges.STARTRESANDSEQ))
+ {
+ if (av.getWrapAlignment())
{
fastPaintWrapped(scrollX);
}
{
fastPaintWrapped(scrollX);
}
- else
- {
- fastPaint(scrollX, 0);
- }
- // bizarrely, we only need to scroll on the x value here as fastpaint
- // copies the full height of the image anyway. Passing in the y value
- // causes nasty repaint artefacts, which only disappear on a full
- // repaint.
}
}
if (av.hasHiddenColumns())
{
firstVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(firstVisibleColumn);
+ .visibleToAbsoluteColumn(firstVisibleColumn);
lastVisibleColumn = alignment.getHiddenColumns()
- .adjustForHiddenColumns(lastVisibleColumn);
+ .visibleToAbsoluteColumn(lastVisibleColumn);
}
int gapHeight = charHeight * (av.getScaleAboveWrapped() ? 2 : 1);
if (av.hasHiddenColumns())
{
displayColumn = alignment.getHiddenColumns()
- .findColumnPosition(displayColumn);
+ .absoluteToVisibleColumn(displayColumn);
}
/*
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(res);
+ .visibleToAbsoluteColumn(res);
}
return res;
int original = seqCanvas.cursorX - dx;
int maxWidth = av.getAlignment().getWidth();
- // TODO: once JAL-2759 is ready, change this loop to something more
- // efficient
- while (!hidden.isVisible(seqCanvas.cursorX)
- && seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0
- && dx != 0)
+ if (!hidden.isVisible(seqCanvas.cursorX))
{
- seqCanvas.cursorX += dx;
+ int visx = hidden.absoluteToVisibleColumn(seqCanvas.cursorX - dx);
+ int[] region = hidden.getRegionWithEdgeAtRes(visx);
+
+ if (region != null) // just in case
+ {
+ if (dx == 1)
+ {
+ // moving right
+ seqCanvas.cursorX = region[1] + 1;
+ }
+ else if (dx == -1)
+ {
+ // moving left
+ seqCanvas.cursorX = region[0] - 1;
+ }
+ }
+ seqCanvas.cursorX = (seqCanvas.cursorX < 0) ? 0 : seqCanvas.cursorX;
}
if (seqCanvas.cursorX >= maxWidth
{
// scrollToWrappedVisible expects x-value to have hidden cols subtracted
int x = av.getAlignment().getHiddenColumns()
- .findColumnPosition(seqCanvas.cursorX);
+ .absoluteToVisibleColumn(seqCanvas.cursorX);
av.getRanges().scrollToWrappedVisible(x);
}
else
{
fixedColumns = true;
int y1 = av.getAlignment().getHiddenColumns()
- .getHiddenBoundaryLeft(startres);
+ .getNextHiddenBoundary(true, startres);
int y2 = av.getAlignment().getHiddenColumns()
- .getHiddenBoundaryRight(startres);
+ .getNextHiddenBoundary(false, startres);
if ((insertGap && startres > y1 && lastres < y1)
|| (!insertGap && startres < y2 && lastres > y2))
if (sg.getSize() == av.getAlignment().getHeight())
{
if ((av.hasHiddenColumns() && startres < av.getAlignment()
- .getHiddenColumns().getHiddenBoundaryRight(startres)))
+ .getHiddenColumns()
+ .getNextHiddenBoundary(false, startres)))
{
endEditing();
return;
public void mouseWheelMoved(MouseWheelEvent e)
{
e.consume();
- if (e.getWheelRotation() > 0)
+ double wheelRotation = e.getPreciseWheelRotation();
+ if (wheelRotation > 0)
{
if (e.isShiftDown())
{
av.getRanges().scrollUp(false);
}
}
- else
+ else if (wheelRotation < 0)
{
if (e.isShiftDown())
{
return true;
}
+
+ /**
+ *
+ * @return null or last search results handled by this panel
+ */
+ public SearchResultsI getLastSearchResults()
+ {
+ return lastSearchResults;
+ }
}
return Collections.emptyList();
}
}
- sf.newAlframes = new ArrayList<AlignFrame>();
+ sf.newAlframes = new ArrayList<>();
sf.run();
return sf.newAlframes;
}
// TODO: Refactor to GUI independent code and write tests.
// indicate if successive sources should be merged into one alignment.
boolean addToLast = false;
- List<String> aresultq = new ArrayList<String>();
- List<String> presultTitle = new ArrayList<String>();
- List<AlignmentI> presult = new ArrayList<AlignmentI>();
- List<AlignmentI> aresult = new ArrayList<AlignmentI>();
+ List<String> aresultq = new ArrayList<>();
+ List<String> presultTitle = new ArrayList<>();
+ List<AlignmentI> presult = new ArrayList<>();
+ List<AlignmentI> aresult = new ArrayList<>();
Iterator<DbSourceProxy> proxies = database.getSelectedSources()
.iterator();
String[] qries;
nqueries = nextFetch.size();
// save the remaining queries in the original array
qries = nextFetch.toArray(new String[nqueries]);
- nextFetch = new ArrayList<String>();
+ nextFetch = new ArrayList<>();
}
DbSourceProxy proxy = proxies.next();
List<AlignmentI> aresult, List<String> nextFetch) throws Exception
{
StringBuilder multiacc = new StringBuilder();
- List<String> tosend = new ArrayList<String>();
+ List<String> tosend = new ArrayList<>();
while (accessions.hasNext())
{
String nel = accessions.next();
package jalview.gui;
import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
public class StructureChooser extends GStructureChooser
implements IProgressIndicator
{
+ private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
+
private static int MAX_QLENGTH = 7820;
private SequenceI selectedSequence;
private boolean cachedPDBExists;
+ private static StructureViewer lastTargetedView = null;
+
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
{
/**
* Initializes parameters used by the Structure Chooser Panel
*/
- public void init()
+ protected void init()
{
if (!Jalview.isHeadlessMode())
{
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
}
+ chk_superpose.setSelected(Cache.getDefault(AUTOSUPERIMPOSE, true));
+
// ensure a filter option is in force for search
populateFilterComboBox(true, cachedPDBExists);
Thread discoverPDBStructuresThread = new Thread(new Runnable()
fetchStructuresMetaData();
// revise filter options if no results were found
populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists);
+ discoverStructureViews();
updateProgressIndicator(null, startTime);
mainFrame.setVisible(true);
updateCurrentView();
}
/**
+ * Builds a drop-down choice list of existing structure viewers to which new
+ * structures may be added. If this list is empty then it, and the 'Add'
+ * button, are hidden.
+ */
+ private void discoverStructureViews()
+ {
+ if (Desktop.instance != null)
+ {
+ targetView.removeAllItems();
+ if (lastTargetedView != null && !lastTargetedView.isVisible())
+ {
+ lastTargetedView = null;
+ }
+ int linkedViewsAt = 0;
+ for (StructureViewerBase view : Desktop.instance
+ .getStructureViewers(null, null))
+ {
+ StructureViewer viewHandler = (lastTargetedView != null
+ && lastTargetedView.sview == view) ? lastTargetedView
+ : StructureViewer.reconfigure(view);
+
+ if (view.isLinkedWith(ap))
+ {
+ targetView.insertItemAt(viewHandler,
+ linkedViewsAt++);
+ }
+ else
+ {
+ targetView.addItem(viewHandler);
+ }
+ }
+
+ /*
+ * show option to Add to viewer if at least 1 viewer found
+ */
+ targetView.setVisible(false);
+ if (targetView.getItemCount() > 0)
+ {
+ targetView.setVisible(true);
+ if (lastTargetedView != null)
+ {
+ targetView.setSelectedItem(lastTargetedView);
+ }
+ else
+ {
+ targetView.setSelectedIndex(0);
+ }
+ }
+ btn_add.setVisible(targetView.isVisible());
+ }
+ }
+
+ /**
* Updates the progress indicator with the specified message
*
* @param message
* @param id
* unique handle for this indicator
*/
- public void updateProgressIndicator(String message, long id)
+ protected void updateProgressIndicator(String message, long id)
{
if (progressIndicator != null)
{
* Retrieve meta-data for all the structure(s) for a given sequence(s) in a
* selection group
*/
- public void fetchStructuresMetaData()
+ void fetchStructuresMetaData()
{
long startTime = System.currentTimeMillis();
pdbRestCleint = PDBFTSRestClient.getInstance();
}
}
- public void loadLocalCachedPDBEntries()
+ protected void loadLocalCachedPDBEntries()
{
ArrayList<CachedPDB> entries = new ArrayList<>();
for (SequenceI seq : selectedSequences)
* @return the built query string
*/
- public static String buildQuery(SequenceI seq)
+ static String buildQuery(SequenceI seq)
{
boolean isPDBRefsFound = false;
boolean isUniProtRefsFound = false;
* @param seqName
* @return
*/
- public static boolean isValidSeqName(String seqName)
+ static boolean isValidSeqName(String seqName)
{
// System.out.println("seqName : " + seqName);
String ignoreList = "pdb,uniprot,swiss-prot";
return true;
}
- public static String getDBRefId(DBRefEntry dbRef)
+ static String getDBRefId(DBRefEntry dbRef)
{
String ref = dbRef.getAccessionId().replaceAll("GO:", "");
return ref;
* @param fieldToFilterBy
* the field to filter by
*/
- public void filterResultSet(final String fieldToFilterBy)
+ void filterResultSet(final String fieldToFilterBy)
{
Thread filterThread = new Thread(new Runnable()
{
* Handles action event for btn_pdbFromFile
*/
@Override
- public void pdbFromFile_actionPerformed()
+ protected void pdbFromFile_actionPerformed()
{
jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
}
/**
- * Validates user selection and activates the view button if all parameters
- * are correct
+ * Validates user selection and enables the 'Add' and 'New View' buttons if
+ * all parameters are correct (the Add button will only be visible if there is
+ * at least one existing structure viewer open). This basically means at least
+ * one structure selected and no error messages.
+ * <p>
+ * The 'Superpose Structures' option is enabled if either more than one
+ * structure is selected, or the 'Add' to existing view option is enabled, and
+ * disabled if the only option is to open a new view of a single structure.
*/
@Override
- public void validateSelections()
+ protected void validateSelections()
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
- btn_view.setEnabled(false);
+ btn_add.setEnabled(false);
String currentView = selectedFilterOpt.getView();
+ int selectedCount = 0;
if (currentView == VIEWS_FILTER)
{
- if (getResultTable().getSelectedRows().length > 0)
+ selectedCount = getResultTable().getSelectedRows().length;
+ if (selectedCount > 0)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
}
}
else if (currentView == VIEWS_LOCAL_PDB)
{
- if (tbl_local_pdb.getSelectedRows().length > 0)
+ selectedCount = tbl_local_pdb.getSelectedRows().length;
+ if (selectedCount > 0)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
}
}
else if (currentView == VIEWS_ENTER_ID)
{
validateAssociationFromFile();
}
+
+ btn_newView.setEnabled(btn_add.isEnabled());
+
+ /*
+ * enable 'Superpose' option if more than one structure is selected,
+ * or there are view(s) available to add structure(s) to
+ */
+ chk_superpose
+ .setEnabled(selectedCount > 1 || targetView.getItemCount() > 0);
}
/**
* Validates inputs from the Manual PDB entry panel
*/
- public void validateAssociationEnterPdb()
+ protected void validateAssociationEnterPdb()
{
AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
.getCmb_assSeq().getSelectedItem();
txt_search.setEnabled(true);
if (isValidPBDEntry)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
lbl_pdbManualFetchStatus.setToolTipText("");
lbl_pdbManualFetchStatus.setIcon(goodImage);
}
/**
* Validates inputs for the manual PDB file selection options
*/
- public void validateAssociationFromFile()
+ protected void validateAssociationFromFile()
{
AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
.getCmb_assSeq().getSelectedItem();
btn_pdbFromFile.setEnabled(true);
if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
lbl_fromFileStatus.setIcon(goodImage);
}
}
}
@Override
- public void cmbAssSeqStateChanged()
+ protected void cmbAssSeqStateChanged()
{
validateSelections();
}
}
return found;
}
+
+ /**
+ * Handles the 'New View' action
+ */
+ @Override
+ protected void newView_ActionPerformed()
+ {
+ targetView.setSelectedItem(null);
+ showStructures(false);
+ }
+
/**
- * Handles action event for btn_ok
+ * Handles the 'Add to existing viewer' action
*/
@Override
- public void ok_ActionPerformed()
+ protected void add_ActionPerformed()
{
showStructures(false);
}
return foundEntry;
}
+ /**
+ * Answers a structure viewer (new or existing) configured to superimpose
+ * added structures or not according to the user's choice
+ *
+ * @param ssm
+ * @return
+ */
+ StructureViewer getTargetedStructureViewer(
+ StructureSelectionManager ssm)
+ {
+ Object sv = targetView.getSelectedItem();
+
+ return sv == null ? new StructureViewer(ssm) : (StructureViewer) sv;
+ }
+
+ /**
+ * Adds PDB structures to a new or existing structure viewer
+ *
+ * @param ssm
+ * @param pdbEntriesToView
+ * @param alignPanel
+ * @param sequences
+ * @return
+ */
private StructureViewer launchStructureViewer(
StructureSelectionManager ssm,
final PDBEntry[] pdbEntriesToView,
long progressId = sequences.hashCode();
setProgressBar(MessageManager
.getString("status.launching_3d_structure_viewer"), progressId);
- final StructureViewer sViewer = new StructureViewer(ssm);
- setProgressBar(null, progressId);
+ final StructureViewer theViewer = getTargetedStructureViewer(ssm);
+ boolean superimpose = chk_superpose.isSelected();
+ theViewer.setSuperpose(superimpose);
+
+ /*
+ * remember user's choice of superimpose or not
+ */
+ Cache.setProperty(AUTOSUPERIMPOSE,
+ Boolean.valueOf(superimpose).toString());
+ setProgressBar(null, progressId);
if (SiftsSettings.isMapWithSifts())
{
List<SequenceI> seqsWithoutSourceDBRef = new ArrayList<>();
}
}
}
- if (seq.getPrimaryDBRefs().size() == 0)
+ if (seq.getPrimaryDBRefs().isEmpty())
{
seqsWithoutSourceDBRef.add(seq);
continue;
setProgressBar(MessageManager.formatMessage(
"status.fetching_dbrefs_for_sequences_without_valid_refs",
y), progressId);
- SequenceI[] seqWithoutSrcDBRef = new SequenceI[y];
- int x = 0;
- for (SequenceI fSeq : seqsWithoutSourceDBRef)
- {
- seqWithoutSrcDBRef[x++] = fSeq;
- }
-
+ SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef
+ .toArray(new SequenceI[y]);
DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef);
dbRefFetcher.fetchDBRefs(true);
setProgressBar(MessageManager.getString(
"status.fetching_3d_structures_for_selected_entries"),
progressId);
- sViewer.viewStructures(pdbEntriesToView, sequences, alignPanel);
+ theViewer.viewStructures(pdbEntriesToView, sequences, alignPanel);
}
else
{
setProgressBar(MessageManager.formatMessage(
"status.fetching_3d_structures_for",
pdbEntriesToView[0].getId()),progressId);
- sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
+ theViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
}
setProgressBar(null, progressId);
- return sViewer;
+ // remember the last viewer we used...
+ lastTargetedView = theViewer;
+ return theViewer;
}
/**
* a unique sequence when more than one sequence selection is made.
*/
@Override
- public void populateCmbAssociateSeqOptions(
+ protected void populateCmbAssociateSeqOptions(
JComboBox<AssociateSeqOptions> cmb_assSeq,
JLabel lbl_associateSeq)
{
}
}
- public boolean isStructuresDiscovered()
+ protected boolean isStructuresDiscovered()
{
return discoveredStructuresSet != null
&& !discoveredStructuresSet.isEmpty();
}
- public Collection<FTSData> getDiscoveredStructuresSet()
- {
- return discoveredStructuresSet;
- }
-
@Override
protected void txt_search_ActionPerformed()
{
}
@Override
- public void tabRefresh()
+ protected void tabRefresh()
{
if (selectedSequences != null)
{
StructureSelectionManager ssm;
+ /**
+ * decide if new structures are aligned to existing ones
+ */
+ private boolean superposeAdded = true;
+
public enum ViewerType
{
JMOL, CHIMERA
ssm = structureSelectionManager;
}
+ /**
+ * Factory to create a proxy for modifying existing structure viewer
+ *
+ */
+ public static StructureViewer reconfigure(
+ JalviewStructureDisplayI display)
+ {
+ StructureViewer sv = new StructureViewer(display.getBinding().getSsm());
+ sv.sview = display;
+ return sv;
+ }
+
+ @Override
+ public String toString()
+ {
+ if (sview != null)
+ {
+ return sview.toString();
+ }
+ return "New View";
+ }
public ViewerType getViewerType()
{
String viewType = Cache.getDefault(Preferences.STRUCTURE_DISPLAY,
new PDBEntry[seqsForPdbs.size()]);
SequenceI[][] theSeqs = seqsForPdbs.values().toArray(
new SequenceI[seqsForPdbs.size()][]);
+ if (sview != null)
+ {
+ sview.setAlignAddedStructures(superposeAdded);
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+
+ for (int pdbep = 0; pdbep < pdbsForFile.length; pdbep++)
+ {
+ PDBEntry pdb = pdbsForFile[pdbep];
+ if (!sview.addAlreadyLoadedFile(theSeqs[pdbep], null, ap,
+ pdb.getId()))
+ {
+ sview.addToExistingViewer(pdb, theSeqs[pdbep], null, ap,
+ pdb.getId());
+ }
+ }
+
+ sview.updateTitleAndMenus();
+ }
+ }).start();
+ return sview;
+ }
if (viewerType.equals(ViewerType.JMOL))
{
- sview = new AppJmol(ap, pdbsForFile, theSeqs);
+ sview = new AppJmol(ap, superposeAdded, pdbsForFile, theSeqs);
}
else if (viewerType.equals(ViewerType.CHIMERA))
{
- sview = new ChimeraViewFrame(pdbsForFile, theSeqs, ap);
+ sview = new ChimeraViewFrame(pdbsForFile, superposeAdded, theSeqs,
+ ap);
}
else
{
public JalviewStructureDisplayI viewStructures(PDBEntry pdb,
SequenceI[] seqsForPdb, AlignmentPanel ap)
{
+ if (sview != null)
+ {
+ sview.setAlignAddedStructures(superposeAdded);
+ String pdbId = pdb.getId();
+ if (!sview.addAlreadyLoadedFile(seqsForPdb, null, ap, pdbId))
+ {
+ sview.addToExistingViewer(pdb, seqsForPdb, null, ap, pdbId);
+ }
+ sview.updateTitleAndMenus();
+ sview.raiseViewer();
+ return sview;
+ }
ViewerType viewerType = getViewerType();
if (viewerType.equals(ViewerType.JMOL))
{
return false;
}
+ /**
+ *
+ * @param pDBid
+ * @return true if view is already showing PDBid
+ */
+ public boolean hasPdbId(String pDBid)
+ {
+ if (sview == null)
+ {
+ return false;
+ }
+
+ return sview.getBinding().hasPdbId(pDBid);
+ }
+
+ public boolean isVisible()
+ {
+ return sview != null && sview.isVisible();
+ }
+
+ public void setSuperpose(boolean alignAddedStructures)
+ {
+ superposeAdded = alignAddedStructures;
+ }
+
}
*/
package jalview.gui;
+import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
}
/**
+ * @return true if added structures should be aligned to existing one(s)
+ */
+ @Override
+ public boolean isAlignAddedStructures()
+ {
+ return alignAddedStructures;
+ }
+
+ /**
+ *
+ * @param true
+ * if added structures should be aligned to existing one(s)
+ */
+ @Override
+ public void setAlignAddedStructures(boolean alignAdded)
+ {
+ alignAddedStructures = alignAdded;
+ }
+
+ /**
*
* @param ap2
* @return true if this Jmol instance is linked with the given alignPanel
*/
protected void addStructure(final PDBEntry pdbentry,
final SequenceI[] seqs, final String[] chains,
- final boolean align, final IProgressIndicator alignFrame)
+ final IProgressIndicator alignFrame)
{
if (pdbentry.getFile() == null)
{
}
}
// and call ourselves again.
- addStructure(pdbentry, seqs, chains, align, alignFrame);
+ addStructure(pdbentry, seqs, chains, alignFrame);
}
}).start();
return;
{ seqs }, new String[][] { chains });
addingStructures = true;
_started = false;
- alignAddedStructures = align;
worker = new Thread(this);
worker.start();
return;
}
- /**
- * Presents a dialog with the option to add an align a structure to an
- * existing structure view
- *
- * @param pdbId
- * @param view
- * @return YES, NO or CANCEL JvOptionPane code
- */
- protected int chooseAlignStructureToViewer(String pdbId,
- StructureViewerBase view)
- {
- int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
- MessageManager.formatMessage("label.add_pdbentry_to_view",
- new Object[]
- { pdbId, view.getTitle() }),
- MessageManager
- .getString("label.align_to_existing_structure_view"),
- JvOptionPane.YES_NO_CANCEL_OPTION);
- return option;
- }
-
protected boolean hasPdbId(String pdbId)
{
return getBinding().hasPdbId(pdbId);
}
- protected abstract List<StructureViewerBase> getViewersFor(
- AlignmentPanel alp);
-
/**
- * Check for any existing views involving this alignment and give user the
- * option to add and align this molecule to one of them
- *
- * @param pdbentry
- * @param seq
- * @param chains
- * @param apanel
- * @param pdbId
- * @return true if user adds to a view, or cancels entirely, else false
+ * Returns a list of any viewer of the instantiated type. The list is
+ * restricted to those linked to the given alignment panel if it is not null.
*/
- protected boolean addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq,
- String[] chains, final AlignmentPanel apanel, String pdbId)
+ protected List<StructureViewerBase> getViewersFor(AlignmentPanel alp)
{
- for (StructureViewerBase view : getViewersFor(apanel))
- {
- // TODO: highlight the view somehow
- /*
- * JAL-1742 exclude view with this structure already mapped (don't offer
- * to align chain B to chain A of the same structure)
- */
- if (view.hasPdbId(pdbId))
- {
- continue;
- }
- int option = chooseAlignStructureToViewer(pdbId, view);
- if (option == JvOptionPane.CANCEL_OPTION)
- {
- return true;
- }
- else if (option == JvOptionPane.YES_OPTION)
- {
- view.useAlignmentPanelForSuperposition(apanel);
- view.addStructure(pdbentry, seq, chains, true, apanel.alignFrame);
- return true;
- }
- else
- {
- // NO_OPTION - offer the next viewer if any
- }
- }
+ return Desktop.instance.getStructureViewers(alp, this.getClass());
+ }
+ @Override
+ public void addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq,
+ String[] chains, final AlignmentViewPanel apanel, String pdbId)
+ {
/*
- * nothing offered and selected
+ * JAL-1742 exclude view with this structure already mapped (don't offer
+ * to align chain B to chain A of the same structure); code may defend
+ * against this possibility before we reach here
*/
- return false;
+ if (hasPdbId(pdbId))
+ {
+ return;
+ }
+ AlignmentPanel alignPanel = (AlignmentPanel) apanel; // Implementation error if this
+ // cast fails
+ useAlignmentPanelForSuperposition(alignPanel);
+ addStructure(pdbentry, seq, chains, alignPanel.alignFrame);
}
/**
* @param apanel
* @param pdbFilename
*/
- protected void addSequenceMappingsToStructure(SequenceI[] seq,
- String[] chains, final AlignmentPanel apanel, String pdbFilename)
+ public void addSequenceMappingsToStructure(SequenceI[] seq,
+ String[] chains, final AlignmentViewPanel alpanel,
+ String pdbFilename)
{
+ AlignmentPanel apanel = (AlignmentPanel) alpanel;
+
// TODO : Fix multiple seq to one chain issue here.
/*
* create the mappings
}
}
- /**
- * Check if the PDB file is already loaded, if so offer to add it to the
- * existing viewer
- *
- * @param seq
- * @param chains
- * @param apanel
- * @param pdbId
- * @return true if the user chooses to add to a viewer, or to cancel entirely
- */
- protected boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains,
- final AlignmentPanel apanel, String pdbId)
+ @Override
+ public boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains,
+ final AlignmentViewPanel apanel, String pdbId)
{
- boolean finished = false;
String alreadyMapped = apanel.getStructureSelectionManager()
.alreadyMappedToFile(pdbId);
- if (alreadyMapped != null)
+ if (alreadyMapped == null)
{
- /*
- * the PDB file is already loaded
- */
- int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.pdb_entry_is_already_displayed", new Object[]
- { pdbId }),
- MessageManager.formatMessage(
- "label.map_sequences_to_visible_window", new Object[]
- { pdbId }),
- JvOptionPane.YES_NO_CANCEL_OPTION);
- if (option == JvOptionPane.CANCEL_OPTION)
- {
- finished = true;
- }
- else if (option == JvOptionPane.YES_OPTION)
- {
- addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped);
- finished = true;
- }
+ return false;
}
- return finished;
+
+ addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped);
+ return true;
}
void setChainMenuItems(List<String> chainNames)
int[] alm = new int[_alignwith.size()];
int a = 0;
- for (AlignmentPanel ap : _alignwith)
+ for (AlignmentPanel alignPanel : _alignwith)
{
- als[a] = ap.av.getAlignment();
+ als[a] = alignPanel.av.getAlignment();
alm[a] = -1;
- alc[a++] = ap.av.getAlignment().getHiddenColumns();
+ alc[a++] = alignPanel.av.getAlignment().getHiddenColumns();
}
reply = getBinding().superposeStructures(als, alm, alc);
if (reply != null)
} catch (Exception e)
{
StringBuffer sp = new StringBuffer();
- for (AlignmentPanel ap : _alignwith)
+ for (AlignmentPanel alignPanel : _alignwith)
{
- sp.append("'" + ap.alignFrame.getTitle() + "' ");
+ sp.append("'" + alignPanel.alignFrame.getTitle() + "' ");
}
Cache.log.info("Couldn't align structures with the " + sp.toString()
+ "associated alignment panels.", e);
}
}
// Set the colour using the current view for the associated alignframe
- for (AlignmentPanel ap : _colourwith)
+ for (AlignmentPanel alignPanel : _colourwith)
{
- binding.colourBySequence(ap);
+ binding.colourBySequence(alignPanel);
}
seqColoursApplied = true;
}
/**
* Configures the title and menu items of the viewer panel.
*/
+ @Override
public void updateTitleAndMenus()
{
AAStructureBindingModel binding = getBinding();
}
@Override
+ public String toString()
+ {
+ return getTitle();
+ }
+
+ @Override
public boolean hasMapping()
{
if (worker != null && (addingStructures || _started))
return seqColoursApplied;
}
+ @Override
+ public void raiseViewer()
+ {
+ toFront();
+ }
+
}
}
else
{
- // int[] intervals = colsel.getVisibleContigs(
- // seqsel.getStartRes(), seqsel.getEndRes() + 1);
- int[] intervals = hidden.getVisibleContigs(
- seqsel.getStartRes(), seqsel.getEndRes() + 1);
- for (int iv = 0; iv < intervals.length; iv += 2)
+ Iterator<int[]> intervals = hidden
+ .getVisContigsIterator(seqsel.getStartRes(),
+ seqsel.getEndRes() + 1, false);
+ while (intervals.hasNext())
{
+ int[] region = intervals.next();
Seg s = new Seg();
- s.setStart(intervals[iv] + 1); // vamsas indices begin at
- // 1, not zero.
- s.setEnd(intervals[iv + 1] + 1);
+ s.setStart(region[0] + 1); // vamsas indices begin at 1,
+ // not zero.
+ s.setEnd(region[1] + 1);
s.setInclusive(true);
range.addSeg(s);
}
long end;
- private boolean parseCalled;
+ /**
+ * true if parse() has been called
+ */
+ private boolean parseCalled = false;
+
+ private boolean parseImmediately = true;
+
+ /**
+ * @return if doParse() was called at construction time
+ */
+ protected boolean isParseImmediately()
+ {
+ return parseImmediately;
+ }
/**
* Creates a new AlignFile object.
{
super(source);
initData();
+
+ // stash flag in case parse needs to know if it has to autoconfigure or was
+ // configured after construction
+ this.parseImmediately = parseImmediately;
+
if (parseImmediately)
{
doParse();
else
{
// consider deferring this till after the file has been parsed ?
- hidden.hideInsertionsFor(sr);
+ hidden.hideList(sr.getInsertions());
}
}
modified = true;
AlignmentAnnotation na = new AlignmentAnnotation(ala[i]);
if (selgp != null)
{
- hidden.makeVisibleAnnotation(selgp.getStartRes(),
- selgp.getEndRes(), na);
+ na.makeVisibleAnnotation(selgp.getStartRes(), selgp.getEndRes(),
+ hidden);
}
else
{
- hidden.makeVisibleAnnotation(na);
+ na.makeVisibleAnnotation(hidden);
}
alv.addAnnotation(na);
}
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
import jalview.gui.JvSwingUtils;
+import jalview.gui.StructureViewer;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
+import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import javax.swing.event.InternalFrameEvent;
import javax.swing.table.TableColumn;
+import net.miginfocom.swing.MigLayout;
+
@SuppressWarnings("serial")
/**
* GUI layout for structure chooser
public abstract class GStructureChooser extends JPanel
implements ItemListener
{
+ private static final Font VERDANA_12 = new Font("Verdana", 0, 12);
+
+ protected static final String VIEWS_FILTER = "VIEWS_FILTER";
+
+ protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE";
+
+ protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
+
+ /*
+ * 'cached' structure view
+ */
+ protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB";
+
protected JPanel statusPanel = new JPanel();
public JLabel statusBar = new JLabel();
- private JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout());
-
protected String frameTitle = MessageManager
.getString("label.structure_chooser");
protected StringBuilder errorWarning = new StringBuilder();
- protected JLabel lbl_result = new JLabel(
- MessageManager.getString("label.select"));
-
- protected JButton btn_view = new JButton();
+ protected JButton btn_add;
- protected JButton btn_cancel = new JButton();
+ protected JButton btn_newView;
protected JButton btn_pdbFromFile = new JButton();
- protected JTextField txt_search = new JTextField(14);
-
- private JPanel pnl_actions = new JPanel();
-
- private JPanel pnl_main = new JPanel();
-
- private JPanel pnl_idInput = new JPanel(new FlowLayout());
+ protected JCheckBox chk_superpose = new JCheckBox(
+ MessageManager.getString("label.superpose_structures"));
- private JPanel pnl_fileChooser = new JPanel(new FlowLayout());
-
- private JPanel pnl_idInputBL = new JPanel(new BorderLayout());
-
- private JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
-
- private JPanel pnl_locPDB = new JPanel(new BorderLayout());
+ protected JTextField txt_search = new JTextField(14);
protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews
.getLayout());
- private BorderLayout mainLayout = new BorderLayout();
-
- protected JCheckBox chk_rememberSettings = new JCheckBox(
- MessageManager.getString("label.dont_ask_me_again"));
-
protected JCheckBox chk_invertFilter = new JCheckBox(
MessageManager.getString("label.invert"));
protected ImageIcon warningImage = new ImageIcon(
getClass().getResource("/images/warning.gif"));
- protected JLabel lbl_warning = new JLabel(warningImage);
-
protected JLabel lbl_loading = new JLabel(loadingImage);
protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
- protected AssciateSeqPanel idInputAssSeqPanel = new AssciateSeqPanel();
-
- protected AssciateSeqPanel fileChooserAssSeqPanel = new AssciateSeqPanel();
-
- protected static final String VIEWS_FILTER = "VIEWS_FILTER";
+ protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel();
- protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE";
+ protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel();
- protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
-
- /**
- * 'cached' structure view
- */
- protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB";
+ protected JComboBox<StructureViewer> targetView = new JComboBox<>();
protected JTable tbl_local_pdb = new JTable();
- protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
-
protected JTabbedPane pnl_filter = new JTabbedPane();
protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
}
};
- protected JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary);
-
public GStructureChooser()
{
try
mainFrame.dispose();
break;
case KeyEvent.VK_ENTER: // enter key
- if (btn_view.isEnabled())
+ if (btn_add.isEnabled())
{
- ok_ActionPerformed();
+ add_ActionPerformed();
}
break;
case KeyEvent.VK_TAB: // tab key
}
else
{
- btn_view.requestFocus();
+ btn_add.requestFocus();
}
evt.consume();
break;
}
}
});
+
+ JButton btn_cancel = new JButton(
+ MessageManager.getString("action.cancel"));
+ btn_cancel.setFont(VERDANA_12);
+ btn_cancel.addActionListener(new java.awt.event.ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ closeAction(pnl_filter.getHeight());
+ }
+ });
+ btn_cancel.addKeyListener(new KeyAdapter()
+ {
+ @Override
+ public void keyPressed(KeyEvent evt)
+ {
+ if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+ {
+ closeAction(pnl_filter.getHeight());
+ }
+ }
+ });
+
tbl_local_pdb.setAutoCreateRowSorter(true);
tbl_local_pdb.getTableHeader().setReorderingAllowed(false);
tbl_local_pdb.addMouseListener(new MouseAdapter()
mainFrame.dispose();
break;
case KeyEvent.VK_ENTER: // enter key
- if (btn_view.isEnabled())
+ if (btn_add.isEnabled())
{
- ok_ActionPerformed();
+ add_ActionPerformed();
}
break;
case KeyEvent.VK_TAB: // tab key
}
else
{
- if (btn_view.isEnabled())
+ if (btn_add.isEnabled())
{
- btn_view.requestFocus();
+ btn_add.requestFocus();
}
else
{
}
}
});
- btn_view.setFont(new java.awt.Font("Verdana", 0, 12));
- btn_view.setText(MessageManager.getString("action.view"));
- btn_view.addActionListener(new java.awt.event.ActionListener()
+
+ btn_newView = new JButton(MessageManager.getString("action.new_view"));
+ btn_newView.setFont(VERDANA_12);
+ btn_newView.addActionListener(new java.awt.event.ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- ok_ActionPerformed();
+ newView_ActionPerformed();
}
});
- btn_view.addKeyListener(new KeyAdapter()
+ btn_newView.addKeyListener(new KeyAdapter()
{
@Override
public void keyPressed(KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_ENTER)
{
- ok_ActionPerformed();
+ newView_ActionPerformed();
}
}
});
- btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
- btn_cancel.setText(MessageManager.getString("action.cancel"));
- btn_cancel.addActionListener(new java.awt.event.ActionListener()
+ btn_add = new JButton(MessageManager.getString("action.add"));
+ btn_add.setFont(VERDANA_12);
+ btn_add.addActionListener(new java.awt.event.ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- closeAction(pnl_filter.getHeight());
+ add_ActionPerformed();
}
});
- btn_cancel.addKeyListener(new KeyAdapter()
+ btn_add.addKeyListener(new KeyAdapter()
{
@Override
public void keyPressed(KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_ENTER)
{
- closeAction(pnl_filter.getHeight());
+ add_ActionPerformed();
}
}
});
- btn_pdbFromFile.setFont(new java.awt.Font("Verdana", 0, 12));
+ btn_pdbFromFile.setFont(VERDANA_12);
String btn_title = MessageManager.getString("label.select_pdb_file");
btn_pdbFromFile.setText(btn_title + " ");
btn_pdbFromFile.addActionListener(new java.awt.event.ActionListener()
}
});
+ JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary);
scrl_foundStructures.setPreferredSize(new Dimension(width, height));
+ JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
scrl_localPDB.setPreferredSize(new Dimension(width, height));
scrl_localPDB.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- cmb_filterOption.setFont(new java.awt.Font("Verdana", 0, 12));
- chk_invertFilter.setFont(new java.awt.Font("Verdana", 0, 12));
- chk_rememberSettings.setFont(new java.awt.Font("Verdana", 0, 12));
- chk_rememberSettings.setVisible(false);
+ chk_invertFilter.setFont(VERDANA_12);
txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true,
MessageManager.getString("label.enter_pdb_id_tip")));
- cmb_filterOption.setToolTipText(
- MessageManager.getString("info.select_filter_option"));
txt_search.getDocument().addDocumentListener(new DocumentListener()
{
@Override
}
});
+ cmb_filterOption.setFont(VERDANA_12);
+ cmb_filterOption.setToolTipText(
+ MessageManager.getString("info.select_filter_option"));
cmb_filterOption.addItemListener(this);
-
// add CustomComboSeparatorsRenderer to filter option combo-box
cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer(
(ListCellRenderer<Object>) cmb_filterOption.getRenderer())
chk_invertFilter.addItemListener(this);
- pnl_actions.add(chk_rememberSettings);
- pnl_actions.add(btn_view);
- pnl_actions.add(btn_cancel);
+ targetView.setVisible(false);
- // pnl_filter.add(lbl_result);
+ JPanel actionsPanel = new JPanel(new MigLayout());
+ actionsPanel.add(targetView, "left");
+ actionsPanel.add(btn_add, "wrap");
+ actionsPanel.add(chk_superpose, "left");
+ actionsPanel.add(btn_newView);
+ actionsPanel.add(btn_cancel, "right");
+
+ JPanel pnl_main = new JPanel();
pnl_main.add(cmb_filterOption);
pnl_main.add(lbl_loading);
pnl_main.add(chk_invertFilter);
lbl_loading.setVisible(false);
+ JPanel pnl_fileChooser = new JPanel(new FlowLayout());
pnl_fileChooser.add(btn_pdbFromFile);
pnl_fileChooser.add(lbl_fromFileStatus);
+ JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.NORTH);
pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER);
+ JPanel pnl_idInput = new JPanel(new FlowLayout());
pnl_idInput.add(txt_search);
pnl_idInput.add(lbl_pdbManualFetchStatus);
+
+ JPanel pnl_idInputBL = new JPanel(new BorderLayout());
pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH);
pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER);
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
.getSource();
int index = sourceTabbedPane.getSelectedIndex();
- btn_view.setVisible(true);
+ btn_add.setVisible(targetView.isVisible());
+ btn_newView.setVisible(true);
btn_cancel.setVisible(true);
if (sourceTabbedPane.getTitleAt(index).equals(configureCols))
{
- btn_view.setEnabled(false);
+ btn_add.setEnabled(false);
btn_cancel.setEnabled(false);
- btn_view.setVisible(false);
+ btn_add.setVisible(false);
+ btn_newView.setEnabled(false);
btn_cancel.setVisible(false);
previousWantedFields = pdbDocFieldPrefs
.getStructureSummaryFields()
pnl_filter.add(foundStructureSummary, scrl_foundStructures);
pnl_filter.add(configureCols, pdbDocFieldPrefs);
+ JPanel pnl_locPDB = new JPanel(new BorderLayout());
pnl_locPDB.add(scrl_localPDB);
pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE);
pnl_switchableViews.add(pnl_filter, VIEWS_FILTER);
pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB);
- this.setLayout(mainLayout);
+ this.setLayout(new BorderLayout());
this.add(pnl_main, java.awt.BorderLayout.NORTH);
this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER);
// this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
statusPanel.setLayout(new GridLayout());
- pnl_actionsAndStatus.add(pnl_actions, BorderLayout.CENTER);
+
+ JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout());
+ pnl_actionsAndStatus.add(actionsPanel, BorderLayout.CENTER);
pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH);
statusPanel.add(statusBar, null);
this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH);
* @author tcnofoegbu
*
*/
- public class AssciateSeqPanel extends JPanel implements ItemListener
+ public class AssociateSeqPanel extends JPanel implements ItemListener
{
private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<>();
private JLabel lbl_associateSeq = new JLabel();
- public AssciateSeqPanel()
+ public AssociateSeqPanel()
{
this.setLayout(new FlowLayout());
this.add(cmb_assSeq);
protected abstract void stateChanged(ItemEvent e);
- protected abstract void ok_ActionPerformed();
+ protected abstract void add_ActionPerformed();
+
+ protected abstract void newView_ActionPerformed();
protected abstract void pdbFromFile_actionPerformed();
protected abstract void txt_search_ActionPerformed();
- public abstract void populateCmbAssociateSeqOptions(
+ protected abstract void populateCmbAssociateSeqOptions(
JComboBox<AssociateSeqOptions> cmb_assSeq,
JLabel lbl_associateSeq);
- public abstract void cmbAssSeqStateChanged();
+ protected abstract void cmbAssSeqStateChanged();
- public abstract void tabRefresh();
+ protected abstract void tabRefresh();
- public abstract void validateSelections();
+ protected abstract void validateSelections();
}
\ No newline at end of file
{
g.setColor(STEM_COLOUR);
int sCol = (lastSSX / charWidth)
- + hiddenColumns.adjustForHiddenColumns(startRes);
+ + hiddenColumns.visibleToAbsoluteColumn(startRes);
int x1 = lastSSX;
int x2 = (x * charWidth);
g.setColor(nonCanColor);
int sCol = (lastSSX / charWidth)
- + hiddenColumns.adjustForHiddenColumns(startRes);
+ + hiddenColumns.visibleToAbsoluteColumn(startRes);
int x1 = lastSSX;
int x2 = (x * charWidth);
{
if (hasHiddenColumns)
{
- column = hiddenColumns.adjustForHiddenColumns(startRes + x);
+ column = hiddenColumns.visibleToAbsoluteColumn(startRes + x);
if (column > row_annotations.length - 1)
{
break;
g.setColor(HELIX_COLOUR);
int sCol = (lastSSX / charWidth)
- + hiddenColumns.adjustForHiddenColumns(startRes);
+ + hiddenColumns.visibleToAbsoluteColumn(startRes);
int x1 = lastSSX;
int x2 = (x * charWidth);
column = sRes + x;
if (hasHiddenColumns)
{
- column = hiddenColumns.adjustForHiddenColumns(column);
+ column = hiddenColumns.visibleToAbsoluteColumn(column);
}
if (column > aaMax)
column = sRes + x;
if (hasHiddenColumns)
{
- column = hiddenColumns.adjustForHiddenColumns(column);
+ column = hiddenColumns.visibleToAbsoluteColumn(column);
}
if (column > aaMax)
// transparency of hidden cols/seqs overlay
private final float TRANSPARENCY = 0.5f;
- private final Color HIDDEN_COLOUR = Color.DARK_GRAY.darker();
-
public static final String UPDATE = "OverviewUpdate";
private static final int MAX_PROGRESS = 100;
if (pixelCol <= endCol)
{
rgbcolor = getColumnColourFromSequence(allGroups, seq,
- alignmentCol, finder);
+ alignmentCol);
// fill in the appropriate number of pixels
for (int row = pixelRow; row <= endRow; ++row)
}
/*
- * Find the colour of a sequence at a specified column position
+ * Find the RGB value of the colour of a sequence at a specified column position
*
* @param seq
* sequence to get colour for
* @param lastcol
* column position to get colour for
- * @param fcfinder
- * FeatureColourFinder to use
* @return colour of sequence at this position, as RGB
*/
- private int getColumnColourFromSequence(SequenceGroup[] allGroups,
- jalview.datamodel.SequenceI seq,
- int lastcol, FeatureColourFinder fcfinder)
+ int getColumnColourFromSequence(SequenceGroup[] allGroups,
+ SequenceI seq, int lastcol)
{
- Color color = Color.white;
+ Color color = resColFinder.GAP_COLOUR;
if ((seq != null) && (seq.getLength() > lastcol))
{
color = resColFinder.getResidueColour(true, shader, allGroups, seq,
- lastcol,
- fcfinder);
+ lastcol, finder);
}
return color.getRGB();
* the graphics object to draw on
* @param anno
* alignment annotation information
- * @param charWidth
- * alignment character width value
* @param y
* y-position for the annotation graph
* @param cols
* the collection of columns used in the overview panel
*/
- public void drawGraph(Graphics g, AlignmentAnnotation anno, int charWidth,
- int y, AlignmentColsCollectionI cols)
+ public void drawGraph(Graphics g, AlignmentAnnotation anno, int y,
+ AlignmentColsCollectionI cols)
{
Annotation[] annotations = anno.annotations;
g.setColor(Color.white);
package jalview.renderer;
import jalview.api.AlignViewportI;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
/**
column = col;
text = txt;
}
-
- /**
- * String representation for inspection when debugging only
- */
- @Override
- public String toString()
- {
- return String.format("%s:%d:%s", major ? "major" : "minor", column,
- text);
- }
}
/**
- * Calculates position markers on the alignment ruler
+ * calculate positions markers on the alignment ruler
*
* @param av
* @param startx
- * left-most column in visible view (0..)
+ * left-most column in visible view
* @param endx
- * - right-most column in visible view (0..)
- * @return
+ * - right-most column in visible view
+ * @return List of ScaleMark holding boolean: true/false for major/minor mark,
+ * marker position in alignment column coords, a String to be rendered
+ * at the position (or null)
*/
public List<ScaleMark> calculateMarks(AlignViewportI av, int startx,
int endx)
int scalestartx = (startx / 10) * 10;
SequenceI refSeq = av.getAlignment().getSeqrep();
- int refSp = 0, refStartI = 0, refEndI = -1;
+ int refSp = 0;
+ int refStartI = 0;
+ int refEndI = -1;
+
+ HiddenColumns hc = av.getAlignment().getHiddenColumns();
+
if (refSeq != null)
{
- // find bounds and set origin appopriately
- // locate first visible position for this sequence
- int[] refbounds = av.getAlignment().getHiddenColumns()
- .locateVisibleBoundsOfSequence(refSeq);
+ // find bounds and set origin appropriately
+ // locate first residue in sequence which is not hidden
+ Iterator<int[]> it = hc.iterator();
+ int index = refSeq.firstResidueOutsideIterator(it);
+ refSp = hc.absoluteToVisibleColumn(index);
+
+ refStartI = refSeq.findIndex(refSeq.getStart()) - 1;
+
+ int seqlength = refSeq.getLength();
+ // get sequence position past the end of the sequence
+ int pastEndPos = refSeq.findPosition(seqlength + 1);
+ refEndI = refSeq.findIndex(pastEndPos - 1) - 1;
- refSp = refbounds[0];
- refStartI = refbounds[4];
- refEndI = refbounds[5];
scalestartx = refSp + ((scalestartx - refSp) / 10) * 10;
}
{
scalestartx += 5;
}
- List<ScaleMark> marks = new ArrayList<ScaleMark>();
+ List<ScaleMark> marks = new ArrayList<>();
+ String string;
+ int refN, iadj;
// todo: add a 'reference origin column' to set column number relative to
for (int i = scalestartx; i <= endx; i += 5)
{
if (((i - refSp) % 10) == 0)
{
- String text;
if (refSeq == null)
{
- int iadj = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(i - 1) + 1;
- text = String.valueOf(iadj);
+ iadj = hc.visibleToAbsoluteColumn(i - 1) + 1;
+ string = String.valueOf(iadj);
}
else
{
- int iadj = av.getAlignment().getHiddenColumns()
- .adjustForHiddenColumns(i - 1);
- int refN = refSeq.findPosition(iadj);
+ iadj = hc.visibleToAbsoluteColumn(i - 1);
+ refN = refSeq.findPosition(iadj);
// TODO show bounds if position is a gap
// - ie L--R -> "1L|2R" for
// marker
if (iadj < refStartI)
{
- text = String.valueOf(iadj - refStartI);
+ string = String.valueOf(iadj - refStartI);
}
else if (iadj > refEndI)
{
- text = "+" + String.valueOf(iadj - refEndI);
+ string = "+" + String.valueOf(iadj - refEndI);
}
else
{
- text = String.valueOf(refN) + refSeq.getCharAt(iadj);
+ string = String.valueOf(refN) + refSeq.getCharAt(iadj);
}
}
- marks.add(new ScaleMark(true, i - startx - 1, text));
+ marks.add(new ScaleMark(true, i - startx - 1, string));
}
else
{
public class StructureMapping
{
+ public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE;
+
+ private static final int PDB_RES_NUM_INDEX = 0;
+
+ private static final int PDB_ATOM_NUM_INDEX = 1;
+
String mappingDetails;
SequenceI sequence;
String pdbchain;
- public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE;
-
- private static final int PDB_RES_NUM_INDEX = 0;
-
- private static final int PDB_ATOM_NUM_INDEX = 1;
-
// Mapping key is residue index while value is an array containing PDB resNum,
// and atomNo
HashMap<Integer, int[]> mapping;
jalview.datamodel.Mapping seqToPdbMapping = null;
+
/**
* Constructor
*
*/
public List<int[]> getPDBResNumRanges(int fromSeqPos, int toSeqPos)
{
- List<int[]> result = new ArrayList<int[]>();
+ List<int[]> result = new ArrayList<>();
int startRes = -1;
int endRes = -1;
{
return seqToPdbMapping;
}
+
+ /**
+ * A hash function that satisfies the contract that if two mappings are
+ * equal(), they have the same hashCode
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((mappingDetails == null) ? 0 : mappingDetails.hashCode());
+ result = prime * result
+ + ((pdbchain == null) ? 0 : pdbchain.hashCode());
+ result = prime * result + ((pdbfile == null) ? 0 : pdbfile.hashCode());
+ result = prime * result + ((pdbid == null) ? 0 : pdbid.hashCode());
+ result = prime * result
+ + ((seqToPdbMapping == null) ? 0 : seqToPdbMapping.hashCode());
+ result = prime * result
+ + ((sequence == null) ? 0 : sequence.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ StructureMapping other = (StructureMapping) obj;
+ if (mappingDetails == null)
+ {
+ if (other.mappingDetails != null)
+ {
+ return false;
+ }
+ }
+ else if (!mappingDetails.equals(other.mappingDetails))
+ {
+ return false;
+ }
+ if (pdbchain == null)
+ {
+ if (other.pdbchain != null)
+ {
+ return false;
+ }
+ }
+ else if (!pdbchain.equals(other.pdbchain))
+ {
+ return false;
+ }
+ if (pdbfile == null)
+ {
+ if (other.pdbfile != null)
+ {
+ return false;
+ }
+ }
+ else if (!pdbfile.equals(other.pdbfile))
+ {
+ return false;
+ }
+ if (pdbid == null)
+ {
+ if (other.pdbid != null)
+ {
+ return false;
+ }
+ }
+ else if (!pdbid.equals(other.pdbid))
+ {
+ return false;
+ }
+ if (seqToPdbMapping == null)
+ {
+ if (other.seqToPdbMapping != null)
+ {
+ return false;
+ }
+ }
+ else if (!seqToPdbMapping.equals(other.seqToPdbMapping))
+ {
+ return false;
+ }
+ if (sequence != other.sequence)
+ {
+ return false;
+ }
+
+ return true;
+ }
}
}
/**
- * Returns the file name for a mapped PDB id (or null if not mapped).
+ * Returns the filename the PDB id is already mapped to if known, or null if
+ * it is not mapped
*
* @param pdbid
* @return
{
for (StructureMapping sm : mappings)
{
- if (sm.getPdbId().equals(pdbid))
+ if (sm.getPdbId().equalsIgnoreCase(pdbid))
{
return sm.pdbfile;
}
{
// FIXME if sourceType is not null, we've lost data here
sourceType = AppletFormatAdapter.checkProtocol(pdbFile);
- pdb = new JmolParser(pdbFile, sourceType);
-
+ pdb = new JmolParser(false, pdbFile, sourceType);
+ pdb.addSettings(parseSecStr && processSecondaryStructure,
+ parseSecStr && addTempFacAnnot,
+ parseSecStr && secStructServices);
+ pdb.doParse();
if (pdb.getId() != null && pdb.getId().trim().length() > 0
&& DataSourceType.FILE == sourceType)
{
{
System.err.println(e.getMessage());
}
+ catch (Exception e)
+ {
+ System.err
+ .println(
+ "Unexpected exception during SIFTS mapping - falling back to NW for this sequence/structure pair");
+ System.err.println(e.getMessage());
+ }
}
if (!foundSiftsMappings.isEmpty())
{
}
if (forStructureView)
{
- mappings.addAll(seqToStrucMapping);
+ for (StructureMapping sm : seqToStrucMapping)
+ {
+ addStructureMapping(sm); // not addAll!
+ }
}
if (progress != null)
{
public void addStructureMapping(StructureMapping sm)
{
- mappings.add(sm);
+ if (!mappings.contains(sm))
+ {
+ mappings.add(sm);
+ }
}
/**
*/
public MapList()
{
- fromShifts = new ArrayList<int[]>();
- toShifts = new ArrayList<int[]>();
+ fromShifts = new ArrayList<>();
+ toShifts = new ArrayList<>();
}
/**
{
int hashCode = 31 * fromRatio;
hashCode = 31 * hashCode + toRatio;
- hashCode = 31 * hashCode + fromShifts.toArray().hashCode();
- hashCode = 31 * hashCode + toShifts.toArray().hashCode();
+ for (int[] shift : fromShifts)
+ {
+ hashCode = 31 * hashCode + shift[0];
+ hashCode = 31 * hashCode + shift[1];
+ }
+ for (int[] shift : toShifts)
+ {
+ hashCode = 31 * hashCode + shift[0];
+ hashCode = 31 * hashCode + shift[1];
+ }
+
return hashCode;
}
}
boolean changed = false;
- List<int[]> merged = new ArrayList<int[]>();
+ List<int[]> merged = new ArrayList<>();
int[] lastRange = ranges.get(0);
int lastDirection = lastRange[1] >= lastRange[0] ? 1 : -1;
lastRange = new int[] { lastRange[0], lastRange[1] };
{
return null;
}
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
if (fs <= fe)
{
intv = fs;
toSequences, fromGapChar);
}
- for (int[] hidden : hiddencols.getHiddenColumnsCopy())
+ Iterator<int[]> regions = hiddencols.iterator();
+ while (regions.hasNext())
{
- mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences,
+ mapHiddenColumns(regions.next(), codonFrames, newHidden,
+ fromSequences,
toSequences, fromGapChar);
}
return; // mappedColumns;
import java.util.Deque;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
if (alignment.getHiddenColumns() != null
&& alignment.getHiddenColumns().hasHiddenColumns())
{
- selection = alignment.getHiddenColumns()
- .getVisibleSequenceStrings(start, end, seqs);
+ for (i = 0; i < iSize; i++)
+ {
+ Iterator<int[]> blocks = alignment.getHiddenColumns()
+ .getVisContigsIterator(start, end + 1, false);
+ selection[i] = seqs[i].getSequenceStringFromIterator(blocks);
+ }
}
else
{
{
if (start == 0)
{
- start = hidden.adjustForHiddenColumns(start);
+ start = hidden.visibleToAbsoluteColumn(start);
}
- end = hidden.getHiddenBoundaryRight(start);
+ end = hidden.getNextHiddenBoundary(false, start);
if (start == end)
{
end = max;
if (hidden != null && hidden.hasHiddenColumns())
{
- start = hidden.adjustForHiddenColumns(end);
- start = hidden.getHiddenBoundaryLeft(start) + 1;
+ start = hidden.visibleToAbsoluteColumn(end);
+ start = hidden.getNextHiddenBoundary(true, start) + 1;
}
} while (end < max);
AlignmentAnnotation clone = new AlignmentAnnotation(annot);
if (selectedOnly && selectionGroup != null)
{
- alignment.getHiddenColumns().makeVisibleAnnotation(
+ clone.makeVisibleAnnotation(
selectionGroup.getStartRes(), selectionGroup.getEndRes(),
- clone);
+ alignment.getHiddenColumns());
}
else
{
- alignment.getHiddenColumns().makeVisibleAnnotation(clone);
+ clone.makeVisibleAnnotation(alignment.getHiddenColumns());
}
ala.add(clone);
}
public AlignmentColsCollectionI getColumns(AlignmentI al)
{
return new VisibleColsCollection(0,
- ranges.getAbsoluteAlignmentWidth() - 1, al);
+ ranges.getAbsoluteAlignmentWidth() - 1, al.getHiddenColumns());
}
@Override
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
// convert to visible positions
- int visXAsRes = hiddenCols.findColumnPosition(xAsRes);
+ int visXAsRes = hiddenCols.absoluteToVisibleColumn(xAsRes);
yAsSeq = hiddenSeqs.adjustForHiddenSeqs(
hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq));
yAsSeq = Math.max(yAsSeq, 0); // -1 if before first visible sequence
// get mouse location in viewport coords, add translation in viewport
// coords,
// convert back to pixel coords
- int vpx = Math.round(mousex * widthRatio);
- int visXAsRes = hiddenCols.findColumnPosition(vpx) + xdiff;
+ int vpx = Math.round((float) mousex * alwidth / width);
+ int visXAsRes = hiddenCols.absoluteToVisibleColumn(vpx) + xdiff;
int vpy = Math.round(mousey * heightRatio);
int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy) + ydiff;
int vpwidth = ranges.getViewportWidth();
// check in case we went off the edge of the alignment
- int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1);
+ int visAlignWidth = hiddenCols.absoluteToVisibleColumn(alwidth - 1);
if (visXAsRes + vpwidth - 1 > visAlignWidth)
{
// went past the end of the alignment, adjust backwards
// if last position was before the end of the alignment, need to update
if (ranges.getEndRes() < visAlignWidth)
{
- visXAsRes = hiddenCols.findColumnPosition(hiddenCols
- .subtractVisibleColumns(vpwidth - 1, alwidth - 1));
+ visXAsRes = hiddenCols.absoluteToVisibleColumn(hiddenCols
+ .offsetByVisibleColumns(-(vpwidth - 1), alwidth - 1));
}
else
{
HiddenColumns hiddenCols)
{
// work with absolute values of startRes and endRes
- int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
- int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
+ int startRes = hiddenCols.visibleToAbsoluteColumn(ranges.getStartRes());
+ int endRes = hiddenCols.visibleToAbsoluteColumn(ranges.getEndRes());
// work with absolute values of startSeq and endSeq
int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
- int vpx = Math.round(mousex * widthRatio);
- return hidden.subtractVisibleColumns(ranges.getViewportWidth() / 2,
+ int vpx = Math.round((float) mousex * alwidth / width);
+ return hidden.offsetByVisibleColumns(-ranges.getViewportWidth() / 2,
vpx);
}
int vpx = Math.round(x * widthRatio);
int vpy = Math.round(y * heightRatio);
- xdiff = ranges.getStartRes() - hiddenCols.findColumnPosition(vpx);
+ xdiff = ranges.getStartRes() - hiddenCols.absoluteToVisibleColumn(vpx);
ydiff = ranges.getStartSeq()
- hiddenSeqs.findIndexWithoutHiddenSeqs(vpy);
}
}
HiddenColumns hidden = al.getHiddenColumns();
- while (x < hidden.adjustForHiddenColumns(startRes))
+ while (x < hidden.visibleToAbsoluteColumn(startRes))
{
if (!scrollRight(false))
{
break;
}
}
- while (x > hidden.adjustForHiddenColumns(endRes))
+ while (x > hidden.visibleToAbsoluteColumn(endRes))
{
if (!scrollRight(true))
{
boolean changedLocation = false;
// convert the x,y location to visible coordinates
- int visX = al.getHiddenColumns().findColumnPosition(x);
+ int visX = al.getHiddenColumns().absoluteToVisibleColumn(x);
int visY = al.getHiddenSequences().findIndexWithoutHiddenSeqs(y);
// if (vis_x,vis_y) is already visible don't do anything
*/
protected float transparency = 1.0f;
- protected Map<String, FeatureColourI> featureColours = new ConcurrentHashMap<String, FeatureColourI>();
+ protected Map<String, FeatureColourI> featureColours = new ConcurrentHashMap<>();
- protected Map<String, Boolean> featureGroups = new ConcurrentHashMap<String, Boolean>();
+ protected Map<String, Boolean> featureGroups = new ConcurrentHashMap<>();
protected String[] renderOrder;
{
av.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
}
- List<String> nft = new ArrayList<String>();
+ List<String> nft = new ArrayList<>();
for (String featureType : featureTypes)
{
if (!fdi.isRegistered(featureType))
renderOrder = neworder;
}
- protected Map<String, float[][]> minmax = new Hashtable<String, float[][]>();
+ protected Map<String, float[][]> minmax = new Hashtable<>();
public Map<String, float[][]> getMinMax()
{
* include features at the position provided their feature type is
* displayed, and feature group is null or marked for display
*/
- List<SequenceFeature> result = new ArrayList<SequenceFeature>();
+ List<SequenceFeature> result = new ArrayList<>();
if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
{
return result;
}
FeaturesDisplayedI featuresDisplayed = av.getFeaturesDisplayed();
- Set<String> oldfeatures = new HashSet<String>();
+ Set<String> oldfeatures = new HashSet<>();
if (renderOrder != null)
{
for (int i = 0; i < renderOrder.length; i++)
}
AlignmentI alignment = av.getAlignment();
- List<String> allfeatures = new ArrayList<String>();
+ List<String> allfeatures = new ArrayList<>();
for (int i = 0; i < alignment.getHeight(); i++)
{
*/
if (minmax == null)
{
- minmax = new Hashtable<String, float[][]>();
+ minmax = new Hashtable<>();
}
synchronized (minmax)
{
*/
private void updateRenderOrder(List<String> allFeatures)
{
- List<String> allfeatures = new ArrayList<String>(allFeatures);
+ List<String> allfeatures = new ArrayList<>(allFeatures);
String[] oldRender = renderOrder;
renderOrder = new String[allfeatures.size()];
boolean initOrders = (featureOrder == null);
{
if (featureOrder == null)
{
- featureOrder = new Hashtable<String, Float>();
+ featureOrder = new Hashtable<>();
}
featureOrder.put(type, new Float(position));
return position;
* note visible feature ordering and colours before update
*/
List<String> visibleFeatures = getDisplayedFeatureTypes();
- Map<String, FeatureColourI> visibleColours = new HashMap<String, FeatureColourI>(
+ Map<String, FeatureColourI> visibleColours = new HashMap<>(
getFeatureColours());
FeaturesDisplayedI av_featuresdisplayed = null;
{
if (featureGroups != null)
{
- List<String> gp = new ArrayList<String>();
+ List<String> gp = new ArrayList<>();
for (String grp : featureGroups.keySet())
{
@Override
public Map<String, FeatureColourI> getDisplayedFeatureCols()
{
- Map<String, FeatureColourI> fcols = new Hashtable<String, FeatureColourI>();
+ Map<String, FeatureColourI> fcols = new Hashtable<>();
if (getViewport().getFeaturesDisplayed() == null)
{
return fcols;
public List<String> getDisplayedFeatureTypes()
{
List<String> typ = getRenderOrder();
- List<String> displayed = new ArrayList<String>();
+ List<String> displayed = new ArrayList<>();
FeaturesDisplayedI feature_disp = av.getFeaturesDisplayed();
if (feature_disp != null)
{
@Override
public List<String> getDisplayedFeatureGroups()
{
- List<String> _gps = new ArrayList<String>();
+ List<String> _gps = new ArrayList<>();
for (String gp : getFeatureGroups())
{
if (checkGroupVisibility(gp, false))
public List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
int resNo)
{
- List<SequenceFeature> result = new ArrayList<SequenceFeature>();
+ List<SequenceFeature> result = new ArrayList<>();
if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
{
return result;
{
return;
}
+
SequenceFeatures.sortFeatures(features, true);
boolean simpleColour = fc == null || fc.isSimpleColour();
SequenceFeature lastFeature = null;
* same extent as another (so would just redraw the same colour);
* (checking type and isContactFeature as a fail-safe here, although
* currently they are guaranteed to match in this context)
+ * don't remove 'redundant' features if transparency is applied
+ * (as feature count affects depth of feature colour)
*/
- if (simpleColour)
+ if (simpleColour && transparency == 1f)
{
if (lastFeature != null && sf.getBegin() == lastFeature.getBegin()
&& sf.getEnd() == lastFeature.getEnd()
*/
abstract public class Pfam extends Xfam
{
- private static final String PFAM_BASEURL_KEY = "PFAM_BASEURL";
+ static final String PFAM_BASEURL_KEY = "PFAM_BASEURL";
private static final String DEFAULT_PFAM_BASEURL = "https://pfam.xfam.org";
*/
abstract public class Rfam extends Xfam
{
- private static final String RFAM_BASEURL_KEY = "RFAM_BASEURL";
+ static final String RFAM_BASEURL_KEY = "RFAM_BASEURL";
private static final String DEFAULT_RFAM_BASEURL = "https://rfam.xfam.org";
{
// Adjust input view for gaps
// propagate insertions into profile
- alhidden = HiddenColumns.propagateInsertions(profileseq, al,
- input);
+ alhidden = al.propagateInsertions(profileseq, input);
}
}
}
a3.resName = "ASP";
a3.resNumber = 41;
- Vector<Bond> v = new Vector<Bond>();
+ Vector<Bond> v = new Vector<>();
v.add(new Bond(a1, a2));
v.add(new Bond(a2, a3));
v.add(new Bond(a3, a1));
@Test(groups = { "Functional" })
public void testMakeResidueList_noAnnotation()
{
- Vector<Atom> atoms = new Vector<Atom>();
+ Vector<Atom> atoms = new Vector<>();
c.atoms = atoms;
c.isNa = true;
atoms.add(makeAtom(4, "N", "MET"));
@Test(groups = { "Functional" })
public void testMakeResidueList_withTempFactor()
{
- Vector<Atom> atoms = new Vector<Atom>();
+ Vector<Atom> atoms = new Vector<>();
c.atoms = atoms;
atoms.add(makeAtom(4, "N", "MET"));
atoms.get(atoms.size() - 1).tfactor = 1f;
atoms.add(makeAtom(5, "CA", "LYS"));
atoms.get(atoms.size() - 1).tfactor = 9f;
atoms.add(makeAtom(6, "O", "LEU"));
- atoms.get(atoms.size() - 1).tfactor = 4f;
+ atoms.get(atoms.size() - 1).tfactor = -4f;
atoms.add(makeAtom(6, "N", "LEU"));
atoms.get(atoms.size() - 1).tfactor = 5f;
atoms.add(makeAtom(6, "CA", "LEU"));
/*
* Verify annotations; note the tempFactor is read from the first atom in
- * each residue i.e. we expect values 1, 7, 4 for the residues
+ * each residue i.e. we expect values 1, 7, -4 for the residues
*/
AlignmentAnnotation[] ann = c.sequence.getAnnotation();
assertEquals(1, ann.length);
assertEquals("Temperature Factor for 1gaqA", ann[0].description);
assertSame(c.sequence, ann[0].sequenceRef);
assertEquals(AlignmentAnnotation.LINE_GRAPH, ann[0].graph);
- assertEquals(0f, ann[0].graphMin, 0.001f);
+ assertEquals(-4f, ann[0].graphMin, 0.001f);
assertEquals(7f, ann[0].graphMax, 0.001f);
assertEquals(3, ann[0].annotations.length);
assertEquals(1f, ann[0].annotations[0].value, 0.001f);
assertEquals(7f, ann[0].annotations[1].value, 0.001f);
- assertEquals(4f, ann[0].annotations[2].value, 0.001f);
+ assertEquals(-4f, ann[0].annotations[2].value, 0.001f);
}
/**
public void testMakeCaBondList()
{
c.isNa = true;
- Vector<Atom> atoms = new Vector<Atom>();
+ Vector<Atom> atoms = new Vector<>();
c.atoms = atoms;
atoms.add(makeAtom(4, "N", "MET"));
atoms.add(makeAtom(4, "CA", "MET"));
public void testMakeCaBondList_nucleotide()
{
c.isNa = false;
- Vector<Atom> atoms = new Vector<Atom>();
+ Vector<Atom> atoms = new Vector<>();
c.atoms = atoms;
atoms.add(makeAtom(4, "N", "G"));
atoms.add(makeAtom(4, "P", "G"));
@Test(groups = { "Functional" })
public void testMakeExactMapping()
{
- Vector<Atom> atoms = new Vector<Atom>();
+ Vector<Atom> atoms = new Vector<>();
c.atoms = atoms;
atoms.add(makeAtom(4, "N", "MET"));
atoms.add(makeAtom(4, "CA", "MET"));
public void testFindXrefSourcesForSequence_proteinToDna()
{
SequenceI seq = new Sequence("Seq1", "MGKYQARLSS");
- List<String> sources = new ArrayList<String>();
+ List<String> sources = new ArrayList<>();
AlignmentI al = new Alignment(new SequenceI[] {});
/*
sources = new CrossRef(new SequenceI[] { seq }, al)
.findXrefSourcesForSequences(false);
// method is patched to remove EMBL from the sources to match
- assertEquals(3, sources.size());
- assertEquals("[EMBLCDS, GENEDB, ENSEMBL]", sources.toString());
+ assertEquals(4, sources.size());
+ assertEquals("[EMBLCDS, GENEDB, ENSEMBL, ENSEMBLGENOMES]",
+ sources.toString());
/*
* add a sequence to the alignment which has a dbref to UNIPROT|A1234
pep1.addDBRef(new DBRefEntry("UNIPROT", "0", "Q9ZTS2"));
AlignmentI al = new Alignment(new SequenceI[] { dna1, pep1 });
- List<SequenceI> result = new ArrayList<SequenceI>();
+ List<SequenceI> result = new ArrayList<>();
/*
* first search for a dbref nowhere on the alignment:
import jalview.io.FormatAdapter;
import java.io.IOException;
+import java.util.Iterator;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
FileFormat.Fasta);
HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(alf, cs);
- Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
+ Iterator<int[]> contigs = cs.getVisContigsIterator(0, alf.getWidth(),
+ false);
+ Dna dna = new Dna(av, contigs);
AlignmentI translated = dna.translateCdna();
assertNotNull("Couldn't do a full width translation of test data.",
translated);
cs.hideColumns(0, ipos - 1);
}
cs.hideColumns(ipos + vwidth, alf.getWidth());
- int[] vcontigs = cs.getVisibleContigs(0, alf.getWidth());
+ Iterator<int[]> vcontigs = cs.getVisContigsIterator(0,
+ alf.getWidth(), false);
AlignViewportI av = new AlignViewport(alf, cs);
Dna dna = new Dna(av, vcontigs);
AlignmentI transAlf = dna.translateCdna();
DataSourceType.PASTE, FileFormat.Fasta);
HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(alf, cs);
- Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
+ Iterator<int[]> contigs = cs.getVisContigsIterator(0, alf.getWidth(),
+ false);
+ Dna dna = new Dna(av, contigs);
AlignmentI translated = dna.translateCdna();
String aa = translated.getSequenceAt(0).getSequenceAsString();
assertEquals(
cs.hideColumns(24, 35); // hide codons 9-12
cs.hideColumns(177, 191); // hide codons 60-64
AlignViewportI av = new AlignViewport(alf, cs);
- Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
+ Iterator<int[]> contigs = cs.getVisContigsIterator(0, alf.getWidth(),
+ false);
+ Dna dna = new Dna(av, contigs);
AlignmentI translated = dna.translateCdna();
String aa = translated.getSequenceAt(0).getSequenceAsString();
assertEquals("AACDDGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVW", aa);
.generate(12, 8, 97, 5, 5);
HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(cdna, cs);
- Dna dna = new Dna(av, new int[] { 0, cdna.getWidth() - 1 });
+ Iterator<int[]> contigs = cs.getVisContigsIterator(0, cdna.getWidth(),
+ false);
+ Dna dna = new Dna(av, contigs);
AlignmentI translated = dna.translateCdna();
/*
}
AlignmentI cdnaReordered = new Alignment(sorted);
av = new AlignViewport(cdnaReordered, cs);
- dna = new Dna(av, new int[] { 0, cdna.getWidth() - 1 });
+ contigs = cs.getVisContigsIterator(0, cdna.getWidth(), false);
+ dna = new Dna(av, contigs);
AlignmentI translated2 = dna.translateCdna();
/*
HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(al, cs);
- Dna testee = new Dna(av, new int[] { 0, al.getWidth() - 1 });
+ Iterator<int[]> contigs = cs.getVisContigsIterator(0, al.getWidth(),
+ false);
+ Dna testee = new Dna(av, contigs);
AlignmentI reversed = testee.reverseCdna(false);
assertEquals(1, reversed.getHeight());
assertEquals(seqRev, reversed.getSequenceAt(0).getSequenceAsString());
*/
package jalview.datamodel;
+import static org.testng.Assert.assertNull;
import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNull;
import jalview.analysis.AlignSeq;
import jalview.gui.JvOptionPane;
Assert.assertTrue(ann.isQuantitative(),
"Mixed 'E' annotation set should be quantitative.");
}
+
+ @Test(groups = "Functional")
+ public void testMakeVisibleAnnotation()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Annotation[] anns = new Annotation[] { null, null, new Annotation(1),
+ new Annotation(2), new Annotation(3), null, null, new Annotation(4),
+ new Annotation(5), new Annotation(6), new Annotation(7),
+ new Annotation(8) };
+ AlignmentAnnotation ann = new AlignmentAnnotation("an", "some an",
+ anns);
+
+ // null annotations
+ AlignmentAnnotation emptyann = new AlignmentAnnotation("an", "some ann",
+ null);
+ emptyann.makeVisibleAnnotation(h);
+ assertNull(emptyann.annotations);
+
+ emptyann.makeVisibleAnnotation(3, 4, h);
+ assertNull(emptyann.annotations);
+
+ // without bounds, does everything
+ ann.makeVisibleAnnotation(h);
+ assertEquals(12, ann.annotations.length);
+ assertNull(ann.annotations[0]);
+ assertNull(ann.annotations[1]);
+ assertEquals(1.0f, ann.annotations[2].value);
+ assertEquals(2.0f, ann.annotations[3].value);
+ assertEquals(3.0f, ann.annotations[4].value);
+ assertNull(ann.annotations[5]);
+ assertNull(ann.annotations[6]);
+ assertEquals(4.0f, ann.annotations[7].value);
+ assertEquals(5.0f, ann.annotations[8].value);
+ assertEquals(6.0f, ann.annotations[9].value);
+ assertEquals(7.0f, ann.annotations[10].value);
+ assertEquals(8.0f, ann.annotations[11].value);
+
+ // without hidden cols, just truncates
+ ann.makeVisibleAnnotation(3, 5, h);
+ assertEquals(3, ann.annotations.length);
+ assertEquals(2.0f, ann.annotations[0].value);
+ assertEquals(3.0f, ann.annotations[1].value);
+ assertNull(ann.annotations[2]);
+
+ anns = new Annotation[] { null, null, new Annotation(1),
+ new Annotation(2), new Annotation(3), null, null, new Annotation(4),
+ new Annotation(5), new Annotation(6), new Annotation(7),
+ new Annotation(8) };
+ ann = new AlignmentAnnotation("an", "some an", anns);
+ h.hideColumns(4, 7);
+ ann.makeVisibleAnnotation(1, 9, h);
+ assertEquals(5, ann.annotations.length);
+ assertNull(ann.annotations[0]);
+ assertEquals(1.0f, ann.annotations[1].value);
+ assertEquals(2.0f, ann.annotations[2].value);
+ assertEquals(5.0f, ann.annotations[3].value);
+ assertEquals(6.0f, ann.annotations[4].value);
+
+ anns = new Annotation[] { null, null, new Annotation(1),
+ new Annotation(2), new Annotation(3), null, null, new Annotation(4),
+ new Annotation(5), new Annotation(6), new Annotation(7),
+ new Annotation(8) };
+ ann = new AlignmentAnnotation("an", "some an", anns);
+ h.hideColumns(1, 2);
+ ann.makeVisibleAnnotation(1, 9, h);
+ assertEquals(3, ann.annotations.length);
+ assertEquals(2.0f, ann.annotations[0].value);
+ assertEquals(5.0f, ann.annotations[1].value);
+ assertEquals(6.0f, ann.annotations[2].value);
+
+ anns = new Annotation[] { null, null, new Annotation(1),
+ new Annotation(2), new Annotation(3), null, null, new Annotation(4),
+ new Annotation(5), new Annotation(6), new Annotation(7),
+ new Annotation(8), new Annotation(9), new Annotation(10),
+ new Annotation(11), new Annotation(12), new Annotation(13),
+ new Annotation(14), new Annotation(15) };
+ ann = new AlignmentAnnotation("an", "some an", anns);
+ h = new HiddenColumns();
+ h.hideColumns(5, 18);
+ h.hideColumns(20, 21);
+ ann.makeVisibleAnnotation(1, 21, h);
+ assertEquals(5, ann.annotations.length);
+ assertEquals(1.0f, ann.annotations[1].value);
+ assertEquals(2.0f, ann.annotations[2].value);
+ assertEquals(3.0f, ann.annotations[3].value);
+ assertNull(ann.annotations[0]);
+ assertNull(ann.annotations[4]);
+ }
}
import jalview.io.FileFormat;
import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
+import jalview.util.Comparison;
import jalview.util.MapList;
import java.io.IOException;
if (raiseAssert)
{
Assert.fail(message
- + " DBRefEntry for sequence in alignment had map to sequence not in dataset");
+ + " DBRefEntry " + dbr + " for sequence "
+ + seqds
+ + " in alignment has map to sequence not in dataset");
}
return false;
}
assertEquals(seq, ala.sequenceRef);
assertEquals("", ala.calcId);
}
+
+ @Test(groups = "Functional")
+ public void testPropagateInsertions()
+ {
+ // create an alignment with no gaps - this will be the profile seq and other
+ // JPRED seqs
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(25, 10, 1234, 0, 0);
+
+ // get the profileseq
+ SequenceI profileseq = al.getSequenceAt(0);
+ SequenceI gappedseq = new Sequence(profileseq);
+ gappedseq.insertCharAt(5, al.getGapCharacter());
+ gappedseq.insertCharAt(6, al.getGapCharacter());
+ gappedseq.insertCharAt(7, al.getGapCharacter());
+ gappedseq.insertCharAt(8, al.getGapCharacter());
+
+ // force different kinds of padding
+ al.getSequenceAt(3).deleteChars(2, 23);
+ al.getSequenceAt(4).deleteChars(2, 27);
+ al.getSequenceAt(5).deleteChars(10, 27);
+
+ // create an alignment view with the gapped sequence
+ SequenceI[] seqs = new SequenceI[1];
+ seqs[0] = gappedseq;
+ AlignmentI newal = new Alignment(seqs);
+ HiddenColumns hidden = new HiddenColumns();
+ hidden.hideColumns(15, 17);
+
+ AlignmentView view = new AlignmentView(newal, hidden, null, true, false,
+ false);
+
+ // confirm that original contigs are as expected
+ Iterator<int[]> visible = hidden.getVisContigsIterator(0, 25, false);
+ int[] region = visible.next();
+ assertEquals("[0, 14]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[18, 24]", Arrays.toString(region));
+
+ // propagate insertions
+ HiddenColumns result = al.propagateInsertions(profileseq, view);
+
+ // confirm that the contigs have changed to account for the gaps
+ visible = result.getVisContigsIterator(0, 25, false);
+ region = visible.next();
+ assertEquals("[0, 10]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[14, 24]", Arrays.toString(region));
+
+ // confirm the alignment has been changed so that the other sequences have
+ // gaps inserted where the columns are hidden
+ assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[10]));
+ assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[11]));
+ assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[12]));
+ assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[13]));
+ assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[14]));
+
+ }
+
+ @Test(groups = "Functional")
+ public void testPropagateInsertionsOverlap()
+ {
+ // test propagateInsertions where gaps and hiddenColumns overlap
+
+ // create an alignment with no gaps - this will be the profile seq and other
+ // JPRED seqs
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(20, 10, 1234, 0, 0);
+
+ // get the profileseq
+ SequenceI profileseq = al.getSequenceAt(0);
+ SequenceI gappedseq = new Sequence(profileseq);
+ gappedseq.insertCharAt(5, al.getGapCharacter());
+ gappedseq.insertCharAt(6, al.getGapCharacter());
+ gappedseq.insertCharAt(7, al.getGapCharacter());
+ gappedseq.insertCharAt(8, al.getGapCharacter());
+
+ // create an alignment view with the gapped sequence
+ SequenceI[] seqs = new SequenceI[1];
+ seqs[0] = gappedseq;
+ AlignmentI newal = new Alignment(seqs);
+
+ // hide columns so that some overlap with the gaps
+ HiddenColumns hidden = new HiddenColumns();
+ hidden.hideColumns(7, 10);
+
+ AlignmentView view = new AlignmentView(newal, hidden, null, true, false,
+ false);
+
+ // confirm that original contigs are as expected
+ Iterator<int[]> visible = hidden.getVisContigsIterator(0, 20, false);
+ int[] region = visible.next();
+ assertEquals("[0, 6]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[11, 19]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
+
+ // propagate insertions
+ HiddenColumns result = al.propagateInsertions(profileseq, view);
+
+ // confirm that the contigs have changed to account for the gaps
+ visible = result.getVisContigsIterator(0, 20, false);
+ region = visible.next();
+ assertEquals("[0, 4]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[7, 19]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
+
+ // confirm the alignment has been changed so that the other sequences have
+ // gaps inserted where the columns are hidden
+ assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[4]));
+ assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[5]));
+ assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[6]));
+ assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[7]));
+ }
+
+ @Test(groups = { "Functional" })
+ public void testPadGaps()
+ {
+ SequenceI seq1 = new Sequence("seq1", "ABCDEF--");
+ SequenceI seq2 = new Sequence("seq2", "-JKLMNO--");
+ SequenceI seq3 = new Sequence("seq2", "-PQR");
+ AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2, seq3 });
+ a.setGapCharacter('.'); // this replaces existing gaps
+ assertEquals("ABCDEF..", seq1.getSequenceAsString());
+ a.padGaps();
+ // trailing gaps are pruned, short sequences padded with gap character
+ assertEquals("ABCDEF.", seq1.getSequenceAsString());
+ assertEquals(".JKLMNO", seq2.getSequenceAsString());
+ assertEquals(".PQR...", seq3.getSequenceAsString());
+ }
}
import java.util.BitSet;
import java.util.Collections;
import java.util.ConcurrentModificationException;
+import java.util.Iterator;
import java.util.List;
import org.testng.annotations.BeforeClass;
// hide column 5 (and adjacent):
cs.hideSelectedColumns(5, al.getHiddenColumns());
// 4,5,6 now hidden:
- List<int[]> hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ Iterator<int[]> regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
// none now selected:
assertTrue(cs.getSelected().isEmpty());
cs.addElement(5);
cs.addElement(6);
cs.hideSelectedColumns(4, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
assertTrue(cs.getSelected().isEmpty());
// repeat, hiding column (4, 5 and) 6
cs.addElement(5);
cs.addElement(6);
cs.hideSelectedColumns(6, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
assertTrue(cs.getSelected().isEmpty());
// repeat, with _only_ adjacent columns selected
cs.addElement(4);
cs.addElement(6);
cs.hideSelectedColumns(5, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
assertTrue(cs.getSelected().isEmpty());
}
cs.hideSelectedColumns(al);
assertTrue(cs.getSelected().isEmpty());
- List<int[]> hidden = cols.getHiddenColumnsCopy();
- assertEquals(4, hidden.size());
- assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
- assertEquals("[7, 9]", Arrays.toString(hidden.get(1)));
- assertEquals("[15, 18]", Arrays.toString(hidden.get(2)));
- assertEquals("[20, 22]", Arrays.toString(hidden.get(3)));
+ Iterator<int[]> regions = cols.iterator();
+ assertEquals(4, cols.getNumberOfRegions());
+ assertEquals("[2, 4]", Arrays.toString(regions.next()));
+ assertEquals("[7, 9]", Arrays.toString(regions.next()));
+ assertEquals("[15, 18]", Arrays.toString(regions.next()));
+ assertEquals("[20, 22]", Arrays.toString(regions.next()));
}
/**
--- /dev/null
+/*
+ * 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.datamodel;
+
+import static org.testng.Assert.assertNull;
+import static org.testng.AssertJUnit.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+public class HiddenColumnsCursorTest
+{
+
+ @Test(groups = { "Functional" })
+ public void testConstructor()
+ {
+ HiddenColumnsCursor cursor = new HiddenColumnsCursor();
+ assertNull(cursor.findRegionForColumn(0, false));
+
+ List<int[]> hlist = new ArrayList<>();
+ cursor = new HiddenColumnsCursor(hlist);
+ assertNull(cursor.findRegionForColumn(0, false));
+
+ cursor = new HiddenColumnsCursor(hlist, 3, 12);
+ assertNull(cursor.findRegionForColumn(0, false));
+
+ hlist.add(new int[] { 3, 7 });
+ hlist.add(new int[] { 15, 25 });
+ cursor = new HiddenColumnsCursor(hlist);
+ HiddenCursorPosition p = cursor.findRegionForColumn(8, false);
+ assertEquals(1, p.getRegionIndex());
+
+ cursor = new HiddenColumnsCursor(hlist, 1, 5);
+ p = cursor.findRegionForColumn(8, false);
+ assertEquals(1, p.getRegionIndex());
+ }
+
+ /**
+ * Test the method which finds the corresponding region given a column
+ */
+ @Test(groups = { "Functional" })
+ public void testFindRegionForColumn()
+ {
+ HiddenColumnsCursor cursor = new HiddenColumnsCursor();
+
+ HiddenCursorPosition pos = cursor.findRegionForColumn(20, false);
+ assertNull(pos);
+
+ List<int[]> hidden = new ArrayList<>();
+ hidden.add(new int[] { 53, 76 });
+ hidden.add(new int[] { 104, 125 });
+
+ cursor = new HiddenColumnsCursor(hidden);
+
+ int regionIndex = cursor.findRegionForColumn(126, false).getRegionIndex();
+ assertEquals(2, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(125, false).getRegionIndex();
+ assertEquals(1, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(108, false).getRegionIndex();
+ assertEquals(1, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(104, false).getRegionIndex();
+ assertEquals(1, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(103, false).getRegionIndex();
+ assertEquals(1, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(77, false).getRegionIndex();
+ assertEquals(1, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(76, false).getRegionIndex();
+ assertEquals(0, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(53, false).getRegionIndex();
+ assertEquals(0, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(52, false).getRegionIndex();
+ assertEquals(0, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(0, false).getRegionIndex();
+ assertEquals(0, regionIndex);
+
+ hidden.add(new int[] { 138, 155 });
+
+ cursor = new HiddenColumnsCursor(hidden);
+
+ regionIndex = cursor.findRegionForColumn(160, false).getRegionIndex();
+ assertEquals(3, regionIndex);
+
+ regionIndex = cursor.findRegionForColumn(100, false).getRegionIndex();
+ assertEquals(1, regionIndex);
+ }
+
+ /**
+ * Test the method which counts the number of hidden columns before a column
+ */
+ @Test(groups = { "Functional" })
+ public void testFindRegionForColumn_Visible()
+ {
+ HiddenColumnsCursor cursor = new HiddenColumnsCursor();
+
+ HiddenCursorPosition pos = cursor.findRegionForColumn(20, true);
+ assertNull(pos);
+
+ List<int[]> hidden = new ArrayList<>();
+ hidden.add(new int[] { 53, 76 });
+ hidden.add(new int[] { 104, 125 });
+
+ cursor = new HiddenColumnsCursor(hidden);
+
+ int offset = cursor.findRegionForColumn(80, true).getHiddenSoFar();
+ assertEquals(46, offset);
+
+ offset = cursor.findRegionForColumn(79, true).getHiddenSoFar();
+ assertEquals(24, offset);
+
+ offset = cursor.findRegionForColumn(53, true).getHiddenSoFar();
+ assertEquals(24, offset);
+
+ offset = cursor.findRegionForColumn(52, true).getHiddenSoFar();
+ assertEquals(0, offset);
+
+ offset = cursor.findRegionForColumn(10, true).getHiddenSoFar();
+ assertEquals(0, offset);
+
+ offset = cursor.findRegionForColumn(0, true).getHiddenSoFar();
+ assertEquals(0, offset);
+
+ offset = cursor.findRegionForColumn(79, true).getHiddenSoFar();
+ assertEquals(24, offset);
+
+ offset = cursor.findRegionForColumn(80, true).getHiddenSoFar();
+ assertEquals(46, offset);
+ }
+}
import static org.testng.AssertJUnit.assertTrue;
import jalview.analysis.AlignmentGenerator;
-import jalview.gui.JvOptionPane;
import java.util.Arrays;
import java.util.BitSet;
-import java.util.List;
-import java.util.Random;
+import java.util.Iterator;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class HiddenColumnsTest
{
-
- @BeforeClass(alwaysRun = true)
- public void setUpJvOptionPane()
- {
- JvOptionPane.setInteractiveMode(false);
- JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
- }
-
/**
* Test the method which counts the number of hidden columns
*/
public void testFindColumnPosition()
{
HiddenColumns cs = new HiddenColumns();
- assertEquals(5, cs.findColumnPosition(5));
+ assertEquals(5, cs.absoluteToVisibleColumn(5));
// hiding column 6 makes no difference
cs.hideColumns(6, 6);
- assertEquals(5, cs.findColumnPosition(5));
+ assertEquals(5, cs.absoluteToVisibleColumn(5));
// hiding column 4 moves column 5 to column 4
cs.hideColumns(4, 4);
- assertEquals(4, cs.findColumnPosition(5));
+ assertEquals(4, cs.absoluteToVisibleColumn(5));
// hiding column 4 moves column 4 to position 3
- assertEquals(3, cs.findColumnPosition(4));
+ assertEquals(3, cs.absoluteToVisibleColumn(4));
// hiding columns 1 and 2 moves column 5 to column 2
cs.hideColumns(1, 2);
- assertEquals(2, cs.findColumnPosition(5));
+ assertEquals(2, cs.absoluteToVisibleColumn(5));
// check with > 1 hidden column regions
// where some columns are in the hidden regions
cs2.hideColumns(40, 44);
// hiding columns 5-10 and 20-27 moves column 8 to column 4
- assertEquals(4, cs2.findColumnPosition(8));
+ assertEquals(4, cs2.absoluteToVisibleColumn(8));
// and moves column 24 to 13
- assertEquals(13, cs2.findColumnPosition(24));
+ assertEquals(13, cs2.absoluteToVisibleColumn(24));
// and moves column 28 to 14
- assertEquals(14, cs2.findColumnPosition(28));
+ assertEquals(14, cs2.absoluteToVisibleColumn(28));
// and moves column 40 to 25
- assertEquals(25, cs2.findColumnPosition(40));
+ assertEquals(25, cs2.absoluteToVisibleColumn(40));
// check when hidden columns start at 0 that the visible column
// is returned as 0
HiddenColumns cs3 = new HiddenColumns();
cs3.hideColumns(0, 4);
- assertEquals(0, cs3.findColumnPosition(2));
+ assertEquals(0, cs3.absoluteToVisibleColumn(2));
+ // check that column after the last hidden region doesn't crash
+ assertEquals(46, cs2.absoluteToVisibleColumn(65));
}
- /**
- * Test the method that finds the visible column position a given distance
- * before another column
- */
@Test(groups = { "Functional" })
- public void testFindColumnNToLeft()
+ public void testVisibleContigsIterator()
{
HiddenColumns cs = new HiddenColumns();
- // test that without hidden columns, findColumnNToLeft returns
- // position n to left of provided position
- int pos = cs.subtractVisibleColumns(3, 10);
- assertEquals(7, pos);
-
- // 0 returns same position
- pos = cs.subtractVisibleColumns(0, 10);
- assertEquals(10, pos);
-
- // overflow to left returns negative number
- pos = cs.subtractVisibleColumns(3, 0);
- assertEquals(-3, pos);
-
- // test that with hidden columns to left of result column
- // behaviour is the same as above
- cs.hideColumns(1, 3);
-
- // position n to left of provided position
- pos = cs.subtractVisibleColumns(3, 10);
- assertEquals(7, pos);
-
- // 0 returns same position
- pos = cs.subtractVisibleColumns(0, 10);
- assertEquals(10, pos);
-
- // test with one set of hidden columns between start and required position
- cs.hideColumns(12, 15);
- pos = cs.subtractVisibleColumns(8, 17);
- assertEquals(5, pos);
-
- // test with two sets of hidden columns between start and required position
- cs.hideColumns(20, 21);
- pos = cs.subtractVisibleColumns(8, 23);
- assertEquals(9, pos);
-
- // repeat last 2 tests with no hidden columns to left of required position
- ColumnSelection colsel = new ColumnSelection();
- cs.revealAllHiddenColumns(colsel);
-
- // test with one set of hidden columns between start and required position
- cs.hideColumns(12, 15);
- pos = cs.subtractVisibleColumns(8, 17);
- assertEquals(5, pos);
-
- // test with two sets of hidden columns between start and required position
- cs.hideColumns(20, 21);
- pos = cs.subtractVisibleColumns(8, 23);
- assertEquals(9, pos);
-
- }
+ Iterator<int[]> visible = cs.getVisContigsIterator(3, 10, false);
+ int[] region = visible.next();
+ assertEquals("[3, 9]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
- @Test(groups = { "Functional" })
- public void testGetVisibleContigs()
- {
- HiddenColumns cs = new HiddenColumns();
cs.hideColumns(3, 6);
cs.hideColumns(8, 9);
cs.hideColumns(12, 12);
- // start position is inclusive, end position exclusive:
- int[] visible = cs.getVisibleContigs(1, 13);
- assertEquals("[1, 2, 7, 7, 10, 11]", Arrays.toString(visible));
-
- visible = cs.getVisibleContigs(4, 14);
- assertEquals("[7, 7, 10, 11, 13, 13]", Arrays.toString(visible));
-
- visible = cs.getVisibleContigs(3, 10);
- assertEquals("[7, 7]", Arrays.toString(visible));
-
- visible = cs.getVisibleContigs(4, 6);
- assertEquals("[]", Arrays.toString(visible));
+ // Test both ends visible region
+
+ // start position is inclusive, end position exclusive
+ visible = cs.getVisContigsIterator(1, 13, false);
+ region = visible.next();
+ assertEquals("[1, 2]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[7, 7]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[10, 11]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
+
+ // Test start hidden, end visible
+ visible = cs.getVisContigsIterator(4, 14, false);
+ region = visible.next();
+ assertEquals("[7, 7]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[10, 11]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[13, 13]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
+
+ // Test start hidden, end hidden
+ visible = cs.getVisContigsIterator(3, 10, false);
+ region = visible.next();
+ assertEquals("[7, 7]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
+
+ // Test start visible, end hidden
+ visible = cs.getVisContigsIterator(0, 13, false);
+ region = visible.next();
+ assertEquals("[0, 2]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[7, 7]", Arrays.toString(region));
+ region = visible.next();
+ assertEquals("[10, 11]", Arrays.toString(region));
+ assertFalse(visible.hasNext());
+
+ // Test empty result
+ visible = cs.getVisContigsIterator(4, 6, false);
+ assertFalse(visible.hasNext());
}
@Test(groups = { "Functional" })
assertFalse(cs.equals(cs2));
assertFalse(cs2.equals(cs));
+ // with the wrong kind of object
+ assertFalse(cs.equals(new HiddenColumnsCursor()));
+
+ // with a different hiddenColumns object - by size
+ HiddenColumns cs3 = new HiddenColumns();
+ cs3.hideColumns(2, 3);
+ assertFalse(cs.equals(cs3));
+
// with hidden columns added in a different order
cs2.hideColumns(6, 9);
+ assertFalse(cs.equals(cs2));
+ assertFalse(cs2.equals(cs));
+
cs2.hideColumns(5, 8);
assertTrue(cs.equals(cs2));
assertTrue(cs.equals(cs));
assertTrue(cs2.equals(cs));
assertTrue(cs2.equals(cs2));
+
+ // different ranges, same size
+ cs.hideColumns(10, 12);
+ cs2.hideColumns(10, 15);
+ assertFalse(cs.equals(cs2));
+
}
@Test(groups = "Functional")
HiddenColumns cs = new HiddenColumns();
cs.hideColumns(10, 11);
cs.hideColumns(5, 7);
+ Iterator<int[]> regions = cs.iterator();
assertEquals("[5, 7]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
HiddenColumns cs2 = new HiddenColumns(cs);
+ regions = cs2.iterator();
assertTrue(cs2.hasHiddenColumns());
- assertEquals(2, cs2.getHiddenColumnsCopy().size());
+ assertEquals(2, cs2.getNumberOfRegions());
// hidden columns are held in column order
assertEquals("[5, 7]",
- Arrays.toString(cs2.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
assertEquals("[10, 11]",
- Arrays.toString(cs2.getHiddenColumnsCopy().get(1)));
+ Arrays.toString(regions.next()));
}
- /**
- * Test the code used to locate the reference sequence ruler origin
- */
- @Test(groups = { "Functional" })
- public void testLocateVisibleBoundsofSequence()
+ @Test(groups = "Functional")
+ public void testCopyConstructor2()
{
- // create random alignment
- AlignmentGenerator gen = new AlignmentGenerator(false);
- AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(10, 11);
+ cs.hideColumns(5, 7);
- HiddenColumns cs = al.getHiddenColumns();
- ColumnSelection colsel = new ColumnSelection();
+ HiddenColumns cs2 = new HiddenColumns(cs, 3, 9, 1);
+ assertTrue(cs2.hasHiddenColumns());
+ Iterator<int[]> regions = cs2.iterator();
- SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E---");
- assertEquals(2, seq.findIndex(seq.getStart()));
-
- // no hidden columns
- assertEquals(
- Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
- seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
-
- // hidden column on gap after end of sequence - should not affect bounds
- colsel.hideSelectedColumns(13, al.getHiddenColumns());
- assertEquals(
- Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
- seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+ // only [5,7] returned, offset by 1
+ assertEquals("[4, 6]",
+ Arrays.toString(regions.next()));
+ assertEquals(3, cs2.getSize());
- cs.revealAllHiddenColumns(colsel);
- // hidden column on gap before beginning of sequence - should vis bounds by
- // one
- colsel.hideSelectedColumns(0, al.getHiddenColumns());
- assertEquals(
- Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 2,
- seq.findIndex(seq.getEnd()) - 2, seq.getStart(),
- seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
-
- cs.revealAllHiddenColumns(colsel);
- // hide columns around most of sequence - leave one residue remaining
- cs.hideColumns(1, 3);
- cs.hideColumns(6, 11);
- assertEquals("-D",
- cs.getVisibleSequenceStrings(0, 5, new SequenceI[] { seq })[0]);
- assertEquals(
- Arrays.toString(new int[] { 1, 1, 3, 3,
- seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
- cs.revealAllHiddenColumns(colsel);
+ cs2 = new HiddenColumns(cs, 8, 15, 4);
+ regions = cs2.iterator();
+ assertTrue(cs2.hasHiddenColumns());
- // hide whole sequence - should just get location of hidden region
- // containing sequence
- cs.hideColumns(1, 11);
- assertEquals(
- Arrays.toString(new int[] { 0, 1, 0, 0,
- seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+ // only [10,11] returned, offset by 4
+ assertEquals("[6, 7]",
+ Arrays.toString(regions.next()));
+ assertEquals(2, cs2.getSize());
+ cs2 = new HiddenColumns(cs, 6, 10, 4);
+ assertFalse(cs2.hasHiddenColumns());
}
- @Test(groups = { "Functional" })
- public void testLocateVisibleBoundsPathologicals()
- {
- // test some pathological cases we missed
- AlignmentI al = new Alignment(new SequenceI[] { new Sequence(
- "refseqGaptest", "KTDVTI----------NFI-----G----L") });
- HiddenColumns cs = new HiddenColumns();
- cs.hideInsertionsFor(al.getSequenceAt(0));
- assertEquals(
- "G",
- ""
- + al.getSequenceAt(0).getCharAt(
- cs.adjustForHiddenColumns(9)));
-
- }
@Test(groups = { "Functional" })
public void testHideColumns()
ColumnSelection colsel = new ColumnSelection();
HiddenColumns cs = al.getHiddenColumns();
colsel.hideSelectedColumns(5, al.getHiddenColumns());
- List<int[]> hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[5, 5]", Arrays.toString(hidden.get(0)));
+ Iterator<int[]> regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[5, 5]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 1);
colsel.hideSelectedColumns(3, al.getHiddenColumns());
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
+ regions = cs.iterator();
+ assertEquals(2, cs.getNumberOfRegions());
// two hidden ranges, in order:
- assertEquals(hidden.size(), cs.getHiddenColumnsCopy().size());
- assertEquals("[3, 3]", Arrays.toString(hidden.get(0)));
- assertEquals("[5, 5]", Arrays.toString(hidden.get(1)));
+ assertEquals("[3, 3]", Arrays.toString(regions.next()));
+ assertEquals("[5, 5]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 2);
// hiding column 4 expands [3, 3] to [3, 4]
// and merges to [5, 5] to make [3, 5]
colsel.hideSelectedColumns(4, al.getHiddenColumns());
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[3, 5]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[3, 5]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 3);
// clear hidden columns (note they are added to selected)
cs.revealAllHiddenColumns(colsel);
// it is now actually null but getter returns an empty list
- assertTrue(cs.getHiddenColumnsCopy().isEmpty());
+ assertEquals(0, cs.getNumberOfRegions());
+ assertEquals(cs.getSize(), 0);
cs.hideColumns(3, 6);
- hidden = cs.getHiddenColumnsCopy();
- int[] firstHiddenRange = hidden.get(0);
+ regions = cs.iterator();
+ int[] firstHiddenRange = regions.next();
assertEquals("[3, 6]", Arrays.toString(firstHiddenRange));
+ assertEquals(cs.getSize(), 4);
// adding a subrange of already hidden should do nothing
cs.hideColumns(4, 5);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 4);
cs.hideColumns(3, 5);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 4);
cs.hideColumns(4, 6);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 4);
cs.hideColumns(3, 6);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 4);
cs.revealAllHiddenColumns(colsel);
cs.hideColumns(2, 4);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[2, 4]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 3);
// extend contiguous with 2 positions overlap
cs.hideColumns(3, 5);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[2, 5]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[2, 5]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 4);
// extend contiguous with 1 position overlap
cs.hideColumns(5, 6);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[2, 6]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[2, 6]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 5);
// extend contiguous with overlap both ends:
cs.hideColumns(1, 7);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[1, 7]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[1, 7]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 7);
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(15, 18);
+ cs.hideColumns(2, 4);
+ cs.hideColumns(7, 9);
+ regions = cs.iterator();
+ assertEquals(3, cs.getNumberOfRegions());
+ assertEquals("[2, 4]", Arrays.toString(regions.next()));
+ assertEquals("[7, 9]", Arrays.toString(regions.next()));
+ assertEquals("[15, 18]", Arrays.toString(regions.next()));
+ assertEquals(cs.getSize(), 10);
}
/**
{
ColumnSelection colsel = new ColumnSelection();
HiddenColumns cs = new HiddenColumns();
+
+ // test with null hidden columns
+ cs.revealHiddenColumns(5, colsel);
+ assertTrue(colsel.getSelected().isEmpty());
+
cs.hideColumns(5, 8);
colsel.addElement(10);
cs.revealHiddenColumns(5, colsel);
- // hidden columns list now null but getter returns empty list:
- assertTrue(cs.getHiddenColumnsCopy().isEmpty());
+
+ // hiddenColumns now empty
+ assertEquals(0, cs.getSize());
+
// revealed columns are marked as selected (added to selection):
assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString());
colsel = new ColumnSelection();
cs = new HiddenColumns();
cs.hideColumns(5, 8);
- List<int[]> hidden = cs.getHiddenColumnsCopy();
+
+ int prevSize = cs.getSize();
cs.revealHiddenColumns(6, colsel);
- assertEquals(hidden.size(), cs.getHiddenColumnsCopy().size());
+ assertEquals(prevSize, cs.getSize());
+ assertTrue(colsel.getSelected().isEmpty());
+
+ // reveal hidden columns when there is more than one region
+ cs.hideColumns(20, 23);
+ // now there are 2 hidden regions
+ assertEquals(2, cs.getNumberOfRegions());
+
+ cs.revealHiddenColumns(20, colsel);
+
+ // hiddenColumns now has one region
+ assertEquals(1, cs.getNumberOfRegions());
+
+ // revealed columns are marked as selected (added to selection):
+ assertEquals("[20, 21, 22, 23]", colsel.getSelected().toString());
+
+ // call with a column past the end of the hidden column ranges
+ colsel.clear();
+ cs.revealHiddenColumns(20, colsel);
+ // hiddenColumns still has 1 region
+ assertEquals(1, cs.getNumberOfRegions());
assertTrue(colsel.getSelected().isEmpty());
}
@Test(groups = { "Functional" })
public void testRevealAllHiddenColumns()
{
- HiddenColumns cs = new HiddenColumns();
+ HiddenColumns hidden = new HiddenColumns();
ColumnSelection colsel = new ColumnSelection();
- cs.hideColumns(5, 8);
- cs.hideColumns(2, 3);
+
+ // test with null hidden columns
+ hidden.revealAllHiddenColumns(colsel);
+ assertTrue(colsel.getSelected().isEmpty());
+
+ hidden.hideColumns(5, 8);
+ hidden.hideColumns(2, 3);
colsel.addElement(11);
colsel.addElement(1);
- cs.revealAllHiddenColumns(colsel);
+ hidden.revealAllHiddenColumns(colsel);
/*
* revealing hidden columns adds them (in order) to the (unordered)
* selection list
*/
- assertTrue(cs.getHiddenColumnsCopy().isEmpty());
- assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected()
- .toString());
+
+ // hiddenColumns now empty
+ assertEquals(0, hidden.getSize());
+
+ assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]",
+ colsel.getSelected().toString());
}
@Test(groups = { "Functional" })
public void testIsVisible()
{
HiddenColumns cs = new HiddenColumns();
+ assertTrue(cs.isVisible(5));
+
cs.hideColumns(2, 4);
cs.hideColumns(6, 7);
assertTrue(cs.isVisible(0));
assertTrue(cs.isVisible(5));
assertFalse(cs.isVisible(6));
assertFalse(cs.isVisible(7));
+ assertTrue(cs.isVisible(8));
}
/**
HiddenColumns cs = new HiddenColumns();
cs.hideColumns(49, 59);
cs.hideColumns(69, 79);
- List<int[]> hidden = cs.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
- assertEquals("[49, 59]", Arrays.toString(hidden.get(0)));
- assertEquals("[69, 79]", Arrays.toString(hidden.get(1)));
+ Iterator<int[]> regions = cs.iterator();
+ assertEquals(2, cs.getNumberOfRegions());
+ assertEquals("[49, 59]", Arrays.toString(regions.next()));
+ assertEquals("[69, 79]", Arrays.toString(regions.next()));
+ assertEquals(22, cs.getSize());
cs.hideColumns(48, 80);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[48, 80]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[48, 80]", Arrays.toString(regions.next()));
+ assertEquals(33, cs.getSize());
/*
* another...joining hidden ranges
cs.hideColumns(50, 60);
// hiding 21-49 should merge to one range
cs.hideColumns(21, 49);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[10, 60]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[10, 60]", Arrays.toString(regions.next()));
+ assertEquals(51, cs.getSize());
/*
* another...left overlap, subsumption, right overlap,
cs.hideColumns(60, 70);
cs.hideColumns(15, 45);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
- assertEquals("[10, 50]", Arrays.toString(hidden.get(0)));
- assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
+ regions = cs.iterator();
+ assertEquals(2, cs.getNumberOfRegions());
+ assertEquals("[10, 50]", Arrays.toString(regions.next()));
+ assertEquals("[60, 70]", Arrays.toString(regions.next()));
+ assertEquals(52, cs.getSize());
}
@Test(groups = { "Functional" })
- public void testHideBitset()
+ public void testHideColumns_BitSet()
{
HiddenColumns cs;
// one hidden range
one.set(1);
cs = new HiddenColumns();
- cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ cs.hideColumns(one);
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals(1, cs.getSize());
one.set(2);
cs = new HiddenColumns();
- cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ cs.hideColumns(one);
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals(2, cs.getSize());
one.set(3);
cs = new HiddenColumns();
- cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ cs.hideColumns(one);
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals(3, cs.getSize());
// split
one.clear(2);
cs = new HiddenColumns();
- cs.hideMarkedBits(one);
- assertEquals(2, cs.getHiddenColumnsCopy().size());
+ cs.hideColumns(one);
+ assertEquals(2, cs.getNumberOfRegions());
+ assertEquals(2, cs.getSize());
- assertEquals(0, cs.adjustForHiddenColumns(0));
- assertEquals(2, cs.adjustForHiddenColumns(1));
- assertEquals(4, cs.adjustForHiddenColumns(2));
+ assertEquals(0, cs.visibleToAbsoluteColumn(0));
+ assertEquals(2, cs.visibleToAbsoluteColumn(1));
+ assertEquals(4, cs.visibleToAbsoluteColumn(2));
// one again
one.clear(1);
cs = new HiddenColumns();
- cs.hideMarkedBits(one);
+ cs.hideColumns(one);
+ assertEquals(1, cs.getSize());
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ assertEquals(1, cs.getNumberOfRegions());
- assertEquals(0, cs.adjustForHiddenColumns(0));
- assertEquals(1, cs.adjustForHiddenColumns(1));
- assertEquals(2, cs.adjustForHiddenColumns(2));
- assertEquals(4, cs.adjustForHiddenColumns(3));
- }
-
- @Test(groups = { "Functional" })
- public void testGetBitset()
- {
- BitSet toMark, fromMark;
- long seed = -3241532;
- Random number = new Random(seed);
- for (int n = 0; n < 1000; n++)
- {
- // create a random bitfield
- toMark = BitSet.valueOf(new long[] { number.nextLong(),
- number.nextLong(), number.nextLong() });
- toMark.set(n * number.nextInt(10), n * (25 + number.nextInt(25)));
- HiddenColumns hc = new HiddenColumns();
- hc.hideMarkedBits(toMark);
-
- // see if we can recover bitfield
- hc.markHiddenRegions(fromMark = new BitSet());
- assertEquals(toMark, fromMark);
- }
- }
-
- @Test(groups = { "Functional" })
- public void testFindHiddenRegionPositions()
- {
- HiddenColumns hc = new HiddenColumns();
-
- List<Integer> positions = hc.findHiddenRegionPositions();
- assertTrue(positions.isEmpty());
-
- hc.hideColumns(3, 7);
- hc.hideColumns(10, 10);
- hc.hideColumns(14, 15);
-
- positions = hc.findHiddenRegionPositions();
- assertEquals(3, positions.size());
- assertEquals(3, positions.get(0).intValue());
- assertEquals(5, positions.get(1).intValue());
- assertEquals(8, positions.get(2).intValue());
+ assertEquals(0, cs.visibleToAbsoluteColumn(0));
+ assertEquals(1, cs.visibleToAbsoluteColumn(1));
+ assertEquals(2, cs.visibleToAbsoluteColumn(2));
+ assertEquals(4, cs.visibleToAbsoluteColumn(3));
}
@Test(groups = { "Functional" })
}
@Test(groups = "Functional")
- public void getVisibleStartAndEndIndexTest()
+ public void testGetVisibleStartAndEndIndex()
{
Sequence seq = new Sequence("testSeq", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
AlignmentI align = new Alignment(new SequenceI[] { seq });
System.out.println(startEnd[0] + " : " + startEnd[1]);
assertEquals(1, startEnd[0]);
assertEquals(23, startEnd[1]);
+
+ // force lowest range to start of alignment
+ hc = new HiddenColumns();
+ hc.hideColumns(3, 4);
+ startEnd = hc.getVisibleStartAndEndIndex(align.getWidth());
+ assertEquals(0, startEnd[0]);
+ assertEquals(25, startEnd[1]);
}
@Test(groups = "Functional")
hc.hideColumns(10, 10);
hc.hideColumns(14, 15);
- result = hc.getRegionWithEdgeAtRes(3);
+ result = hc.getRegionWithEdgeAtRes(2);
assertEquals(3, result[0]);
assertEquals(7, result[1]);
+ result = hc.getRegionWithEdgeAtRes(4);
+ assertEquals(10, result[0]);
+ assertEquals(10, result[1]);
+
result = hc.getRegionWithEdgeAtRes(5);
assertEquals(10, result[0]);
assertEquals(10, result[1]);
result = hc.getRegionWithEdgeAtRes(6);
assertNull(result);
+
+ result = hc.getRegionWithEdgeAtRes(0);
+ assertNull(result);
+
+ result = hc.getRegionWithEdgeAtRes(7);
+ assertEquals(14, result[0]);
+ assertEquals(15, result[1]);
+
+ result = hc.getRegionWithEdgeAtRes(8);
+ assertEquals(14, result[0]);
+ assertEquals(15, result[1]);
+
+ result = hc.getRegionWithEdgeAtRes(16);
+ assertNull(result);
}
@Test(groups = "Functional")
- public void testPropagateInsertions()
+ public void testHasHiddenColumns()
{
- // create an alignment with no gaps - this will be the profile seq and other
- // JPRED seqs
- AlignmentGenerator gen = new AlignmentGenerator(false);
- AlignmentI al = gen.generate(20, 10, 1234, 0, 0);
-
- // get the profileseq
- SequenceI profileseq = al.getSequenceAt(0);
- SequenceI gappedseq = new Sequence(profileseq);
- gappedseq.insertCharAt(5, al.getGapCharacter());
- gappedseq.insertCharAt(6, al.getGapCharacter());
- gappedseq.insertCharAt(7, al.getGapCharacter());
- gappedseq.insertCharAt(8, al.getGapCharacter());
-
- // create an alignment view with the gapped sequence
- SequenceI[] seqs = new SequenceI[1];
- seqs[0] = gappedseq;
- AlignmentI newal = new Alignment(seqs);
- HiddenColumns hidden = new HiddenColumns();
- hidden.hideColumns(15, 17);
-
- AlignmentView view = new AlignmentView(newal, hidden, null, true, false,
- false);
-
- // confirm that original contigs are as expected
- int[] oldcontigs = hidden.getVisibleContigs(0, 20);
- int[] testcontigs = { 0, 14, 18, 19 };
- assertTrue(Arrays.equals(oldcontigs, testcontigs));
-
- // propagate insertions
- HiddenColumns result = HiddenColumns.propagateInsertions(profileseq, al,
- view);
-
- // confirm that the contigs have changed to account for the gaps
- int[] newcontigs = result.getVisibleContigs(0, 20);
- testcontigs[1] = 10;
- testcontigs[2] = 14;
- assertTrue(Arrays.equals(newcontigs, testcontigs));
-
+ HiddenColumns h = new HiddenColumns();
+
+ // new HiddenColumns2 has no hidden cols
+ assertFalse(h.hasHiddenColumns());
+
+ // some columns hidden, returns true
+ h.hideColumns(5, 10);
+ assertTrue(h.hasHiddenColumns());
+
+ // reveal columns, no hidden cols again
+ ColumnSelection sel = new ColumnSelection();
+ h.revealAllHiddenColumns(sel);
+ assertFalse(h.hasHiddenColumns());
+ }
+
+ @Test(groups = "Functional")
+ public void testHasManyHiddenColumns()
+ {
+ HiddenColumns h = new HiddenColumns();
+
+ // h has no hidden cols
+ assertFalse(h.hasMultiHiddenColumnRegions());
+
+ // one set of columns hidden, returns false
+ h.hideColumns(5, 10);
+ assertFalse(h.hasMultiHiddenColumnRegions());
+
+ // two sets hidden, returns true
+ h.hideColumns(15, 17);
+ assertTrue(h.hasMultiHiddenColumnRegions());
+
+ // back to one block, asserts false
+ h.hideColumns(11, 14);
+ assertFalse(h.hasMultiHiddenColumnRegions());
+ }
+
+ @Test(groups = "Functional")
+ public void testAdjustForHiddenColumns()
+ {
+ HiddenColumns h = new HiddenColumns();
+ // returns input value when there are no hidden columns
+ assertEquals(10, h.visibleToAbsoluteColumn(10));
+
+ h.hideColumns(20, 30);
+ assertEquals(10, h.visibleToAbsoluteColumn(10));
+ assertEquals(20 + 11, h.visibleToAbsoluteColumn(20));
+ assertEquals(35 + 11, h.visibleToAbsoluteColumn(35));
+
+ h.hideColumns(5, 7);
+ assertEquals(10 + 3, h.visibleToAbsoluteColumn(10));
+ assertEquals(20 + 14, h.visibleToAbsoluteColumn(20));
+ assertEquals(35 + 14, h.visibleToAbsoluteColumn(35));
+
+ ColumnSelection sel = new ColumnSelection();
+ h.revealAllHiddenColumns(sel);
+ h.hideColumns(0, 1);
+ assertEquals(4, h.visibleToAbsoluteColumn(2));
+ }
+
+ @Test(groups = "Functional")
+ public void testGetNextHiddenBoundary_Left()
+ {
+ HiddenColumns h = new HiddenColumns();
+
+ // returns same value if no hidden cols
+ assertEquals(3, h.getNextHiddenBoundary(true, 3));
+
+ h.hideColumns(5, 10);
+ assertEquals(10, h.getNextHiddenBoundary(true, 15));
+ assertEquals(3, h.getNextHiddenBoundary(true, 3));
+ assertEquals(7, h.getNextHiddenBoundary(true, 7));
+
+ h.hideColumns(15, 20);
+ assertEquals(10, h.getNextHiddenBoundary(true, 15));
+ assertEquals(20, h.getNextHiddenBoundary(true, 21));
+ }
+
+ @Test(groups = "Functional")
+ public void testGetNextHiddenBoundary_Right()
+ {
+ HiddenColumns h = new HiddenColumns();
+
+ // returns same value if no hidden cols
+ assertEquals(3, h.getNextHiddenBoundary(false, 3));
+
+ h.hideColumns(5, 10);
+ assertEquals(5, h.getNextHiddenBoundary(false, 3));
+ assertEquals(15, h.getNextHiddenBoundary(false, 15));
+ assertEquals(7, h.getNextHiddenBoundary(false, 7));
+
+ h.hideColumns(15, 20);
+ assertEquals(15, h.getNextHiddenBoundary(false, 7));
+ assertEquals(15, h.getNextHiddenBoundary(false, 14));
+
+ // returns same value if there is no next hidden column
+ assertEquals(22, h.getNextHiddenBoundary(false, 22));
+ }
+
+ @Test(groups = "Functional")
+ public void testIterator()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Iterator<int[]> result = h.iterator();
+ assertFalse(result.hasNext());
+
+ h.hideColumns(5, 10);
+ result = h.iterator();
+ int[] next = result.next();
+ assertEquals(5, next[0]);
+ assertEquals(10, next[1]);
+ assertFalse(result.hasNext());
+
+ h.hideColumns(22, 23);
+ result = h.iterator();
+ next = result.next();
+ assertEquals(5, next[0]);
+ assertEquals(10, next[1]);
+ next = result.next();
+ assertEquals(22, next[0]);
+ assertEquals(23, next[1]);
+ assertFalse(result.hasNext());
+
+ // test for only one hidden region at start of alignment
+ ColumnSelection sel = new ColumnSelection();
+ h.revealAllHiddenColumns(sel);
+ h.hideColumns(0, 1);
+ result = h.iterator();
+ next = result.next();
+ assertEquals(0, next[0]);
+ assertEquals(1, next[1]);
+ assertFalse(result.hasNext());
+ }
+
+ /* @Test(groups = "Functional")
+ public void testGetVisibleSequenceStrings()
+ {
+ HiddenColumns h = new HiddenColumns();
+ SequenceI seq1 = new Sequence("TEST1", "GALMFWKQESPVICYHRNDT");
+ SequenceI seq2 = new Sequence("TEST2", "VICYHRNDTGA");
+ SequenceI[] seqs = new SequenceI[2];
+ seqs[0] = seq1;
+ seqs[1] = seq2;
+ String[] result = h.getVisibleSequenceStrings(5, 10, seqs);
+ assertEquals(2, result.length);
+ assertEquals("WKQES", result[0]);
+ assertEquals("RNDTG", result[1]);
+
+ h.hideColumns(6, 8);
+ result = h.getVisibleSequenceStrings(5, 10, seqs);
+ assertEquals(2, result.length);
+ assertEquals("WS", result[0]);
+ assertEquals("RG", result[1]);
+
+ SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E---");
+ ColumnSelection sel = new ColumnSelection();
+ h.revealAllHiddenColumns(sel);
+ h.hideColumns(1, 3);
+ h.hideColumns(6, 11);
+ assertEquals("-D",
+ h.getVisibleSequenceStrings(0, 5, new SequenceI[]
+ { seq })[0]);
+ }*/
+
+ @Test(groups = "Functional")
+ public void testHideInsertionsFor()
+ {
+ HiddenColumns h = new HiddenColumns();
+ HiddenColumns h2 = new HiddenColumns();
+ SequenceI seq1 = new Sequence("TEST1", "GAL---MFW-KQESPVICY--HRNDT");
+ SequenceI seq2 = new Sequence("TEST1", "GALMFWKQESPVICYHRNDT");
+
+ h.hideList(seq2.getInsertions());
+ assertTrue(h.equals(h2));
+ assertEquals(0, h.getSize());
+
+ h.hideList(seq1.getInsertions());
+ h2.hideColumns(3, 5);
+ h2.hideColumns(9, 9);
+ h2.hideColumns(19, 20);
+ assertTrue(h.equals(h2));
+ assertEquals(6, h.getSize());
+ }
+
+ @Test(groups = "Functional")
+ public void testHideColumns_BitSet_range()
+ {
+ HiddenColumns h = new HiddenColumns();
+ HiddenColumns h2 = new HiddenColumns();
+
+ BitSet tohide = new BitSet(25);
+ h.hideColumns(tohide);
+ assertTrue(h.equals(h2));
+
+ // when setting bitset, first param is inclusive, second exclusive
+ tohide.set(3, 6);
+ tohide.set(9);
+ tohide.set(15, 21);
+ h.clearAndHideColumns(tohide, 5, 23);
+
+ h2.hideColumns(5, 5);
+ h2.hideColumns(9, 9);
+ h2.hideColumns(15, 20);
+ assertTrue(h.equals(h2));
+ assertEquals(h.getSize(), h2.getSize());
+
+ tohide.clear();
+ tohide.set(41);
+ h.clearAndHideColumns(tohide, 23, 30);
+ assertTrue(h.equals(h2));
+ assertEquals(h.getSize(), h2.getSize());
+
+ tohide.set(41);
+ h.clearAndHideColumns(tohide, 30, 45);
+ h2.hideColumns(41, 41);
+ assertTrue(h.equals(h2));
+ assertEquals(h.getSize(), h2.getSize());
+
+ tohide.clear();
+ tohide.set(25, 28);
+ h.clearAndHideColumns(tohide, 17, 50);
+ h2 = new HiddenColumns();
+ h2.hideColumns(5, 5);
+ h2.hideColumns(9, 9);
+ h2.hideColumns(15, 16);
+ h2.hideColumns(25, 27);
+ assertTrue(h.equals(h2));
+ assertEquals(h.getSize(), h2.getSize());
+
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(3, 5);
+ hc.hideColumns(15, 20);
+ hc.hideColumns(45, 60);
+
+ tohide = new BitSet();
+
+ // all unhidden if tohide is empty and range covers hidden
+ hc.clearAndHideColumns(tohide, 1, 70);
+ assertTrue(!hc.hasHiddenColumns());
+ assertEquals(0, hc.getSize());
+
+ hc.hideColumns(3, 5);
+ hc.hideColumns(15, 20);
+ hc.hideColumns(45, 60);
+ assertEquals(25, hc.getSize());
+
+ // but not if range does not cover hidden
+ hc.clearAndHideColumns(tohide, 23, 40);
+ assertTrue(hc.hasHiddenColumns());
+ assertEquals(25, hc.getSize());
+
+ // and partial unhide if range partially covers
+ hc.clearAndHideColumns(tohide, 1, 17);
+ Iterator<int[]> it = hc.iterator();
+ assertTrue(it.hasNext());
+ int[] region = it.next();
+
+ assertEquals(18, region[0]);
+ assertEquals(20, region[1]);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+
+ assertEquals(45, region[0]);
+ assertEquals(60, region[1]);
+
+ assertFalse(it.hasNext());
+ assertEquals(19, hc.getSize());
+ }
+
+ @Test(groups = "Functional")
+ public void testOffsetByVisibleColumns()
+ {
+ HiddenColumns h = new HiddenColumns();
+ int result = h.offsetByVisibleColumns(-1, 10);
+ assertEquals(9, result);
+
+ h.hideColumns(7, 9);
+ result = h.offsetByVisibleColumns(-4, 10);
+ assertEquals(3, result);
+
+ h.hideColumns(14, 15);
+ result = h.offsetByVisibleColumns(-4, 10);
+ assertEquals(3, result);
+
+ result = h.offsetByVisibleColumns(-10, 17);
+ assertEquals(2, result);
+
+ result = h.offsetByVisibleColumns(-1, 7);
+ assertEquals(5, result);
+
+ result = h.offsetByVisibleColumns(-1, 8);
+ assertEquals(5, result);
+
+ result = h.offsetByVisibleColumns(-3, 15);
+ assertEquals(10, result);
+
+ ColumnSelection sel = new ColumnSelection();
+ h.revealAllHiddenColumns(sel);
+ h.hideColumns(0, 30);
+ result = h.offsetByVisibleColumns(-31, 0);
+ assertEquals(-31, result);
+
+ HiddenColumns cs = new HiddenColumns();
+
+ // test that without hidden columns, offsetByVisibleColumns returns
+ // position n to left of provided position
+ long pos = cs.offsetByVisibleColumns(-3, 10);
+ assertEquals(7, pos);
+
+ // 0 returns same position
+ pos = cs.offsetByVisibleColumns(0, 10);
+ assertEquals(10, pos);
+
+ // overflow to left returns negative number
+ pos = cs.offsetByVisibleColumns(-3, 0);
+ assertEquals(-3, pos);
+
+ // test that with hidden columns to left of result column
+ // behaviour is the same as above
+ cs.hideColumns(1, 3);
+
+ // position n to left of provided position
+ pos = cs.offsetByVisibleColumns(-3, 10);
+ assertEquals(7, pos);
+
+ // 0 returns same position
+ pos = cs.offsetByVisibleColumns(0, 10);
+ assertEquals(10, pos);
+
+ // test with one set of hidden columns between start and required position
+ cs.hideColumns(12, 15);
+ pos = cs.offsetByVisibleColumns(-8, 17);
+ assertEquals(5, pos);
+
+ // test with two sets of hidden columns between start and required position
+ cs.hideColumns(20, 21);
+ pos = cs.offsetByVisibleColumns(-8, 23);
+ assertEquals(9, pos);
+
+ // repeat last 2 tests with no hidden columns to left of required position
+ ColumnSelection colsel = new ColumnSelection();
+ cs.revealAllHiddenColumns(colsel);
+
+ // test with one set of hidden columns between start and required position
+ cs.hideColumns(12, 15);
+ pos = cs.offsetByVisibleColumns(-8, 17);
+ assertEquals(5, pos);
+
+ // test with two sets of hidden columns between start and required position
+ cs.hideColumns(20, 21);
+ pos = cs.offsetByVisibleColumns(-8, 23);
+ assertEquals(9, pos);
+
+ // test with right (positive) offsets
+
+ // test that without hidden columns, offsetByVisibleColumns returns
+ // position n to right of provided position
+ pos = cs.offsetByVisibleColumns(3, 7);
+ assertEquals(10, pos);
+
+ // test that with hidden columns to left of result column
+ // behaviour is the same as above
+ cs.hideColumns(1, 3);
+
+ // test with one set of hidden columns between start and required position
+ cs.hideColumns(12, 15);
+ pos = cs.offsetByVisibleColumns(8, 5);
+ assertEquals(17, pos);
+
+ // test with two sets of hidden columns between start and required position
+ cs.hideColumns(20, 21);
+ pos = cs.offsetByVisibleColumns(8, 9);
+ assertEquals(23, pos);
+
+ // repeat last 2 tests with no hidden columns to left of required position
+ colsel = new ColumnSelection();
+ cs.revealAllHiddenColumns(colsel);
+
+ // test with one set of hidden columns between start and required position
+ cs.hideColumns(12, 15);
+ pos = cs.offsetByVisibleColumns(8, 5);
+ assertEquals(17, pos);
+
+ // test with two sets of hidden columns between start and required position
+ cs.hideColumns(20, 21);
+ pos = cs.offsetByVisibleColumns(8, 9);
+ assertEquals(23, pos);
+ }
+
+ @Test(groups = "Functional")
+ public void testBoundedIterator()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Iterator<int[]> it = h.getBoundedIterator(0, 10);
+
+ // no hidden columns = nothing to iterate over
+ assertFalse(it.hasNext());
+
+ // [start,end] contains all hidden columns
+ // all regions are returned
+ h.hideColumns(3, 10);
+ h.hideColumns(14, 16);
+ it = h.getBoundedIterator(0, 20);
+ assertTrue(it.hasNext());
+ int[] next = it.next();
+ assertEquals(3, next[0]);
+ assertEquals(10, next[1]);
+ next = it.next();
+ assertEquals(14, next[0]);
+ assertEquals(16, next[1]);
+ assertFalse(it.hasNext());
+
+ // [start,end] overlaps a region
+ // 1 region returned
+ it = h.getBoundedIterator(5, 7);
+ assertTrue(it.hasNext());
+ next = it.next();
+ assertEquals(3, next[0]);
+ assertEquals(10, next[1]);
+ assertFalse(it.hasNext());
+
+ // [start,end] fully contains 1 region and start of last
+ // - 2 regions returned
+ it = h.getBoundedIterator(3, 15);
+ assertTrue(it.hasNext());
+ next = it.next();
+ assertEquals(3, next[0]);
+ assertEquals(10, next[1]);
+ next = it.next();
+ assertEquals(14, next[0]);
+ assertEquals(16, next[1]);
+ assertFalse(it.hasNext());
+
+ // [start,end] contains end of first region and whole of last region
+ // - 2 regions returned
+ it = h.getBoundedIterator(4, 20);
+ assertTrue(it.hasNext());
+ next = it.next();
+ assertEquals(3, next[0]);
+ assertEquals(10, next[1]);
+ next = it.next();
+ assertEquals(14, next[0]);
+ assertEquals(16, next[1]);
+ assertFalse(it.hasNext());
+ }
+
+ @Test(groups = "Functional")
+ public void testBoundedStartIterator()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Iterator<Integer> it = h.getStartRegionIterator(0, 10);
+
+ // no hidden columns = nothing to iterate over
+ assertFalse(it.hasNext());
+
+ // [start,end] contains all hidden columns
+ // all regions are returned
+ h.hideColumns(3, 10);
+ h.hideColumns(14, 16);
+ it = h.getStartRegionIterator(0, 20);
+ assertTrue(it.hasNext());
+ int next = it.next();
+ assertEquals(3, next);
+ next = it.next();
+ assertEquals(6, next);
+ assertFalse(it.hasNext());
+
+ // [start,end] does not contain a start of a region
+ // no regions to iterate over
+ it = h.getStartRegionIterator(4, 5);
+ assertFalse(it.hasNext());
+
+ // [start,end] fully contains 1 region and start of last
+ // - 2 regions returned
+ it = h.getStartRegionIterator(3, 7);
+ assertTrue(it.hasNext());
+ next = it.next();
+ assertEquals(3, next);
+ next = it.next();
+ assertEquals(6, next);
+ assertFalse(it.hasNext());
+
+ // [start,end] contains whole of last region
+ // - 1 region returned
+ it = h.getStartRegionIterator(4, 20);
+ assertTrue(it.hasNext());
+ next = it.next();
+ assertEquals(6, next);
+ assertFalse(it.hasNext());
+ }
+
+ @Test(groups = "Functional")
+ public void testVisibleBlocksVisBoundsIterator()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Iterator<int[]> regions = h.getVisContigsIterator(0, 31, true);
+
+ // only 1 visible region spanning 0-30 if nothing is hidden
+ assertTrue(regions.hasNext());
+ int[] region = regions.next();
+ assertEquals(0, region[0]);
+ assertEquals(30, region[1]);
+ assertFalse(regions.hasNext());
+
+ // hide 1 region in middle
+ // 2 regions one on either side
+ // second region boundary accounts for hidden columns
+ h.hideColumns(10, 15);
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(0, region[0]);
+ assertEquals(9, region[1]);
+ region = regions.next();
+ assertEquals(16, region[0]);
+ assertEquals(36, region[1]);
+ assertFalse(regions.hasNext());
+
+ // single hidden region at left
+ h = new HiddenColumns();
+ h.hideColumns(0, 5);
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(6, region[0]);
+ assertEquals(36, region[1]);
+ assertFalse(regions.hasNext());
+
+ // single hidden region at right
+ h = new HiddenColumns();
+ h.hideColumns(27, 30);
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(0, region[0]);
+ assertEquals(26, region[1]);
+ region = regions.next();
+ assertEquals(31, region[0]);
+ assertEquals(34, region[1]);
+ assertFalse(regions.hasNext());
+
+ // hidden region at left + hidden region in middle
+ h = new HiddenColumns();
+ h.hideColumns(0, 5);
+ h.hideColumns(23, 25);
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(6, region[0]);
+ assertEquals(22, region[1]);
+ region = regions.next();
+ assertEquals(26, region[0]);
+ assertEquals(39, region[1]);
+ assertFalse(regions.hasNext());
+
+ // hidden region at right + hidden region in middle
+ h = new HiddenColumns();
+ h.hideColumns(27, 30);
+ h.hideColumns(11, 14);
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(0, region[0]);
+ assertEquals(10, region[1]);
+ region = regions.next();
+ assertEquals(15, region[0]);
+ assertEquals(26, region[1]);
+ region = regions.next();
+ assertEquals(31, region[0]);
+ assertEquals(38, region[1]);
+ assertFalse(regions.hasNext());
+
+ // hidden region at left and right
+ h = new HiddenColumns();
+ h.hideColumns(27, 35);
+ h.hideColumns(0, 4);
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(5, region[0]);
+ assertEquals(26, region[1]);
+ region = regions.next();
+ assertEquals(36, region[0]);
+ assertEquals(44, region[1]);
+ assertFalse(regions.hasNext());
+
+ // multiple hidden regions
+ h = new HiddenColumns();
+ h.hideColumns(1, 1);
+ h.hideColumns(3, 5);
+ h.hideColumns(9, 11);
+ h.hideColumns(22, 26);
+
+ regions = h.getVisContigsIterator(0, 31, true);
+
+ assertTrue(regions.hasNext());
+ region = regions.next();
+ assertEquals(0, region[0]);
+ assertEquals(0, region[1]);
+ region = regions.next();
+ assertEquals(2, region[0]);
+ assertEquals(2, region[1]);
+ region = regions.next();
+ assertEquals(6, region[0]);
+ assertEquals(8, region[1]);
+ region = regions.next();
+ assertEquals(12, region[0]);
+ assertEquals(21, region[1]);
+ region = regions.next();
+ assertEquals(27, region[0]);
+ assertEquals(42, region[1]);
+ assertFalse(regions.hasNext());
+ }
+
+ /*
+ * the VisibleColsIterator is tested elsewhere, this just tests that
+ * it can be retrieved from HiddenColumns
+ */
+ @Test(groups = "Functional")
+ public void testGetVisibleColsIterator()
+ {
+ HiddenColumns h = new HiddenColumns();
+ Iterator<Integer> it = h.getVisibleColsIterator(0, 10);
+
+ assertTrue(it instanceof RangeElementsIterator);
+ }
+
+ @Test(groups = "Functional")
+ public void testHashCode()
+ {
+ HiddenColumns h = new HiddenColumns();
+ h.hideColumns(0, 25);
+
+ int result = h.hashCode();
+ assertTrue(result > 0);
+
+ h.hideColumns(30, 50);
+ assertTrue(h.hashCode() > 0);
+ assertTrue(result != h.hashCode());
}
}
import static org.testng.Assert.assertTrue;
+import java.util.Iterator;
import java.util.NoSuchElementException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-public class VisibleColsIteratorTest
+public class RangeElementsIteratorTest
{
HiddenColumns hiddenCols;
@Test(groups = { "Functional" })
public void testHasNextAndNextWithHidden()
{
- VisibleColsIterator it = new VisibleColsIterator(0, 6, hiddenCols);
+ Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 6);
int count = 0;
while (it.hasNext())
{
- it.next();
+ int result = it.next();
+ System.out.println(result);
count++;
}
assertTrue(count == 4, "hasNext() is false after 4 iterations");
@Test(groups = { "Functional" })
public void testHasNextAndNextNoHidden()
{
- VisibleColsIterator it2 = new VisibleColsIterator(0, 3,
- new HiddenColumns());
+ HiddenColumns test = new HiddenColumns();
+ Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
int count = 0;
while (it2.hasNext())
{
@Test(groups = { "Functional" })
public void testHasNextAndNextStartHidden()
{
- VisibleColsIterator it3 = new VisibleColsIterator(0, 6,
- hiddenColsAtStart);
+ Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6);
int count = 0;
while (it3.hasNext())
{
@Test(groups = { "Functional" })
public void testHasNextAndNextEndHidden()
{
- VisibleColsIterator it4 = new VisibleColsIterator(0, 4, hiddenCols);
+ Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
int count = 0;
while (it4.hasNext())
{
expectedExceptions = { NoSuchElementException.class })
public void testLastNextWithHidden() throws NoSuchElementException
{
- VisibleColsIterator it = new VisibleColsIterator(0, 3, hiddenCols);
+ Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);
while (it.hasNext())
{
it.next();
expectedExceptions = { NoSuchElementException.class })
public void testLastNextNoHidden() throws NoSuchElementException
{
- VisibleColsIterator it2 = new VisibleColsIterator(0, 3,
- new HiddenColumns());
+ HiddenColumns test = new HiddenColumns();
+ Iterator<Integer> it2 = test.getVisibleColsIterator(0, 3);
while (it2.hasNext())
{
it2.next();
expectedExceptions = { NoSuchElementException.class })
public void testLastNextStartHidden() throws NoSuchElementException
{
- VisibleColsIterator it3 = new VisibleColsIterator(0, 6,
- hiddenColsAtStart);
+ Iterator<Integer> it3 = hiddenColsAtStart.getVisibleColsIterator(0, 6);
while (it3.hasNext())
{
it3.next();
expectedExceptions = { NoSuchElementException.class })
public void testLastNextEndHidden() throws NoSuchElementException
{
- VisibleColsIterator it4 = new VisibleColsIterator(0, 4, hiddenCols);
+ Iterator<Integer> it4 = hiddenCols.getVisibleColsIterator(0, 4);
while (it4.hasNext())
{
it4.next();
expectedExceptions = { UnsupportedOperationException.class })
public void testRemove() throws UnsupportedOperationException
{
- VisibleColsIterator it = new VisibleColsIterator(0, 3, hiddenCols);
+ Iterator<Integer> it = hiddenCols.getVisibleColsIterator(0, 3);
it.remove();
}
}
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.analysis.AlignmentGenerator;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
import jalview.datamodel.PDBEntry.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import junit.extensions.PA;
-
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
public class SequenceTest
{
Assert.assertEquals(pdbe1a,
sq.getDatasetSequence().getPDBEntry("1PDB"),
"PDB Entry '1PDB' not found on dataset sequence via getPDBEntry.");
- ArrayList<Annotation> annotsList = new ArrayList<Annotation>();
+ ArrayList<Annotation> annotsList = new ArrayList<>();
System.out.println(">>>>>> " + sq.getSequenceAsString().length());
annotsList.add(new Annotation("A", "A", 'X', 0.1f));
annotsList.add(new Annotation("A", "A", 'X', 0.1f));
}
@Test(groups = { "Functional" })
+ public void testGapBitset()
+ {
+ SequenceI sq = new Sequence("test/8-13", "-ABC---DE-F--");
+ BitSet bs = sq.gapBitset();
+ BitSet expected = new BitSet();
+ expected.set(0);
+ expected.set(4, 7);
+ expected.set(9);
+ expected.set(11, 13);
+
+ assertTrue(bs.equals(expected));
+
+ }
+
public void testFindFeatures_largeEndPos()
{
/*
assertEquals(8, sq.getDatasetSequence().getStart());
assertEquals(9, sq.getDatasetSequence().getEnd());
}
+
+ /**
+ * Test the code used to locate the reference sequence ruler origin
+ */
+ @Test(groups = { "Functional" })
+ public void testLocateVisibleStartofSequence()
+ {
+ // create random alignment
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+
+ HiddenColumns cs = al.getHiddenColumns();
+ ColumnSelection colsel = new ColumnSelection();
+
+ SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E---");
+ assertEquals(2, seq.findIndex(seq.getStart()));
+
+ // no hidden columns
+ assertEquals(seq.findIndex(seq.getStart()) - 1,
+ seq.firstResidueOutsideIterator(cs.iterator()));
+
+ // hidden column on gap after end of sequence - should not affect bounds
+ colsel.hideSelectedColumns(13, al.getHiddenColumns());
+ assertEquals(seq.findIndex(seq.getStart()) - 1,
+ seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ // hidden column on gap before beginning of sequence - should vis bounds by
+ // one
+ colsel.hideSelectedColumns(0, al.getHiddenColumns());
+ assertEquals(seq.findIndex(seq.getStart()) - 2,
+ cs.absoluteToVisibleColumn(
+ seq.firstResidueOutsideIterator(cs.iterator())));
+
+ cs.revealAllHiddenColumns(colsel);
+ // hide columns around most of sequence - leave one residue remaining
+ cs.hideColumns(1, 3);
+ cs.hideColumns(6, 11);
+
+ Iterator<int[]> it = cs.getVisContigsIterator(0, 6, false);
+
+ assertEquals("-D", seq.getSequenceStringFromIterator(it));
+ // cs.getVisibleSequenceStrings(0, 5, new SequenceI[]
+ // { seq })[0]);
+
+ assertEquals(4, seq.firstResidueOutsideIterator(cs.iterator()));
+ cs.revealAllHiddenColumns(colsel);
+
+ // hide whole sequence - should just get location of hidden region
+ // containing sequence
+ cs.hideColumns(1, 11);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 15);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ SequenceI seq2 = new Sequence("RefSeq2", "-------A-SD-ASD--E---");
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(7, 17);
+ assertEquals(0, seq2.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(3, 17);
+ assertEquals(0, seq2.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(3, 19);
+ assertEquals(0, seq2.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 0);
+ assertEquals(1, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 1);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 2);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(1, 1);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(1, 2);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(1, 3);
+ assertEquals(4, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 2);
+ cs.hideColumns(5, 6);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 2);
+ cs.hideColumns(5, 6);
+ cs.hideColumns(9, 10);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 2);
+ cs.hideColumns(7, 11);
+ assertEquals(3, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(2, 4);
+ cs.hideColumns(7, 11);
+ assertEquals(1, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(2, 4);
+ cs.hideColumns(7, 12);
+ assertEquals(1, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(1, 11);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 12);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 4);
+ cs.hideColumns(6, 12);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 1);
+ cs.hideColumns(3, 12);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(3, 14);
+ cs.hideColumns(17, 19);
+ assertEquals(0, seq2.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(3, 7);
+ cs.hideColumns(9, 14);
+ cs.hideColumns(17, 19);
+ assertEquals(0, seq2.firstResidueOutsideIterator(cs.iterator()));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(0, 1);
+ cs.hideColumns(3, 4);
+ cs.hideColumns(6, 8);
+ cs.hideColumns(10, 12);
+ assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
+
+ }
}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+public class StartRegionIteratorTest
+{
+ /**
+ * Test the start region iterator
+ */
+ @Test(groups = { "Functional" })
+ public void testBasicBoundsIterator()
+ {
+ List<int[]> hiddenColumns = null;
+
+ // null hidden columns
+ Iterator<Integer> it = new StartRegionIterator(3, 10,
+ hiddenColumns);
+ assertFalse(it.hasNext());
+
+ hiddenColumns = new ArrayList<>();
+
+ // no hidden columns
+ it = new StartRegionIterator(3, 10, hiddenColumns);
+ assertFalse(it.hasNext());
+
+ // add some hidden columns
+ hiddenColumns.add(new int[] { 5, 10 });
+ hiddenColumns.add(new int[] { 25, 40 });
+
+ it = new StartRegionIterator(3, 10, hiddenColumns);
+ assertTrue(it.hasNext());
+ Integer result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(3, 15, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(3, 18, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(3, 19, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(19, (int) result);
+ assertFalse(it.hasNext());
+
+ hiddenColumns.add(new int[] { 47, 50 });
+
+ it = new StartRegionIterator(15, 60, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(19, (int) result);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(25, (int) result);
+ assertFalse(it.hasNext());
+ }
+
+ /**
+ * Test the start region iterator with null cursor
+ */
+ @Test(groups = { "Functional" })
+ public void testBoundsIteratorUsingNullCursor()
+ {
+ List<int[]> hiddenColumns = null;
+ HiddenCursorPosition pos = null;
+
+ // null hidden columns
+ Iterator<Integer> it = new StartRegionIterator(pos, 3, 10,
+ hiddenColumns);
+ assertFalse(it.hasNext());
+
+ hiddenColumns = new ArrayList<>();
+
+ // no hidden columns
+ it = new StartRegionIterator(pos, 3, 10, hiddenColumns);
+ assertFalse(it.hasNext());
+
+ // add some hidden columns
+ hiddenColumns.add(new int[] { 5, 10 });
+ hiddenColumns.add(new int[] { 25, 40 });
+
+ it = new StartRegionIterator(pos, 3, 10, hiddenColumns);
+ assertTrue(it.hasNext());
+ Integer result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(pos, 3, 15, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(pos, 3, 18, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(pos, 3, 19, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(19, (int) result);
+ assertFalse(it.hasNext());
+
+ hiddenColumns.add(new int[] { 47, 50 });
+
+ it = new StartRegionIterator(pos, 15, 60, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(19, (int) result);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(25, (int) result);
+ assertFalse(it.hasNext());
+ }
+
+ /**
+ * Test the start region iterator with nonnull cursor
+ */
+ @Test(groups = { "Functional" })
+ public void testBoundsIteratorUsingCursor()
+ {
+ List<int[]> hiddenColumns = new ArrayList<>();
+
+ // add some hidden columns
+ hiddenColumns.add(new int[] { 5, 10 });
+ hiddenColumns.add(new int[] { 25, 40 });
+
+ HiddenCursorPosition pos = new HiddenCursorPosition(0, 0);
+
+ Iterator<Integer> it = new StartRegionIterator(pos, 3, 10,
+ hiddenColumns);
+ assertTrue(it.hasNext());
+ Integer result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(pos, 3, 15, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(pos, 3, 18, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertFalse(it.hasNext());
+
+ it = new StartRegionIterator(pos, 3, 19, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(5, (int) result);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(19, (int) result);
+ assertFalse(it.hasNext());
+
+ pos = new HiddenCursorPosition(1, 6);
+ hiddenColumns.add(new int[] { 47, 50 });
+
+ it = new StartRegionIterator(pos, 15, 60, hiddenColumns);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(19, (int) result);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(25, (int) result);
+ assertFalse(it.hasNext());
+ }
+}
--- /dev/null
+/*
+ * 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.datamodel;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+public class VisibleContigsIteratorTest
+{
+ /**
+ * Test the iterator with single visible regions
+ */
+ @Test(groups = { "Functional" })
+ public void testSimpleVisibleRegions()
+ {
+ List<int[]> hiddenColumns = null;
+
+ // null hidden columns
+ VisibleContigsIterator it = new VisibleContigsIterator(3, 10,
+ hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ int[] result = it.next();
+ assertEquals(3, result[0]);
+ assertEquals(9, result[1]);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+
+ hiddenColumns = new ArrayList<>();
+
+ // no hidden columns
+ it = new VisibleContigsIterator(3, 10,
+ hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(3, result[0]);
+ assertEquals(9, result[1]);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+
+ // hidden columns, but not where we are looking
+ hiddenColumns.add(new int[] { 5, 10 });
+ hiddenColumns.add(new int[] { 25, 40 });
+
+ it = new VisibleContigsIterator(2, 3, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(2, result[0]);
+ assertEquals(2, result[1]);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+
+ it = new VisibleContigsIterator(5, 7, hiddenColumns);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+
+ it = new VisibleContigsIterator(11, 15, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(11, result[0]);
+ assertEquals(14, result[1]);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+
+ it = new VisibleContigsIterator(50, 60, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(50, result[0]);
+ assertEquals(59, result[1]);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ }
+
+ /**
+ * Test the iterator with multiple visible regions
+ */
+ @Test(groups = { "Functional" })
+ public void testMultipleVisibleRegions()
+ {
+ List<int[]> hiddenColumns = new ArrayList<>();
+ hiddenColumns.add(new int[] { 5, 10 });
+ hiddenColumns.add(new int[] { 25, 40 });
+
+ // all hidden columns covered
+ VisibleContigsIterator it = new VisibleContigsIterator(3, 50,
+ hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ int[] result = it.next();
+ assertEquals(3, result[0]);
+ assertEquals(4, result[1]);
+
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(11, result[0]);
+ assertEquals(24, result[1]);
+
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(41, result[0]);
+ assertEquals(49, result[1]);
+
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ }
+
+ /**
+ * Test the iterator with regions which start/end at hidden region edges
+ */
+ @Test(groups = { "Functional" })
+ public void testVisibleRegionsAtHiddenEdges()
+ {
+ List<int[]> hiddenColumns = new ArrayList<>();
+ hiddenColumns.add(new int[] { 5, 10 });
+ hiddenColumns.add(new int[] { 25, 40 });
+
+ VisibleContigsIterator it = new VisibleContigsIterator(0, 10,
+ hiddenColumns);
+ assertTrue(it.hasNext());
+ assertTrue(it.endsAtHidden());
+ int[] result = it.next();
+ assertEquals(0, result[0]);
+ assertEquals(4, result[1]);
+ assertFalse(it.hasNext());
+ assertTrue(it.endsAtHidden());
+
+ it = new VisibleContigsIterator(2, 11, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertTrue(it.endsAtHidden());
+ result = it.next();
+ assertEquals(2, result[0]);
+ assertEquals(4, result[1]);
+ assertFalse(it.hasNext());
+ assertTrue(it.endsAtHidden());
+
+ it = new VisibleContigsIterator(2, 12, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(2, result[0]);
+ assertEquals(4, result[1]);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(11, result[0]);
+ assertEquals(11, result[1]);
+ assertFalse(it.hasNext());
+ assertFalse(it.endsAtHidden());
+
+ it = new VisibleContigsIterator(13, 25, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(13, result[0]);
+ assertEquals(24, result[1]);
+ assertFalse(it.hasNext());
+
+ it = new VisibleContigsIterator(13, 26, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertTrue(it.endsAtHidden());
+ result = it.next();
+ assertEquals(13, result[0]);
+ assertEquals(24, result[1]);
+ assertFalse(it.hasNext());
+
+ it = new VisibleContigsIterator(13, 27, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertTrue(it.endsAtHidden());
+ result = it.next();
+ assertEquals(13, result[0]);
+ assertEquals(24, result[1]);
+ assertFalse(it.hasNext());
+
+ it = new VisibleContigsIterator(13, 41, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertTrue(it.endsAtHidden());
+ result = it.next();
+ assertEquals(13, result[0]);
+ assertEquals(24, result[1]);
+ assertFalse(it.hasNext());
+
+ it = new VisibleContigsIterator(13, 42, hiddenColumns);
+ assertTrue(it.hasNext());
+ assertFalse(it.endsAtHidden());
+ result = it.next();
+ assertEquals(13, result[0]);
+ assertEquals(24, result[1]);
+ assertTrue(it.hasNext());
+ result = it.next();
+ assertEquals(41, result[0]);
+ assertEquals(41, result[1]);
+ }
+}
*/
package jalview.ext.jmol;
+import static org.junit.Assert.assertNotNull;
+import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.bin.Jalview;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.JvOptionPane;
import jalview.gui.StructureViewer;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileLoader;
+
+import java.lang.reflect.InvocationTargetException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@BeforeClass(alwaysRun = true)
public static void setUpBeforeClass() throws Exception
{
- Jalview.main(new String[] { "-noquestionnaire", "-nonews", "-props",
- "test/jalview/ext/rbvi/chimera/testProps.jvprops" });
+ Jalview.main(
+ new String[]
+ { "-noquestionnaire", "-nonews", "-props",
+ "test/jalview/ext/rbvi/chimera/testProps.jvprops" });
}
/**
@Test(groups = { "Functional" })
public void testSingleSeqViewJMol()
{
- Cache.setProperty(Preferences.STRUCTURE_DISPLAY, ViewerType.JMOL.name());
+ Cache.setProperty(Preferences.STRUCTURE_DISPLAY,
+ ViewerType.JMOL.name());
String inFile = "examples/1gaq.txt";
- AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, DataSourceType.FILE);
+ AlignFrame af = new jalview.io.FileLoader()
+ .LoadFileWaitTillLoaded(inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
for (SequenceI sq : af.getViewport().getAlignment().getSequences())
{
{
for (int q = 0; q < dsq.getAllPDBEntries().size(); q++)
{
- final StructureViewer structureViewer = new StructureViewer(af
- .getViewport().getStructureSelectionManager());
+ final StructureViewer structureViewer = new StructureViewer(
+ af.getViewport().getStructureSelectionManager());
structureViewer.setViewerType(ViewerType.JMOL);
JalviewStructureDisplayI jmolViewer = structureViewer
.viewStructures(dsq.getAllPDBEntries().elementAt(q),
- new SequenceI[] { sq }, af.getCurrentView()
- .getAlignPanel());
+ new SequenceI[]
+ { sq }, af.getCurrentView().getAlignPanel());
/*
* Wait for viewer load thread to complete
*/
}
}
+ @Test(groups = { "Functional" })
+ public void testAddStrToSingleSeqViewJMol()
+ throws InvocationTargetException, InterruptedException
+ {
+ Cache.setProperty(Preferences.STRUCTURE_DISPLAY,
+ ViewerType.JMOL.name());
+ String inFile = "examples/1gaq.txt";
+ AlignFrame af = new jalview.io.FileLoader(true)
+ .LoadFileWaitTillLoaded(inFile, DataSourceType.FILE);
+ assertTrue("Didn't read input file " + inFile, af != null);
+ // show a structure for 4th Sequence
+ SequenceI sq1 = af.getViewport().getAlignment().getSequences().get(0);
+ final StructureViewer structureViewer = new StructureViewer(
+ af.getViewport().getStructureSelectionManager());
+ structureViewer.setViewerType(ViewerType.JMOL);
+ JalviewStructureDisplayI jmolViewer = structureViewer.viewStructures(
+ sq1.getDatasetSequence().getAllPDBEntries().elementAt(0),
+ new SequenceI[]
+ { sq1 }, af.getCurrentView().getAlignPanel());
+ /*
+ * Wait for viewer load thread to complete
+ */
+ try
+ {
+ while (!jmolViewer.getBinding().isFinishedInit())
+ {
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e)
+ {
+ }
+
+ assertTrue(jmolViewer.isVisible());
+
+ // add another pdb file and add it to view
+ final String _inFile = "examples/3W5V.pdb";
+ inFile = _inFile;
+ FileLoader fl = new FileLoader();
+ fl.LoadFile(af.getCurrentView(), _inFile, DataSourceType.FILE,
+ FileFormat.PDB);
+ try
+ {
+ int time = 0;
+ do
+ {
+ Thread.sleep(50); // hope we can avoid race condition
+
+ } while (++time < 30
+ && af.getViewport().getAlignment().getHeight() == 3);
+ } catch (Exception q)
+ {
+ }
+ ;
+ assertTrue("Didn't paste additional structure" + inFile,
+ af.getViewport().getAlignment().getHeight() > 3);
+ SequenceI sq2 = af.getViewport().getAlignment().getSequenceAt(3);
+ PDBEntry pdbe = sq2.getDatasetSequence().getAllPDBEntries().get(0);
+ assertTrue(pdbe.getFile().contains(inFile));
+ structureViewer.viewStructures(pdbe, new SequenceI[] { sq2 },
+ af.alignPanel);
+ /*
+ * Wait for viewer load thread to complete
+ */
+ try
+ {
+ while (structureViewer.isBusy())
+ {
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e)
+ {
+ }
+ assertEquals(jmolViewer.getBinding().getPdbCount(), 2);
+ String mouseOverTest = "[GLY]293:A.CA/2.1 #2164";
+ ((JalviewJmolBinding) jmolViewer.getBinding()).mouseOverStructure(2164,
+ mouseOverTest);
+ SearchResultsI highlight = af.alignPanel.getSeqPanel()
+ .getLastSearchResults();
+ assertNotNull("Didn't find highlight from second structure mouseover",
+ highlight.getResults(sq2, sq2.getStart(), sq2.getEnd()));
+ }
}
import jalview.util.MessageManager;
import java.awt.Color;
-import java.util.List;
+import java.util.Iterator;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
*/
assertFalse(alignFrame.hideFeatureColumns("exon", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy()
- .isEmpty());
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 0);
assertFalse(alignFrame.hideFeatureColumns("exon", false));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy()
- .isEmpty());
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 0);
/*
* hiding a feature in all columns does nothing
*/
assertFalse(alignFrame.hideFeatureColumns("Metal", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- List<int[]> hidden = alignFrame.getViewport().getAlignment()
- .getHiddenColumns()
- .getHiddenColumnsCopy();
- assertTrue(hidden.isEmpty());
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 0);
/*
* hide a feature present in some columns
* [1-3], [6-8] base zero
*/
assertTrue(alignFrame.hideFeatureColumns("Turn", true));
- hidden = alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy();
- assertEquals(hidden.size(), 2);
- assertEquals(hidden.get(0)[0], 1);
- assertEquals(hidden.get(0)[1], 3);
- assertEquals(hidden.get(1)[0], 6);
- assertEquals(hidden.get(1)[1], 8);
+ Iterator<int[]> regions = alignFrame.getViewport().getAlignment()
+ .getHiddenColumns().iterator();
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 2);
+ int[] next = regions.next();
+ assertEquals(next[0], 1);
+ assertEquals(next[1], 3);
+ next = regions.next();
+ assertEquals(next[0], 6);
+ assertEquals(next[1], 8);
}
@BeforeClass(alwaysRun = true)
import jalview.io.FormatAdapter;
import java.io.IOException;
-import java.util.List;
+import java.util.Iterator;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
HiddenColumns currentHidden = af.getViewport().getAlignment()
.getHiddenColumns();
- List<int[]> regions = currentHidden.getHiddenColumnsCopy();
- assertEquals(regions.get(0)[0], 0);
- assertEquals(regions.get(0)[1], 3);
- assertEquals(regions.get(1)[0], 22);
- assertEquals(regions.get(1)[1], 25);
+ Iterator<int[]> regions = currentHidden.iterator();
+ int[] next = regions.next();
+ assertEquals(0, next[0]);
+ assertEquals(3, next[1]);
+ next = regions.next();
+ assertEquals(22, next[0]);
+ assertEquals(25, next[1]);
// now reset hidden columns
acc.reset();
currentHidden = af.getViewport().getAlignment().getHiddenColumns();
- regions = currentHidden.getHiddenColumnsCopy();
- assertEquals(regions.get(0)[0], 10);
- assertEquals(regions.get(0)[1], 20);
+ regions = currentHidden.iterator();
+ next = regions.next();
+ assertEquals(10, next[0]);
+ assertEquals(20, next[1]);
// check works with empty hidden columns as old columns
oldhidden = new HiddenColumns();
acc.reset();
currentHidden = af.getViewport().getAlignment().getHiddenColumns();
- regions = currentHidden.getHiddenColumnsCopy();
- assertEquals(regions.get(0)[0], 10);
- assertEquals(regions.get(0)[1], 20);
+ regions = currentHidden.iterator();
+ next = regions.next();
+ assertEquals(10, next[0]);
+ assertEquals(20, next[1]);
}
}
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.datamodel.ColumnSelection;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import java.awt.Component;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import javax.swing.JMenu;
public void testConfigureReferenceAnnotationsMenu_noSequenceSelected()
{
JMenuItem menu = new JMenuItem();
- List<SequenceI> seqs = new ArrayList<SequenceI>();
+ List<SequenceI> seqs = new ArrayList<>();
testee.configureReferenceAnnotationsMenu(menu, seqs);
assertFalse(menu.isEnabled());
// now try null list
List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
// create list of links and list of DBRefs
- List<String> links = new ArrayList<String>();
- List<DBRefEntry> refs = new ArrayList<DBRefEntry>();
+ List<String> links = new ArrayList<>();
+ List<DBRefEntry> refs = new ArrayList<>();
// links as might be added into Preferences | Connections dialog
links.add("EMBL-EBI Search | http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$"
}
// if there are no valid links the Links submenu is disabled
- List<String> nomatchlinks = new ArrayList<String>();
+ List<String> nomatchlinks = new ArrayList<>();
nomatchlinks.add("NOMATCH | http://www.uniprot.org/uniprot/$"
+ DB_ACCESSION + "$");
assertFalse(linkMenu.isEnabled());
}
+
+ /**
+ * Test for adding feature links
+ */
+ @Test(groups = { "Functional" })
+ public void testHideInsertions()
+ {
+ // get sequences from the alignment
+ List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
+
+ // add our own seqs to avoid problems with changes to existing sequences
+ // (gap at end of sequences varies depending on how tests are run!)
+ Sequence seqGap1 = new Sequence("GappySeq",
+ "AAAA----AA-AAAAAAA---AAA-----------AAAAAAAAAA--");
+ seqGap1.createDatasetSequence();
+ seqs.add(seqGap1);
+ Sequence seqGap2 = new Sequence("LessGappySeq",
+ "AAAAAA-AAAAA---AAA--AAAAA--AAAAAAA-AAAAAA");
+ seqGap2.createDatasetSequence();
+ seqs.add(seqGap2);
+ Sequence seqGap3 = new Sequence("AnotherGapSeq",
+ "AAAAAA-AAAAAA--AAAAAA-AAAAAAAAAAA---AAAAAAAA");
+ seqGap3.createDatasetSequence();
+ seqs.add(seqGap3);
+ Sequence seqGap4 = new Sequence("NoGaps",
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
+ seqGap4.createDatasetSequence();
+ seqs.add(seqGap4);
+
+ ColumnSelection sel = new ColumnSelection();
+ parentPanel.av.getAlignment().getHiddenColumns()
+ .revealAllHiddenColumns(sel);
+
+ // get the Popup Menu for 7th sequence - no insertions
+ testee = new PopupMenu(parentPanel, (Sequence) seqs.get(7), null);
+ testee.hideInsertions_actionPerformed(null);
+
+ HiddenColumns hidden = parentPanel.av.getAlignment().getHiddenColumns();
+ Iterator<int[]> it = hidden.iterator();
+ assertFalse(it.hasNext());
+
+ // get the Popup Menu for GappySeq - this time we have insertions
+ testee = new PopupMenu(parentPanel, (Sequence) seqs.get(4), null);
+ testee.hideInsertions_actionPerformed(null);
+ hidden = parentPanel.av.getAlignment().getHiddenColumns();
+ it = hidden.iterator();
+
+ assertTrue(it.hasNext());
+ int[] region = it.next();
+ assertEquals(region[0], 4);
+ assertEquals(region[1], 7);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 10);
+ assertEquals(region[1], 10);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 18);
+ assertEquals(region[1], 20);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 24);
+ assertEquals(region[1], 34);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 45);
+ assertEquals(region[1], 46);
+
+ assertFalse(it.hasNext());
+
+ sel = new ColumnSelection();
+ hidden.revealAllHiddenColumns(sel);
+
+ // make a sequence group and hide insertions within the group
+ SequenceGroup sg = new SequenceGroup();
+ sg.setStartRes(8);
+ sg.setEndRes(42);
+ sg.addSequence(seqGap2, false);
+ sg.addSequence(seqGap3, false);
+ parentPanel.av.setSelectionGroup(sg);
+
+ // hide columns outside and within selection
+ // only hidden columns outside the collection will be retained (unless also
+ // gaps in the selection)
+ hidden.hideColumns(1, 10);
+ hidden.hideColumns(31, 40);
+
+ // get the Popup Menu for LessGappySeq in the sequence group
+ testee = new PopupMenu(parentPanel, (Sequence) seqs.get(5), null);
+ testee.hideInsertions_actionPerformed(null);
+ hidden = parentPanel.av.getAlignment().getHiddenColumns();
+ it = hidden.iterator();
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 1);
+ assertEquals(region[1], 7);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 13);
+ assertEquals(region[1], 14);
+
+ assertTrue(it.hasNext());
+ region = it.next();
+ assertEquals(region[0], 34);
+ assertEquals(region[1], 34);
+ }
+
}
+/*
+ * 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.testng.Assert.assertEquals;
import java.awt.Font;
import java.awt.FontMetrics;
-import junit.extensions.PA;
-
import org.testng.annotations.Test;
-import sun.swing.SwingUtilities2;
+import junit.extensions.PA;
public class SeqCanvasTest
{
av.setScaleAboveWrapped(true);
av.setScaleLeftWrapped(true);
av.setScaleRightWrapped(true);
- FontMetrics fm = SwingUtilities2.getFontMetrics(testee, av.getFont());
+ FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("000") + charWidth;
assertEquals(labelWidth, 39); // 3 x 9 + charWidth
av.setScaleAboveWrapped(true);
av.setScaleLeftWrapped(true);
av.setScaleRightWrapped(true);
- FontMetrics fm = SwingUtilities2.getFontMetrics(testee, av.getFont());
+ FontMetrics fm = testee.getFontMetrics(av.getFont());
int labelWidth = fm.stringWidth("000") + charWidth;
assertEquals(labelWidth, 39); // 3 x 9 + charWidth
int annotationHeight = testee.getAnnotationHeight();
package jalview.gui;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.fts.api.FTSData;
import jalview.jbgui.GStructureChooser.FilterOption;
+import java.util.Collection;
import java.util.Vector;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
public class StructureChooserTest
{
SequenceI[] selectedSeqs = new SequenceI[] { seq };
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null);
sc.fetchStructuresMetaData();
- assertTrue(sc.getDiscoveredStructuresSet() != null);
- assertTrue(sc.getDiscoveredStructuresSet().size() > 0);
+ Collection<FTSData> ss = (Collection<FTSData>) PA.getValue(sc,
+ "discoveredStructuresSet");
+ assertNotNull(ss);
+ assertTrue(ss.size() > 0);
}
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@Test(singleThreaded = true)
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
+ @DataProvider(name = "initialAccessions")
+ static Object[][] getAccessions()
+ {
+ return new String[][] { { "UNIPROT", "P00338" },
+ { "UNIPROT", "Q8Z9G6" },
+ { "ENSEMBLGENOMES", "CAD01290" } };
+ }
+
/**
* test store and recovery of all reachable cross refs from all reachable
* crossrefs for one or more fetched db refs. Currently, this test has a known
*
* @throws Exception
*/
- @Test(groups = { "Operational" }, enabled = true)
- public void testRetrieveAndShowCrossref() throws Exception
+ @Test(
+ groups =
+ { "Operational" },
+ dataProvider = "initialAccessions",
+ enabled = true)
+ public void testRetrieveAndShowCrossref(String forSource,
+ String forAccession) throws Exception
{
List<String> failedDBRetr = new ArrayList<>();
List<String> keyseq = new ArrayList<>();
HashMap<String, File> savedProjects = new HashMap<>();
- for (String[] did : new String[][] { { "UNIPROT", "P00338" } })
- {
+// for (String[] did : new String[][] { { "UNIPROT", "P00338" } })
+// {
// pass counters - 0 - first pass, 1 means retrieve project rather than
// perform action
int pass1 = 0, pass2 = 0, pass3 = 0;
// { pass 2 = 0 { pass 3 = 0 } }
do
{
- String first = did[0] + " " + did[1];
+ String first = forSource + " " + forAccession;//did[0] + " " + did[1];
AlignFrame af = null;
boolean dna;
AlignmentI retral;
// retrieve dbref
List<AlignFrame> afs = jalview.gui.SequenceFetcher.fetchAndShow(
- did[0], did[1]);
+ forSource, forAccession);
+ // did[0], did[1]);
if (afs.size() == 0)
{
failedDBRetr.add("Didn't retrieve " + first);
pass1++;
}
} while (pass1 < 3);
- }
+
if (failedXrefMenuItems.size() > 0)
{
for (String s : failedXrefMenuItems)
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
TEST_SEQ_HEIGHT = expectedSeqs.size();
TEST_GRP_HEIGHT = expectedGrps.size();
TEST_ANOT_HEIGHT = expectedAnnots.size();
- TEST_CS_HEIGHT = expectedColSel.getHiddenColumnsCopy().size();
+ TEST_CS_HEIGHT = expectedColSel.getNumberOfRegions();
exportSettings = new AlignExportSettingI()
{
{
HiddenColumns cs = testJsonFile.getHiddenColumns();
Assert.assertNotNull(cs);
- Assert.assertNotNull(cs.getHiddenColumnsCopy());
- List<int[]> hiddenCols = cs.getHiddenColumnsCopy();
- Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT);
- Assert.assertEquals(hiddenCols.get(0), expectedColSel
- .getHiddenColumnsCopy().get(0),
+
+ Iterator<int[]> it = cs.iterator();
+ Iterator<int[]> colselit = expectedColSel.iterator();
+ Assert.assertTrue(it.hasNext());
+ Assert.assertEquals(cs.getNumberOfRegions(), TEST_CS_HEIGHT);
+ Assert.assertEquals(it.next(), colselit.next(),
"Mismatched hidden columns!");
}
}
+ /**
+ * Test for JAL-2223 - multiple mappings in View Mapping report
+ *
+ * @throws Exception
+ */
+ @Test(groups = { "Functional" })
+ public void noDuplicatePdbMappingsMade() throws Exception
+ {
+ StructureImportSettings.setProcessSecondaryStructure(true);
+ StructureImportSettings.setVisibleChainAnnotation(true);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/exampleFile_2_7.jar", DataSourceType.FILE);
+ assertNotNull(af, "Didn't read in the example file correctly.");
+
+ // locate Jmol viewer
+ // count number of PDB mappings the structure selection manager holds -
+ String pdbFile = af.getCurrentView().getStructureSelectionManager()
+ .findFileForPDBId("1A70");
+ assertEquals(
+ af.getCurrentView().getStructureSelectionManager()
+ .getMapping(pdbFile).length,
+ 2, "Expected only two mappings for 1A70");
+
+ }
+
@Test(groups = { "Functional" })
public void viewRefPdbAnnotation() throws Exception
{
String afid = af.getViewport().getSequenceSetId();
// remember reference sequence for each panel
- Map<String, SequenceI> refseqs = new HashMap<String, SequenceI>();
+ Map<String, SequenceI> refseqs = new HashMap<>();
/*
* mark sequence 2, 3, 4.. in panels 1, 2, 3...
* remember representative and hidden sequences marked
* on each panel
*/
- Map<String, SequenceI> repSeqs = new HashMap<String, SequenceI>();
- Map<String, List<String>> hiddenSeqNames = new HashMap<String, List<String>>();
+ Map<String, SequenceI> repSeqs = new HashMap<>();
+ Map<String, List<String>> hiddenSeqNames = new HashMap<>();
/*
* mark sequence 2, 3, 4.. in panels 1, 2, 3...
repIndex = Math.max(repIndex, 1);
SequenceI repSeq = alignment.getSequenceAt(repIndex);
repSeqs.put(ap.getViewName(), repSeq);
- List<String> hiddenNames = new ArrayList<String>();
+ List<String> hiddenNames = new ArrayList<>();
hiddenSeqNames.put(ap.getViewName(), hiddenNames);
/*
--- /dev/null
+/*
+ * 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.renderer;
+
+import static org.testng.Assert.assertEquals;
+
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
+import jalview.renderer.seqfeatures.FeatureRenderer;
+import jalview.schemes.FeatureColour;
+import jalview.schemes.ZappoColourScheme;
+import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.OverviewDimensions;
+import jalview.viewmodel.OverviewDimensionsShowHidden;
+import jalview.viewmodel.ViewportRanges;
+
+import java.awt.Color;
+
+import org.testng.annotations.Test;
+public class OverviewRendererTest
+{
+
+ @Test
+ public void testGetColumnColourFromSequence()
+ {
+ OverviewResColourFinder cf = new OverviewResColourFinder(false,
+ Color.PINK, Color.green); // gapColour, hiddenColour
+ Sequence seq1 = new Sequence("seq1", "PQ-RL-");
+ Sequence seq2 = new Sequence("seq2", "FVE");
+ AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
+ AlignmentViewport av = new AlignViewport(al);
+ OverviewDimensions od = new OverviewDimensionsShowHidden(new ViewportRanges(al), false);
+ ResidueShaderI rs = new ResidueShader(new ZappoColourScheme());
+ FeatureRenderer fr = new FeatureRenderer(av);
+ OverviewRenderer or = new OverviewRenderer(fr, od, al, rs, cf);
+
+ // P is magenta (see ResidueProperties.zappo)
+ assertEquals(or.getColumnColourFromSequence(null, seq1, 0), Color.magenta.getRGB());
+ // Q is green
+ assertEquals(or.getColumnColourFromSequence(null, seq1, 1),
+ Color.green.getRGB());
+ // gap is pink (specified in OverviewResColourFinder constructor above)
+ assertEquals(or.getColumnColourFromSequence(null, seq1, 2),
+ Color.pink.getRGB());
+ // F is orange
+ assertEquals(or.getColumnColourFromSequence(null, seq2, 0),
+ Color.orange.getRGB());
+ // E is red
+ assertEquals(or.getColumnColourFromSequence(null, seq2, 2),
+ Color.red.getRGB());
+ // past end of sequence colour as gap (JAL-2929)
+ assertEquals(or.getColumnColourFromSequence(null, seq2, 3),
+ Color.pink.getRGB());
+
+ /*
+ * now add a feature on seq1
+ */
+ seq1.addSequenceFeature(
+ new SequenceFeature("Pfam", "desc", 1, 4, null));
+ fr.findAllFeatures(true);
+ av.setShowSequenceFeatures(true);
+ fr.setColour("Pfam", new FeatureColour(Color.yellow));
+ assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
+ Color.yellow.getRGB());
+
+ // don't show sequence features
+ av.setShowSequenceFeatures(false);
+ assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
+ Color.magenta.getRGB());
+ }
+}
+/*
+ * 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.renderer.seqfeatures;
import static org.testng.Assert.assertEquals;
fr.filterFeaturesForDisplay(features, new FeatureColour(Color.black,
Color.white, 0f, 1f));
assertEquals(features.size(), 4);
- assertTrue(features.contains(sf1));
- assertTrue(features.contains(sf3));
- assertTrue(features.contains(sf4));
- assertTrue(features.contains(sf5));
+ assertFalse(features.contains(sf2));
/*
* co-located features with colour by label
assertTrue(features.contains(sf3));
assertTrue(features.contains(sf4));
assertTrue(features.contains(sf5));
+
+ /*
+ * no filtering if transparency is applied
+ */
+ fr.setTransparency(0.5f);
+ features = seq.getSequenceFeatures();
+ fr.setGroupVisibility("group2", true);
+ fr.filterFeaturesForDisplay(features, new FeatureColour(Color.RED));
+ assertEquals(features.size(), 5);
}
}
@Test(groups = { "Functional" })
public void compareTransferredToRefPDBAnnot() throws Exception
{
+ StructureImportSettings.setProcessSecondaryStructure(true);
+ StructureImportSettings.setVisibleChainAnnotation(true);
StructureImportSettings.setShowSeqFeatures(true);
AlignFrame ref = new FileLoader(false)
.LoadFileWaitTillLoaded("test/jalview/ext/jmol/1QCF.pdb",
+/*
+ * 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.structure;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import jalview.datamodel.Mapping;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.util.MapList;
+
import java.util.HashMap;
import java.util.List;
public class StructureMappingTest
{
@Test(groups = "Functional")
- public void testgetPDBResNumRanges()
+ public void testGetPDBResNumRanges()
{
- HashMap<Integer, int[]> map = new HashMap<Integer, int[]>();
+ HashMap<Integer, int[]> map = new HashMap<>();
StructureMapping mapping = new StructureMapping(null, null, null, null,
map, null);
assertEquals(ranges.get(1)[0], 15);
assertEquals(ranges.get(1)[1], 15);
}
+
+ @Test(groups = "Functional")
+ public void testEquals()
+ {
+ SequenceI seq1 = new Sequence("seq1", "ABCDE");
+ SequenceI seq2 = new Sequence("seq1", "ABCDE");
+ String pdbFile = "a/b/file1.pdb";
+ String pdbId = "1a70";
+ String chain = "A";
+ String mappingDetails = "these are the mapping details, honest";
+ HashMap<Integer, int[]> map = new HashMap<>();
+
+ Mapping seqToPdbMapping = new Mapping(seq1,
+ new MapList(new int[]
+ { 1, 5 }, new int[] { 2, 6 }, 1, 1));
+ StructureMapping sm1 = new StructureMapping(seq1, pdbFile, pdbId, chain,
+ map, mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(null));
+ assertFalse(sm1.equals("x"));
+
+ StructureMapping sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain,
+ map, mappingDetails, seqToPdbMapping);
+ assertTrue(sm1.equals(sm2));
+ assertTrue(sm2.equals(sm1));
+ assertEquals(sm1.hashCode(), sm2.hashCode());
+
+ // with different sequence
+ sm2 = new StructureMapping(seq2, pdbFile, pdbId, chain, map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different file
+ sm2 = new StructureMapping(seq1, "a/b/file2.pdb", pdbId, chain, map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different pdbid (case sensitive)
+ sm2 = new StructureMapping(seq1, pdbFile, "1A70", chain, map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different chain
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, "B", map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // map is ignore for this test
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, null,
+ mappingDetails, seqToPdbMapping);
+ assertTrue(sm1.equals(sm2));
+ assertTrue(sm2.equals(sm1));
+
+ // with different mapping details
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map,
+ "different details!", seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different seq to pdb mapping
+ Mapping map2 = new Mapping(seq1,
+ new MapList(new int[]
+ { 1, 5 }, new int[] { 3, 7 }, 1, 1));
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map,
+ mappingDetails, map2);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+ }
}
MapList ml7 = new MapList(codons, protein, 3, 1); // toShifts differ
assertTrue(ml.equals(ml));
+ assertEquals(ml.hashCode(), ml.hashCode());
assertTrue(ml.equals(ml1));
+ assertEquals(ml.hashCode(), ml1.hashCode());
assertTrue(ml1.equals(ml));
assertFalse(ml.equals(null));
@Test(groups = { "Functional" })
public void testGetRanges()
{
- List<int[]> ranges = new ArrayList<int[]>();
+ 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)));
public void testAddRange()
{
int[] range = { 1, 5 };
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
// add to empty list:
MapList.addRange(range, ranges);
public void testCoalesceRanges()
{
assertNull(MapList.coalesceRanges(null));
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
assertSame(ranges, MapList.coalesceRanges(ranges));
ranges.add(new int[] { 1, 3 });
assertSame(ranges, MapList.coalesceRanges(ranges));
@Test(groups = { "Functional" })
public void testCoalesceRanges_withOverlap()
{
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
ranges.add(new int[] { 1, 3 });
ranges.add(new int[] { 2, 5 });
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;
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
assertEquals("[]", dnaSelection.getSelected().toString());
- List<int[]> hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[0, 4]", Arrays.toString(hidden.get(0)));
+ Iterator<int[]> regions = dnaHidden.iterator();
+ assertEquals(1, dnaHidden.getNumberOfRegions());
+ assertEquals("[0, 4]", Arrays.toString(regions.next()));
/*
* Column 1 in protein picks up Seq1/K which maps to cols 0-3 in dna
proteinSelection.hideSelectedColumns(1, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
+ regions = dnaHidden.iterator();
+ assertEquals(1, dnaHidden.getNumberOfRegions());
+ assertEquals("[0, 3]", Arrays.toString(regions.next()));
/*
* Column 2 in protein picks up gaps only - no mapping
proteinSelection.hideSelectedColumns(2, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- assertTrue(dnaHidden.getHiddenColumnsCopy().isEmpty());
+ assertEquals(0, dnaHidden.getNumberOfRegions());
/*
* Column 3 in protein picks up Seq1/P, Seq2/Q, Seq3/S which map to columns
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
assertEquals("[0, 1, 2, 3]", dnaSelection.getSelected().toString());
- hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[5, 10]", Arrays.toString(hidden.get(0)));
+ regions = dnaHidden.iterator();
+ assertEquals(1, dnaHidden.getNumberOfRegions());
+ assertEquals("[5, 10]", Arrays.toString(regions.next()));
/*
* Combine hiding columns 1 and 3 to get discontiguous hidden columns
proteinSelection.hideSelectedColumns(3, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
- assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
- assertEquals("[5, 10]", Arrays.toString(hidden.get(1)));
+ regions = dnaHidden.iterator();
+ assertEquals(2, dnaHidden.getNumberOfRegions());
+ assertEquals("[0, 3]", Arrays.toString(regions.next()));
+ assertEquals("[5, 10]", Arrays.toString(regions.next()));
}
@Test(groups = { "Functional" })
+/*
+ * 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.ws.dbsources;
import static org.testng.Assert.assertEquals;
@Test(groups = "Functional")
public void testGetURL()
{
+ String path = "pfam.xfam.org/family/ABC/alignment/full";
+
// with default value for domain
String url = new PfamFull().getURL(" abc ");
- assertEquals(url, "http://pfam.xfam.org/family/ABC/alignment/full");
+ assertEquals(url, "https://" + path);
// with override in properties
- Cache.setProperty("PFAM_DOMAIN", "https://pfam.xfam.org");
+ Cache.setProperty(Pfam.PFAM_BASEURL_KEY, "http://pfam.xfam.org");
url = new PfamFull().getURL(" abc ");
- assertEquals(url, "https://pfam.xfam.org/family/ABC/alignment/full");
+ assertEquals(url, "http://" + path);
}
}
+/*
+ * 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.ws.dbsources;
import static org.testng.Assert.assertEquals;
@Test(groups = "Functional")
public void testGetURL()
{
+ String path = "pfam.xfam.org/family/ABC/alignment/seed";
+
// with default value for domain
String url = new PfamSeed().getURL(" abc ");
- assertEquals(url, "http://pfam.xfam.org/family/ABC/alignment/seed");
+ assertEquals(url, "https://" + path);
// with override in properties
- Cache.setProperty("PFAM_DOMAIN", "https://pfam.xfam.org");
+ Cache.setProperty(Pfam.PFAM_BASEURL_KEY, "http://pfam.xfam.org");
url = new PfamSeed().getURL(" abc ");
- assertEquals(url, "https://pfam.xfam.org/family/ABC/alignment/seed");
+ assertEquals(url, "http://" + path);
}
}
+/*
+ * 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.ws.dbsources;
import static org.testng.Assert.assertEquals;
@Test(groups = "Functional")
public void testGetURL()
{
+ String path = "rfam.xfam.org/family/ABC/alignment/full";
+
// with default value for domain
String url = new RfamFull().getURL(" abc ");
- assertEquals(url, "http://rfam.xfam.org/family/ABC/alignment/full");
+ assertEquals(url, "https://" + path);
// with override in properties
- Cache.setProperty("RFAM_DOMAIN", "https://rfam.xfam.org");
+ Cache.setProperty(Rfam.RFAM_BASEURL_KEY, "http://rfam.xfam.org");
url = new RfamFull().getURL(" abc ");
- assertEquals(url, "https://rfam.xfam.org/family/ABC/alignment/full");
+ assertEquals(url, "http://" + path);
}
}
+/*
+ * 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.ws.dbsources;
import static org.testng.Assert.assertEquals;
@Test(groups = "Functional")
public void testGetURL()
{
+ String path = "rfam.xfam.org/family/ABC/alignment/stockholm";
+
// with default value for domain
String url = new RfamSeed().getURL(" abc ");
- assertEquals(url,
- "http://rfam.xfam.org/family/ABC/alignment/stockholm");
+ assertEquals(url, "https://" + path);
// with override in properties
- Cache.setProperty("RFAM_DOMAIN", "https://rfam.xfam.org");
+ Cache.setProperty(Rfam.RFAM_BASEURL_KEY, "http://rfam.xfam.org");
url = new RfamSeed().getURL(" abc ");
- assertEquals(url,
- "https://rfam.xfam.org/family/ABC/alignment/stockholm");
+ assertEquals(url, "http://" + path);
}
}
<string><![CDATA[logo.gif]]></string>
</property>
<property name="smallIconPath">
- <string><![CDATA[/home/cruisecontrol/jalview/resources/images/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/resources/images/]]></string>
</property>
<property name="largeIconPath">
- <string><![CDATA[/home/cruisecontrol/jalview/resources/images/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/resources/images/]]></string>
</property>
<property name="macOSXIconPath">
- <string><![CDATA[/home/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
</property>
<property name="macOSXIconName">
<string><![CDATA[mac_logo.icns]]></string>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/dist/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/dist/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
</object>
</method>
<method name="addElement">
+ <object class="com.zerog.ia.installer.actions.InstallZipfile" objectID="9a1f46efeef911a">
+ <property name="belongsToUninstallPhase">
+ <boolean>false</boolean>
+ </property>
+ <property name="rollbackEnabledCancel">
+ <boolean>true</boolean>
+ </property>
+ <property name="rollbackEnabledError">
+ <boolean>true</boolean>
+ </property>
+ <property name="ruleExpression">
+ <string><![CDATA[]]></string>
+ </property>
+ <property name="unixPermissions">
+ <string><![CDATA[664]]></string>
+ </property>
+ <property name="sourceName">
+ <string><![CDATA[VAqua4.jar]]></string>
+ </property>
+ <property name="overrideUnixPermissions">
+ <boolean>false</boolean>
+ </property>
+ <property name="sourcePath">
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
+ </property>
+ <property name="shouldUninstall">
+ <boolean>true</boolean>
+ </property>
+ <property name="rollbackEnabledCancel">
+ <boolean>true</boolean>
+ </property>
+ <property name="rollbackEnabledError">
+ <boolean>true</boolean>
+ </property>
+ <property name="destinationName">
+ <string><![CDATA[VAqua4.jar]]></string>
+ </property>
+ <property name="fileSize">
+ <long>1355141</long>
+ </property>
+ <property name="macBinary">
+ <boolean>false</boolean>
+ </property>
+ <property name="targetCheckKind">
+ <int>0</int>
+ </property>
+ <property name="ruleExpression">
+ <string><![CDATA[]]></string>
+ </property>
+ </object>
+ </method>
+ <method name="addElement">
<object class="com.zerog.ia.installer.actions.InstallZipfile" objectID="1936efeefab93">
<property name="belongsToUninstallPhase">
<boolean>false</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<string><![CDATA[The installer cannot run on your configuration. It will now quit.]]></string>
</property>
<property name="userSplashPath">
- <string><![CDATA[/home/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
</property>
<property name="userSplashName">
<string><![CDATA[jalview.gif]]></string>
<boolean>true</boolean>
</property>
<property name="buildOutputLocation">
- <string><![CDATA[/opt/homes/cruisecontrol/live/cruisecontrol/checkout/next-release-jalview/utils/InstallAnywhere/Jalview_Build_Output]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/utils/InstallAnywhere/Jalview_Build_Output]]></string>
</property>
<property name="relatedProjectSettings">
<object class="com.zerog.ia.installer.RelatedProjectSettings" objectID="97f2363da6ac">
<boolean>true</boolean>
</property>
<property name="backgroundImagePath">
- <string><![CDATA[/home/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
</property>
<property name="backgroundImageName">
<string><![CDATA[align.gif]]></string>
<object refID="24485f8ca673"/>
<object refID="24485f8ba674"/>
<object refID="24485f8ca674"/>
+ <object refID="9a1f46efeef911a"/>
<object class="com.zerog.ia.installer.actions.CreateShortcut" objectID="3cd8e2ffa672">
<property name="belongsToUninstallPhase">
<boolean>false</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/doc/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/doc/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/lib]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/lib]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<object refID="24485f8ca673"/>
<object refID="24485f8ba674"/>
<object refID="24485f8ca674"/>
+ <object refID="9a1f46efeef911a"/>
<object refID="b1a16838a449"/>
<object refID="b1a16839a449"/>
<object refID="495aeddb8b3d"/>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples/groovy]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples/groovy]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/home/cruisecontrol/jalview/examples]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/examples]]></string>
</property>
<property name="shouldUninstall">
<boolean>false</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/opt/homes/cruisecontrol/live/cruisecontrol/checkout/next-release-jalview/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<boolean>false</boolean>
</property>
<property name="sourcePath">
- <string><![CDATA[/opt/homes/cruisecontrol/live/cruisecontrol/checkout/next-release-jalview/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/]]></string>
</property>
<property name="shouldUninstall">
<boolean>true</boolean>
<string><![CDATA[]]></string>
</property>
<property name="imagePath">
- <string><![CDATA[/home/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
+ <string><![CDATA[/homes/cruisecontrol/jalview/utils/InstallAnywhere/]]></string>
</property>
<property name="imageName">
<string><![CDATA[bartonGroup.gif]]></string>
<project name="jalviewInstallAnywhere" default="build" basedir=".">
<property name="IA_LOCATION" value="/home/cruisecontrol/InstallAnywhere 2013/"/>
<property name="IA_PROJECT" location="Jalview.iap_xml"/>
- <property name="ABS_PATH" value="/home/cruisecontrol/jalview"/> <!-- \/utils\/InstallAnywhere"/> --> <!--/home/cruisecontrol/jalview"/> -->
+ <property name="ABS_PATH" value="/homes/cruisecontrol/jalview"/> <!-- \/utils\/InstallAnywhere"/> --> <!--/home/cruisecontrol/jalview"/> -->
<!-- location of top level of jalview distribution directory -->
<property name="CUR_PATH" location="../../." />
<property name="USER_HOME" location="~" />