+/*
+ * 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.
+ */
+
import jalview.workers.FeatureCounterI;
import jalview.workers.AlignmentAnnotationFactory;
<mapID target="memory" url="html/memory.html" />
<mapID target="groovy" url="html/features/groovy.html" />
+ <mapID target="groovy.featurecounter" url="html/groovy/featureCounter.html" />
<mapID target="privacy" url="html/privacy.html" />
<mapID target="vamsas" url="html/vamsas/index.html"/>
<mapID target="aminoAcids" url="html/misc/aminoAcids.html" />
<mapID target="biojson" url="html/features/bioJsonFormat.html" />
<mapID target="pdbfetcher" url="html/features/pdbsequencefetcher.html" />
+ <mapID target="siftsmapping" url="html/features/siftsmapping.html" />
<mapID target="pdbchooser" url="html/features/structurechooser.html" />
<mapID target="selectcolbyannot" url="html/features/columnFilterByAnnotation.html" />
<mapID target="biojsmsa" url="html/features/biojsmsa.html" />
<tocitem text="What's new" target="new" expand="true">
<tocitem text="Retrieval from ENSEMBL" target="ensemblfetch" />
<tocitem text="UniProt Free Text Search" target="uniprotfetcher" />
-
+ <tocitem text="SIFTS for mapping PDB structures to UniProt" target="siftsmapping" />
<tocitem text="Latest Release Notes" target="release"/>
</tocitem>
</tocitem>
<tocitem text="Preferences" target="preferences" />
<tocitem text="Memory Settings" target="memory" expand="false"/>
+ <tocitem text="Scripting with Groovy" target="groovy">
+ <tocitem text="Groovy Feature Counter example" target="groovy.featurecounter"/>
+ </tocitem>
<tocitem text="Command Line" target="commandline" expand="false">
<tocitem text="Command Line Arguments" target="clarguments" />
- <tocitem text="Groovy Shell" target="groovy" />
</tocitem>
<tocitem text="Privacy" target="privacy" />
</tocitem>
entry from the consensus annotation label to copy the alignment's
consensus sequence to the clipboard.
<p>
- <strong>Sequence logo</strong>
+ <a name="logo"><strong>Sequence logo</strong></a>
</p>
By clicking on the label you can also activate the sequence logo. It
indicates the relative amount of residues per column which can be
<p>
<strong>Reference Sequence Alignment Views</strong>
</p>
+ <p>Many alignment analysis tasks concern a query, or reference
+ sequence. For instance, when searching for sequences from other
+ organisms that are similar to a newly sequenced gene, or when
+ searching for structurally similar sequences for use in homology
+ modelling.</p>
+<p>
+ <strong>What happens when a reference sequence is defined ?</strong>
+ </p>
<p>
The reference sequence for an alignment is indicated by its ID being
- shown in bold. When a reference sequence has been defined, the <strong>Format→Show
- unconserved</strong> option highlights mutations with respect to the
- reference sequence, rather than the alignment's consensus sequence.
- </p>
+ shown in bold. In addition:</p>
+ <ul>
+ <li><strong>Reference sequence numbering</strong>. Instead of
+ column numbers, the alignment ruler shows the reference sequence
+ positions at each column. At each tick mark, either the reference
+ sequence symbol and position is given, or the column number when a
+ gap is present at that position in the reference sequence.</li>
+ <li><strong>Format→Show unconserved</strong> highlights
+ mutations with respect to the reference sequence, rather than the
+ alignment's consensus sequence.</li>
+ </ul>
<p>
+ <strong>Defining the reference sequence</strong>
+ </p>
+ <p>Each alignment view can have its own reference sequence.</p>
<ul>
- <li>Jalview automatically assigns a reference sequence when <a
- href="../webServices/jnet.html"
- >JPred4</a> predictions are imported.
- </li>
- <li><strong>Assigning a reference sequence</strong><br /> A
- sequence can be marked as the reference sequence by right-clicking
- on it's ID to open the popup menu, and selecting the "<strong>(Sequence
- ID)→Mark as Reference</strong>" entry."</li>
+ <li><strong>Manually assigning a reference sequence</strong><br />
+ A sequence can be marked as the reference sequence by
+ right-clicking on its ID to open the popup menu, and selecting the
+ "<strong>(Sequence ID)→Mark as Reference</strong>" entry.</li>
+ <li><strong>Defining a reference when importing
+ annotation</strong><br />Jalview automatically assigns a reference
+ sequence when importing analysis results, such as those returned
+ from <a href="../webServices/jnet.html">JPred4</a> . A reference
+ sequence can also be assigned via the <a
+ href="../features/annotationsFormat.html#refsandviews">SET_REF</a> command in
+ an alignment annotation file.</li>
</ul>
<p>
<em>Reference sequence based alignment visualisation was
- introduced in Jalview 2.9.</em>
+ introduced in Jalview 2.9, and support for storage and retrieval
+ of reference sequence views in 2.10.</em>
</p>
</html>
<strong>Alignment RNA Structure Consensus Annotation</strong>
</p>
+ <p>The RNA structure consensus displayed below the alignment gives the
+ percentage of valid base pairs per column for the first secondary
+ structure annotation shown on the annotation panel. These values are
+ shown as a histogram labeled "StrucConsensus", where a
+ symbol below each bar indicates whether the majority of base pairs
+ are:<ul>
+ <li>'(' - Watson-Crick (C:G, A:U/T)</li>
+ <li>'[' - Non-canonical (a.ka. wobble) (G:U/T)</li>
+ <li>'{' - Invalid (a.k.a. tertiary) (the rest)</li>
+ </ul>
+ <p>Mousing over the column gives the fraction of pairs classified
+ as Watson-Crick, Canonical or Invalid.</p>
+
+ <p>By default
+ this calculation includes gaps in columns. You can choose to ignore
+ gaps in the calculation by right clicking on the label
+ "StrucConsensus" to the left of the structure consensus bar
+ chart.<br>
+
<p>
- The RNA structure consensus displayed below the alignment is the
- percentage of valid base pairs per column. It is calculated in
- relation to a secondary structure and just paired columns are
- calculated. The canonical Watson-Crick base pairings (A-T/U, G-C)
- and the wobble base pair (G-T/U) are regarded as valid pairings.<br>
- The amount of valid base pairs is indicated by the profile in the
- Alignment Annotation row.<br> By default this calculation
- includes gaps in columns. You can choose to ignore gaps in the
- calculation by right clicking on the label "StrConsensus"
- to the left of the structure consensus bar chart.<br>
- <p>
- <strong>Structure logo</strong>
- </p>
- By clicking on the label you can also activate the structure logo. It
- is very similar to a sequence logo but counts the numbers of base
- pairs. There are two residues per column, the actual column and the
- interacting base. The opening bracket is always the one on the left
- side.
- <br> Like sequence logos the relative amount of a specific base
- pair can be estimated by its size in the logo. The tool tip of a
- column gives the exact numbers for all occurring valid base pairs.
+ <strong>RNA Structure logo</strong><br /> Right-clicking on the
+ label allows you to enable the structure logo. It is very similar to
+ a sequence logo but instead shows the distribution of base pairs.
+ There are two residues per column, the actual column and the
+ interacting base. The opening bracket is always the one on the left
+ side. <br> Like <a href="consensus.html#logo">sequence
+ logos</a>, the relative amount of a specific base pair can be
+ estimated by its size in the logo, and this can be made more obvious
+ by <em>normalising</em> the logo (enabled via the popup menu). When
+ the logo is displayed, the tool tip for a column gives the exact
+ percentages for all base pairs at that position.
</p>
</body>
</html>
* along with Jalview. If not, see <http://www.gnu.org/licenses/>.
* The Jalview Authors are detailed in the 'AUTHORS' file.
-->
-<head><title>Alignment Annotation</title></head>
+<head>
+<title>Alignment Annotation</title>
+</head>
<body>
-<p><strong>Alignment Annotation</strong></p>
+ <p>
+ <strong>Alignment Annotation</strong>
+ </p>
-<p>In addition to the definition of groups and sequence features,
- Jalview can display symbols and graphs under the columns of an
- alignment, and allow you to mark particular columns of an alignment and add symbols and text
- in the annotation area shown below the alignment (which may be hidden if <strong>View→Show
- Annotation</strong> is not ticked). Any displayed annotation row can be hidden (using the pop-up
- menu obtained by right-clicking the label), or re-ordered by dragging the label to a new
- position with the left mouse button.</p>
-<p>
-Web services can also add annotation to an alignment (see the <a
-href="../webServices/jnet.html">JNet</a> and <a
-href="../webServices/proteinDisorder.html">Disorder</a> protein
-structure prediction services), and as of Jalview 2.08 quantitative
-and symbolic annotations can be added to an alignment via an <a
-href="annotationsFormat.html">Annotations File</a> dragged into the
-alignment window or loaded from the alignment's file menu.
-</p>
-<p><a name="seqannots"/><strong>Sequence Reference Annotation</strong>
-</p>
-<p>
- Sequence reference annotation is created from 3D structure
- data, and from the results of sequence based prediction of
- <a href="../webServices/jnet.html">secondary structure</a> and <a
- href="../webServices/proteinDisorder.html">disordered region</a>
- prediction methods.
-</p>
-<p><strong>Sequence Group Annotation</strong>
-</p>
-<p>
- If sequence groups are defined, <a href="../calculations/conservation.html">Conservation</a>
- and <a href="../calculations/consensus.html">Consensus</a> annotation can be enabled
- for each group from the <a href="../menus/alwannotation.html">Annotations menu</a>, or can
- be imported from a Jalview <a href="annotationsFormat.html">Annotations file</a>.
-</p>
-<p><strong>Sequence Selection from Annotation</strong>
-</p>
-<p>
- Sequences associated with sequence (or sequence group) annotations can be selected by
- double-clicking the annotation label with these key combinations:
- <ul>
- <li>double-click - Select associated sequences (replaces current selection)</li>
- <li>shift double-click - add sequences to selection</li>
- <li>Ctrl (Mac CMD) double-click - toggles inclusion of associated sequences in the current selection</li>
- </ul>
- Note this also works in combination with manual sequence selection in the alignment.
-<p><strong>Interactive Alignment Annotation</strong></p>
-<p>
-Annotation rows are added using the <strong>Annotation Label</strong>
-menu, which is obtained by clicking anywhere on the annotation row labels
-area (below the sequence ID area).
-</p>
-<ul>
- <li><strong>Add New Row</strong><br>
- <em>Adds a new, named annotation row (a dialog box will pop up for you to
- enter the label for the new row). </em> </li>
- <li><strong>Edit Label/Description</strong><br>
- <em>This opens a dialog where you can change the name (displayed label), or the description
- (as shown on the label tooltip) of the clicked annotation. </em> </li>
- <li><strong>Hide This Row</strong><br>
- <em>Hides the annotation row whose label was clicked in order to bring up
- the menu.</em> </li>
- <li><strong>Hide All <em><label></em></strong><br>
- <em>Hides all annotation rows whose label matches the one clicked.
- (This option is only shown for annotations that relate to individual sequences,
- not for whole alignment annotations. Since Jalview 2.8.2.)</em> </li>
- <li><strong>Delete This Row</strong><br>
- <em>Deletes the annotation row whose label was clicked in order to bring up
- the menu.</em> </li>
- <li><strong>Show All Hidden Rows</strong><br>
- <em>Shows all hidden annotation rows.</em> </li>
- <li><strong>Export Annotation</strong> <em>(Application only)</em><br>
- <em>Annotations can be saved to file or output to a text window in either the
- Jalview annotations format or as a spreadsheet style set of comma separated values (CSV). </em> </li>
- <li><strong>Show Values in Text Box</strong> <em>(applet only)</em><br>
- <em>Opens a text box with a list of comma-separated values corresponding
- to the annotation (numerical or otherwise) at each position in the row.
- This is useful to export alignment quality measurements for further analysis.</em>
- </li>
- <li><strong>Scale Label To Column</strong><em>(introduced in 2.5)</em><br>
- <em>Selecting this toggles whether column labels will be shrunk to fit within each column, or displayed using the view's standard font size.</em></li>
-</ul>
-<p>
-<strong>Editing Label and secondary structure Annotation</strong></p>
-<p>
-Use the <strong>left mouse button</strong> to select a position along the row that are to
-be annotated - these regions will be coloured red. <strong>Control</strong> and <strong>shift</strong> in combination
-with the left-click will select more than one position, or a range of
-positions on the alignment.
-</p>
-<p>Once the desired position has been selected, use the <strong>right mouse
-button</strong> to open the <strong>annotation menu</strong>:</p>
-<ul>
-<li>Helix<br><em>Mark selected positions with a helix glyph (a red
-oval), and optional text label (see below). A
-dialog box will open for you to enter the text. Consecutive ovals
-will be rendered as an unbroken red line.</em>
-</li>
-<li>Sheet<br><em>Mark selected positions with a sheet glyph (a green
-arrow oriented from left to right), and optional text label (see
-below). A dialog box will open for you to enter the text. Consecutive
-arrows will be joined together to form a single green arrow.</em>
-</li>
-<li><a name="rna">RNA Helix</a> (only shown when working with nucleotide sequences)<br>
-<em>Mark selected positions as participating in a base pair
-either upstream or downstream. When the dialog box opens, enter a
-'(' to indicate these bases pair with columns upstream (to right),
-and ')' to indicate this region pairs with bases to the left of the
-highlighted columns.<br />If any brackets do not match up, then an
-orange square will highlight the first position where a bracket was
-found not to match.
-</em>
-</li>
-<li>Label<br><em>Set the text label at the selected positions. A
-dialog box will open for you to enter the text. If
-more than one consecutive position is marked with the same label, only
-the first position's label will be rendered.</em>
-</li>
-<li>Colour<br><em>Changes the colour of the annotation text label.</em>
-</li>
-<li>Remove Annotation<br><em>Blanks any annotation at the selected positions on
-the row. Note: <strong>This cannot be undone</strong></em>
-</li>
-</ul>
-<p>
-User defined annotation is stored and retrieved using <a
-href="../features/jalarchive.html">Jalview Archives</a>.
-</p>
-<p><em>Current Limitations</em></p>
-<p>As of version 2.5, the Jalview user interface does not support the
-creation and editing of quantitative annotation (histograms and line graphs), or
-to create annotation associated with a specific sequence. It is also incapable of
-annotation grouping or changing the style of existing annotation (to change between line or bar charts, or to make multiple line graphs). These annotation capabilities are only possible by the import of an
-<a href="annotationsFormat.html">Annotation file</a>.<br>
-</p>
+ <p>
+ In addition to the definition of groups and sequence features,
+ Jalview can display symbols and graphs under the columns of an
+ alignment. These annotation tracks are displayed in the annotation
+ area below the alignment. The annotation area's visibility is
+ controlled with the <strong>View→Show Annotation</strong>
+ option.
+ </p>
+ <p>
+ <strong>Types of annotation</strong>
+ <ul>
+ <li><a name="seqannots"><strong>Sequence
+ associated annotation.</strong></a><br/>Data displayed on sequence annotation
+ rows are associated with the positions of a sequence. Often this
+ is 'Reference annotation' such as secondary structure information
+ derived from 3D structure data, or from the results of sequence
+ based prediction of <a href="../webServices/jnet.html">secondary
+ structure</a> and <a href="../webServices/proteinDisorder.html">disorder</a>.
+ If reference annotation is available for a the currently selected
+ sequences, it can be shown by selecting the <strong>Add
+ Reference Annotation</strong> option in the sequence or selection popup
+ menu.</li>
+ <li><strong>Group associated annotation.</strong><br/>Data can be associated with
+ groups defined on the alignment. If sequence groups are defined, <a
+ href="../calculations/conservation.html">Conservation</a> and <a
+ href="../calculations/consensus.html">Consensus</a> annotation can
+ be enabled for each group from the <a
+ href="../menus/alwannotation.html">Annotations menu</a>, or can be
+ imported from a Jalview <a href="annotationsFormat.html">Annotations
+ file</a>.</li>
+ <li><strong>Alignment associated annotation.</strong><br />Annotation rows
+ associated with columns on the alignment are simply 'alignment
+ annotation'. Controls allow you to <a href="#iaannot">interactively create
+ alignment annotation</a> to add labels and symbols to alignment columns.
+ Jalview's consensus, conservation and quality calculations also
+ create histogram and sequence logo annotations on the alignment.
+ </li>
+ </ul>
+ <p>
+ <strong>Importing and exporting annotation</strong><br />
+ Annotations on an alignment view are saved in Jalview project files.
+ You can also load <a href="annotationsFormat.html">Annotations
+ Files</a> in order to add any kind of quantitative and symbolic
+ annotations to an alignment. To see an example, use the <strong>Export
+ Features/Annotation</strong> option from an alignment window's File menu.
+ </p>
+ <p>
+ <strong>Layout and display controls</strong><br /> Individual and
+ groups of annotation rows can be shown or hidden using the pop-up
+ menu obtained by right-clicking the label. You can also reorder them
+ by dragging the label to a new position with the left mouse button.
+ The
+ <strong>Annotations</strong> menu provides settings controlling the
+ ordering and display of sequence, group and alignment associated
+ annotation. The
+ <strong>Colour by annotation</strong> option in the colour menu
+ allows annotation to be used to
+ <a href="../colourSchemes/annotationColouring.html">shade the
+ alignment</a>. Annotations can also be used to
+ <a href="../features/columnFilterByAnnotation.html">select or
+ hide columns</a> via the dialog opened from the
+ <strong>Selection</strong> menu.
+ </p>
+ <p>
+ <strong>Sequence Highlighting and Selection from Annotation</strong>
+ </p>
+ <p>
+ A <strong>single click</strong> on the label of an annotation row
+ associated with sequences and sequence groups will cause the
+ associated sequences to be highlighted in the alignment view. <strong>Double
+ clicking</strong> the label will select the associated sequences, replacing
+ any existing selection. Like with other kinds of selection, <strong>shift
+ double-click</strong> will add associated sequences, and <strong>Ctrl
+ (Mac CMD) double-click</strong> will toggle inclusion of associated
+ sequences in the selection.
+ <p>
+ <strong>Interactive Alignment Annotation</strong>
+ </p>
+ <p>
+ <a name="iaannot"> Annotation rows</a> are added using the <strong>Annotation
+ Label</strong> menu, which is obtained by clicking anywhere on the
+ annotation row labels area (below the sequence ID area).
+ </p>
+ <ul>
+ <li><strong>Add New Row</strong><br> <em>Adds a new,
+ named annotation row (a dialog box will pop up for you to enter
+ the label for the new row). </em></li>
+ <li><strong>Edit Label/Description</strong><br> <em>This
+ opens a dialog where you can change the name (displayed label),
+ or the description (as shown on the label tooltip) of the
+ clicked annotation. </em></li>
+ <li><strong>Hide This Row</strong><br> <em>Hides the
+ annotation row whose label was clicked in order to bring up the
+ menu.</em></li>
+ <li><strong>Hide All <em><label></em></strong><br> <em>Hides
+ all annotation rows whose label matches the one clicked. (This
+ option is only shown for annotations that relate to individual
+ sequences, not for whole alignment annotations. Since Jalview
+ 2.8.2.)</em></li>
+ <li><strong>Delete This Row</strong><br> <em>Deletes
+ the annotation row whose label was clicked in order to bring up
+ the menu.</em></li>
+ <li><strong>Show All Hidden Rows</strong><br> <em>Shows
+ all hidden annotation rows.</em></li>
+ <li><strong>Export Annotation</strong> <em>(Application
+ only)</em><br> <em>Annotations can be saved to file or
+ output to a text window in either the Jalview annotations format
+ or as a spreadsheet style set of comma separated values (CSV). </em>
+ </li>
+ <li><strong>Show Values in Text Box</strong> <em>(applet
+ only)</em><br> <em>Opens a text box with a list of
+ comma-separated values corresponding to the annotation
+ (numerical or otherwise) at each position in the row. This is
+ useful to export alignment quality measurements for further
+ analysis.</em></li>
+ <li><strong>Scale Label To Column</strong><em>(introduced
+ in 2.5)</em><br> <em>Selecting this toggles whether column
+ labels will be shrunk to fit within each column, or displayed
+ using the view's standard font size.</em></li>
+ </ul>
+ <p>
+ <strong>Editing labels and secondary structure annotation rows</strong>
+ </p>
+ <p>
+ Use the <strong>left mouse button</strong> to select a position
+ along the row that are to be annotated - these regions will be
+ coloured red. Press <strong>Control</strong> or <strong>shift</strong> in
+ combination with the left-click to either select an additional position,
+ or a range of positions on the alignment.
+ </p>
+ <p>
+ Once positions have been selected, use the <strong>right
+ mouse button</strong> and select one of the following from the <strong>annotation menu</strong>:
+ </p>
+ <ul>
+ <li>Helix<br>
+ <em>Marks selected positions with a helix glyph (a red oval),
+ and optional text label (see below). A dialog box will open for
+ you to enter the text. Consecutive ovals will be rendered as an
+ unbroken red line.</em>
+ </li>
+ <li>Sheet<br>
+ <em>Marks selected positions with a sheet glyph (a green arrow
+ oriented from left to right), and optional text label (see
+ below). A dialog box will open for you to enter the text.
+ Consecutive arrows will be joined together to form a single
+ green arrow.</em>
+ </li>
+ <li><a name="rna">RNA Helix</a> (only shown when working with
+ nucleotide sequences)<br> <em>Marks selected positions
+ as participating in a base pair either upstream or downstream.
+ When the dialog box opens, enter a '(' to indicate these bases
+ pair with columns upstream (to right), and ')' to indicate this
+ region pairs with bases to the left of the highlighted columns.
+ Other kinds of base-pair annotation are also supported (e.g. 'A'
+ and 'a', or '<' and '>'), and Jalview will suggest an
+ appropriate symbol based on the closest unmatched
+ parenthesis to the left.<br />If any brackets do not match up, then an
+ orange square will highlight the first position where a bracket
+ was found not to match.
+ </em></li>
+ <li>Label<br>
+ <em>Set the text label at the selected positions. A dialog box
+ will open for you to enter the text. If more than one
+ consecutive position is marked with the same label, only the
+ first position's label will be rendered.</em>
+ </li>
+ <li>Colour<br>
+ <em>Changes the colour of the annotation text label.</em>
+ </li>
+ <li>Remove Annotation<br>
+ <em>Blanks any annotation at the selected positions on the row.
+ Note: <strong>This cannot be undone</strong>
+ </em>
+ </li>
+ </ul>
+ <p>
+ User defined annotation is stored and retrieved using <a
+ href="../features/jalarchive.html">Jalview Archives</a>.
+ </p>
+ <p>
+ <em>Current Limitations</em>
+ </p>
+ <p>
+ The Jalview user interface does not support interactive
+ creation and editing of quantitative annotation (histograms and line
+ graphs), or to create annotation associated with a specific
+ sequence or group. It is also incapable of annotation grouping or changing
+ the style of existing annotation (e.g. to change between line or bar
+ charts, or to make multiple line graphs). These annotation
+ capabilities are only possible by the import of an <a
+ href="annotationsFormat.html">Annotation file</a>.<br>
+ </p>
</body>
</html>
</p>
<p>
<strong><em>Feature settings pop-up menu</em></strong><br> <strong>Right-click</strong>
- on a feature to open a pop-up menu that allows you to sort the
- alignment or current selection using that feature type (see below),
- or toggle the type of colouring used for the feature. Features may
- be highlighted with either a single colour or a <a
- href="featureschemes.html"
- >feature colourscheme</a> based on either the scores associated with
- that feature or from the feature's description (e.g. to distinguish
+ on a feature to open a pop-up menu that allows you to<ul><li>Hide, show and
+ select columns containing that feature</li><li>Sort the alignment or
+ current selection using that feature type (see below)</li><li>Toggle the
+ type of colouring used for the feature</li></ul><p>Features may be highlighted
+ with either a single colour or a <a href="featureschemes.html">feature
+ colourscheme</a> based on either the scores associated with that
+ feature or from the feature's description (e.g. to distinguish
different names associated with a DOMAIN feature).
</p>
<p>
<strong>The Groovy Shell</strong>
</p>
<p>
- <a href="http://www.groovy-lang.org/">Groovy</a> is an "<em>agile
- and dynamic language for the Java platform</em>". The groovy
- scripting language makes it extremely easy to programmatically
- interact with Java programs, in much the same way that Javascript is
- used to generate and interact with applets and other objects on the
- page.
+ Groovy (<a href="http://www.groovy-lang.org/">www.groovy-lang.org</a>)
+ is an "<em>agile and dynamic language for the Java
+ platform</em>". The groovy scripting language makes it extremely
+ easy to programmatically interact with Java programs, in much the
+ same way that Javascript is used to generate and interact with
+ applets and other objects on the page.
</p>
<p>
- <strong><em>Getting Groovy...</em> </strong><br> Jalview comes with
- an embedded installation of Groovy. All you need is to select <strong>Tools→Groovy
- Console...</strong> menu option from the Jalview Desktop's
- drop-down menu. After a short pause, you should then see the <a
- href="http://groovy-lang.org/groovyconsole.html"
- >Groovy Console</a> appear. This allows you to interactively execute Groovy
- scripts within the Jalview run-time environment.
+ <em>Getting Groovy...</em><br> Jalview comes with an embedded
+ installation of Groovy. Just select <strong>Tools→Groovy
+ Console...</strong> from the Jalview Desktop's drop-down menu. After a
+ short pause, you should then see the <a
+ href="http://groovy-lang.org/groovyconsole.html">Groovy
+ Console</a> appear. This allows you to interactively execute Groovy
+ scripts whilst Jalview is running. We've also provided a <strong>Calculations→Execute
+ Groovy Script</strong> button so you can execute the currently loaded
+ groovy script whilst viewing an alignment.
</p>
<p>
<strong>Executing groovy scripts on Jalview startup</strong><br>
</em>
</p>
<p>
- <strong>Executing a groovy script on a particular alignment</strong><br/>
-
- <p>
<strong>Access to Jalview's functions from Groovy Scripts</strong><br>
- There is as yet no properly defined scripting interface to Jalview,
- but all the public methods of the jalview class hierarchy can be
- called from Groovy scripts. The access point for this is the <strong>Jalview</strong>
- object defined in the groovy environment which corresponds to the
- <pre>jalview.gui.Desktop</pre>
- object which manages all the Jalview windows. Here's an example to get
- you started:
- <br>
+ The scripting interface to Jalview is still a work in progress, so
+ we recommend you also take a look at Jalview's source, since all the
+ public methods of the jalview class hierarchy can be called from
+ Groovy scripts. In addition, the following objects are also defined:
+
+
+ <ul>
+ <li><strong>Jalview</strong> - this is bound to <code>jalview.bin.Jalview</code>.<br />Useful
+ methods include:
+ <ul>
+ <li>Jalview.getAlignFrames() - returns a list of
+ jalview.gui.AlignFrame objects</li>
+ <li>Jalview.getCurrentAlignFrame() - returns the alignment
+ window which is currently being looked at by the user</li>
+ </ul></li>
+ <li><strong>currentAlFrame</strong> - this is only defined when
+ running a Groovy script via the -groovy command line argument. It
+ returns the first alignment window created after acting on the
+ other arguments passed on the command line.</li>
+ </ul>
+ <p>
+ <em>A simple script</em><br />
<ul>
<li>Getting the title, alignment and first sequence from the
current alignFrame<br> <pre>
def seq = alignment.getSequenceAt(0);
</pre>
</li>
- <li>When running a groovy script from the command line, the
- alignment that was just loaded can be referred to like so:<br>
- <pre>
+ <li>If you wanted to do the same thing from the command line, you can refer to
+ alignment that was just loaded with currentAlFrame:<br>
+ <pre>
print currentAlFrame.getTitle();</pre>
</ul>
- If you have downloaded the InstallAnywhere version of Jalview, you can
- find additional groovy scripts in the examples/groovy subfolder of the
- installation directory.
+ <p>
+ <em>Example scripts</em><br />If you have downloaded the
+ InstallAnywhere version of Jalview, you can find additional groovy
+ scripts in the examples/groovy subfolder of the installation
+ directory. The examples are also available at <a
+ href="http://www.jalview.org/examples/groovy">http://www.jalview.org/examples/groovy</a>.
+ </p>
+ <p>
+ <em>Using Groovy to add new Alignment Calculations</em><br />We've
+ simplified the alignment analysis programming interface in Jalview
+ 2.10 to make it easy for you to add your own dynamic annotation
+ tracks with Groovy. Have a look at the <a
+ href="../groovy/featureCounter.html">featureCounter.groovy</a>
+ example for more information.
+ </p>
+
</body>
</html>
record and use that information to construct a mapping between the
sequence and downloaded structure.</p>
<p>If, for some reason, no SIFTS mapping data exists, then Jalview
- will generate a mapping using its built-in Needleman and Wunsch
- global alignment algorithm. This method of mapping was used for all
- structures prior to version 2.10.
- <p>
- <strong>Controlling and troubleshooting SIFTS mappings</strong> <br />
+ will generate a mapping using the built-in Needleman and Wunsch
+ global alignment algorithm. This is how sequence-structure mappings
+ were created before version 2.10.</p>
+ <p><strong>Controlling and troubleshooting SIFTS mappings</strong> <br />
Configuration options controlling whether SIFTS mappings are used
can be found in the <strong>Tools → Preferences →
Structure tab</strong>, under 'Sequence ↔ Structure method'.<br /> <em>Note:</em>
<strong>Multi-Chain Mappings</strong> <br />SIFTS gives Jalview the
ability to display multi-chain mappings between UniProt sequences
and PDB structure data. This is important when working with
- multimeric proteins, since the biological unit will contain several
+ multimeric proteins, when the biological assembly can contain several
structures for the same protein sequence. Multi-chain mapping allows
all residues in a structure to be located in the alignment, and
also, when shading the structure by sequence colours, enables
conservation patterns between oligomer interfaces to be explored.
</p>
- <p>To see this in action, load uniprot sequence for FER1_MAIZE
- then veiw PDB structure for 3B2F, you will notice that mousing over
+ <p>To see this in action, Retrieve the UniProt sequence
+ FER1_MAIZE, and then view one of its structures: 3B2F. Mousing over
the sequence results to two positions being highlighted in the
- structure, also colouring the sequence transfers the color to all
+ structure, and colouring the alignment transfers the color to all
the mapped chains in the structure.</p>
<p>
<Strong>Viewing Mapping Output</Strong> <br /> The mapping provided
by the SIFTS record is accessible via <strong>File →
View mapping</strong> menu of the structure viewers. The screenshot below
- is the mapping output for the <Strong>{FER1_MAIZE ↔
- 3B2F}</Strong> example described above, and confirms that all two chains
- were mapped. The mapping method used can be seen within the area
- highlighted with red boarder.
+ shows the mapping created between UniProt sequence FER1_MAIZE and proteins in PDB 3B2F, which reports thattwo chains
+ were mapped. The mapping method is also reported (highlighted with red border).
<p>
 <img src="sifts_mapping_output.png" align="left"
alt="SIFTS mapping output" />
+ <br/>
<p>
<em>SIFTS Mapping integration was added in Jalview 2.10</em>
</p>
<strong>Structure Chooser</strong>
</p>
- The Structure Chooser interface provides a smart technique for
- selecting PDB structures to view in Jalview by querying readily
- available meta-data of structures. The Interface can be invoked by
- selecting the
- <strong>"3D Structure Data.."</strong> option from a sequence's
- <a href="../menus/popupMenu.html">pop-up menu</a>. Some of the main
- features it provides are listed below:
+ <p>
+ The Structure Chooser interface allows you to interactively select
+ which PDB structures to view for the currently selected set of
+ sequences. It's opened by selecting the <strong>"3D
+ Structure Data.."</strong> option from the Sequence ID panel's <a
+ href="../menus/popupMenu.html">pop-up menu</a>. The dialog
+ provides:
+ </p>
<ul>
<li>Automatic discovery, retrieval and association of PDB
- entries for an alignment's sequences</li>
- <li>Visualisation of discovered structures' meta-data</li>
- <li>Ability to configure the meta-data entries to visualise</li>
- <li>Auto-selection of the best structure via filtering by the
- available metric parameters in the meta-data (i.e. resolution,
- quality etc).</li>
- <li>Selection of multiple structures in a single operation</li>
+ entries for sequences</li>
+ <li>Exploration of meta-data for available 3D structures</li>
+ <li>Automatic selection of the 'best structure' to display for
+ each sequence</li>
+ <li>Manual association of PDB entries by entering a PDB Id</li>
+ <li>Association of structure data from a local file (in mmCIF
+ or PDB format)</li>
</ul>
- Additionally, the Structure Chooser retains the following contemporary
- features of Jalview:
- <ul>
- <li>Manual association of PDB entries via entering the PDB Id
- or From File</li>
- <li>Ability to view cached PDB entries</li>
- </ul>
-
- <strong>Associating PDB files with Sequences</strong>
- <br> Discovery/Association of PDB entries to a sequence now
- happens automatically during the initialisation of the Structure
- Chooser Interface. Jalview uses the sequence's ID to query the PDB
- Rest API provided by the EBI to discover PDB Ids associated with the
- sequence.
-
- <br>
- <br>
- <strong>Configuring displayed meta-data for Structures</strong>
- <br> To configure the visible meta-data displayed for the
- discovered structures, click the 'Configure Displayed Columns' tab,
- then tick the options which you intend to make visible.
-
- <br>
- <br>
- <strong>Auto-selection of best Structures</strong>
- <br> Jalview can automatically filter and select the best
- structures using various metric categories avaialble from the
- meta-data of the structures. To perform this simply select any of the
- following options from the drop-down menu in the Structure Chooser
- interface: Best UniProt coverage, Higest Resolution, Best Quality,
- Highest Protein Chain etc. When the 'Invert' option is selected,
- Jalview returns an inverse result for the current selected option in
- the drop-down menu.
+ <p>
+ <strong>Automated discovery of structure data</strong>
+ </p>
+ <p>After selecting "3D Structure Data ..", Jalview queries the PDB
+ via the PDBe SOLR Rest API provided by EMBL-EBI to discover PDB ids
+ associated with the sequence. It does this based on the sequence's
+ ID string, and any other associated database IDs.</p>
+ <p>
+ <strong>Exploration of meta-data for available structures</strong>
+ </p>
+ <p>Information on each structure available is displayed in columns
+ in the dialog box. By default, only the title, resolution and PDB
+ identifier are shown, but many more are provided by the PDBe. To
+ configure which ones are displayed, select the 'Configure Displayed
+ Columns' tab and tick the columns which you want to see.</p>
+ <p>
+ <strong>Selection of the best structure for each sequence</strong>
+ </p>
+ <p>Jalview can automatically select the best structures according
+ to meta-data provided by the PDB. By default, the 'Best Quality'
+ structure for each sequence will be selected, but clicking on the
+ drop down menu allows other criteria to be chosen, including
+ Resolution (only defined for X-Ray structures), Highest Protein
+ Chain etc. When 'Invert' is selected, structures are selected in
+ reverse order for the current criteria (e.g. worst quality rather
+ than best).</p>
<p>
<img src="schooser_main.png" style="width: 464px; height: 369px;">
sample alignment. Note however that if no structures were
auto-discovered, a different interface for manual association will
be invoked as seen in the screenshot below.
+
<p>
<img src="schooser_enter-id.png"
- style="width: 464px; height: 369px;"
- >
+ style="width: 464px; height: 369px;">
+
<p>
<strong>Manual selection/association of PDB files with
Sequences</strong>
</p>
- <p>To manually associate PDB files with a sequence, select any of
- the follwing options listed below from the drop-down menu in the
- interface:
+ <p>To manually associate PDB files with a sequence, select 'From
+ File', or 'Enter PDB Id' from the drop-down menu:
+
<ul>
- <li><strong>From File</strong> - You can load a PDB file from
- the local machine or network and associate it with the selected
- sequence. PDB files associated in this way will also be saved in
- the <a href="jalarchive.html">Jalview Archive file</a>.<br></li>
- <li><strong>Enter PDB Id</strong> - Jalview will use the PDB
- Rest API, provided by the EBI, to fetch the PDB file with the
- entered Id.<br></li>
- <li><strong>Cached PDB Entries</strong> - You can view PDB
- structures which have previously been downloaded/viewed using this
- option. Jalview caches previously downloaded PDB entries in the
- computer memory. However, if the project is saved before exiting
- Jalview, Jalview will serialize the cached entries to the file
- system.</li>
+ <li><strong>From File</strong> - allows you to load a PDB file
+ from the local machine or network and associate it with the
+ selected sequence. PDB files associated in this way will also be
+ saved in the <a href="jalarchive.html">Jalview Archive file</a>.<br></li>
+ <li><strong>Enter PDB Id</strong> - allows you specify a PDB ID
+ for your sequence. The PDB Rest API, provided by EMBL-EBI, is used
+ to validate and fetch structure data.<br></li>
</ul>
+ <p>
+ <strong>Viewing existing structures for your sequences</strong>
+ </p>
+ <p>
+ If you have previously associated structure data on the alignment,
+ selecting <strong>Cached PDB Entries</strong> from the drop down
+ menu allows you to select these structures for display.
+ </p>
<p>
<em>The Structure Chooser interface was introduced in Jalview
Entries</strong> option from the drop down menu at the top of the
dialog box.</li>
</ul></li>
- <li>To view selected structures, click the <strong>"View"</strong>
- button.
- </li>
+ <li><strong>To view selected structures, click the <strong>"View"</strong>
+ button.</strong><br />
+ <ul>
+ <li>Additional structure data will be downloaded with the
+ EMBL-EBI's dbfetch service</li>
+ <li><a href="siftsmapping.html">SIFTS</a> records will also
+ be downloaded for mapping UniProt protein sequence data to PDB
+ coordinates.</li>
+ </ul></li>
</ol>
The
--- /dev/null
+<html>
+<!--
+ * 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.
+ -->
+<head>
+<title>Extending Jalview with Groovy - Feature Counter Example</title>
+</head>
+<body>
+ <p>
+ <strong>Extending Jalview with Groovy - A customisable
+ feature counter</strong><br />
+ <br />The groovy script below shows how to add a new calculation
+ track to a Jalview alignment window.</p><p>As currently written, it will
+ add two tracks to a protein alignment view which count Pfam features
+ in each column, and ones where a charge residue also occur.</p><p>To try
+ it for yourself:</p><ol><li>Copy and paste it into the groovy script
+ console</li><li>Load the example Feredoxin project (the one that opens
+ by default when you first launched Jalview)</li><li>Select <strong>Calculations→Execute
+ Groovy Script</strong> from the alignment window's menu bar to run the script on
+ the current view.</li></ol>
+ <em><a
+ href="http://www.jalview.org/examples/groovy/featureCounter.groovy">http://www.jalview.org/examples/groovy/featureCounter.groovy</a> - rendered with <a href="http://hilite.me">hilite.me</a></em>
+ <!-- HTML generated using hilite.me -->
+ <div
+ style="background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;">
+ <pre style="margin: 0; line-height: 125%">
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * Jalview - A Sequence Alignment Editor and Viewer (Version 2.10)</span>
+<span style="color: #888888"> * Copyright (C) 2016 The Jalview Authors</span>
+<span style="color: #888888"> * </span>
+<span style="color: #888888"> * This file is part of Jalview.</span>
+<span style="color: #888888"> * </span>
+<span style="color: #888888"> * Jalview is free software: you can redistribute it and/or</span>
+<span style="color: #888888"> * modify it under the terms of the GNU General Public License </span>
+<span style="color: #888888"> * as published by the Free Software Foundation, either version 3</span>
+<span style="color: #888888"> * of the License, or (at your option) any later version.</span>
+<span style="color: #888888"> * </span>
+<span style="color: #888888"> * Jalview is distributed in the hope that it will be useful, but </span>
+<span style="color: #888888"> * WITHOUT ANY WARRANTY; without even the implied warranty </span>
+<span style="color: #888888"> * of MERCHANTABILITY or FITNESS FOR A PARTICULAR </span>
+<span style="color: #888888"> * PURPOSE. See the GNU General Public License for more details.</span>
+<span style="color: #888888"> * </span>
+<span style="color: #888888"> * You should have received a copy of the GNU General Public License</span>
+<span style="color: #888888"> * along with Jalview. If not, see <http://www.gnu.org/licenses/>.</span>
+<span style="color: #888888"> * The Jalview Authors are detailed in the 'AUTHORS' file.</span>
+<span style="color: #888888"> */</span>
+
+<span style="color: #008800; font-weight: bold">import</span> <span
+ style="color: #0e84b5; font-weight: bold">jalview.workers.FeatureCounterI</span><span
+ style="color: #333333">;</span>
+<span style="color: #008800; font-weight: bold">import</span> <span
+ style="color: #0e84b5; font-weight: bold">jalview.workers.AlignmentAnnotationFactory</span><span
+ style="color: #333333">;</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * Example script that registers two alignment annotation calculators</span>
+<span style="color: #888888"> * - one that counts residues in a column with Pfam annotation</span>
+<span style="color: #888888"> * - one that counts only charged residues with Pfam annotation</span>
+<span style="color: #888888"> *</span>
+<span style="color: #888888"> * To try:</span>
+<span style="color: #888888"> * 1. load uniref50.fa from the examples folder</span>
+<span style="color: #888888"> * 2. load features onto it from from examples/exampleFeatures.txt</span>
+<span style="color: #888888"> * 3. Open this script in the Groovy console.</span>
+<span style="color: #888888"> * 4. Either execute this script from the console, or via Calculate->Run Groovy Script</span>
+<span style="color: #888888"> </span>
+<span style="color: #888888"> * To explore further, try changing this script to count other kinds of occurrences of </span>
+<span style="color: #888888"> * residue and sequence features at columns in an alignment.</span>
+<span style="color: #888888"> */</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * A closure that returns true for any Charged residue</span>
+<span style="color: #888888"> */</span>
+<span style="color: #333399; font-weight: bold">def</span> isCharged <span
+ style="color: #333333">=</span> <span style="color: #333333">{</span> residue <span
+ style="color: #333333">-></span>
+ <span style="color: #008800; font-weight: bold">switch</span><span
+ style="color: #333333">(</span>residue<span
+ style="color: #333333">)</span> <span style="color: #333333">{</span>
+ <span style="color: #008800; font-weight: bold">case</span> <span
+ style="color: #333333">[</span><span
+ style="background-color: #fff0f0">'D'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'d'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'E'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'e'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'H'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'h'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'K'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'k'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'R'</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">'r'</span><span
+ style="color: #333333">]:</span>
+ <span style="color: #008800; font-weight: bold">return</span> <span
+ style="color: #008800; font-weight: bold">true</span>
+ <span style="color: #333333">}</span>
+ <span style="color: #008800; font-weight: bold">false</span>
+<span style="color: #333333">}</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * A closure that returns 1 if sequence features include type 'Pfam', else 0</span>
+<span style="color: #888888"> * Argument should be a list of SequenceFeature </span>
+<span style="color: #888888"> */</span>
+<span style="color: #333399; font-weight: bold">def</span> hasPfam <span
+ style="color: #333333">=</span> <span style="color: #333333">{</span> features <span
+ style="color: #333333">-></span>
+ <span style="color: #008800; font-weight: bold">for</span> <span
+ style="color: #333333">(</span>sf <span
+ style="color: #008800; font-weight: bold">in</span> features<span
+ style="color: #333333">)</span>
+ <span style="color: #333333">{</span>
+ <span style="color: #888888">/*</span>
+<span style="color: #888888"> * Here we inspect the type of the sequence feature.</span>
+<span style="color: #888888"> * You can also test sf.description, sf.score, sf.featureGroup,</span>
+<span style="color: #888888"> * sf.strand, sf.phase, sf.begin, sf.end</span>
+<span style="color: #888888"> * or sf.getValue(attributeName) for GFF 'column 9' properties</span>
+<span style="color: #888888"> */</span>
+ <span style="color: #008800; font-weight: bold">if</span> <span
+ style="color: #333333">(</span><span
+ style="background-color: #fff0f0">"Pfam"</span><span
+ style="color: #333333">.</span><span style="color: #0000CC">equals</span><span
+ style="color: #333333">(</span>sf<span style="color: #333333">.</span><span
+ style="color: #0000CC">type</span><span style="color: #333333">))</span>
+ <span style="color: #333333">{</span>
+ <span style="color: #008800; font-weight: bold">return</span> <span
+ style="color: #008800; font-weight: bold">true</span>
+ <span style="color: #333333">}</span>
+ <span style="color: #333333">}</span>
+ <span style="color: #008800; font-weight: bold">false</span>
+<span style="color: #333333">}</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * Closure that computes an annotation based on </span>
+<span style="color: #888888"> * presence of particular residues and features</span>
+<span style="color: #888888"> * Parameters are</span>
+<span style="color: #888888"> * - the name (label) for the alignment annotation</span>
+<span style="color: #888888"> * - the description (tooltip) for the annotation</span>
+<span style="color: #888888"> * - a closure (groovy function) that tests whether to include a residue</span>
+<span style="color: #888888"> * - a closure that tests whether to increment count based on sequence features </span>
+<span style="color: #888888"> */</span>
+<span style="color: #333399; font-weight: bold">def</span> getColumnCounter <span
+ style="color: #333333">=</span> <span style="color: #333333">{</span> name<span
+ style="color: #333333">,</span> desc<span style="color: #333333">,</span> acceptResidue<span
+ style="color: #333333">,</span> acceptFeatures <span
+ style="color: #333333">-></span>
+ <span style="color: #333333">[</span>
+ <span style="color: #997700; font-weight: bold">getName:</span> <span
+ style="color: #333333">{</span> name <span
+ style="color: #333333">},</span>
+ <span style="color: #997700; font-weight: bold">getDescription:</span> <span
+ style="color: #333333">{</span> desc <span
+ style="color: #333333">},</span>
+ <span style="color: #997700; font-weight: bold">getMinColour:</span> <span
+ style="color: #333333">{</span> <span style="color: #333333">[</span><span
+ style="color: #0000DD; font-weight: bold">0</span><span
+ style="color: #333333">,</span> <span
+ style="color: #0000DD; font-weight: bold">255</span><span
+ style="color: #333333">,</span> <span
+ style="color: #0000DD; font-weight: bold">255</span><span
+ style="color: #333333">]</span> <span style="color: #333333">},</span> <span
+ style="color: #888888">// cyan</span>
+ <span style="color: #997700; font-weight: bold">getMaxColour:</span> <span
+ style="color: #333333">{</span> <span style="color: #333333">[</span><span
+ style="color: #0000DD; font-weight: bold">0</span><span
+ style="color: #333333">,</span> <span
+ style="color: #0000DD; font-weight: bold">0</span><span
+ style="color: #333333">,</span> <span
+ style="color: #0000DD; font-weight: bold">255</span><span
+ style="color: #333333">]</span> <span style="color: #333333">},</span> <span
+ style="color: #888888">// blue</span>
+ <span style="color: #997700; font-weight: bold">count:</span>
+ <span style="color: #333333">{</span> res<span
+ style="color: #333333">,</span> feats <span
+ style="color: #333333">-></span>
+ <span style="color: #333399; font-weight: bold">def</span> c <span
+ style="color: #333333">=</span> <span
+ style="color: #0000DD; font-weight: bold">0</span>
+ <span style="color: #008800; font-weight: bold">if</span> <span
+ style="color: #333333">(</span>acceptResidue<span
+ style="color: #333333">.</span><span style="color: #0000CC">call</span><span
+ style="color: #333333">(</span>res<span style="color: #333333">))</span>
+ <span style="color: #333333">{</span>
+ <span style="color: #008800; font-weight: bold">if</span> <span
+ style="color: #333333">(</span>acceptFeatures<span
+ style="color: #333333">.</span><span style="color: #0000CC">call</span><span
+ style="color: #333333">(</span>feats<span style="color: #333333">))</span>
+ <span style="color: #333333">{</span>
+ c<span style="color: #333333">++</span>
+ <span style="color: #333333">}</span>
+ <span style="color: #333333">}</span>
+ c
+ <span style="color: #333333">}</span>
+ <span style="color: #333333">]</span> <span
+ style="color: #008800; font-weight: bold">as</span> FeatureCounterI
+<span style="color: #333333">}</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * Define an annotation row that counts any residue with Pfam domain annotation</span>
+<span style="color: #888888"> */</span>
+<span style="color: #333399; font-weight: bold">def</span> pfamAnnotation <span
+ style="color: #333333">=</span> getColumnCounter<span
+ style="color: #333333">(</span><span
+ style="background-color: #fff0f0">"Pfam"</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">"Count of residues with Pfam domain annotation"</span><span
+ style="color: #333333">,</span> <span style="color: #333333">{</span><span
+ style="color: #008800; font-weight: bold">true</span><span
+ style="color: #333333">},</span> hasPfam<span
+ style="color: #333333">)</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * Define an annotation row that counts charged residues with Pfam domain annotation</span>
+<span style="color: #888888"> */</span>
+<span style="color: #333399; font-weight: bold">def</span> chargedPfamAnnotation <span
+ style="color: #333333">=</span> getColumnCounter<span
+ style="color: #333333">(</span><span
+ style="background-color: #fff0f0">"Pfam charged"</span><span
+ style="color: #333333">,</span> <span
+ style="background-color: #fff0f0">"Count of charged residues with Pfam domain annotation"</span><span
+ style="color: #333333">,</span> isCharged<span
+ style="color: #333333">,</span> hasPfam<span
+ style="color: #333333">)</span>
+
+<span style="color: #888888">/*</span>
+<span style="color: #888888"> * Register the annotations</span>
+<span style="color: #888888"> */</span>
+AlignmentAnnotationFactory<span style="color: #333333">.</span><span
+ style="color: #0000CC">newCalculator</span><span
+ style="color: #333333">(</span>pfamAnnotation<span
+ style="color: #333333">)</span>
+AlignmentAnnotationFactory<span style="color: #333333">.</span><span
+ style="color: #0000CC">newCalculator</span><span
+ style="color: #333333">(</span>chargedPfamAnnotation<span
+ style="color: #333333">)</span>
+</pre>
+ </div>
+</body>
+</html>
<body>
<p>
- <strong>Alignment Window Annotations Menu</strong> (Since Jalview
- 2.8.2)
+ <strong>Alignment Window Annotations Menu</strong> <em>Since Jalview
+ 2.8.2</em>
</p>
<ul>
<li><strong>Show Alignment Related</strong><em><br>
<li><strong>Annotation Label Popup Menu</strong><br> <em>This
menu is opened by clicking anywhere on the annotation row labels
area (below the sequence ID area).</em>
+ <br/><em><strong>Mac Users:</strong> pressing CTRL whilst clicking
+ the mouse/track pad is the same as a right-click. See your
+ system's settings to configure your track-pad's corners to
+ generate right-clicks.</em>
<ul>
<li><strong>Add New Row</strong><br> <em>Adds a
new, named annotation row (a dialog box will pop up for you
<p>
The <a href="popupMenu.html">Popup Menus</a> are opened by clicking
with the right mouse button in the alignment display area or on a
- sequence label in the alignment window.
+ sequence label in the alignment window.<br />
+ <em><strong>Mac Users:</strong> pressing CTRL whilst clicking
+ the mouse/track pad is the same as a right-click. See your
+ system's settings to configure your track-pad's corners to
+ generate right-clicks.</em>
</p>
<p>
The <a href="alwannotationpanel.html">Annotations Menu</a> is opened
<body>
<p>
- <strong>Popup Menu</strong><br> <em>This menu is visible
- when right clicking either within a selected region on the
- alignment or on a selected sequence name. It may not be accessible
- when in 'Cursor Mode' (toggled with the F2 key).</em>
+ <strong>Popup Menu</strong><br> <em>This menu is visible when
+ right clicking either within a selected region on the alignment or
+ on a selected sequence name. It may not be accessible when in
+ 'Cursor Mode' (toggled with the F2 key).</em><br /> <em><strong>Mac Users:</strong> pressing CTRL whilst clicking
+ the mouse/track pad is the same as a right-click. See your
+ system's settings to configure your track-pad's corners to
+ generate right-clicks.</em>
</p>
<ul>
<li><strong>Selection</strong>
</ul></li>
<li><strong>3D Structure Data...</strong> </strong><em>This menu is
visible when you right-click on a sequence name. When this
- option is clicked, Jalview will open a <a
- href="../features/structurechooser.html"
- >'Structure Chooser' </a> dialogue with options to select the
- structure which will eventually be opened in a 3D interactive
- view.<br> These entries will only be present if the
- sequence has <a href="../features/viewingpdbs.html">associated
- PDB structures</a>.
+ option is clicked, Jalview will open the <a
+ href="../features/structurechooser.html">'Structure
+ Chooser' </a>, which allows you to discover and view 3D structures
+ for the current selection. For more info, see <a
+ href="../features/viewingpdbs.html">viewing PDB structures</a>.
</em></li>
<li><strong>VARNA 2D Structure</strong><br />
<em> If the sequence or alignment has RNA structure, then <strong>VARNA
<tr>
<td width="60" nowrap>
<div align="center">
- <strong><a name="Jalview.2.10.0">2.10.0</a><br /> <em>20/9/2016</em></strong>
+ <strong><a name="Jalview.2.10.0">2.10.0</a><br /> <em>27/9/2016</em></strong>
</div>
</td>
<td><em>General</em>
<li><!-- JAL-2164,JAL-1919,-->Jmol now primary parser for importing structure data to Jalview. Enables mmCIF and better PDB parsing.</li>
<li><!-- JAL-192 --->Alignment ruler shows positions relative to reference sequence</li>
<li><!-- JAL-2202 -->Position/residue shown in status bar when mousing over sequence associated annotation</li>
+ <li><!-- JAL-2171 -->Default RNA SS symbol to 'matching bracket' for manual entry</li>
+ <li><!-- JAL-2214 -->RNA Structure consensus indicates wc-only '()', canonical '[]' and invalid '{}' base pair populations for each column</li>
+ <li><!-- JAL-2092 -->Feature settings popup menu options for showing or hiding columns containing a feature</li>
+ <li><!-- JAL-1557 -->Edit selected group by double clicking on group and sequence associated annotation labels</li>
</ul> <em>Application</em>
<ul>
<li><!-- JAL---></li>
<li><!-- JAL---></li>
<li><!-- JAL---></li>
<li><!-- JAL---></li>
- <li><!-- JAL---></li>
- <li><!-- JAL---></li>
+ <li><!-- JAL-1957, JAL-1479 JAL-1491 -->UniProt - PDB protein structure mappings with the EMBL-EBI PDBe SIFTS database</li>
+ <li><!-- JAL-2079 -->Updated download sites used for Rfam and Pfam sources to xfam.org</li>
+ <li><!-- JAL-2084 -->Disabled Rfam(Full) in the sequence fetcher</li>
<li><!-- JAL-2123 -->Show residue labels in Chimera when mousing over sequences in Jalview</li>
<li><!-- JAL-2027-->Support for reverse-complement coding regions in ENA and EMBL</li>
<li><!-- JAL-1855, JAL-2113, JAL-2114-->Upgrade to EMBL XML 1.2 for ENA record retrieval</li>
- <li><!-- JAL 1812 -->New 'execute Groovy script' option in an alignment window's Calculate menu</li>
- <li><!-- JAL 1812 -->Allow groovy scripts that call Jalview.getAlignFrames() to run in headless mode</li>
+ <li><!-- JAL-2027 -->Support for ENA CDS records with reverse complement operator</li>
+ <li><!-- JAL-1812 -->New 'execute Groovy script' option in an alignment window's Calculate menu</li>
+ <li><!-- JAL-1812 -->Allow groovy scripts that call Jalview.getAlignFrames() to run in headless mode</li>
+ <li><!-- JAL-2068 -->Support for creating new alignment calculation workers from groovy scripts</li>
<li><!-- JAL-1369 --->Store/restore reference sequence in Jalview projects</li>
- <li><!-- JAL-1803-->Chain codes for a sequence's PDB associations are now saved/restored from project</li>
- <li><!-- JAL-2183-->Double click on an entry in Jalview's database chooser opens a sequence fetcher</li>
- <li><!-- JAL-2183-->Free-text search client for UniProt using the UniProt web API</li>
-
+ <li><!-- JAL-1803 -->Chain codes for a sequence's PDB associations are now saved/restored from project</li>
+ <li><!-- JAL-2183 -->Double click on an entry in Jalview's database chooser opens a sequence fetcher</li>
+ <li><!-- JAL-1563 -->Free-text search client for UniProt using the UniProt REST API</li>
+ <li><!-- JAL-2168 -->-nonews command line parameter to prevent the news reader opening</li>
+
</ul> <em>Applet</em>
<ul>
<li><!-- JAL-2077 -->reinstate CTRL-click for opening pop-up menu on OSX</li>
<li><!-- JAL-2018-->Export features in Jalview format (again) includes graduated colourschemes</li>
<li><!-- JAL-1722, JAL-2001-->More responsive when working with big alignments and lots of hidden columns</li>
- <li><!-- JAL-2053-->hidden column markers not always rendered at right of alignment window</li>
+ <li><!-- JAL-2053-->Hidden column markers not always rendered at right of alignment window</li>
<li><!-- JAL-2067, JAL- -->Tidied up links in help file table of contents</li>
<li><!-- JAL-2072 -->Feature based tree calculation not shown for DNA alignments</li>
<li><!-- JAL-2075 -->Hidden columns ignored during feature based tree calculation</li>
<li><!-- JAL-2065 -->Alignment view stops updating when show unconserved enabled for group on alignment</li>
<li><!-- JAL-2086 -->Cannot insert gaps into sequence when set as reference</li>
<li><!-- JAL-2146 -->Alignment column in status incorrectly shown as "Sequence position" when mousing over annotation</li>
+ <li><!-- JAL-2099 -->Incorrect column numbers in ruler when hidden columns present</li>
+ <li><!-- JAL-1577 -->Colour by RNA Helices not enabled when user created annotation added to alignment</li>
+ <li><!-- JAL-1841 -->RNA Structure consensus only computed for '()' base pair annotation</li>
+ <li><!-- JAL-2215, JAL-1841 -->Enabling 'Ignore Gaps' results in zero scores for all base pairs in RNA Structure Consensus</li>
+ <li><!-- JAL-2174-->Extend selection with columns containing feature not working</li>
+ <li><!-- JAL-2275 -->Pfam format writer puts extra space at beginning of sequence</li>
+ <li><!-- JAL-1827 -->Incomplete sequence extracted from pdb entry 3a6s </li>
</ul>
<em>Application</em>
<li><!-- JAL-1011 -->Columns are suddenly selected in other alignments and views when revealing hidden columns</li>
<li><!-- JAL-1989 -->Hide columns not mirrored in complement view in a cDNA/Protein splitframe</li>
<li><!-- JAL-1369 -->Cannot save/restore representative sequence from project when only one sequence is represented</li>
-
+ <li><!-- JAL-2002 -->Disabled 'Best Uniprot Coverage' option in Structure Chooser</li>
+ <li><!-- JAL-2215 -->Modifying 'Ignore Gaps' on consensus or structure consensus didn't refresh annotation panel</li>
+ <li><!-- JAL-1962 -->View mapping in structure view shows mappings between sequence and all chains in a PDB file</li>
<!-- may exclude, this is an external service stability issue JAL-1941 /> RNA 3D structure not added via DSSR service</li> -->
</ul>
<em>Applet</em>
<ul>
- <li><!-- --></li>
+ <li><!-- JAL-2151 -->Incorrect columns are selected when hidden columns present before start of sequence</li>
</ul>
</div>
</td>
<p>
<strong>Highlights in Jalview 2.10</strong>
<ul>
- <li><strong>Ensembl sequence fetcher.</strong> Annotated Genes, transcripts and
- proteins can be retrieved via Jalview's new Ensembl REST client.</li>
- <li><strong>Improved sequence/structure mappings.</strong>
- Jalview now utilises the PDBe's SIFTS database (at EMBL-EBI) to
- match PDB data positions in UniProt sequences.</li>
+ <li><strong>Ensembl sequence fetcher.</strong> Annotated Genes,
+ transcripts and proteins can be retrieved via Jalview's new <a
+ href="features/ensemblsequencefetcher.html">Ensembl REST
+ client</a>. Support for import of Ensembl data also allows:
+ <ul>
+ <li><strong>Sequence variant data.</strong> Jalview
+ propagates variant annotation imported via Ensembl onto
+ protein products, complete with associated metadata such as
+ clinical significance.</li>
+ <li><strong>Aligned locus view.</strong> Transcripts
+ retrieved for a gene identifier via the Ensembl or
+ EnsemblGenomes sequence databases are automatically aligned to
+ their reference genome.</li>
+ </ul></li>
+ <li><strong>Working with structures.</strong>
+ <ul>
+ <li><strong>More accurate structure mappings.</strong>
+ Jalview now utilises the PDBe's SIFTS database (at EMBL-EBI)
+ to <a href="features/siftsmapping.html">match structures
+ to UniProt sequences</a>, even for structures containing
+ multiple copies of a sequence.</li>
+ <li><strong>Import structures as mmCIF</strong>. Jalview
+ now downloads data from the EMBL-EBI's PDBe site as <a href="features/mmcif.html">mmCIF</a>.
+ This allows very large structures to be imported, such as the HIV virus capsid assembly.</li>
+ </ul></li>
+ <li><strong>UniProt Free Text Search</strong>. The new search
+ dialog for UniProt allows you to browse and retrieve sequences
+ from UniProt with free-text search and more structured queries</li>
+ <li><strong>Reference sequence based alignment
+ visualisation.</strong>. When a reference sequence is defined for the
+ alignment, the alignment column ruler is now numbered according to
+ the reference sequence. The reference sequence for alignment views
+ can also be saved and restored from Jalview projects.</li>
+ <li></li>
</ul>
</body>
*/
AlignedCodonFrame dnaToCdsMapping = new AlignedCodonFrame();
MapList dnaToCdsMap = new MapList(mapList.getFromRanges(),
- cdsRange, 1,
- 1);
+ cdsRange, 1, 1);
dnaToCdsMapping.addMap(dnaSeq.getDatasetSequence(), cdsSeqDss,
dnaToCdsMap);
if (!mappings.contains(dnaToCdsMapping))
/*
* transfer any features on dna that overlap the CDS
*/
- transferFeatures(dnaSeq, cdsSeq, cdsToProteinMap, null,
+ transferFeatures(dnaSeq, cdsSeq, dnaToCdsMap, null,
SequenceOntologyI.CDS);
}
}
import jalview.datamodel.Annotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.schemes.ResidueProperties;
import java.awt.Color;
-import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
/**
int end;
- Vector seqNums; // vector of int vectors where first is sequence checksum
+ Vector<int[]> seqNums; // vector of int vectors where first is sequence
+ // checksum
int maxLength = 0; // used by quality calcs
boolean seqNumsChanged = false; // updated after any change via calcSeqNum;
- Hashtable[] total;
+ Map<String, Integer>[] total;
boolean canonicaliseAa = true; // if true then conservation calculation will
// symbol
/** Stores calculated quality values */
- public Vector quality;
+ private Vector<Double> quality;
/** Stores maximum and minimum values of quality values */
- public Double[] qualityRange = new Double[2];
+ private double[] qualityRange = new double[2];
- String consString = "";
+ private Sequence consSequence;
- Sequence consSequence;
+ private int threshold;
- Hashtable propHash;
+ private String name = "";
- int threshold;
-
- String name = "";
-
- int[][] cons2;
+ private int[][] cons2;
private String[] consSymbs;
*
* @param name
* Name of conservation
- * @param propHash
- * hash of properties for each symbol
* @param threshold
* to count the residues in residueHash(). commonly used value is 3
* @param sequences
* @param end
* end residue position
*/
- public Conservation(String name, Hashtable propHash, int threshold,
+ public Conservation(String name, int threshold,
List<SequenceI> sequences, int start, int end)
{
this.name = name;
- this.propHash = propHash;
this.threshold = threshold;
this.start = start;
this.end = end;
seqNums.addElement(new int[sq.length() + 1]);
}
- if (sq.hashCode() != ((int[]) seqNums.elementAt(i))[0])
+ if (sq.hashCode() != seqNums.elementAt(i)[0])
{
int j;
int len;
*/
public void calculate()
{
- Hashtable resultHash, ht;
int thresh, j, jSize = sequences.length;
int[] values; // Replaces residueHash
- String type, res = null;
char c;
- Enumeration enumeration2;
total = new Hashtable[maxLength];
if (canonicaliseAa)
{ // lookup the base aa code symbol
- c = (char) jalview.schemes.ResidueProperties.aaIndex[sequences[j]
- .getCharAt(i)];
+ c = (char) ResidueProperties.aaIndex[sequences[j].getCharAt(i)];
if (c > 20)
{
c = '-';
else
{
// recover canonical aa symbol
- c = jalview.schemes.ResidueProperties.aa[c].charAt(0);
+ c = ResidueProperties.aa[c].charAt(0);
}
}
else
thresh = (threshold * (jSize)) / 100;
// loop over all the found residues
- resultHash = new Hashtable();
+ Hashtable<String, Integer> resultHash = new Hashtable<String, Integer>();
for (char v = '-'; v < 'Z'; v++)
{
if (values[v] > thresh)
{
- res = String.valueOf(v);
+ String res = String.valueOf(v);
// Now loop over the properties
- enumeration2 = propHash.keys();
-
- while (enumeration2.hasMoreElements())
+ for (String type : ResidueProperties.propHash.keySet())
{
- type = (String) enumeration2.nextElement();
- ht = (Hashtable) propHash.get(type);
+ Map<String, Integer> ht = ResidueProperties.propHash.get(type);
// Have we ticked this before?
if (!resultHash.containsKey(type))
resultHash.put(type, ht.get("-"));
}
}
- else if (((Integer) resultHash.get(type)).equals(ht.get(res)) == false)
+ else if (!resultHash.get(type).equals(ht.get(res)))
{
resultHash.put(type, new Integer(-1));
}
* Calculates the conservation sequence
*
* @param consflag
- * if true, poitiveve conservation; false calculates negative
+ * if true, positive conservation; false calculates negative
* conservation
* @param percentageGaps
* commonly used value is 25
public void verdict(boolean consflag, float percentageGaps)
{
StringBuffer consString = new StringBuffer();
- String type;
- Integer result;
- int[] gapcons;
- int totGaps, count;
- float pgaps;
- Hashtable resultHash;
- Enumeration enumeration;
// NOTE THIS SHOULD CHECK IF THE CONSEQUENCE ALREADY
// EXISTS AND NOT OVERWRITE WITH '-', BUT THIS CASE
consSymbs = new String[end - start + 1];
for (int i = start; i <= end; i++)
{
- gapcons = countConsNGaps(i);
- totGaps = gapcons[1];
- pgaps = ((float) totGaps * 100) / sequences.length;
+ int[] gapcons = countConsNGaps(i);
+ int totGaps = gapcons[1];
+ float pgaps = ((float) totGaps * 100) / sequences.length;
consSymbs[i - start] = new String();
if (percentageGaps > pgaps)
{
- resultHash = total[i - start];
+ Map<String, Integer> resultHash = total[i - start];
// Now find the verdict
- count = 0;
- enumeration = resultHash.keys();
-
- while (enumeration.hasMoreElements())
+ int count = 0;
+ for (String type : resultHash.keySet())
{
- type = (String) enumeration.nextElement();
- result = (Integer) resultHash.get(type);
+ int result = resultHash.get(type).intValue();
// Do we want to count +ve conservation or +ve and -ve cons.?
if (consflag)
{
- if (result.intValue() == 1)
+ if (result == 1)
{
consSymbs[i - start] = type + " " + consSymbs[i - start];
count++;
}
else
{
- if (result.intValue() != -1)
+ if (result != -1)
{
+ if (result == 0)
{
- if (result.intValue() == 0)
- {
- consSymbs[i - start] = consSymbs[i - start] + " !" + type;
- }
- else
- {
- consSymbs[i - start] = type + " " + consSymbs[i - start];
- }
+ consSymbs[i - start] = consSymbs[i - start] + " !" + type;
+ }
+ else
+ {
+ consSymbs[i - start] = type + " " + consSymbs[i - start];
}
-
count++;
}
}
*/
private void percentIdentity2()
{
- seqNums = new Vector();
+ seqNums = new Vector<int[]>();
// calcSeqNum(s);
int i = 0, iSize = sequences.length;
// Do we need to calculate this again?
while (j < sequences.length)
{
- sqnum = (int[]) seqNums.elementAt(j);
+ sqnum = seqNums.elementAt(j);
for (i = 1; i < sqnum.length; i++)
{
/**
* Calculates the quality of the set of sequences
*
- * @param start
+ * @param startRes
* Start residue
- * @param end
+ * @param endRes
* End residue
*/
- public void findQuality(int start, int end)
+ public void findQuality(int startRes, int endRes)
{
- quality = new Vector();
+ quality = new Vector<Double>();
double max = -10000;
- int[][] BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62();
+ int[][] BLOSUM62 = ResidueProperties.getBLOSUM62();
// Loop over columns // JBPNote Profiling info
// long ts = System.currentTimeMillis();
for (l = 0; l < size; l++)
{
- lengths[l] = ((int[]) seqNums.elementAt(l)).length - 1;
+ lengths[l] = seqNums.elementAt(l).length - 1;
}
- for (j = start; j <= end; j++)
+ for (j = startRes; j <= endRes; j++)
{
bigtot = 0;
{
tot = 0;
xx = new double[24];
- seqNum = (j < lengths[k]) ? ((int[]) seqNums.elementAt(k))[j + 1]
+ seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1]
: 23; // Sequence, or gap at the end
// This is a loop over r
double newmax = -10000;
- for (j = start; j <= end; j++)
+ for (j = startRes; j <= endRes; j++)
{
- tmp = ((Double) quality.elementAt(j)).doubleValue();
+ tmp = quality.elementAt(j).doubleValue();
tmp = ((max - tmp) * (size - cons2[j][23])) / size;
// System.out.println(tmp+ " " + j);
}
// System.out.println("Quality " + s);
- qualityRange[0] = new Double(0);
- qualityRange[1] = new Double(newmax);
+ qualityRange[0] = 0D;
+ qualityRange[1] = newmax;
}
/**
- * complete the given consensus and quuality annotation rows. Note: currently
+ * Complete the given consensus and quuality annotation rows. Note: currently
* this method will enlarge the given annotation row if it is too small,
* otherwise will leave its length unchanged.
*
char c;
- if (conservation.annotations != null
+ if (conservation != null && conservation.annotations != null
&& conservation.annotations.length < alWidth)
{
conservation.annotations = new Annotation[alWidth];
if (quality2 != null)
{
- quality2.graphMax = qualityRange[1].floatValue();
+ quality2.graphMax = (float) qualityRange[1];
if (quality2.annotations != null
&& quality2.annotations.length < alWidth)
{
quality2.annotations = new Annotation[alWidth];
}
- qmin = qualityRange[0].floatValue();
- qmax = qualityRange[1].floatValue();
+ qmin = (float) qualityRange[0];
+ qmax = (float) qualityRange[1];
}
for (int i = istart; i < alWidth; i++)
value = 10;
}
- float vprop = value - min;
- vprop /= max;
- int consp = i - start;
- String conssym = (value > 0 && consp > -1 && consp < consSymbs.length) ? consSymbs[consp]
- : "";
- conservation.annotations[i] = new Annotation(String.valueOf(c),
- conssym, ' ', value, new Color(minR + (maxR * vprop), minG
- + (maxG * vprop), minB + (maxB * vprop)));
+ if (conservation != null)
+ {
+ float vprop = value - min;
+ vprop /= max;
+ int consp = i - start;
+ String conssym = (value > 0 && consp > -1 && consp < consSymbs.length) ? consSymbs[consp]
+ : "";
+ conservation.annotations[i] = new Annotation(String.valueOf(c),
+ conssym, ' ', value, new Color(minR + (maxR * vprop), minG
+ + (maxG * vprop), minB + (maxB * vprop)));
+ }
// Quality calc
if (quality2 != null)
{
- value = ((Double) quality.elementAt(i)).floatValue();
- vprop = value - qmin;
+ value = quality.elementAt(i).floatValue();
+ float vprop = value - qmin;
vprop /= qmax;
quality2.annotations[i] = new Annotation(" ",
String.valueOf(value), ' ', value, new Color(minR
*
* @param name
* - name of conservation
- * @param consHash
- * - hash table of properties for each amino acid (normally
- * ResidueProperties.propHash)
* @param threshold
* - minimum number of conserved residues needed to indicate
* conservation (typically 3)
* @return Conservation object ready for use in visualization
*/
public static Conservation calculateConservation(String name,
- Hashtable consHash, int threshold, List<SequenceI> seqs,
- int start, int end, boolean posOrNeg, int consPercGaps,
- boolean calcQuality)
- {
- Conservation cons = new Conservation(name, consHash, threshold, seqs,
- start, end);
- return calculateConservation(cons, posOrNeg, consPercGaps, calcQuality);
- }
-
- /**
- * @param b
- * positive (true) or negative (false) conservation
- * @param consPercGaps
- * percentage of gaps tolerated in column
- * @param calcQuality
- * flag indicating if alignment quality should be calculated
- * @return Conservation object ready for use in visualization
- */
- public static Conservation calculateConservation(Conservation cons,
- boolean b, int consPercGaps, boolean calcQuality)
+ int threshold, List<SequenceI> seqs, int start, int end,
+ boolean posOrNeg, int consPercGaps, boolean calcQuality)
{
+ Conservation cons = new Conservation(name, threshold, seqs, start, end);
cons.calculate();
- cons.verdict(b, consPercGaps);
-
+ cons.verdict(posOrNeg, consPercGaps);
+
if (calcQuality)
{
cons.findQuality();
}
-
+
return cons;
}
}
}
/**
- * Answers true if the base-pair is either a canonical (A-T/U, C-G) or a
- * wobble (G-T/U) pair (either way round), else false
+ * Answers true if the base-pair is either a Watson-Crick (A:T/U, C:G) or a
+ * wobble (G:T/U) pair (either way round), else false
*
* @param first
* @param second
}
/**
+ * Answers true if the base-pair is Watson-Crick - (A:T/U or C:G, either way
+ * round), else false
+ *
+ * @param first
+ * @param second
+ * @return
+ */
+ public static boolean isCanonicalPair(char first, char second)
+ {
+
+ if (first > 'Z')
+ {
+ first -= 32;
+ }
+ if (second > 'Z')
+ {
+ second -= 32;
+ }
+
+ switch (first)
+ {
+ case 'A':
+ switch (second)
+ {
+ case 'T':
+ case 'U':
+ return true;
+ }
+ break;
+ case 'G':
+ switch (second)
+ {
+ case 'C':
+ return true;
+ }
+ break;
+ case 'C':
+ switch (second)
+ {
+ case 'G':
+ return true;
+ }
+ break;
+ case 'T':
+ case 'U':
+ switch (second)
+ {
+ case 'A':
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ /**
* Returns the matching close pair symbol for the given opening symbol.
* Currently returns a-z for A-Z, or )]}> for ([{<, or the input symbol if it
* is not a valid opening symbol.
for (int i = start; i < end; i++) // foreach column
{
- int canonicalOrWobblePairCount = 0;
+ int canonicalOrWobblePairCount = 0, canonical = 0;
int otherPairCount = 0;
+ int nongap = 0;
maxResidue = "-";
values = new int[255];
pairs = new int[255][255];
values['-']++;
continue;
}
-
+ nongap++;
/*
* ensure upper-case for counting purposes
*/
}
if (Rna.isCanonicalOrWobblePair(c, cEnd))
{
- values['(']++;
- maxResidue = "(";
canonicalOrWobblePairCount++;
+ if (Rna.isCanonicalPair(c, cEnd))
+ {
+ canonical++;
+ }
}
else
{
- values['[']++;
- maxResidue = "[";
otherPairCount++;
}
pairs[c][cEnd]++;
}
}
- // nonGap++;
}
residueHash = new Hashtable();
residueHash.put(PAIRPROFILE, pairs);
}
-
+ values['('] = canonicalOrWobblePairCount;
+ values['['] = canonical;
+ values['{'] = otherPairCount;
/*
* the count is the number of valid pairs (as a percentage, determines
* the relative size of the profile logo)
int count = canonicalOrWobblePairCount;
/*
- * currently displaying as '(' if most pairs are valid, or as
- * '[' if there are more invalid than valid pairs
+ * display '(' if most pairs are canonical, or as
+ * '[' if there are more wobble pairs.
*/
- if (!maxResidue.equals("-"))
+ if (canonicalOrWobblePairCount > 0 || otherPairCount > 0)
{
- maxResidue = canonicalOrWobblePairCount >= otherPairCount ? "("
+ if (canonicalOrWobblePairCount >= otherPairCount)
+ {
+ maxResidue = (canonicalOrWobblePairCount - canonical) < canonical ? "("
: "[";
+ }
+ else
+ {
+ maxResidue = "{";
+ }
}
residueHash.put(MAXCOUNT, new Integer(count));
residueHash.put(MAXRESIDUE, maxResidue);
percentage = ((float) count * 100) / jSize;
residueHash.put(PID_GAPS, new Float(percentage));
- // percentage = ((float) count * 100) / (float) nongap;
- // residueHash.put(PID_NOGAPS, new Float(percentage));
+ percentage = ((float) count * 100) / nongap;
+ residueHash.put(PID_NOGAPS, new Float(percentage));
+
if (result[i] == null)
{
result[i] = residueHash;
{
values[')'] = values['('];
values[']'] = values['['];
+ values['}'] = values['{'];
values['('] = 0;
values['['] = 0;
- maxResidue = maxResidue.equals("(") ? ")" : "]";
+ values['{'] = 0;
+ maxResidue = maxResidue.equals("(") ? ")"
+ : maxResidue.equals("[") ? "]" : "}";
residueHash = new Hashtable();
if (profile)
percentage = ((float) count * 100) / jSize;
residueHash.put(PID_GAPS, new Float(percentage));
+ percentage = ((float) count * 100) / nongap;
+ residueHash.put(PID_NOGAPS, new Float(percentage));
+
result[bpEnd] = residueHash;
}
}
*/
public int calcPanelHeight();
+ /**
+ * Answers true if the viewport has at least one column selected
+ *
+ * @return
+ */
+ boolean hasSelectedColumns();
+
+ /**
+ * Answers true if the viewport has at least one hidden column
+ *
+ * @return
+ */
boolean hasHiddenColumns();
boolean isValidCharWidth();
boolean isClosed();
/**
+ * Dispose of all references or resources held by the viewport
+ */
+ void dispose();
+
+ /**
* get the associated calculation thread manager for the view
*
* @return
import jalview.schemes.HydrophobicColourScheme;
import jalview.schemes.NucleotideColourScheme;
import jalview.schemes.PIDColourScheme;
-import jalview.schemes.ResidueProperties;
import jalview.schemes.StrandColourScheme;
import jalview.schemes.TaylorColourScheme;
import jalview.schemes.TurnColourScheme;
if (conservationMenuItem.getState())
{
- sg.cs.setConservation(Conservation.calculateConservation("Group",
- ResidueProperties.propHash, 3, sg.getSequences(ap.av
- .getHiddenRepSequences()), 0, ap.av.getAlignment()
- .getWidth(), false, ap.av.getConsPercGaps(), false));
+ sg.cs.setConservation(Conservation.calculateConservation("Group", 3,
+ sg.getSequences(ap.av.getHiddenRepSequences()), 0, ap.av
+ .getAlignment().getWidth(), false, ap.av
+ .getConsPercGaps(), false));
SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
SliderPanel.showConservationSlider();
}
// Hide everything by the current selection - this is a hack - we do the
// invert and then hide
// first check that there will be visible columns after the invert.
- if ((viewport.getColumnSelection() != null
- && viewport.getColumnSelection().getSelected() != null && viewport
- .getColumnSelection().getSelected().size() > 0)
+ if (viewport.hasSelectedColumns()
|| (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
.getEndRes()))
{
hide = true;
viewport.hideAllSelectedSeqs();
}
- else if (!(toggleCols && viewport.getColumnSelection().getSelected()
- .size() > 0))
+ else if (!(toggleCols && viewport.hasSelectedColumns()))
{
viewport.showAllHiddenSeqs();
}
if (toggleCols)
{
- if (viewport.getColumnSelection().getSelected().size() > 0)
+ if (viewport.hasSelectedColumns())
{
viewport.hideSelectedColumns();
if (!toggleSeqs)
// this value is set false when selection area being dragged
boolean fastPaint = true;
- public void finalize()
+ @Override
+ public void finalize() throws Throwable
{
alignFrame = null;
av = null;
annotationPanel = null;
annotationPanelHolder = null;
annotationSpaceFillerHolder = null;
+ super.finalize();
}
public AlignmentPanel(AlignFrame af, final AlignViewport av)
addComponentListener(new ComponentAdapter()
{
+ @Override
public void componentResized(ComponentEvent evt)
{
setScrollValues(av.getStartRes(), av.getStartSeq());
final AlignmentPanel ap = this;
av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
{
+ @Override
public void propertyChange(java.beans.PropertyChangeEvent evt)
{
if (evt.getPropertyName().equals("alignment"))
* automatically adjust annotation panel height for new annotation whilst
* ensuring the alignment is still visible.
*/
+ @Override
public void adjustAnnotationHeight()
{
// TODO: display vertical annotation scrollbar if necessary
}
+ @Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
int oldX = av.getStartRes();
/**
* Repaint the alignment and annotations, and, optionally, any overview window
*/
+ @Override
public void paintAlignment(boolean updateOverview)
{
final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
}
}
+ @Override
public void update(Graphics g)
{
paint(g);
}
+ @Override
public void paint(Graphics g)
{
invalidate();
import jalview.datamodel.SequenceNode;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
import jalview.util.Format;
import jalview.util.MappingUtils;
Color col = new Color((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255));
- setColor((SequenceNode) tree.getGroups().elementAt(i), col.brighter());
+ setColor(tree.getGroups().elementAt(i), col.brighter());
- Vector<SequenceNode> l = tree.findLeaves((SequenceNode) tree
+ Vector<SequenceNode> l = tree.findLeaves(tree
.getGroups().elementAt(i));
Vector<SequenceI> sequences = new Vector<SequenceI>();
if (av.getGlobalColourScheme() != null
&& av.getGlobalColourScheme().conservationApplied())
{
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg.getSequences(null),
- sg.getStartRes(), sg.getEndRes());
+ Conservation c = new Conservation("Group", 3,
+ sg.getSequences(null), sg.getStartRes(), sg.getEndRes());
c.calculate();
c.verdict(false, av.getConsPercGaps());
private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF
.toString();
+ private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
+ .toString();
/*
* a date formatter using a fixed (rather than the user's) locale;
.println("Jalview Version: " + codeVersion + codeInstallation);
StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
- .getDefault(
-"PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT));
-
+ .getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT));
+ StructureImportSettings
+ .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER);
+ // StructureImportSettings
+ // .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
+ // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
// jnlpVersion will be null if we're using InstallAnywhere
// Dont do this check if running in headless mode
if (jnlpVersion == null
SequenceI rs = sel.getSequenceAt(0);
start = rs.findIndex(start);
end = rs.findIndex(end);
- List<Integer> cs = csel.getSelected();
+ List<Integer> cs = new ArrayList<Integer>(csel.getSelected());
csel.clear();
for (Integer selectedCol : cs)
{
}
@Override
- public void finalize()
+ public void finalize() throws Throwable
{
if (getDataset() != null)
{
getDataset().removeAlignmentRef();
}
+ nullReferences();
+ super.finalize();
+ }
+
+ /**
+ * Defensively nulls out references in case this object is not garbage
+ * collected
+ */
+ void nullReferences()
+ {
dataset = null;
sequences = null;
groups = null;
}
/**
- * decrement the alignmentRefs counter by one and call finalize if it goes to
- * zero.
+ * decrement the alignmentRefs counter by one and null references if it goes
+ * to zero.
+ *
+ * @throws Throwable
*/
- private void removeAlignmentRef()
+ private void removeAlignmentRef() throws Throwable
{
if (--alignmentRefs == 0)
{
- finalize();
+ nullReferences();
}
}
/*
* list of selected columns (ordered by selection order, not column order)
*/
- private List<Integer> order = new ArrayList<Integer>();
+ private List<Integer> order;
+
+ /*
+ * an unmodifiable view of the selected columns list
+ */
+ private List<Integer> _uorder;
/**
* bitfield for column selection - allows quick lookup
*/
- private BitSet selected = new BitSet();
+ private BitSet selected;
+
+ /**
+ * Constructor
+ */
+ IntList()
+ {
+ order = new ArrayList<Integer>();
+ _uorder = Collections.unmodifiableList(order);
+ selected = new BitSet();
+ }
+
+ /**
+ * Copy constructor
+ *
+ * @param other
+ */
+ IntList(IntList other)
+ {
+ this();
+ if (other != null)
+ {
+ int j = other.size();
+ for (int i = 0; i < j; i++)
+ {
+ add(other.elementAt(i));
+ }
+ }
+ }
/**
* adds a new column i to the selection - only if i is not already selected
*
* @param i
*/
- public void add(int i)
+ void add(int i)
{
if (!selected.get(i))
{
}
}
- public void clear()
+ void clear()
{
order.clear();
selected.clear();
}
- public void remove(int col)
+ void remove(int col)
{
Integer colInt = new Integer(col);
}
}
- public boolean contains(Integer colInt)
+ boolean contains(Integer colInt)
{
return selected.get(colInt);
}
- public boolean isEmpty()
+ boolean isEmpty()
{
return order.isEmpty();
}
- public List<Integer> getList()
+ /**
+ * Returns a read-only view of the selected columns list
+ *
+ * @return
+ */
+ List<Integer> getList()
{
- return order;
+ return _uorder;
}
- public int size()
+ int size()
{
return order.size();
}
* @param i
* @return
*/
- public int elementAt(int i)
+ int elementAt(int i)
{
return order.get(i);
}
* @param change
* - delta for shift
*/
- public void compensateForEdits(int start, int change)
+ void compensateForEdits(int start, int change)
{
BitSet mask = new BitSet();
for (int i = 0; i < order.size(); i++)
selected.or(mask);
}
- public boolean isSelected(int column)
+ boolean isSelected(int column)
{
return selected.get(column);
}
- public int getMaxColumn()
+ int getMaxColumn()
{
return selected.length() - 1;
}
- public int getMinColumn()
+ int getMinColumn()
{
return selected.get(0) ? 0 : selected.nextSetBit(0);
}
/**
* @return a series of selection intervals along the range
*/
- public List<int[]> getRanges()
+ List<int[]> getRanges()
{
List<int[]> rlist = new ArrayList<int[]>();
if (selected.isEmpty())
}
/**
- * Returns a list of selected columns. The list contains no duplicates but is
- * not necessarily ordered. It also may include columns hidden from the
- * current view. This returns a copy of the actual list, and changes to the
- * copy will not affect the selection.
+ * Returns a read-only view of the (possibly empty) list of selected columns
+ * <p>
+ * The list contains no duplicates but is not necessarily ordered. It also may
+ * include columns hidden from the current view. To modify (for example sort)
+ * the list, you should first make a copy.
+ * <p>
+ * The list is not thread-safe: iterating over it could result in
+ * ConcurrentModificationException if it is modified by another thread.
*/
public List<Integer> getSelected()
{
- return new ArrayList<Integer>(selection.getList());
+ return selection.getList();
}
/**
{
if (copy != null)
{
- if (copy.selection != null)
- {
- selection = new IntList();
- for (int i = 0, j = copy.selection.size(); i < j; i++)
- {
- selection.add(copy.selection.elementAt(i));
- }
- }
+ selection = new IntList(copy.selection);
if (copy.hiddenColumns != null)
{
hiddenColumns = new Vector<int[]>(copy.hiddenColumns.size());
import jalview.analysis.AAFrequency;
import jalview.analysis.Conservation;
import jalview.schemes.ColourSchemeI;
-import jalview.schemes.ResidueProperties;
import java.awt.Color;
import java.util.ArrayList;
if ((conservation != null)
|| (cs != null && cs.conservationApplied()))
{
- Conservation c = new Conservation(groupName,
- ResidueProperties.propHash, 3, sequences, startRes,
- endRes + 1);
+ Conservation c = new Conservation(groupName, 3, sequences,
+ startRes, endRes + 1);
c.calculate();
c.verdict(false, consPercGaps);
if (conservation != null)
// Hide everything by the current selection - this is a hack - we do the
// invert and then hide
// first check that there will be visible columns after the invert.
- if ((viewport.getColumnSelection() != null
- && viewport.getColumnSelection().getSelected() != null && viewport
- .getColumnSelection().getSelected().size() > 0)
+ if (viewport.hasSelectedColumns()
|| (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
.getEndRes()))
{
hideSelSequences_actionPerformed(null);
hide = true;
}
- else if (!(toggleCols && viewport.getColumnSelection().getSelected()
- .size() > 0))
+ else if (!(toggleCols && viewport.hasSelectedColumns()))
{
showAllSeqs_actionPerformed(null);
}
if (toggleCols)
{
- if (viewport.getColumnSelection().getSelected().size() > 0)
+ if (viewport.hasSelectedColumns())
{
hideSelColumns_actionPerformed(null);
if (!toggleSeqs)
* @param align
* DOCUMENT ME!
*/
+ @Override
public void setAlignment(AlignmentI align)
{
replaceMappings(align);
- this.alignment = align;
+ super.setAlignment(align);
}
/**
*/
private boolean dontScrollComplement;
+ private PropertyChangeListener propertyChangeListener;
+
/**
* Creates a new AlignmentPanel object.
*
vscroll.addAdjustmentListener(this);
final AlignmentPanel ap = this;
- av.addPropertyChangeListener(new PropertyChangeListener()
+ propertyChangeListener = new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent evt)
alignmentChanged();
}
}
- });
+ };
+ av.addPropertyChangeListener(propertyChangeListener);
fontChanged();
adjustAnnotationHeight();
updateLayout();
PaintRefresher.RemoveComponent(getSeqPanel().seqCanvas);
PaintRefresher.RemoveComponent(getIdPanel().getIdCanvas());
PaintRefresher.RemoveComponent(this);
+
+ /*
+ * try to ensure references are nulled
+ */
+ if (annotationPanel != null)
+ {
+ annotationPanel.dispose();
+ }
+
if (av != null)
{
+ av.removePropertyChangeListener(propertyChangeListener);
jalview.structure.StructureSelectionManager ssm = av
.getStructureSelectionManager();
ssm.removeStructureViewerListener(getSeqPanel(), null);
ssm.removeCommandListener(av);
ssm.removeStructureViewerListener(getSeqPanel(), null);
ssm.removeSelectionListener(getSeqPanel());
- av.setAlignment(null);
+ av.dispose();
av = null;
}
else
AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
+ boolean fullRepaint = false;
if (evt.getActionCommand().equals(ADDNEW))
{
AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
ap.av.getAlignment().addAnnotation(newAnnotation);
ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
+ fullRepaint = true;
}
else if (evt.getActionCommand().equals(EDITNAME))
{
+ String name = aa[selectedRow].label;
editLabelDescription(aa[selectedRow]);
- repaint();
+ if (!name.equalsIgnoreCase(aa[selectedRow].label))
+ {
+ fullRepaint = true;
+ }
}
else if (evt.getActionCommand().equals(HIDE))
{
{
ap.av.getAlignment().deleteAnnotation(aa[selectedRow]);
ap.av.getCalcManager().removeWorkerForAnnotation(aa[selectedRow]);
+ fullRepaint = true;
}
else if (evt.getActionCommand().equals(SHOWALL))
{
aa[i].visible = true;
}
}
+ fullRepaint = true;
}
else if (evt.getActionCommand().equals(OUTPUT_TEXT))
{
aa[selectedRow].scaleColLabel = !aa[selectedRow].scaleColLabel;
}
- refresh();
+ refresh(fullRepaint);
}
/**
* Redraw sensibly.
+ *
+ * @adjustHeight if true, try to recalculate panel height for visible
+ * annotations
*/
- protected void refresh()
+ protected void refresh(boolean adjustHeight)
{
- ap.validateAnnotationDimensions(false);
+ ap.validateAnnotationDimensions(adjustHeight);
ap.addNotify();
- ap.repaint();
+ if (adjustHeight)
+ {
+ // sort, repaint, update overview
+ ap.paintAlignment(true);
+ }
+ else
+ {
+ // lightweight repaint
+ ap.repaint();
+ }
}
/**
*/
boolean editLabelDescription(AlignmentAnnotation annotation)
{
+ // TODO i18n
EditNameDialog dialog = new EditNameDialog(annotation.label,
annotation.description, " Annotation Name ",
"Annotation Description ", "Edit Annotation Name/Description",
// ann.visible = false;
// }
// }
- refresh();
+ refresh(true);
}
});
pop.add(hideType);
{
ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap);
}
+ ap.alignmentChanged();
}
});
pop.add(cbmi);
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
boolean mouseDragging = false;
- boolean MAC = false;
-
// for editing cursor
int cursorX = 0;
*/
public AnnotationPanel(AlignmentPanel ap)
{
-
- MAC = jalview.util.Platform.isAMac();
-
ToolTipManager.sharedInstance().registerComponent(this);
ToolTipManager.sharedInstance().setInitialDelay(0);
ToolTipManager.sharedInstance().setDismissDelay(10000);
StringBuilder collatedInput = new StringBuilder(64);
String last = "";
ColumnSelection viscols = av.getColumnSelection();
- // TODO: refactor and save av.getColumnSelection for efficiency
- List<Integer> selected = viscols.getSelected();
+
+ /*
+ * the selection list (read-only view) is in selection order, not
+ * column order; make a copy so we can sort it
+ */
+ List<Integer> selected = new ArrayList<Integer>(viscols.getSelected());
Collections.sort(selected);
for (int index : selected)
{
return null;
}
}
+
+ /**
+ * Try to ensure any references held are nulled
+ */
+ public void dispose()
+ {
+ av = null;
+ ap = null;
+ image = null;
+ fadedImage = null;
+ gg = null;
+ _mwl = null;
+
+ /*
+ * I created the renderer so I will dispose of it
+ */
+ if (renderer != null)
+ {
+ renderer.dispose();
+ }
+ }
}
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
* ((openFrameCount - 1) % 10) + yOffset);
}
+ /*
+ * add an entry for the new frame in the Window menu
+ * (and remove it when the frame is closed)
+ */
final JMenuItem menuItem = new JMenuItem(title);
- frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ frame.addInternalFrameListener(new InternalFrameAdapter()
{
@Override
- public void internalFrameActivated(
- javax.swing.event.InternalFrameEvent evt)
+ public void internalFrameActivated(InternalFrameEvent evt)
{
JInternalFrame itf = desktop.getSelectedFrame();
if (itf != null)
{
itf.requestFocus();
}
-
}
@Override
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
+ public void internalFrameClosed(InternalFrameEvent evt)
{
PaintRefresher.RemoveComponent(frame);
{
openFrameCount--;
}
+
+ /*
+ * ensure no reference to alignFrame retained by menu item listener
+ */
+ if (menuItem.getActionListeners().length > 0)
+ {
+ menuItem.removeActionListener(menuItem.getActionListeners()[0]);
+ }
windowMenu.remove(menuItem);
JInternalFrame itf = desktop.getSelectedFrame();
if (itf != null)
{
itf.requestFocus();
+ if (itf instanceof AlignFrame)
+ {
+ Jalview.setCurrentAlignFrame((AlignFrame) itf);
+ }
}
System.gc();
};
}
}
});
- menuItem.addMouseListener(new MouseListener()
- {
-
- @Override
- public void mouseReleased(MouseEvent e)
- {
- }
-
- @Override
- public void mousePressed(MouseEvent e)
- {
- }
-
- @Override
- public void mouseExited(MouseEvent e)
- {
- try
- {
- frame.setSelected(false);
- } catch (PropertyVetoException e1)
- {
- }
- }
-
- @Override
- public void mouseEntered(MouseEvent e)
- {
- try
- {
- frame.setSelected(true);
- } catch (PropertyVetoException e1)
- {
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e)
- {
-
- }
- });
windowMenu.add(menuItem);
@Override
public void closeAll_actionPerformed(ActionEvent e)
{
+ // TODO show a progress bar while closing?
JInternalFrame[] frames = desktop.getAllFrames();
for (int i = 0; i < frames.length; i++)
{
{
}
}
+ Jalview.setCurrentAlignFrame(null);
System.out.println("ALL CLOSED");
if (v_client != null)
{
{
ssm.resetAll();
}
+ System.gc();
}
@Override
*/
package jalview.gui;
+import jalview.analysis.Conservation;
import jalview.api.FeatureColourI;
import jalview.api.ViewStyleI;
import jalview.api.structures.JalviewStructureDisplayI;
}
if (jGroup.getConsThreshold() != 0)
{
- jalview.analysis.Conservation c = new jalview.analysis.Conservation(
- "All", ResidueProperties.propHash, 3,
+ Conservation c = new Conservation("All", 3,
sg.getSequences(null), 0, sg.getWidth() - 1);
c.calculate();
c.verdict(false, 25);
*/
package jalview.gui;
+import jalview.analysis.Conservation;
import jalview.binding.Annotation;
import jalview.binding.AnnotationElement;
import jalview.binding.Features;
import jalview.datamodel.PDBEntry;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.ResidueProperties;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.jarInputStreamProvider;
if (groups[i].getConsThreshold() != 0)
{
- jalview.analysis.Conservation c = new jalview.analysis.Conservation(
- "All", ResidueProperties.propHash, 3,
+ Conservation c = new Conservation("All", 3,
sg.getSequences(null), 0, sg.getWidth() - 1);
c.calculate();
c.verdict(false, 25);
import jalview.schemes.NucleotideColourScheme;
import jalview.schemes.PIDColourScheme;
import jalview.schemes.PurinePyrimidineColourScheme;
-import jalview.schemes.ResidueProperties;
import jalview.schemes.StrandColourScheme;
import jalview.schemes.TaylorColourScheme;
import jalview.schemes.TurnColourScheme;
if (conservationMenuItem.isSelected())
{
// JBPNote: Conservation name shouldn't be i18n translated
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg.getSequences(ap.av
- .getHiddenRepSequences()), sg.getStartRes(),
+ Conservation c = new Conservation("Group", 3, sg.getSequences(ap.av
+ .getHiddenRepSequences()), sg.getStartRes(),
sg.getEndRes() + 1);
c.calculate();
{
final long progressSessionId = System.currentTimeMillis();
final StructureSelectionManager ssm = ap.getStructureSelectionManager();
+ final int preferredHeight = pnl_filter.getHeight();
ssm.setProgressIndicator(this);
ssm.setProgressSessionId(progressSessionId);
new Thread(new Runnable()
@Override
public void run()
{
- FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
- .getSelectedItem());
- String currentView = selectedFilterOpt.getView();
- if (currentView == VIEWS_FILTER)
- {
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ String currentView = selectedFilterOpt.getView();
+ if (currentView == VIEWS_FILTER)
+ {
int pdbIdColIndex = getResultTable().getColumn("PDB Id")
.getModelIndex();
int refSeqColIndex = getResultTable().getColumn("Ref Sequence")
- .getModelIndex();
+ .getModelIndex();
int[] selectedRows = getResultTable().getSelectedRows();
- PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
- int count = 0;
- ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
- for (int row : selectedRows)
- {
+ PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
+ int count = 0;
+ ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
+ for (int row : selectedRows)
+ {
String pdbIdStr = getResultTable().getValueAt(row,
- pdbIdColIndex)
- .toString();
+ pdbIdColIndex).toString();
SequenceI selectedSeq = (SequenceI) getResultTable()
- .getValueAt(row,
- refSeqColIndex);
- selectedSeqsToView.add(selectedSeq);
+ .getValueAt(row, refSeqColIndex);
+ selectedSeqsToView.add(selectedSeq);
PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
if (pdbEntry == null)
{
pdbEntry = getFindEntry(pdbIdStr,
selectedSeq.getAllPDBEntries());
}
- if (pdbEntry == null)
- {
- pdbEntry = new PDBEntry();
- pdbEntry.setId(pdbIdStr);
- pdbEntry.setType(PDBEntry.Type.PDB);
- selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
- }
- pdbEntriesToView[count++] = pdbEntry;
- }
- SequenceI[] selectedSeqs = selectedSeqsToView
- .toArray(new SequenceI[selectedSeqsToView.size()]);
+ if (pdbEntry == null)
+ {
+ pdbEntry = new PDBEntry();
+ pdbEntry.setId(pdbIdStr);
+ pdbEntry.setType(PDBEntry.Type.PDB);
+ selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
+ }
+ pdbEntriesToView[count++] = pdbEntry;
+ }
+ SequenceI[] selectedSeqs = selectedSeqsToView
+ .toArray(new SequenceI[selectedSeqsToView.size()]);
launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs);
- }
- else if (currentView == VIEWS_LOCAL_PDB)
- {
- int[] selectedRows = tbl_local_pdb.getSelectedRows();
- PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
- int count = 0;
+ }
+ else if (currentView == VIEWS_LOCAL_PDB)
+ {
+ int[] selectedRows = tbl_local_pdb.getSelectedRows();
+ PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
+ int count = 0;
int pdbIdColIndex = tbl_local_pdb.getColumn("PDB Id")
.getModelIndex();
- int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
- .getModelIndex();
- ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
- for (int row : selectedRows)
- {
- PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
- pdbIdColIndex);
- pdbEntriesToView[count++] = pdbEntry;
- SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
- refSeqColIndex);
- selectedSeqsToView.add(selectedSeq);
- }
- SequenceI[] selectedSeqs = selectedSeqsToView
- .toArray(new SequenceI[selectedSeqsToView.size()]);
+ int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
+ .getModelIndex();
+ ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
+ for (int row : selectedRows)
+ {
+ PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
+ pdbIdColIndex);
+ pdbEntriesToView[count++] = pdbEntry;
+ SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(
+ row, refSeqColIndex);
+ selectedSeqsToView.add(selectedSeq);
+ }
+ SequenceI[] selectedSeqs = selectedSeqsToView
+ .toArray(new SequenceI[selectedSeqsToView.size()]);
launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs);
- }
- else if (currentView == VIEWS_ENTER_ID)
- {
- SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
- .getCmb_assSeq().getSelectedItem()).getSequence();
- if (userSelectedSeq != null)
- {
- selectedSequence = userSelectedSeq;
- }
+ }
+ else if (currentView == VIEWS_ENTER_ID)
+ {
+ SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
+ .getCmb_assSeq().getSelectedItem()).getSequence();
+ if (userSelectedSeq != null)
+ {
+ selectedSequence = userSelectedSeq;
+ }
- String pdbIdStr = txt_search.getText();
- PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
- if (pdbEntry == null)
- {
- pdbEntry = new PDBEntry();
+ String pdbIdStr = txt_search.getText();
+ PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
+ if (pdbEntry == null)
+ {
+ pdbEntry = new PDBEntry();
if (pdbIdStr.split(":").length > 1)
{
pdbEntry.setId(pdbIdStr.split(":")[0]);
{
pdbEntry.setId(pdbIdStr);
}
- pdbEntry.setType(PDBEntry.Type.PDB);
- selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
- }
+ pdbEntry.setType(PDBEntry.Type.PDB);
+ selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
+ }
- PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
+ PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
launchStructureViewer(ssm, pdbEntriesToView, ap,
new SequenceI[] { selectedSequence });
- }
- else if (currentView == VIEWS_FROM_FILE)
- {
- SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
- .getCmb_assSeq().getSelectedItem()).getSequence();
- if (userSelectedSeq != null)
- {
- selectedSequence = userSelectedSeq;
- }
- PDBEntry fileEntry = new AssociatePdbFileWithSeq()
- .associatePdbWithSeq(selectedPdbFileName,
- jalview.io.AppletFormatAdapter.FILE,
- selectedSequence, true, Desktop.instance);
+ }
+ else if (currentView == VIEWS_FROM_FILE)
+ {
+ SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
+ .getCmb_assSeq().getSelectedItem()).getSequence();
+ if (userSelectedSeq != null)
+ {
+ selectedSequence = userSelectedSeq;
+ }
+ PDBEntry fileEntry = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq(selectedPdbFileName,
+ jalview.io.AppletFormatAdapter.FILE,
+ selectedSequence, true, Desktop.instance);
launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap,
new SequenceI[] { selectedSequence });
- }
- closeAction();
+ }
+ closeAction(preferredHeight);
}
}).start();
}
if (SiftsSettings.isMapWithSifts())
{
- ArrayList<SequenceI> seqsWithoutSourceDBRef = new ArrayList<SequenceI>();
+ List<SequenceI> seqsWithoutSourceDBRef = new ArrayList<SequenceI>();
int p = 0;
// TODO: skip PDBEntry:Sequence pairs where PDBEntry doesn't look like a
// real PDB ID. For moment, we can also safely do this if there is already
{
seqWithoutSrcDBRef[x++] = fSeq;
}
- new DBRefFetcher(seqWithoutSrcDBRef).fetchDBRefs(true);
+ DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef);
+ dbRefFetcher.fetchDBRefs(true);
}
}
if (pdbEntriesToView.length > 1)
import jalview.datamodel.SequenceNode;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
import jalview.structure.SelectionSource;
import jalview.util.Format;
if (aps[a].av.getGlobalColourScheme() != null
&& aps[a].av.getGlobalColourScheme().conservationApplied())
{
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg.getSequences(null),
- sg.getStartRes(), sg.getEndRes());
-
+ Conservation c = new Conservation("Group", 3,
+ sg.getSequences(null), sg.getStartRes(), sg.getEndRes());
c.calculate();
c.verdict(false, aps[a].av.getConsPercGaps());
sg.cs.setConservation(c);
Thread udthread = new Thread(new Runnable()
{
+ @Override
public void run()
{
Cache.log.info("Jalview updating to the Vamsas Session.");
final VamsasApplication client = this;
vclient.addDocumentUpdateHandler(new PropertyChangeListener()
{
+ @Override
public void propertyChange(PropertyChangeEvent evt)
{
Cache.log.debug("Dealing with document update event.");
uk.ac.vamsas.client.Events.DOCUMENT_REQUESTTOCLOSE,
new PropertyChangeListener()
{
+ @Override
public void propertyChange(PropertyChangeEvent evt)
{
if (client.promptUser)
{
String last = null;
+ @Override
public void handleMessage(Message message)
{
if (vobj2jv == null)
selecter = new SelectionListener()
{
+ @Override
public void selection(SequenceGroup seqsel,
ColumnSelection colsel, SelectionSource source)
{
{
// gather selected columns outwith the sequence positions
// too
- for (Object obj : colsel.getSelected())
+ for (Integer ival : colsel.getSelected())
{
- int ival = ((Integer) obj).intValue();
Pos p = new Pos();
- p.setI(ival + 1);
+ p.setI(ival.intValue() + 1);
range.addPos(p);
}
}
import jalview.datamodel.SequenceI;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
import java.io.BufferedReader;
else if (key.equalsIgnoreCase("consThreshold"))
{
sg.cs.setConservationInc(Integer.parseInt(value));
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg.getSequences(null),
- sg.getStartRes(), sg.getEndRes() + 1);
+ Conservation c = new Conservation("Group", 3,
+ sg.getSequences(null), sg.getStartRes(),
+ sg.getEndRes() + 1);
c.calculate();
c.verdict(false, 25); // TODO: refer to conservation percent threshold
alignFile = new JPredFile(inFile, type);
((JPredFile) alignFile).removeNonSequences();
}
- else if (format.equals("PDB") || format.equalsIgnoreCase("mmCIF"))
+ else if (format.equals("PDB"))
+ {
+ // TODO obtain config value from preference settings.
+ // Set value to 'true' to test PDB processing with Jmol: JAL-1213
+ boolean isParseWithJMOL = StructureImportSettings
+ .getDefaultPDBFileParser().equalsIgnoreCase(
+ StructureImportSettings.StructureParser.JMOL_PARSER
+ .toString());
+ if (isParseWithJMOL)
+ {
+ StructureImportSettings.addSettings(annotFromStructure,
+ localSecondaryStruct, serviceSecondaryStruct);
+ alignFile = new jalview.ext.jmol.JmolParser(inFile, type);
+ }
+ else
+ {
+ StructureImportSettings.addSettings(annotFromStructure,
+ localSecondaryStruct, serviceSecondaryStruct);
+ StructureImportSettings.setShowSeqFeatures(true);
+ alignFile = new MCview.PDBfile(annotFromStructure,
+ localSecondaryStruct, serviceSecondaryStruct, inFile,
+ type);
+ }
+ ((StructureFile) alignFile).setDbRefType(format);
+ }
+ else if (format.equalsIgnoreCase("mmCIF"))
{
StructureImportSettings.addSettings(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct);
- alignFile = new JmolParser(inFile, type);
+ alignFile = new jalview.ext.jmol.JmolParser(inFile, type);
((StructureFile) alignFile).setDbRefType(format);
}
else if (format.equals("STH"))
return dsregitem;
}
- protected void finalize()
+ @Override
+ protected void finalize() throws Throwable
{
if (dsObjReg != null)
{
{
dsItemReg.clear();
}
+ super.finalize();
}
}
jvlite.setExecutor(this);
}
- public void finalize()
+ @Override
+ protected void finalize() throws Throwable
{
jvlite = null;
executor = null;
jsExecQueue.clear();
}
jsExecQueue = null;
+ super.finalize();
}
private Vector jsExecQueue;
executor = null;
}
+ @Override
public void run()
{
while (jsExecQueue != null)
final Exception[] jsex = new Exception[1];
Runnable exec = new Runnable()
{
+ @Override
public void run()
{
try
if (jex instanceof netscape.javascript.JSException
&& jvlite.jsfallbackEnabled)
{
- jsex[0] = (netscape.javascript.JSException) jex;
+ jsex[0] = jex;
if (jvlite.debug)
{
System.err.println("Falling back to javascript: url call");
return _listenerfn;
}
- public void finalise()
+ public void finalize() throws Throwable
{
jvlite = null;
super.finalize();
protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
- private JTabbedPane pnl_filter = new JTabbedPane();
+ protected JTabbedPane pnl_filter = new JTabbedPane();
protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
PreferenceSource.STRUCTURE_CHOOSER,
@Override
public void actionPerformed(ActionEvent e)
{
- closeAction();
+ closeAction(pnl_filter.getHeight());
}
});
btn_cancel.addKeyListener(new KeyAdapter()
{
if (evt.getKeyCode() == KeyEvent.VK_ENTER)
{
- closeAction();
+ closeAction(pnl_filter.getHeight());
}
}
});
@Override
public void internalFrameClosing(InternalFrameEvent e)
{
- closeAction();
+ closeAction(pnl_filter.getHeight());
}
});
mainFrame.setVisible(true);
Desktop.addInternalFrame(mainFrame, frameTitle, width, height);
}
- protected void closeAction()
+ protected void closeAction(int preferredHeight)
{
// System.out.println(">>>>>>>>>> closing internal frame!!!");
// System.out.println("width : " + mainFrame.getWidth());
// System.out.println("x : " + mainFrame.getX());
// System.out.println("y : " + mainFrame.getY());
tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth());
- tempUserPrefs.put("structureChooser.height", pnl_filter.getHeight());
+ tempUserPrefs.put("structureChooser.height", preferredHeight);
tempUserPrefs.put("structureChooser.x", mainFrame.getX());
tempUserPrefs.put("structureChooser.y", mainFrame.getY());
mainFrame.dispose();
}
+
public boolean wantedFieldsUpdated()
{
if (previousWantedFields == null)
import jalview.datamodel.ColumnSelection;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
+import jalview.util.Platform;
import java.awt.BasicStroke;
import java.awt.Color;
*/
private final boolean debugRedraw;
+ private int charWidth, endRes, charHeight;
+
+ private boolean validCharWidth, hasHiddenColumns;
+
+ private FontMetrics fm;
+
+ private final boolean MAC = Platform.isAMac();
+
+ boolean av_renderHistogram = true, av_renderProfile = true,
+ av_normaliseProfile = false;
+
+ ColourSchemeI profcolour = null;
+
+ private ColumnSelection columnSelection;
+
+ private Hashtable[] hconsensus;
+
+ private Hashtable[] complementConsensus;
+
+ private Hashtable[] hStrucConsensus;
+
+ private boolean av_ignoreGapsConsensus;
+
+ /**
+ * attributes set from AwtRenderPanelI
+ */
+ /**
+ * old image used when data is currently being calculated and cannot be
+ * rendered
+ */
+ private Image fadedImage;
+
+ /**
+ * panel being rendered into
+ */
+ private ImageObserver annotationPanel;
+
+ /**
+ * width of image to render in panel
+ */
+ private int imgWidth;
+
+ /**
+ * offset to beginning of visible area
+ */
+ private int sOffset;
+
+ /**
+ * offset to end of visible area
+ */
+ private int visHeight;
+
+ /**
+ * indicate if the renderer should only render the visible portion of the
+ * annotation given the current view settings
+ */
+ private boolean useClip = true;
+
+ /**
+ * master flag indicating if renderer should ever try to clip. not enabled for
+ * jalview 2.8.1
+ */
+ private boolean canClip = false;
+
public AnnotationRenderer()
{
this(false);
this.debugRedraw = debugRedraw;
}
+ /**
+ * Remove any references and resources when this object is no longer required
+ */
+ public void dispose()
+ {
+ hconsensus = null;
+ complementConsensus = null;
+ hStrucConsensus = null;
+ fadedImage = null;
+ annotationPanel = null;
+ }
+
void drawStemAnnot(Graphics g, Annotation[] row_annotations,
int lastSSX, int x, int y, int iconOffset, int startRes,
int column, boolean validRes, boolean validEnd)
g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 7);
}
- private int charWidth, endRes, charHeight;
-
- private boolean validCharWidth, hasHiddenColumns;
-
- private FontMetrics fm;
-
- private final boolean MAC = jalview.util.Platform.isAMac();
-
- boolean av_renderHistogram = true, av_renderProfile = true,
- av_normaliseProfile = false;
-
- ColourSchemeI profcolour = null;
-
- private ColumnSelection columnSelection;
-
- private Hashtable[] hconsensus;
-
- private Hashtable[] complementConsensus;
-
- private Hashtable[] hStrucConsensus;
-
- private boolean av_ignoreGapsConsensus;
-
- /**
- * attributes set from AwtRenderPanelI
- */
- /**
- * old image used when data is currently being calculated and cannot be
- * rendered
- */
- private Image fadedImage;
-
- /**
- * panel being rendered into
- */
- private ImageObserver annotationPanel;
-
- /**
- * width of image to render in panel
- */
- private int imgWidth;
-
- /**
- * offset to beginning of visible area
- */
- private int sOffset;
-
- /**
- * offset to end of visible area
- */
- private int visHeight;
-
- /**
- * indicate if the renderer should only render the visible portion of the
- * annotation given the current view settings
- */
- private boolean useClip = true;
-
- /**
- * master flag indicating if renderer should ever try to clip. not enabled for
- * jalview 2.8.1
- */
- private boolean canClip = false;
-
void drawNotCanonicalAnnot(Graphics g, Color nonCanColor,
Annotation[] row_annotations, int lastSSX, int x, int y,
int iconOffset, int startRes, int column, boolean validRes,
import java.awt.Color;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
static
{
- aa3Hash.put("ALA", new Integer(0));
- aa3Hash.put("ARG", new Integer(1));
- aa3Hash.put("ASN", new Integer(2));
- aa3Hash.put("ASP", new Integer(3)); // D
- aa3Hash.put("CYS", new Integer(4));
- aa3Hash.put("GLN", new Integer(5)); // Q
- aa3Hash.put("GLU", new Integer(6)); // E
- aa3Hash.put("GLY", new Integer(7));
- aa3Hash.put("HIS", new Integer(8));
- aa3Hash.put("ILE", new Integer(9));
- aa3Hash.put("LEU", new Integer(10));
- aa3Hash.put("LYS", new Integer(11));
- aa3Hash.put("MET", new Integer(12));
- aa3Hash.put("PHE", new Integer(13));
- aa3Hash.put("PRO", new Integer(14));
- aa3Hash.put("SER", new Integer(15));
- aa3Hash.put("THR", new Integer(16));
- aa3Hash.put("TRP", new Integer(17));
- aa3Hash.put("TYR", new Integer(18));
- aa3Hash.put("VAL", new Integer(19));
+ aa3Hash.put("ALA", Integer.valueOf(0));
+ aa3Hash.put("ARG", Integer.valueOf(1));
+ aa3Hash.put("ASN", Integer.valueOf(2));
+ aa3Hash.put("ASP", Integer.valueOf(3)); // D
+ aa3Hash.put("CYS", Integer.valueOf(4));
+ aa3Hash.put("GLN", Integer.valueOf(5)); // Q
+ aa3Hash.put("GLU", Integer.valueOf(6)); // E
+ aa3Hash.put("GLY", Integer.valueOf(7));
+ aa3Hash.put("HIS", Integer.valueOf(8));
+ aa3Hash.put("ILE", Integer.valueOf(9));
+ aa3Hash.put("LEU", Integer.valueOf(10));
+ aa3Hash.put("LYS", Integer.valueOf(11));
+ aa3Hash.put("MET", Integer.valueOf(12));
+ aa3Hash.put("PHE", Integer.valueOf(13));
+ aa3Hash.put("PRO", Integer.valueOf(14));
+ aa3Hash.put("SER", Integer.valueOf(15));
+ aa3Hash.put("THR", Integer.valueOf(16));
+ aa3Hash.put("TRP", Integer.valueOf(17));
+ aa3Hash.put("TYR", Integer.valueOf(18));
+ aa3Hash.put("VAL", Integer.valueOf(19));
// IUB Nomenclature for ambiguous peptides
- aa3Hash.put("ASX", new Integer(20)); // "B";
- aa3Hash.put("GLX", new Integer(21)); // Z
- aa3Hash.put("XAA", new Integer(22)); // X unknown
- aa3Hash.put("-", new Integer(23));
- aa3Hash.put("*", new Integer(23));
- aa3Hash.put(".", new Integer(23));
- aa3Hash.put(" ", new Integer(23));
- aa3Hash.put("Gap", new Integer(23));
- aa3Hash.put("UR3", new Integer(24));
+ aa3Hash.put("ASX", Integer.valueOf(20)); // "B";
+ aa3Hash.put("GLX", Integer.valueOf(21)); // Z
+ aa3Hash.put("XAA", Integer.valueOf(22)); // X unknown
+ aa3Hash.put("-", Integer.valueOf(23));
+ aa3Hash.put("*", Integer.valueOf(23));
+ aa3Hash.put(".", Integer.valueOf(23));
+ aa3Hash.put(" ", Integer.valueOf(23));
+ aa3Hash.put("Gap", Integer.valueOf(23));
+ aa3Hash.put("UR3", Integer.valueOf(24));
}
static
public static final Color midBlue = new Color(100, 100, 255);
- public static final Vector scaleColours = new Vector();
-
- static
- {
- scaleColours.addElement(new Color(114, 0, 147));
- scaleColours.addElement(new Color(156, 0, 98));
- scaleColours.addElement(new Color(190, 0, 0));
- scaleColours.addElement(Color.red);
- scaleColours.addElement(new Color(255, 125, 0));
- scaleColours.addElement(Color.orange);
- scaleColours.addElement(new Color(255, 194, 85));
- scaleColours.addElement(Color.yellow);
- scaleColours.addElement(new Color(255, 255, 181));
- scaleColours.addElement(Color.white);
- }
-
- public static final Color[] taylor = { new Color(204, 255, 0), // A
- // Greenish-yellowy-yellow
+ // not currently in use
+ // public static final Vector<Color> scaleColours = new Vector<Color>();
+ // static
+ // {
+ // scaleColours.addElement(new Color(114, 0, 147));
+ // scaleColours.addElement(new Color(156, 0, 98));
+ // scaleColours.addElement(new Color(190, 0, 0));
+ // scaleColours.addElement(Color.red);
+ // scaleColours.addElement(new Color(255, 125, 0));
+ // scaleColours.addElement(Color.orange);
+ // scaleColours.addElement(new Color(255, 194, 85));
+ // scaleColours.addElement(Color.yellow);
+ // scaleColours.addElement(new Color(255, 255, 181));
+ // scaleColours.addElement(Color.white);
+ // }
+
+ public static final Color[] taylor = { new Color(204, 255, 0),
+ // A Greenish-yellowy-yellow
new Color(0, 0, 255), // R Blueish-bluey-blue
new Color(204, 0, 255), // N Blueish-reddy-blue
new Color(255, 0, 0), // D Reddish-reddy-red
{ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
-8, -8, -8, -8, -8, -8, 1 }, };
- public static final Hashtable ssHash = new Hashtable(); // stores the number
- // value of the aa
-
- static
- {
- ssHash.put("H", Color.magenta);
- ssHash.put("E", Color.yellow);
- ssHash.put("-", Color.white);
- ssHash.put(".", Color.white);
- ssHash.put("S", Color.cyan);
- ssHash.put("T", Color.blue);
- ssHash.put("G", Color.pink);
- ssHash.put("I", Color.pink);
- ssHash.put("B", Color.yellow);
- }
+ // not currently used
+ // public static final Map<String, Color> ssHash = new Hashtable<String,
+ // Color>();
+ // static
+ // {
+ // ssHash.put("H", Color.magenta);
+ // ssHash.put("E", Color.yellow);
+ // ssHash.put("-", Color.white);
+ // ssHash.put(".", Color.white);
+ // ssHash.put("S", Color.cyan);
+ // ssHash.put("T", Color.blue);
+ // ssHash.put("G", Color.pink);
+ // ssHash.put("I", Color.pink);
+ // ssHash.put("B", Color.yellow);
+ // }
/*
* new Color(60, 136, 238), // U Color.white, // I Color.white, // X
scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
-
}
public static final Color[] pidColours = { midBlue,
public static final float[] pidThresholds = { 80, 60, 40, };
- public static Map<String, List<String>> codonHash = new HashMap<String, List<String>>();
-
- private static List<String> Lys = new ArrayList<String>();
-
- private static List<String> Asn = new ArrayList<String>();
-
- private static List<String> Gln = new ArrayList<String>();
-
- private static List<String> His = new ArrayList<String>();
-
- private static List<String> Glu = new ArrayList<String>();
-
- private static List<String> Asp = new ArrayList<String>();
-
- private static List<String> Tyr = new ArrayList<String>();
-
- private static List<String> Thr = new ArrayList<String>();
-
- private static List<String> Pro = new ArrayList<String>();
-
- private static List<String> Ala = new ArrayList<String>();
-
- private static List<String> Ser = new ArrayList<String>();
-
- private static List<String> Arg = new ArrayList<String>();
-
- private static List<String> Gly = new ArrayList<String>();
-
- private static List<String> Trp = new ArrayList<String>();
-
- private static List<String> Cys = new ArrayList<String>();
-
- private static List<String> Ile = new ArrayList<String>();
-
- private static List<String> Met = new ArrayList<String>();
-
- private static List<String> Leu = new ArrayList<String>();
-
- private static List<String> Val = new ArrayList<String>();
-
- private static List<String> Phe = new ArrayList<String>();
-
- public static List<String> STOP = new ArrayList<String>();
+ public static List<String> STOP = Arrays.asList("TGA", "TAA", "TAG");
public static String START = "ATG";
- static
- {
- codonHash.put("K", Lys);
- codonHash.put("N", Asn);
- codonHash.put("Q", Gln);
- codonHash.put("H", His);
- codonHash.put("E", Glu);
- codonHash.put("D", Asp);
- codonHash.put("Y", Tyr);
- codonHash.put("T", Thr);
- codonHash.put("P", Pro);
- codonHash.put("A", Ala);
- codonHash.put("S", Ser);
- codonHash.put("R", Arg);
- codonHash.put("G", Gly);
- codonHash.put("W", Trp);
- codonHash.put("C", Cys);
- codonHash.put("I", Ile);
- codonHash.put("M", Met);
- codonHash.put("L", Leu);
- codonHash.put("V", Val);
- codonHash.put("F", Phe);
- codonHash.put("STOP", STOP);
- }
-
/**
* Nucleotide Ambiguity Codes
*/
// make all codons for this combination
char allres[][] = new char[tpos.length][];
String _acodon = "";
- char _anuc;
for (ipos = 0; ipos < tpos.length; ipos++)
{
if (acodon[ipos].length == 0 || tpos[ipos] < 0)
}
}
}
-
- }
-
- static
- {
- Lys.add("AAA");
- Lys.add("AAG");
- Asn.add("AAC");
- Asn.add("AAT");
-
- Gln.add("CAA");
- Gln.add("CAG");
- His.add("CAC");
- His.add("CAT");
-
- Glu.add("GAA");
- Glu.add("GAG");
- Asp.add("GAC");
- Asp.add("GAT");
-
- Tyr.add("TAC");
- Tyr.add("TAT");
-
- Thr.add("ACA");
- Thr.add("ACG");
- Thr.add("ACC");
- Thr.add("ACT");
-
- Pro.add("CCA");
- Pro.add("CCG");
- Pro.add("CCC");
- Pro.add("CCT");
-
- Ala.add("GCA");
- Ala.add("GCG");
- Ala.add("GCC");
- Ala.add("GCT");
-
- Ser.add("TCA");
- Ser.add("TCG");
- Ser.add("TCC");
- Ser.add("TCT");
- Ser.add("AGC");
- Ser.add("AGT");
-
- Arg.add("AGA");
- Arg.add("AGG");
- Arg.add("CGA");
- Arg.add("CGG");
- Arg.add("CGC");
- Arg.add("CGT");
-
- Gly.add("GGA");
- Gly.add("GGG");
- Gly.add("GGC");
- Gly.add("GGT");
-
- STOP.add("TGA");
- STOP.add("TAA");
- STOP.add("TAG");
-
- Trp.add("TGG");
-
- Cys.add("TGC");
- Cys.add("TGT");
-
- Ile.add("ATA");
- Ile.add("ATC");
- Ile.add("ATT");
-
- Met.add("ATG");
-
- Leu.add("CTA");
- Leu.add("CTG");
- Leu.add("CTC");
- Leu.add("CTT");
- Leu.add("TTA");
- Leu.add("TTG");
-
- Val.add("GTA");
- Val.add("GTG");
- Val.add("GTC");
- Val.add("GTT");
-
- Phe.add("TTC");
- Phe.add("TTT");
}
// Stores residue codes/names and colours and other things
- public static Hashtable propHash = new Hashtable();
+ public static Map<String, Map<String, Integer>> propHash = new Hashtable<String, Map<String, Integer>>();
- public static Hashtable hydrophobic = new Hashtable();
+ public static Map<String, Integer> hydrophobic = new Hashtable<String, Integer>();
- public static Hashtable polar = new Hashtable();
+ public static Map<String, Integer> polar = new Hashtable<String, Integer>();
- public static Hashtable small = new Hashtable();
+ public static Map<String, Integer> small = new Hashtable<String, Integer>();
- public static Hashtable positive = new Hashtable();
+ public static Map<String, Integer> positive = new Hashtable<String, Integer>();
- public static Hashtable negative = new Hashtable();
+ public static Map<String, Integer> negative = new Hashtable<String, Integer>();
- public static Hashtable charged = new Hashtable();
+ public static Map<String, Integer> charged = new Hashtable<String, Integer>();
- public static Hashtable aromatic = new Hashtable();
+ public static Map<String, Integer> aromatic = new Hashtable<String, Integer>();
- public static Hashtable aliphatic = new Hashtable();
+ public static Map<String, Integer> aliphatic = new Hashtable<String, Integer>();
- public static Hashtable tiny = new Hashtable();
+ public static Map<String, Integer> tiny = new Hashtable<String, Integer>();
- public static Hashtable proline = new Hashtable();
+ public static Map<String, Integer> proline = new Hashtable<String, Integer>();
static
{
- hydrophobic.put("I", new Integer(1));
- hydrophobic.put("L", new Integer(1));
- hydrophobic.put("V", new Integer(1));
- hydrophobic.put("C", new Integer(1));
- hydrophobic.put("A", new Integer(1));
- hydrophobic.put("G", new Integer(1));
- hydrophobic.put("M", new Integer(1));
- hydrophobic.put("F", new Integer(1));
- hydrophobic.put("Y", new Integer(1));
- hydrophobic.put("W", new Integer(1));
- hydrophobic.put("H", new Integer(1));
- hydrophobic.put("K", new Integer(1));
- hydrophobic.put("X", new Integer(1));
- hydrophobic.put("-", new Integer(1));
- hydrophobic.put("*", new Integer(1));
- hydrophobic.put("R", new Integer(0));
- hydrophobic.put("E", new Integer(0));
- hydrophobic.put("Q", new Integer(0));
- hydrophobic.put("D", new Integer(0));
- hydrophobic.put("N", new Integer(0));
- hydrophobic.put("S", new Integer(0));
- hydrophobic.put("T", new Integer(0));
- hydrophobic.put("P", new Integer(0));
+ hydrophobic.put("I", Integer.valueOf(1));
+ hydrophobic.put("L", Integer.valueOf(1));
+ hydrophobic.put("V", Integer.valueOf(1));
+ hydrophobic.put("C", Integer.valueOf(1));
+ hydrophobic.put("A", Integer.valueOf(1));
+ hydrophobic.put("G", Integer.valueOf(1));
+ hydrophobic.put("M", Integer.valueOf(1));
+ hydrophobic.put("F", Integer.valueOf(1));
+ hydrophobic.put("Y", Integer.valueOf(1));
+ hydrophobic.put("W", Integer.valueOf(1));
+ hydrophobic.put("H", Integer.valueOf(1));
+ hydrophobic.put("K", Integer.valueOf(1));
+ hydrophobic.put("X", Integer.valueOf(1));
+ hydrophobic.put("-", Integer.valueOf(1));
+ hydrophobic.put("*", Integer.valueOf(1));
+ hydrophobic.put("R", Integer.valueOf(0));
+ hydrophobic.put("E", Integer.valueOf(0));
+ hydrophobic.put("Q", Integer.valueOf(0));
+ hydrophobic.put("D", Integer.valueOf(0));
+ hydrophobic.put("N", Integer.valueOf(0));
+ hydrophobic.put("S", Integer.valueOf(0));
+ hydrophobic.put("T", Integer.valueOf(0));
+ hydrophobic.put("P", Integer.valueOf(0));
}
static
{
- polar.put("Y", new Integer(1));
- polar.put("W", new Integer(1));
- polar.put("H", new Integer(1));
- polar.put("K", new Integer(1));
- polar.put("R", new Integer(1));
- polar.put("E", new Integer(1));
- polar.put("Q", new Integer(1));
- polar.put("D", new Integer(1));
- polar.put("N", new Integer(1));
- polar.put("S", new Integer(1));
- polar.put("T", new Integer(1));
- polar.put("X", new Integer(1));
- polar.put("-", new Integer(1));
- polar.put("*", new Integer(1));
- polar.put("I", new Integer(0));
- polar.put("L", new Integer(0));
- polar.put("V", new Integer(0));
- polar.put("C", new Integer(0));
- polar.put("A", new Integer(0));
- polar.put("G", new Integer(0));
- polar.put("M", new Integer(0));
- polar.put("F", new Integer(0));
- polar.put("P", new Integer(0));
+ polar.put("Y", Integer.valueOf(1));
+ polar.put("W", Integer.valueOf(1));
+ polar.put("H", Integer.valueOf(1));
+ polar.put("K", Integer.valueOf(1));
+ polar.put("R", Integer.valueOf(1));
+ polar.put("E", Integer.valueOf(1));
+ polar.put("Q", Integer.valueOf(1));
+ polar.put("D", Integer.valueOf(1));
+ polar.put("N", Integer.valueOf(1));
+ polar.put("S", Integer.valueOf(1));
+ polar.put("T", Integer.valueOf(1));
+ polar.put("X", Integer.valueOf(1));
+ polar.put("-", Integer.valueOf(1));
+ polar.put("*", Integer.valueOf(1));
+ polar.put("I", Integer.valueOf(0));
+ polar.put("L", Integer.valueOf(0));
+ polar.put("V", Integer.valueOf(0));
+ polar.put("C", Integer.valueOf(0));
+ polar.put("A", Integer.valueOf(0));
+ polar.put("G", Integer.valueOf(0));
+ polar.put("M", Integer.valueOf(0));
+ polar.put("F", Integer.valueOf(0));
+ polar.put("P", Integer.valueOf(0));
}
static
{
- small.put("I", new Integer(0));
- small.put("L", new Integer(0));
- small.put("V", new Integer(1));
- small.put("C", new Integer(1));
- small.put("A", new Integer(1));
- small.put("G", new Integer(1));
- small.put("M", new Integer(0));
- small.put("F", new Integer(0));
- small.put("Y", new Integer(0));
- small.put("W", new Integer(0));
- small.put("H", new Integer(0));
- small.put("K", new Integer(0));
- small.put("R", new Integer(0));
- small.put("E", new Integer(0));
- small.put("Q", new Integer(0));
- small.put("D", new Integer(1));
- small.put("N", new Integer(1));
- small.put("S", new Integer(1));
- small.put("T", new Integer(1));
- small.put("P", new Integer(1));
- small.put("-", new Integer(1));
- small.put("*", new Integer(1));
+ small.put("I", Integer.valueOf(0));
+ small.put("L", Integer.valueOf(0));
+ small.put("V", Integer.valueOf(1));
+ small.put("C", Integer.valueOf(1));
+ small.put("A", Integer.valueOf(1));
+ small.put("G", Integer.valueOf(1));
+ small.put("M", Integer.valueOf(0));
+ small.put("F", Integer.valueOf(0));
+ small.put("Y", Integer.valueOf(0));
+ small.put("W", Integer.valueOf(0));
+ small.put("H", Integer.valueOf(0));
+ small.put("K", Integer.valueOf(0));
+ small.put("R", Integer.valueOf(0));
+ small.put("E", Integer.valueOf(0));
+ small.put("Q", Integer.valueOf(0));
+ small.put("D", Integer.valueOf(1));
+ small.put("N", Integer.valueOf(1));
+ small.put("S", Integer.valueOf(1));
+ small.put("T", Integer.valueOf(1));
+ small.put("P", Integer.valueOf(1));
+ small.put("-", Integer.valueOf(1));
+ small.put("*", Integer.valueOf(1));
}
static
{
- positive.put("I", new Integer(0));
- positive.put("L", new Integer(0));
- positive.put("V", new Integer(0));
- positive.put("C", new Integer(0));
- positive.put("A", new Integer(0));
- positive.put("G", new Integer(0));
- positive.put("M", new Integer(0));
- positive.put("F", new Integer(0));
- positive.put("Y", new Integer(0));
- positive.put("W", new Integer(0));
- positive.put("H", new Integer(1));
- positive.put("K", new Integer(1));
- positive.put("R", new Integer(1));
- positive.put("E", new Integer(0));
- positive.put("Q", new Integer(0));
- positive.put("D", new Integer(0));
- positive.put("N", new Integer(0));
- positive.put("S", new Integer(0));
- positive.put("T", new Integer(0));
- positive.put("P", new Integer(0));
- positive.put("-", new Integer(1));
- positive.put("*", new Integer(1));
+ positive.put("I", Integer.valueOf(0));
+ positive.put("L", Integer.valueOf(0));
+ positive.put("V", Integer.valueOf(0));
+ positive.put("C", Integer.valueOf(0));
+ positive.put("A", Integer.valueOf(0));
+ positive.put("G", Integer.valueOf(0));
+ positive.put("M", Integer.valueOf(0));
+ positive.put("F", Integer.valueOf(0));
+ positive.put("Y", Integer.valueOf(0));
+ positive.put("W", Integer.valueOf(0));
+ positive.put("H", Integer.valueOf(1));
+ positive.put("K", Integer.valueOf(1));
+ positive.put("R", Integer.valueOf(1));
+ positive.put("E", Integer.valueOf(0));
+ positive.put("Q", Integer.valueOf(0));
+ positive.put("D", Integer.valueOf(0));
+ positive.put("N", Integer.valueOf(0));
+ positive.put("S", Integer.valueOf(0));
+ positive.put("T", Integer.valueOf(0));
+ positive.put("P", Integer.valueOf(0));
+ positive.put("-", Integer.valueOf(1));
+ positive.put("*", Integer.valueOf(1));
}
static
{
- negative.put("I", new Integer(0));
- negative.put("L", new Integer(0));
- negative.put("V", new Integer(0));
- negative.put("C", new Integer(0));
- negative.put("A", new Integer(0));
- negative.put("G", new Integer(0));
- negative.put("M", new Integer(0));
- negative.put("F", new Integer(0));
- negative.put("Y", new Integer(0));
- negative.put("W", new Integer(0));
- negative.put("H", new Integer(0));
- negative.put("K", new Integer(0));
- negative.put("R", new Integer(0));
- negative.put("E", new Integer(1));
- negative.put("Q", new Integer(0));
- negative.put("D", new Integer(1));
- negative.put("N", new Integer(0));
- negative.put("S", new Integer(0));
- negative.put("T", new Integer(0));
- negative.put("P", new Integer(0));
- negative.put("-", new Integer(1));
- negative.put("*", new Integer(1));
+ negative.put("I", Integer.valueOf(0));
+ negative.put("L", Integer.valueOf(0));
+ negative.put("V", Integer.valueOf(0));
+ negative.put("C", Integer.valueOf(0));
+ negative.put("A", Integer.valueOf(0));
+ negative.put("G", Integer.valueOf(0));
+ negative.put("M", Integer.valueOf(0));
+ negative.put("F", Integer.valueOf(0));
+ negative.put("Y", Integer.valueOf(0));
+ negative.put("W", Integer.valueOf(0));
+ negative.put("H", Integer.valueOf(0));
+ negative.put("K", Integer.valueOf(0));
+ negative.put("R", Integer.valueOf(0));
+ negative.put("E", Integer.valueOf(1));
+ negative.put("Q", Integer.valueOf(0));
+ negative.put("D", Integer.valueOf(1));
+ negative.put("N", Integer.valueOf(0));
+ negative.put("S", Integer.valueOf(0));
+ negative.put("T", Integer.valueOf(0));
+ negative.put("P", Integer.valueOf(0));
+ negative.put("-", Integer.valueOf(1));
+ negative.put("*", Integer.valueOf(1));
}
static
{
- charged.put("I", new Integer(0));
- charged.put("L", new Integer(0));
- charged.put("V", new Integer(0));
- charged.put("C", new Integer(0));
- charged.put("A", new Integer(0));
- charged.put("G", new Integer(0));
- charged.put("M", new Integer(0));
- charged.put("F", new Integer(0));
- charged.put("Y", new Integer(0));
- charged.put("W", new Integer(0));
- charged.put("H", new Integer(1));
- charged.put("K", new Integer(1));
- charged.put("R", new Integer(1));
- charged.put("E", new Integer(1));
- charged.put("Q", new Integer(0));
- charged.put("D", new Integer(1));
- charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
+ charged.put("I", Integer.valueOf(0));
+ charged.put("L", Integer.valueOf(0));
+ charged.put("V", Integer.valueOf(0));
+ charged.put("C", Integer.valueOf(0));
+ charged.put("A", Integer.valueOf(0));
+ charged.put("G", Integer.valueOf(0));
+ charged.put("M", Integer.valueOf(0));
+ charged.put("F", Integer.valueOf(0));
+ charged.put("Y", Integer.valueOf(0));
+ charged.put("W", Integer.valueOf(0));
+ charged.put("H", Integer.valueOf(1));
+ charged.put("K", Integer.valueOf(1));
+ charged.put("R", Integer.valueOf(1));
+ charged.put("E", Integer.valueOf(1));
+ charged.put("Q", Integer.valueOf(0));
+ charged.put("D", Integer.valueOf(1));
+ charged.put("N", Integer.valueOf(0)); // Asparagine is polar but not
+ // charged.
// Alternative would be charged and
// negative (in basic form)?
- charged.put("S", new Integer(0));
- charged.put("T", new Integer(0));
- charged.put("P", new Integer(0));
- charged.put("-", new Integer(1));
- charged.put("*", new Integer(1));
+ charged.put("S", Integer.valueOf(0));
+ charged.put("T", Integer.valueOf(0));
+ charged.put("P", Integer.valueOf(0));
+ charged.put("-", Integer.valueOf(1));
+ charged.put("*", Integer.valueOf(1));
}
static
{
- aromatic.put("I", new Integer(0));
- aromatic.put("L", new Integer(0));
- aromatic.put("V", new Integer(0));
- aromatic.put("C", new Integer(0));
- aromatic.put("A", new Integer(0));
- aromatic.put("G", new Integer(0));
- aromatic.put("M", new Integer(0));
- aromatic.put("F", new Integer(1));
- aromatic.put("Y", new Integer(1));
- aromatic.put("W", new Integer(1));
- aromatic.put("H", new Integer(1));
- aromatic.put("K", new Integer(0));
- aromatic.put("R", new Integer(0));
- aromatic.put("E", new Integer(0));
- aromatic.put("Q", new Integer(0));
- aromatic.put("D", new Integer(0));
- aromatic.put("N", new Integer(0));
- aromatic.put("S", new Integer(0));
- aromatic.put("T", new Integer(0));
- aromatic.put("P", new Integer(0));
- aromatic.put("-", new Integer(1));
- aromatic.put("*", new Integer(1));
+ aromatic.put("I", Integer.valueOf(0));
+ aromatic.put("L", Integer.valueOf(0));
+ aromatic.put("V", Integer.valueOf(0));
+ aromatic.put("C", Integer.valueOf(0));
+ aromatic.put("A", Integer.valueOf(0));
+ aromatic.put("G", Integer.valueOf(0));
+ aromatic.put("M", Integer.valueOf(0));
+ aromatic.put("F", Integer.valueOf(1));
+ aromatic.put("Y", Integer.valueOf(1));
+ aromatic.put("W", Integer.valueOf(1));
+ aromatic.put("H", Integer.valueOf(1));
+ aromatic.put("K", Integer.valueOf(0));
+ aromatic.put("R", Integer.valueOf(0));
+ aromatic.put("E", Integer.valueOf(0));
+ aromatic.put("Q", Integer.valueOf(0));
+ aromatic.put("D", Integer.valueOf(0));
+ aromatic.put("N", Integer.valueOf(0));
+ aromatic.put("S", Integer.valueOf(0));
+ aromatic.put("T", Integer.valueOf(0));
+ aromatic.put("P", Integer.valueOf(0));
+ aromatic.put("-", Integer.valueOf(1));
+ aromatic.put("*", Integer.valueOf(1));
}
static
{
- aliphatic.put("I", new Integer(1));
- aliphatic.put("L", new Integer(1));
- aliphatic.put("V", new Integer(1));
- aliphatic.put("C", new Integer(0));
- aliphatic.put("A", new Integer(0));
- aliphatic.put("G", new Integer(0));
- aliphatic.put("M", new Integer(0));
- aliphatic.put("F", new Integer(0));
- aliphatic.put("Y", new Integer(0));
- aliphatic.put("W", new Integer(0));
- aliphatic.put("H", new Integer(0));
- aliphatic.put("K", new Integer(0));
- aliphatic.put("R", new Integer(0));
- aliphatic.put("E", new Integer(0));
- aliphatic.put("Q", new Integer(0));
- aliphatic.put("D", new Integer(0));
- aliphatic.put("N", new Integer(0));
- aliphatic.put("S", new Integer(0));
- aliphatic.put("T", new Integer(0));
- aliphatic.put("P", new Integer(0));
- aliphatic.put("-", new Integer(1));
- aliphatic.put("*", new Integer(1));
+ aliphatic.put("I", Integer.valueOf(1));
+ aliphatic.put("L", Integer.valueOf(1));
+ aliphatic.put("V", Integer.valueOf(1));
+ aliphatic.put("C", Integer.valueOf(0));
+ aliphatic.put("A", Integer.valueOf(0));
+ aliphatic.put("G", Integer.valueOf(0));
+ aliphatic.put("M", Integer.valueOf(0));
+ aliphatic.put("F", Integer.valueOf(0));
+ aliphatic.put("Y", Integer.valueOf(0));
+ aliphatic.put("W", Integer.valueOf(0));
+ aliphatic.put("H", Integer.valueOf(0));
+ aliphatic.put("K", Integer.valueOf(0));
+ aliphatic.put("R", Integer.valueOf(0));
+ aliphatic.put("E", Integer.valueOf(0));
+ aliphatic.put("Q", Integer.valueOf(0));
+ aliphatic.put("D", Integer.valueOf(0));
+ aliphatic.put("N", Integer.valueOf(0));
+ aliphatic.put("S", Integer.valueOf(0));
+ aliphatic.put("T", Integer.valueOf(0));
+ aliphatic.put("P", Integer.valueOf(0));
+ aliphatic.put("-", Integer.valueOf(1));
+ aliphatic.put("*", Integer.valueOf(1));
}
static
{
- tiny.put("I", new Integer(0));
- tiny.put("L", new Integer(0));
- tiny.put("V", new Integer(0));
- tiny.put("C", new Integer(0));
- tiny.put("A", new Integer(1));
- tiny.put("G", new Integer(1));
- tiny.put("M", new Integer(0));
- tiny.put("F", new Integer(0));
- tiny.put("Y", new Integer(0));
- tiny.put("W", new Integer(0));
- tiny.put("H", new Integer(0));
- tiny.put("K", new Integer(0));
- tiny.put("R", new Integer(0));
- tiny.put("E", new Integer(0));
- tiny.put("Q", new Integer(0));
- tiny.put("D", new Integer(0));
- tiny.put("N", new Integer(0));
- tiny.put("S", new Integer(1));
- tiny.put("T", new Integer(0));
- tiny.put("P", new Integer(0));
- tiny.put("-", new Integer(1));
- tiny.put("*", new Integer(1));
+ tiny.put("I", Integer.valueOf(0));
+ tiny.put("L", Integer.valueOf(0));
+ tiny.put("V", Integer.valueOf(0));
+ tiny.put("C", Integer.valueOf(0));
+ tiny.put("A", Integer.valueOf(1));
+ tiny.put("G", Integer.valueOf(1));
+ tiny.put("M", Integer.valueOf(0));
+ tiny.put("F", Integer.valueOf(0));
+ tiny.put("Y", Integer.valueOf(0));
+ tiny.put("W", Integer.valueOf(0));
+ tiny.put("H", Integer.valueOf(0));
+ tiny.put("K", Integer.valueOf(0));
+ tiny.put("R", Integer.valueOf(0));
+ tiny.put("E", Integer.valueOf(0));
+ tiny.put("Q", Integer.valueOf(0));
+ tiny.put("D", Integer.valueOf(0));
+ tiny.put("N", Integer.valueOf(0));
+ tiny.put("S", Integer.valueOf(1));
+ tiny.put("T", Integer.valueOf(0));
+ tiny.put("P", Integer.valueOf(0));
+ tiny.put("-", Integer.valueOf(1));
+ tiny.put("*", Integer.valueOf(1));
}
static
{
- proline.put("I", new Integer(0));
- proline.put("L", new Integer(0));
- proline.put("V", new Integer(0));
- proline.put("C", new Integer(0));
- proline.put("A", new Integer(0));
- proline.put("G", new Integer(0));
- proline.put("M", new Integer(0));
- proline.put("F", new Integer(0));
- proline.put("Y", new Integer(0));
- proline.put("W", new Integer(0));
- proline.put("H", new Integer(0));
- proline.put("K", new Integer(0));
- proline.put("R", new Integer(0));
- proline.put("E", new Integer(0));
- proline.put("Q", new Integer(0));
- proline.put("D", new Integer(0));
- proline.put("N", new Integer(0));
- proline.put("S", new Integer(0));
- proline.put("T", new Integer(0));
- proline.put("P", new Integer(1));
- proline.put("-", new Integer(1));
- proline.put("*", new Integer(1));
+ proline.put("I", Integer.valueOf(0));
+ proline.put("L", Integer.valueOf(0));
+ proline.put("V", Integer.valueOf(0));
+ proline.put("C", Integer.valueOf(0));
+ proline.put("A", Integer.valueOf(0));
+ proline.put("G", Integer.valueOf(0));
+ proline.put("M", Integer.valueOf(0));
+ proline.put("F", Integer.valueOf(0));
+ proline.put("Y", Integer.valueOf(0));
+ proline.put("W", Integer.valueOf(0));
+ proline.put("H", Integer.valueOf(0));
+ proline.put("K", Integer.valueOf(0));
+ proline.put("R", Integer.valueOf(0));
+ proline.put("E", Integer.valueOf(0));
+ proline.put("Q", Integer.valueOf(0));
+ proline.put("D", Integer.valueOf(0));
+ proline.put("N", Integer.valueOf(0));
+ proline.put("S", Integer.valueOf(0));
+ proline.put("T", Integer.valueOf(0));
+ proline.put("P", Integer.valueOf(1));
+ proline.put("-", Integer.valueOf(1));
+ proline.put("*", Integer.valueOf(1));
}
static
propMatrixF[i][j] = 0;
propMatrixPos[i][j] = 0;
propMatrixEpos[i][j] = 0;
- for (Enumeration<String> en = propHash.keys(); en.hasMoreElements();)
+ for (String ph : propHash.keySet())
{
- String ph = en.nextElement();
- Map<String, Integer> pph = (Map<String, Integer>) propHash
- .get(ph);
+ Map<String, Integer> pph = propHash.get(ph);
if (pph.get(ic) != null && pph.get(jc) != null)
{
int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
return pog;
}
- public static Vector getCodons(String res)
- {
- if (codonHash.containsKey(res))
- {
- return (Vector) codonHash.get(res);
- }
-
- return null;
- }
-
public static String codonTranslate(String lccodon)
{
- if (false)
- {
- return _codonTranslate(lccodon);
- }
String cdn = codonHash2.get(lccodon.toUpperCase());
if ("*".equals(cdn))
{
return cdn;
}
- public static String _codonTranslate(String lccodon)
- {
- String codon = lccodon.toUpperCase();
- // all base ambiguity codes yield an 'X' amino acid residue
- if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
- {
- return "X";
- }
- for (String key : codonHash.keySet())
- {
- if (codonHash.get(key).contains(codon))
- {
- return key;
- }
- }
-
- return null;
- }
-
public static int[][] getDefaultPeptideMatrix()
{
return ResidueProperties.getBLOSUM62();
return pog;
}
- public static Hashtable toDssp3State;
+ public static Hashtable<String, String> toDssp3State;
static
{
- toDssp3State = new Hashtable();
+ toDssp3State = new Hashtable<String, String>();
toDssp3State.put("H", "H");
toDssp3State.put("E", "E");
toDssp3State.put("C", " ");
String ssc = ssstring.substring(i, i + 1);
if (toDssp3State.containsKey(ssc))
{
- ss.append((String) toDssp3State.get(ssc));
+ ss.append(toDssp3State.get(ssc));
}
else
{
}
- public static String getCanonicalAminoAcid(String aa)
+ public static String getCanonicalAminoAcid(String aA)
{
- String canonical = modifications.get(aa);
- return canonical == null ? aa : canonical;
+ String canonical = modifications.get(aA);
+ return canonical == null ? aA : canonical;
}
// main method generates perl representation of residue property hash
// / cut here
public static void main(String[] args)
{
- Hashtable aa = new Hashtable();
+ Hashtable<String, Vector<String>> aaProps = new Hashtable<String, Vector<String>>();
System.out.println("my %aa = {");
// invert property hashes
- Enumeration prop = propHash.keys();
- while (prop.hasMoreElements())
+ for (String pname : propHash.keySet())
{
- String pname = (String) prop.nextElement();
- Hashtable phash = (Hashtable) propHash.get(pname);
- Enumeration res = phash.keys();
- while (res.hasMoreElements())
+ Map<String, Integer> phash = propHash.get(pname);
+ for (String rname : phash.keySet())
{
- String rname = (String) res.nextElement();
- Vector aprops = (Vector) aa.get(rname);
+ Vector<String> aprops = aaProps.get(rname);
if (aprops == null)
{
- aprops = new Vector();
- aa.put(rname, aprops);
+ aprops = new Vector<String>();
+ aaProps.put(rname, aprops);
}
- Integer hasprop = (Integer) phash.get(rname);
+ Integer hasprop = phash.get(rname);
if (hasprop.intValue() == 1)
{
aprops.addElement(pname);
}
}
}
- Enumeration res = aa.keys();
+ Enumeration<String> res = aaProps.keys();
while (res.hasMoreElements())
{
- String rname = (String) res.nextElement();
+ String rname = res.nextElement();
System.out.print("'" + rname + "' => [");
- Enumeration props = ((Vector) aa.get(rname)).elements();
+ Enumeration<String> props = aaProps.get(rname).elements();
while (props.hasMoreElements())
{
- System.out.print("'" + (String) props.nextElement() + "'");
+ System.out.print("'" + props.nextElement() + "'");
if (props.hasMoreElements())
{
System.out.println(", ");
/**
* Returns a list of residue characters for the specified inputs
*
- * @param nucleotide
+ * @param forNucleotide
* @param includeAmbiguous
* @return
*/
- public static List<String> getResidues(boolean nucleotide,
+ public static List<String> getResidues(boolean forNucleotide,
boolean includeAmbiguous)
{
List<String> result = new ArrayList<String>();
- if (nucleotide)
+ if (forNucleotide)
{
for (String nuc : nucleotideName.keySet())
{
* Determines the parser used for parsing PDB format file. Possible options
* are : JMolParser|JalveiwParser
*/
+ private static StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
public static void addSettings(boolean addAlignmentAnnotations,
boolean processSecStr, boolean externalSecStr)
{
.valueOf(defaultStructureFileFormat.toUpperCase());
}
+ public static String getDefaultPDBFileParser()
+ {
+ return defaultPDBFileParser.toString();
+ }
+
+ public static void setDefaultPDBFileParser(
+ StructureParser defaultPDBFileParser)
+ {
+ StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
+ }
+
+ public static void setDefaultPDBFileParser(String defaultPDBFileParser)
+ {
+ StructureImportSettings.defaultPDBFileParser = StructureParser
+ .valueOf(defaultPDBFileParser.toUpperCase());
+ }
}
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.PIDColourScheme;
-import jalview.schemes.ResidueProperties;
import jalview.structure.CommandListener;
import jalview.structure.StructureSelectionManager;
import jalview.structure.VamsasSource;
import jalview.workers.StrucConsensusThread;
import java.awt.Color;
+import java.beans.PropertyChangeSupport;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.BitSet;
public void updateConservation(final AlignmentViewPanel ap)
{
// see note in mantis : issue number 8585
- if (alignment.isNucleotide() || conservation == null
+ if (alignment.isNucleotide()
+ || (conservation == null && quality == null)
|| !autoCalculateConsensus)
{
return;
return false;
}
+ public void setAlignment(AlignmentI align)
+ {
+ this.alignment = align;
+ }
+
+ /**
+ * Clean up references when this viewport is closed
+ */
+ @Override
+ public void dispose()
+ {
+ /*
+ * defensively null out references to large objects in case
+ * this object is not garbage collected (as if!)
+ */
+ consensus = null;
+ complementConsensus = null;
+ strucConsensus = null;
+ conservation = null;
+ quality = null;
+ groupConsensus = null;
+ groupConservation = null;
+ hconsensus = null;
+ hcomplementConsensus = null;
+ // TODO removed listeners from changeSupport?
+ changeSupport = null;
+ setAlignment(null);
+ }
+
@Override
public boolean isClosed()
{
}
@Override
+ public boolean hasSelectedColumns()
+ {
+ ColumnSelection columnSelection = getColumnSelection();
+ return columnSelection != null && columnSelection.hasSelectedColumns();
+ }
+
+ @Override
public boolean hasHiddenColumns()
{
return colSel != null && colSel.hasHiddenColumns();
return ignoreGapsInConsensusCalculation;
}
- // / property change stuff
-
+ // property change stuff
// JBPNote Prolly only need this in the applet version.
- private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
+ private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
this);
protected boolean showConservation = true;
cs.setConsensus(hconsensus);
if (cs.conservationApplied())
{
- cs.setConservation(Conservation.calculateConservation("All",
- ResidueProperties.propHash, 3, alignment.getSequences(), 0,
- alignment.getWidth(), false, getConsPercGaps(), false));
+ cs.setConservation(Conservation.calculateConservation("All", 3,
+ alignment.getSequences(), 0, alignment.getWidth(), false,
+ getConsPercGaps(), false));
}
}
if (sg != null
&& (sgs = sg.getStartRes()) >= 0
&& sg.getStartRes() <= (sge = sg.getEndRes())
- && (colSel == null || colSel.getSelected() == null || colSel
- .getSelected().size() == 0))
+ && !this.hasSelectedColumns())
{
if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
{
}
try
{
- cons = Conservation.calculateConservation("All",
- jalview.schemes.ResidueProperties.propHash, 3,
+ cons = Conservation.calculateConservation("All", 3,
alignment.getSequences(), 0, alWidth - 1, false,
ConsPercGaps, quality != null);
} catch (IndexOutOfBoundsException x)
/*
* scenario:
* dna1 --> [4, 6] [10,12] --> pep1
- * dna2 --> [1, 3] [7, 9] [13,15] --> pep1
+ * dna2 --> [1, 3] [7, 9] [13,15] --> pep2
*/
SequenceI dna1 = new Sequence("dna1", "aaaGGGcccTTTaaa");
SequenceI dna2 = new Sequence("dna2", "GGGcccTTTaaaCCC");
dna.setDataset(null);
/*
+ * put a variant feature on dna2 base 8
+ * - should transfer to cds2 base 5
+ */
+ dna2.addSequenceFeature(new SequenceFeature("variant", "hgmd", 8, 8,
+ 0f, null));
+
+ /*
* need a sourceDbRef if we are to construct dbrefs to the CDS
* sequence from the dna contig sequences
*/
assertSame(cds2Dss, m.getSequence());
assertEquals(7, m.getStart());
assertEquals(9, m.getEnd());
+
+ /*
+ * check cds2 acquired a variant feature in position 5
+ */
+ SequenceFeature[] sfs = cds2Dss.getSequenceFeatures();
+ assertNotNull(sfs);
+ assertEquals(1, sfs.length);
+ assertEquals("variant", sfs[0].type);
+ assertEquals(5, sfs[0].begin);
+ assertEquals(5, sfs[0].end);
}
/**
}
}
+ @Test(groups = { "Functional" })
+ public void testIsCanonicalPair()
+ {
+ String bases = "acgtuACGTU";
+ for (int i = 0; i < bases.length(); i++)
+ {
+ for (int j = 0; j < bases.length(); j++)
+ {
+ char first = bases.charAt(i);
+ char second = bases.charAt(j);
+ boolean result = Rna.isCanonicalPair(first, second);
+ String pair = new String(new char[] { first, second })
+ .toUpperCase();
+ if (pair.equals("AT") || pair.equals("TA") || pair.equals("AU")
+ || pair.equals("UA") || pair.equals("GC")
+ || pair.equals("CG"))
+ {
+ assertTrue(pair + " should be valid", result);
+ }
+ else
+ {
+ assertFalse(pair + " should be invalid", result);
+ }
+ }
+ }
+ }
+
/**
* Tests for isOpeningParenthesis with char or String argument
*/
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotSame;
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.fail;
import java.util.Arrays;
import java.util.BitSet;
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
import java.util.List;
import org.testng.annotations.Test;
// removing an element in the list removes it
cs.removeElement(2);
- // ...but not from the copy list!
- assertEquals(2, sel.size());
+ // ...and also from the read-only view
+ assertEquals(1, sel.size());
sel = cs.getSelected();
assertEquals(1, sel.size());
assertEquals(new Integer(5), sel.get(0));
* were added
*/
@Test(groups = { "Functional" })
- public void testGetSelection()
+ public void testGetSelected()
{
ColumnSelection cs = new ColumnSelection();
int[] sel = { 4, 3, 7, 21 };
cs.addElement(col);
}
- List<Integer> selected1 = cs.getSelected();
- assertEquals(4, selected1.size());
+ List<Integer> selected = cs.getSelected();
+ assertEquals(4, selected.size());
+ assertEquals("[4, 3, 7, 21]", selected.toString());
/*
- * getSelected returns a copy, verify the list
- * is externally immutable
+ * getSelected returns a read-only view of the list
+ * verify the view follows any changes in it
*/
- selected1.clear();
- List<Integer> selected2 = cs.getSelected();
- assertNotSame(selected1, selected2);
- assertEquals(4, selected2.size());
- int i = 0;
- for (int col : sel)
+ cs.removeElement(7);
+ cs.addElement(1);
+ cs.removeElement(4);
+ assertEquals("[3, 21, 1]", selected.toString());
+ }
+
+ /**
+ * Test to verify that the list returned by getSelection cannot be modified
+ */
+ @Test(groups = { "Functional" })
+ public void testGetSelected_isReadOnly()
+ {
+ ColumnSelection cs = new ColumnSelection();
+ cs.addElement(3);
+
+ List<Integer> selected = cs.getSelected();
+ try
+ {
+ selected.clear();
+ fail("expected exception");
+ } catch (UnsupportedOperationException e)
+ {
+ // expected
+ }
+ try
+ {
+ selected.add(1);
+ fail("expected exception");
+ } catch (UnsupportedOperationException e)
+ {
+ // expected
+ }
+ try
+ {
+ selected.remove(3);
+ fail("expected exception");
+ } catch (UnsupportedOperationException e)
{
- assertEquals(col, selected2.get(i++).intValue());
+ // expected
}
+ try
+ {
+ Collections.sort(selected);
+ fail("expected exception");
+ } catch (UnsupportedOperationException e)
+ {
+ // expected
+ }
+ }
- cs.removeElement(7);
+ /**
+ * Test that demonstrates a ConcurrentModificationException is thrown if you
+ * change the selection while iterating over it
+ */
+ @Test(
+ groups = "Functional",
+ expectedExceptions = { ConcurrentModificationException.class })
+ public void testGetSelected_concurrentModification()
+ {
+ ColumnSelection cs = new ColumnSelection();
+ cs.addElement(0);
cs.addElement(1);
- cs.removeElement(4);
+ cs.addElement(2);
- List<Integer> selected3 = cs.getSelected();
- assertEquals(3, selected3.size());
- assertEquals(3, selected3.get(0).intValue());
- assertEquals(21, selected3.get(1).intValue());
- assertEquals(1, selected3.get(2).intValue());
+ /*
+ * simulate changing the list under us (e.g. in a separate
+ * thread) while iterating over it -> ConcurrentModificationException
+ */
+ List<Integer> selected = cs.getSelected();
+ for (Integer col : selected)
+ {
+ if (col.intValue() == 0)
+ {
+ cs.removeElement(1);
+ }
+ }
}
@Test(groups = "Functional")
assertTrue(selected.contains(6));
assertTrue(selected.contains(10));
}
+
+ @Test(groups = "Functional")
+ public void testCopyConstructor()
+ {
+ ColumnSelection cs = new ColumnSelection();
+ cs.addElement(3);
+ cs.addElement(1);
+ cs.hideColumns(10, 11);
+ cs.hideColumns(5, 7);
+ assertEquals("[5, 7]", Arrays.toString(cs.getHiddenColumns().get(0)));
+
+ ColumnSelection cs2 = new ColumnSelection(cs);
+ assertTrue(cs2.hasSelectedColumns());
+ assertTrue(cs2.hasHiddenColumns());
+ // order of column selection is preserved
+ assertEquals("[3, 1]", cs2.getSelected().toString());
+ assertEquals(2, cs2.getHiddenColumns().size());
+ // hidden columns are held in column order
+ assertEquals("[5, 7]", Arrays.toString(cs2.getHiddenColumns().get(0)));
+ assertEquals("[10, 11]", Arrays.toString(cs2.getHiddenColumns().get(1)));
+ }
}
import jalview.io.AppletFormatAdapter;
import jalview.io.FileLoader;
import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
import java.util.Vector;
Cache.applicationProperties.setProperty("ADD_SS_ANN",
Boolean.TRUE.toString());
StructureImportSettings.setDefaultStructureFileFormat("PDB");
+ StructureImportSettings
+ .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
}
@Test(groups = { "Functional" })
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.Sequence;
@BeforeClass(alwaysRun = true)
public static void setUpBeforeClass() throws Exception
{
- jalview.bin.Jalview.main(new String[] { "-props",
- "test/jalview/testProps.jvprops" });
+ Jalview.main(new String[] { "-props", "test/jalview/testProps.jvprops" });
}
@BeforeMethod(alwaysRun = true)
assertTrue(ssmMappings.contains(acf2));
assertFalse(ssmMappings.contains(acf3));
}
+
+ /**
+ * Test for JAL-1306 - conservation thread should run even when only Quality
+ * (and not Conservation) is enabled in Preferences
+ */
+ @Test(groups = { "Functional" })
+ public void testUpdateConservation_qualityOnly()
+ {
+ Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
+ Boolean.TRUE.toString());
+ Cache.applicationProperties.setProperty("SHOW_QUALITY",
+ Boolean.TRUE.toString());
+ Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
+ Boolean.FALSE.toString());
+ Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+ Boolean.FALSE.toString());
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", FormatAdapter.FILE);
+ AlignmentAnnotation[] anns = af.viewport.getAlignment().getAlignmentAnnotation();
+ assertNotNull("No annotations found", anns);
+ assertEquals("More than one annotation found", 1, anns.length);
+ assertTrue("Annotation is not Quality",
+ anns[0].description.startsWith("Alignment Quality"));
+ Annotation[] annotations = anns[0].annotations;
+ assertNotNull("Quality annotations are null", annotations);
+ assertNotNull("Quality in column 1 is null", annotations[0]);
+ assertTrue("No quality value in column 1", annotations[0].value > 10f);
+ }
}
@BeforeMethod(alwaysRun = true)
public void setUp() throws IOException
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
// pin down annotation sort order for test
Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS,
SequenceAnnotationOrder.NONE.name());
import jalview.bin.Cache;
import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import org.testng.annotations.AfterClass;
foo.setPreferredSize(new Dimension(600, 800));
cfoo.setSize(600, 800);
final JInternalFrame cont = new JInternalFrame("My Frame");
- JTextArea evt;
- cont.setPreferredSize(new Dimension(400, 300));
- cont.add(evt = new JTextArea(
- "Click here and drag text over this window to freeze java.\n\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\nThis is a dummy string. See teh dummy string go.\n"));
+ cont.setPreferredSize(new Dimension(400, 400));
+ String msg = "This is a dummy string. See the dummy string go.\n";
+ msg += msg; // 2
+ msg += msg; // 4
+ msg += msg; // 8
+ msg += msg; // 16
+ JTextArea evt = new JTextArea(
+ "Click here and drag text over this window to freeze java.\n\n"
+ + msg);
+ cont.add(evt);
cont.pack();
foo.add("A frame", cont);
foo.setVisible(true);
foo.setEnabled(true);
foo.doLayout();
cfoo.add(foo);
- final JMenu jm = new JMenu("Do");
- JMenuItem jmi = new JMenuItem("this");
- jm.add(jmi);
- evt.addMouseListener(new MouseListener()
+ // final JMenu jm = new JMenu("Do");
+ // JMenuItem jmi = new JMenuItem("this");
+ // jm.add(jmi);
+ evt.addMouseListener(new MouseAdapter()
{
@Override
- public void mouseReleased(MouseEvent e)
- {
- }
-
- @Override
- public void mousePressed(MouseEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void mouseExited(MouseEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void mouseEntered(MouseEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public void mouseClicked(MouseEvent e)
{
// JFrame parent = new JFrame();
});
cont.setVisible(true);
- jmi.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent arg0)
- {
- EditNameDialog end = new EditNameDialog("Sequence Name",
- "Sequence Description", "label 1", "Label 2",
- "Try and drag between the two text fields", cont);
- assert (end != null);
- finish = true;
- }
- });
+ // jmi.addActionListener(new ActionListener()
+ // {
+ //
+ // @Override
+ // public void actionPerformed(ActionEvent arg0)
+ // {
+ // EditNameDialog end = new EditNameDialog("Sequence Name",
+ // "Sequence Description", "label 1", "Label 2",
+ // "Try and drag between the two text fields", cont);
+ // assert (end != null);
+ // finish = true;
+ // }
+ // });
foo.setVisible(true);
cfoo.setVisible(true);
while (!finish)
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
import java.io.File;
{
System.out.println("CalcId: " + aa.getCalcId());
- // if (StructureImportSettings.getDefaultPDBFileParser().equals(
- // StructureParser.JALVIEW_PARSER))
- // {
- // assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId));
- // }
+ if (StructureImportSettings.getDefaultPDBFileParser().equals(
+ StructureParser.JALVIEW_PARSER))
+ {
+ assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId));
+ }
}
}
}
}
assertEquals(
"Generated and imported alignment have different annotation sets",
- aa_new_size, aa_original_size);
+ aa_original_size, aa_new_size);
// check sequences, annotation and features
SequenceI[] seq_original = new SequenceI[al.getSequencesArray().length];
+ codon.getKey() + "\", \"" + codon.getValue() + "\");");
}
}
-
- @Test(groups = { "Functional" })
- public void checkOldCodonagainstNewCodonTable()
- {
- // note - this test will be removed once the old codon table (including
- // Vectors) is removed
- String additional = "", failtrans = "", differentTr = "";
- for (String amacid : ResidueProperties.codonHash.keySet())
- {
- for (String codon : ResidueProperties.codonHash.get(amacid))
- {
- String trans = ResidueProperties.codonTranslate(codon);
- String oldtrans = ResidueProperties._codonTranslate(codon);
- if (trans == null)
- {
- additional += "\nOld translation table includes additional codons for "
- + amacid + " : " + codon;
- }
- if (oldtrans == null)
- {
- failtrans += ("\nold translation routine failed for old translation entry (aa was "
- + amacid + " codon was " + codon + ")");
- }
- if (!oldtrans.equals(trans))
- {
- differentTr += ("\nDifferent translation for old and new routines: "
- + amacid
- + " "
- + codon
- + " => expected "
- + oldtrans
- + " and got " + trans);
- }
- }
- }
- assertTrue("" + additional + "\n" + failtrans + "\n" + differentTr,
- additional.length() == 0 && failtrans.length() == 0
- && differentTr.length() == 0);
- }
}
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
import jalview.ws.seqfetcher.DbSourceProxy;
import java.util.List;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
// ensure 'add annotation from structure' is selected
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
Boolean.TRUE.toString());
@Test(groups = { "Network" }, enabled = true)
public void testRnaSeqRetrieve() throws Exception
{
- Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
- Boolean.TRUE.toString());
Cache.applicationProperties.setProperty("PDB_DOWNLOAD_FORMAT",
"PDB");
List<DbSourceProxy> sps = sf.getSourceProxy("PDB");
@Test(groups = { "Network" }, enabled = true)
public void testPdbSeqRetrieve() throws Exception
{
- Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
- Boolean.TRUE.toString());
StructureImportSettings.setDefaultStructureFileFormat("PDB");
+ StructureImportSettings
+ .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
testRetrieveProteinSeqFromPDB();
}
@Test(groups = { "Network" }, enabled = true)
public void testmmCifSeqRetrieve() throws Exception
{
- Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
- Boolean.TRUE.toString());
StructureImportSettings.setDefaultStructureFileFormat("mmCIF");
testRetrieveProteinSeqFromPDB();
}