From: gmungoc Date: Fri, 11 May 2018 11:29:53 +0000 (+0100) Subject: JAL-2629 update spike branch to latest X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6d882bd2c72c5fe9e8d0a8eb9df4de7a86bbc773;p=jalview.git JAL-2629 update spike branch to latest --- diff --git a/.classpath b/.classpath index f4b8cf8..0cdc4b9 100644 --- a/.classpath +++ b/.classpath @@ -48,6 +48,7 @@ + diff --git a/THIRDPARTYLIBS b/THIRDPARTYLIBS index e0be904..e2baa85 100644 --- a/THIRDPARTYLIBS +++ b/THIRDPARTYLIBS @@ -49,6 +49,8 @@ jfreesvg-2.1.jar : GPL v3 licensed library from the JFree suite: http://www.jfre quaqua: v.8.0 (latest stable) by Randel S Hofer. LGPL and BSD Modified license: downloaded from http://www.randelshofer.ch/quaqua/ +vaqua: v4 (latest stable) by Alan Snyder et al. GPLv2 with Classpathe xception, also includes contributions from Quaqua: ownloaded from http://violetlib.org/vaqua/overview.html + lib/htsjdk-1.120-SNAPSHOT.jar: (currently not required for 2.10) built from maven master at https://github.com/samtools/htsjdk MIT License to Broad Institute lib/biojava-core-4.1.0.jar LGPLv2.1 - latest license at https://github.com/biojava/biojava/blob/master/LICENSE diff --git a/help/help.jhm b/help/help.jhm index 506b3f3..4ea119c 100755 --- a/help/help.jhm +++ b/help/help.jhm @@ -54,6 +54,7 @@ + diff --git a/help/helpTOC.xml b/help/helpTOC.xml index 71b7ef9..ca86625 100755 --- a/help/helpTOC.xml +++ b/help/helpTOC.xml @@ -24,6 +24,8 @@ + + diff --git a/help/html/features/chimera.html b/help/html/features/chimera.html index 68ac465..e1227de 100644 --- a/help/html/features/chimera.html +++ b/help/html/features/chimera.html @@ -211,41 +211,32 @@ structure in the alignment. The regions used to calculate the superposition will be highlighted using the 'Cartoon' rendering style, and the remaining data shown as a chain - trace.

+ trace.
+
-
  • EXPERIMENTAL FEATURES
    - - These are only available if the Tools→Enable - Experimental Features option is enabled. (Since Jalview 2.10.2) -
      -
    • Write Jalview features
      Selecting - this option will create new residue attributes for any - features currently visible in the associated alignment - views, allowing those positions to be selected and - analysed with via Chimera's 'Render by Attribute' tool - (found in the Tools submenu called Structure Analysis).
      -
      If you use this option, please remember to select - the Refresh Menus option in Chimera's Render by - Attribute dialog box in order to see the attributes - derived from Jalview sequence features. -

      - View - this function's issue in Jalview's bug tracker
    • -
    • Fetch Chimera Attributes
      This - submenu lists available Chimera residue attributes that - can be imported as Jalview features on associated - sequences.
      This is particularly useful for - transferring quantitative positional annotation. For - example, structure similarity for an alignment can be - visualised by transferring the local RMSD attributes - generated by Chimera's Match->Align tool onto aligned - sequences and displayed with a Graduated feature colour - scheme. -
      View - this function's issue in Jalview's bug tracker
    • -
  • -
  • Help
    +
  • Write Jalview + features
    Selecting this option will create + new residue attributes for any features currently visible in + the associated alignment views, allowing those positions to + be selected and analysed with via Chimera's 'Render by + Attribute' tool (found in the Tools submenu called Structure + Analysis).

    If you use this option, please + remember to select the Refresh Menus option in + Chimera's Render by Attribute dialog box in order to see the + attributes derived from Jalview sequence features. +
  • +
  • Fetch Chimera Attributes
    This + submenu lists available Chimera residue attributes that can + be imported as Jalview features on associated sequences.
    This + is particularly useful for transferring quantitative + positional annotation. For example, structure similarity for + an alignment can be visualised by transferring the local + RMSD attributes generated by Chimera's Match->Align tool + onto aligned sequences and displayed with a Graduated feature colour + scheme.
  • + +
  • Help
    • Chimera Help
      diff --git a/help/html/features/jmol.html b/help/html/features/jmol.html index 0cd6168..ac2489b 100644 --- a/help/html/features/jmol.html +++ b/help/html/features/jmol.html @@ -61,16 +61,10 @@

      -->

      Superposing structures based on - their aligned sequences
      If several structures are - available on the alignment, you may add additional structures to an - existing Jmol view by selecting their entry in the appropriate - pop-up menu. Jalview will ask you if you wish to add the structure - to the existing alignment, and if you do, it will import and - superimpose the new PDB file using the corresponding positions from - the alignment. If the alignment is subsequently edited, you can use - the Jmol→Align menu option from - the menu bar of the structure view window to superpose the - structures using the updated alignment.
      Sequence + their aligned sequences

      If several structures are shown + in a view, you can superimpose them using the corresponding + positions from the alignment via the Jmol→Align + menu option from the menu bar of the structure view window.
      Sequence based structure superposition was added in Jalview 2.6

      diff --git a/help/html/features/preferences.html b/help/html/features/preferences.html index 533af5c..5bca358 100755 --- a/help/html/features/preferences.html +++ b/help/html/features/preferences.html @@ -369,7 +369,7 @@ and PDB file association (if available). The Jalview id/start-end option is ignored if Modeller output is selected.

      - e"Editinge" Preferences tab + "Editing" Preferences tab

      There are currently three options available which can be selected / deselected.

      diff --git a/help/html/features/schooser_enter-id.png b/help/html/features/schooser_enter-id.png index f551c50..4af0d53 100644 Binary files a/help/html/features/schooser_enter-id.png and b/help/html/features/schooser_enter-id.png differ diff --git a/help/html/features/schooser_main.png b/help/html/features/schooser_main.png index ab69427..ca793fd 100644 Binary files a/help/html/features/schooser_main.png and b/help/html/features/schooser_main.png differ diff --git a/help/html/features/structurechooser.html b/help/html/features/structurechooser.html index fc71826..785c429 100644 --- a/help/html/features/structurechooser.html +++ b/help/html/features/structurechooser.html @@ -25,14 +25,14 @@

      - Structure Chooser + Structure Chooser Dialog Box

      - The Structure Chooser interface allows you to interactively select - which PDB structures to view for the currently selected set of + The Structure Chooser allows you to select + 3D structures to view for the currently selected set of sequences. It is opened by selecting the "3D - Structure Data.." option from the Sequence ID panel's option from the Sequence ID panel's pop-up menu. The dialog provides:

      @@ -49,11 +49,16 @@

      Selecting and Viewing Structures

      +

      The drop-down menu offers different options for structure + discovery; the 'Cached' view is shown automatically if existing + structure data has been imported for the selected sequences, and if + none is available, the import PDB/mmCIF file options are shown.

      Once one or more structures have been selected, pressing the View - button will import them into Add button will import them a new or existing - structure view. + structure view. When multiple views are available, use the + drop-down menu to pick the target viewer for the structures.

      Automated discovery of structure data @@ -89,17 +94,16 @@ criteria (e.g. worst quality rather than best).

      - + -
      The screenshot above shows the Structure Chooser interface - along with the meta-data of auto-discovered structures for the - sample alignment. If no structures were - auto-discovered, options for manually associating PDB records will be shown (see below). -

      +
      The screenshot above shows the Structure Chooser displayed after + selecting all the sequences in the Jalview example project. If no + structures were auto-discovered, options for manually associating + PDB records will be shown (see below).

      Exploration of meta-data for available structures

      Information on each structure available is displayed in columns @@ -109,7 +113,7 @@ Columns' tab and tick the columns which you want to see.

      + style="width: 464px; height: 173px;">
      Manual selection/association of PDB files with Sequences diff --git a/help/html/features/viewingpdbs.html b/help/html/features/viewingpdbs.html index 45d979f..b1ad4ba 100755 --- a/help/html/features/viewingpdbs.html +++ b/help/html/features/viewingpdbs.html @@ -82,6 +82,7 @@ provided it is installed and can be launched by Jalview. The default viewer can be configured in the Structure tab in the Tools→Preferences dialog box. +

      Structure data imported into Jalview can also be processed to display secondary structure and temperature factor annotation. See @@ -89,44 +90,30 @@ for more information.

      - After pressing the - 'View' button in the Structure Chooser
      The behaviour of - the 'View' button depends on the number of structures selected, and - whether structure views already exist for the selected structures or - aligned sequences. +
      Controlling where the new structures + will be shown +
      The Structure Chooser offers several options + for viewing a structure.
      New View will open a new + structure viewer for the selected structures, but if there are views + already open, you can select which one to use, and press the Add + button. Jalview can automatically superimpose new structures based + on the linked alignments - but if this is not desirable, simple + un-tick the Superpose Structures checkbox. +

      -

      If multiple structures are selected, then Jalview will always - create a new structure view. The selected structures will be - imported into this view, and superposed with the matched positions - from the aligned sequences. A message in the structure viewer's - status bar will be shown if not enough aligned columns were - available to perform a superposition.

      - If a single PDB structure is selected, one of the - following will happen: + Superposing structures
      Jalview superposes structures using + the visible portions of any associated sequence alignments. A + message in the structure viewer's status bar will be shown if not + enough aligned columns were available to perform a superposition.

      - -
        -
      • If no structures are open, then an interactive display of - the structure will be opened in a new window.
      • - -
      • If another structure is already shown for the current - alignment, then you will be asked if you want to add and to the structure in the existing view. - (new feature in Jalview 2.6). -
      • - -
      • If the structure is already shown, then you will be - prompted to associate the sequence with an existing view of the - selected structure. This is useful when working with multi-domain - or multi-chain PDB files.
      • - -
      • See the Jmol - and Chimera PDB viewer help pages for - more information about the display. -
      • -
      - +

      + See the Jmol + and Chimera help pages for + more information about their capabilities.

      +

      Retrieving sequences from the PDB
      You can diff --git a/help/html/menus/desktopMenu.html b/help/html/menus/desktopMenu.html index a93ce4b..d716e33 100755 --- a/help/html/menus/desktopMenu.html +++ b/help/html/menus/desktopMenu.html @@ -86,7 +86,7 @@ the Groovy Console for interactive scripting.

    • -
    • Enable Experimental Features Enable or disable features still under development in Jalview's user interface. This setting is remembered in your preferences. +
  • Vamsas For more details, read the diff --git a/help/html/releases.html b/help/html/releases.html index 006ee5c..dd2bb62 100755 --- a/help/html/releases.html +++ b/help/html/releases.html @@ -70,19 +70,33 @@ li:before {
    - 2.10.4
    27/02/2018
    + 2.10.4
    8/05/2018
    • - Mouse cursor changes to indicate Sequence ID and annotation area margins can be click-dragged to adjust them.
    • + New Structure Chooser control + for disabling automatic superposition of multiple + structures and open structures in existing views + +
    • + Mouse cursor changes to indicate Sequence + ID and annotation area margins can be click-dragged to + adjust them. +
    • +
    • + Jalview uses HTTPS for Uniprot, Xfam and + Ensembl services +
    • - Jalview uses HTTPS for Uniprot, Xfam and Ensembl services + Improved performance for large alignments + and lots of hidden columns
    • - Improved performance for large alignments and lots of hidden columns + Improved performance when rendering lots + of features (particularly when transparency is disabled)
    @@ -90,20 +104,111 @@ li:before {
    • - Slow redraw when Overview panel shown overlapping alignment panel + Structure and Overview aren't updated + when Colour By Annotation threshold slider is adjusted +
    • +
    • + Slow redraw when Overview panel shown + overlapping alignment panel +
    • +
    • + overview doesn't show end of unpadded + sequence as gaps +
    • +
    • + Cross-reference handling improved: CDS not handled correctly if transcript has no UTR +
    • +
    • + +
    • +
    • + Linked scrolling via protein horizontal + scroll bar doesn't work for some CDS/Protein views +
    • +
    • + Trackpad scrolling is broken on OSX on + Java 1.8u153 onwards and Java 1.9u4+. +
    • +
    • + Tooltip shouldn't be displayed for empty + columns in annotation row +
    • +
    • + Preferences panel's ID Width control is + honored in interactive and batch mode +
    • +
    • + Linked sequence highlighting doesn't work + for structures added to existing Jmol view +
    • +
    • + 'View Mappings' includes duplicate + entries after importing project with multiple views +
    • +
    • + Viewing or annotating Uniprot + protein sequences via SIFTS from associated PDB entries + with negative residue numbers or missing residues fails +
    • +
    • + Exception when shading sequence with negative + Temperature Factor values from annotated PDB files (e.g. + as generated by CONSURF)
    • - Linked scrolling via protein horizontal scroll bar doesn't work for some CDS/Protein views + Invert displayed features very slow when + structure and/or overview windows are also shown +
    • +
    • + Selecting columns from highlighted regions + very slow for alignments with large numbers of sequences +
    • +
    • + Copy Consensus fails for group consensus + with 'StringIndexOutOfBounds' +
    • +
    • + VAqua(4) provided as fallback Look and Feel for OSX + platforms running Java 10 +
    • +
    • + Adding a structure to existing structure + view appears to do nothing because the view is hidden behind the alignment view
    • -
    • Trackpad scrolling is broken on OSX on Java 1.8u153 onwards and Java 1.9u4+.
    • -
    • Tooltip shouldn't be displayed for empty columns in annotation row
    • -
    • Preferences panel's ID Width control is honored in interactive and batch mode
    • -
    Applet
      -
    • Copy consensus sequence option in applet should copy the group consensus when popup is opened on it
    • -
    -
    - + Applet +
      +
    • + Copy consensus sequence option in applet + should copy the group consensus when popup is opened on it +
    • +
    + Batch Mode +
      +
    • + Fixed ID width preference is not respected +
    • +
    + New Known Defects +
      +
    • + Exceptions occasionally raised when + editing a large alignment and overview is displayed +
    • +
    • + 'Overview updating' progress bar is shown + repeatedly after a series of edits even when the overview + is no longer reflecting updates +
    • +
    • + 'SIFTS Mapping Error' when viewing + structures for protein subsequence (if 'Trim Retrieved + Sequences' enabled) or Ensembl isoforms (Workaround in + 2.10.4 is to fail back to N&W mapping) +
    • +
    + + diff --git a/help/html/whatsNew.html b/help/html/whatsNew.html index d3972f5..0abd2a7 100755 --- a/help/html/whatsNew.html +++ b/help/html/whatsNew.html @@ -27,27 +27,24 @@ What's new in Jalview 2.10.4 ?

    - This is the February 2018 release of Jalview, with several minor bug fixes and enhanvements. - The full list bugs fixed in this release can be found in the 2.10.4 - Release Notes. In addition, Jalview 2.10.4 provides: + This is the May 2018 release of Jalview, and the last in the 2.10.x series. Jalview 2.10.4 includes:

      -
    • +
    • Numerous efficiency improvements in the renderer and overview when working with large alignments with lots of hidden columns
    • +
    • Use of HTTPS when connecting to Uniprot, Ensembl and other EBI web services
    • +
    • Critical patches for running Jalview on OSX with Java 10
    • +
    • Easier adjustment of the Alignment ID panel and Annotation panel
    • +
    • Improved support for mapping between 3D Structures and Uniprot Protein Sequences
    • +
    • Improved support for discovering CDS and transcripts for Proteins and Ensembl gene IDs
    • +
    • New buttons on the Structure Chooser for adding structures + to an existing view, and disabling automatic superposition + according to linked alignments
    • +
    • Annotation transfer between Chimera and Jalview (formerly only + available in 'Experimental' mode)

    - Experimental Features + The full list of bugs fixed in this release can be found in the 2.10.4 + Release Notes.

    -

    - Remember, please enable the Experimental Features option in - the Jalview Desktop's Tools menu, and then restart Jalview - if you want to try out features below: -

    - - diff --git a/lib/VAqua4.jar b/lib/VAqua4.jar new file mode 100644 index 0000000..c1e7cfc Binary files /dev/null and b/lib/VAqua4.jar differ diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 609c6a8..db3dbf8 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -405,10 +405,6 @@ label.view_name_original = Original label.enter_view_name = Enter View Name label.enter_label = Enter label label.enter_label_for_the_structure = Enter a label for the structure -label.pdb_entry_is_already_displayed = {0} is already displayed.\nDo you want to re-use this viewer ? -label.map_sequences_to_visible_window = Map Sequences to Visible Window: {0} -label.add_pdbentry_to_view = Do you want to add {0} to the view called\n{1}\n -label.align_to_existing_structure_view = Align to existing structure view label.pdb_entries_couldnt_be_retrieved = The following pdb entries could not be retrieved from the PDB\:\n{0}\nPlease retry, or try downloading them manually. label.couldnt_load_file = Couldn't load file label.couldnt_find_pdb_id_in_file = Couldn't find a PDB id in the file supplied. Please enter an Id to identify this structure. @@ -1222,7 +1218,6 @@ label.pdb_sequence_fetcher = PDB Sequence Fetcher label.result = result label.results = results label.structure_chooser = Structure Chooser -label.select = Select : label.invert = Invert label.select_pdb_file = Select PDB File info.select_filter_option = Select Filter Option/Manual Entry @@ -1387,6 +1382,7 @@ label.hmmer = HMMER label.trim_termini = Trim Non-Matching Termini label.trim_termini_desc = If true, non-matching regions on either end of the resulting alignment are removed. label.no_of_sequences = Number of sequences returned +label.reporting_cutoff = Reporting Cut-off label.freq_alignment = Use alignment background frequencies label.freq_uniprot = Use Uniprot background frequencies label.hmmalign_options = hmmalign options @@ -1397,17 +1393,17 @@ label.invalid_folder = Invalid Folder label.number_of_results = Number of Results to Return label.auto_align_seqs = Automatically Align Fetched Sequences label.use_accessions = Return Accessions -label.seq_e_value = Sequence E-value Cutoff +label.seq_evalue = Sequence E-value Cut-off label.seq_score = Sequence Score Threshold -label.dom_e_value = Domain E-value Cutoff +label.dom_evalue = Domain E-value Cut-off label.dom_score = Domain Score Threshold label.number_of_results_desc = The maximum number of hmmsearch results to display label.auto_align_seqs_desc = If true, all fetched sequences will be aligned to the hidden Markov model with which the search was performed label.use_accessions_desc = If true, the accession number of each sequence is returned, rather than that sequence's name label.seq_e_value_desc = The E-value cutoff for returned sequences (hmmsearch -E) -label.seq_score_desc = The score threshold for returned sequences -label.dom_e_value_desc = The E-value cutoff for returned domains (hmmsearch -domE) -label.dom_score_desc = The score threshold for returned domains +label.seq_score_desc = The score threshold for returned sequences (hmmsearch -T) +label.dom_e_value_desc = The E-value cutoff for returned domains (hmmsearch --domE) +label.dom_score_desc = The score threshold for returned domains (hmmsearch --domT) label.add_database = Add Database label.this_alignment = This alignment warn.invalid_format = This is not a valid database file format. The current supported formats are Fasta, Stockholm and Pfam. diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 6dfefa3..0144522 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -370,10 +370,6 @@ label.ignore_unmatched_dropped_files = Ignorar los ficheros sin coincidencias? label.enter_view_name = Introduzca un nombre para la vista label.enter_label = Introducir etiqueta label.enter_label_for_the_structure = Introducir una etiqueta para la estructura -label.pdb_entry_is_already_displayed = {0} Ya est\u00E1 mostrado.\nQuieres volver a usar este visor? -label.map_sequences_to_visible_window = Mapa de secuencias en ventana visible: {0} -label.add_pdbentry_to_view = Quieres a\u00F1adir {0} a la vista llamada\n{1}\n -label.align_to_existing_structure_view = Alinear a una estructura ya existente label.pdb_entries_couldnt_be_retrieved = Las siguientes entradas pdb no pueden ser extra\u00EDdas del PDB\:\n{0}\nPor favor, prueba descarg\u00E1ndolas manualmente. label.couldnt_load_file = No se pudo cargar el fichero label.couldnt_find_pdb_id_in_file = No se pudo encontrar un Id PDB en el fichero suministrado. Por favor, introduzca un Id para identificar esta estructura. @@ -1176,7 +1172,6 @@ label.structures_filter=Filtro de Estructuras label.scale_protein_to_cdna=Adaptar proteína a cDNA label.scale_protein_to_cdna_tip=Hacer a los residuos de proteínas de la misma anchura que los codones en ventanas divididas status.loading_cached_pdb_entries=Cargando Entradas PDB en Caché -label.select=Seleccionar : label.select_by_annotation=Seleccionar/Ocultar Columnas por Anotación action.select_by_annotation=Seleccionar/Ocultar Columnas por Anotación... action.export_features=Exportar Características diff --git a/schemas/jalview.xsd b/schemas/jalview.xsd index 48824e7..d5cd5bc 100755 --- a/schemas/jalview.xsd +++ b/schemas/jalview.xsd @@ -287,6 +287,11 @@ + + + name of the project jar entry that holds the HMM file with the profile for the sequence + + diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 29b994e..904a860 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -45,11 +45,11 @@ public class PDBChain public String id; - public Vector bonds = new Vector(); + public Vector bonds = new Vector<>(); - public Vector atoms = new Vector(); + public Vector atoms = new Vector<>(); - public Vector residues = new Vector(); + public Vector residues = new Vector<>(); public int offset; @@ -343,12 +343,13 @@ public class PDBChain boolean deoxyn = false; boolean nucleotide = false; StringBuilder seq = new StringBuilder(256); - Vector resFeatures = new Vector(); - Vector resAnnotation = new Vector(); - int i, iSize = atoms.size() - 1; + Vector resFeatures = new Vector<>(); + Vector resAnnotation = new Vector<>(); + int iSize = atoms.size() - 1; int resNumber = -1; char insCode = ' '; - for (i = 0; i <= iSize; i++) + + for (int i = 0; i <= iSize; i++) { Atom tmp = atoms.elementAt(i); resNumber = tmp.resNumber; @@ -362,7 +363,7 @@ public class PDBChain offset = resNumber; } - Vector resAtoms = new Vector(); + Vector resAtoms = new Vector<>(); // Add atoms to a vector while the residue number // remains the same as the first atom's resNumber (res) while ((resNumber == res) && (ins == insCode) && (i < atoms.size())) @@ -469,7 +470,8 @@ public class PDBChain if (StructureImportSettings.isShowSeqFeatures()) { - for (i = 0, iSize = resFeatures.size(); i < iSize; i++) + iSize = resFeatures.size(); + for (int i = 0; i < iSize; i++) { sequence.addSequenceFeature(resFeatures.elementAt(i)); resFeatures.setElementAt(null, i); @@ -478,20 +480,20 @@ public class PDBChain if (visibleChainAnnotation) { Annotation[] annots = new Annotation[resAnnotation.size()]; - float max = 0; - for (i = 0, iSize = annots.length; i < iSize; i++) + float max = 0f; + float min = 0f; + iSize = annots.length; + for (int i = 0; i < iSize; i++) { annots[i] = resAnnotation.elementAt(i); - if (annots[i].value > max) - { - max = annots[i].value; - } + max = Math.max(max, annots[i].value); + min = Math.min(min, annots[i].value); resAnnotation.setElementAt(null, i); } AlignmentAnnotation tfactorann = new AlignmentAnnotation( "Temperature Factor", "Temperature Factor for " + pdbid + id, - annots, 0, max, AlignmentAnnotation.LINE_GRAPH); + annots, min, max, AlignmentAnnotation.LINE_GRAPH); tfactorann.setSequenceRef(sequence); sequence.addAlignmentAnnotation(tfactorann); } diff --git a/src/jalview/api/structures/JalviewStructureDisplayI.java b/src/jalview/api/structures/JalviewStructureDisplayI.java index b4612cf..8f778f7 100644 --- a/src/jalview/api/structures/JalviewStructureDisplayI.java +++ b/src/jalview/api/structures/JalviewStructureDisplayI.java @@ -20,6 +20,9 @@ */ package jalview.api.structures; +import jalview.api.AlignmentViewPanel; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; import jalview.schemes.ColourSchemeI; import jalview.structures.models.AAStructureBindingModel; @@ -69,4 +72,57 @@ public interface JalviewStructureDisplayI */ boolean hasMapping(); + /** + * Checks if the PDB file is already loaded in this viewer, if so just adds + * mappings as necessary and answers true, else answers false. This supports + * the use case of adding additional chains of the same structure to a viewer. + * + * @param seq + * @param chains + * @param apanel + * @param pdbId + * @return + */ + boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains, + AlignmentViewPanel apanel, String pdbId); + + /** + * Adds one or more chains (sequences) of a PDB structure to this structure + * viewer + * + * @param pdbentry + * @param seq + * @param chains + * @param apanel + * @param pdbId + * @return + */ + void addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq, + String[] chains, AlignmentViewPanel apanel, String pdbId); + + /** + * refresh GUI after reconfiguring structure(s) and alignment panels + */ + void updateTitleAndMenus(); + + /** + * Answers true if the viewer should attempt to align any added structures, + * else false + * + * @return + */ + boolean isAlignAddedStructures(); + + /** + * Sets the flag for whether added structures should be aligned + * + * @param alignAdded + */ + void setAlignAddedStructures(boolean alignAdded); + + /** + * Raise the panel to the top of the stack... + */ + void raiseViewer(); + } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index bc93c37..e66b7ae 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -279,6 +279,8 @@ public class Jalview UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { + System.err.println("Unexpected Look and Feel Exception"); + ex.printStackTrace(); } if (Platform.isAMac()) { @@ -294,6 +296,20 @@ public class Jalview System.err.println( "Failed to set QuaQua look and feel: " + e.toString()); } + if (!ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel() + .equals(UIManager.getLookAndFeel())) + { + try + { + System.err.println( + "Quaqua LaF not available. Using VAqua(4)."); + // UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel"); + } catch (Throwable e) + { + System.err.println( + "Failed to reset look and feel: " + e.toString()); + } + } } /* diff --git a/src/jalview/datamodel/HiddenMarkovModel.java b/src/jalview/datamodel/HiddenMarkovModel.java index 3c2c437..e3eb160 100644 --- a/src/jalview/datamodel/HiddenMarkovModel.java +++ b/src/jalview/datamodel/HiddenMarkovModel.java @@ -1,6 +1,5 @@ package jalview.datamodel; -import jalview.bin.Cache; import jalview.io.HMMFile; import jalview.schemes.ResidueProperties; import jalview.util.Comparison; @@ -100,11 +99,14 @@ public class HiddenMarkovModel this.hmmSeq = sq; if (sq.getDatasetSequence() == hmm.mapToHmmConsensus.getTo()) { + // same dataset sequence e.g. after realigning search results this.mapToHmmConsensus = hmm.mapToHmmConsensus; } else { - Cache.log.error("Error: HMM copied with change of mapped sequence"); + // different dataset sequence e.g. after loading HMM from project + this.mapToHmmConsensus = new Mapping(sq.getDatasetSequence(), + hmm.mapToHmmConsensus.getMap()); } } diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index cde50e5..d1e3fcc 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -267,9 +267,12 @@ public class SearchResults implements SearchResultsI { int count = 0; BitSet mask = new BitSet(); + int startRes = sqcol.getStartRes(); + int endRes = sqcol.getEndRes(); + for (SequenceI s : sqcol.getSequences()) { - int[] cols = getResults(s, sqcol.getStartRes(), sqcol.getEndRes()); + int[] cols = getResults(s, startRes, endRes); if (cols != null) { for (int pair = 0; pair < cols.length; pair += 2) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 9464c74..7972626 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -825,7 +825,7 @@ public class Sequence extends ASequence implements SequenceI * @param curs * @return */ - protected int findIndex(int pos, SequenceCursor curs) + protected int findIndex(final int pos, SequenceCursor curs) { if (!isValidCursor(curs)) { @@ -851,10 +851,15 @@ public class Sequence extends ASequence implements SequenceI while (newPos != pos) { col += delta; // shift one column left or right - if (col < 0 || col == sequence.length) + if (col < 0) { break; } + if (col == sequence.length) + { + col--; // return last column if we failed to reach pos + break; + } if (!Comparison.isGap(sequence[col])) { newPos += delta; @@ -862,7 +867,14 @@ public class Sequence extends ASequence implements SequenceI } col++; // convert back to base 1 - updateCursor(pos, col, curs.firstColumnPosition); + + /* + * only update cursor if we found the target position + */ + if (newPos == pos) + { + updateCursor(pos, col, curs.firstColumnPosition); + } return col; } diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 41bc116..8832278 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -478,6 +478,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel lastCommand = command; } + Thread colourby = null; /** * Sends a set of colour commands to the structure viewer * @@ -485,15 +486,28 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ @Override protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + final StructureMappingcommandSet[] colourBySequenceCommands) { - for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands) + if (colourby != null) { - for (String cbyseq : cpdbbyseq.commands) + colourby.interrupt(); + colourby = null; + } + colourby = new Thread(new Runnable() + { + @Override + public void run() { - executeWhenReady(cbyseq); + for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands) + { + for (String cbyseq : cpdbbyseq.commands) + { + executeWhenReady(cbyseq); + } + } } - } + }); + colourby.start(); } /** @@ -862,19 +876,30 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel try { // recover PDB filename for the model hovered over. - int _mp = _modelFileNameMap.length - 1, - mnumber = new Integer(mdlId).intValue() - 1; - while (mnumber < _modelFileNameMap[_mp]) + int mnumber = new Integer(mdlId).intValue() - 1; + if (_modelFileNameMap != null) { - _mp--; + int _mp = _modelFileNameMap.length - 1; + + while (mnumber < _modelFileNameMap[_mp]) + { + _mp--; + } + pdbfilename = modelFileNames[_mp]; } - pdbfilename = modelFileNames[_mp]; - if (pdbfilename == null) + else { - pdbfilename = new File(viewer.ms.getModelFileName(mnumber)) - .getAbsolutePath(); - } + if (mnumber >= 0 && mnumber < modelFileNames.length) + { + pdbfilename = modelFileNames[mnumber]; + } + if (pdbfilename == null) + { + pdbfilename = new File(viewer.ms.getModelFileName(mnumber)) + .getAbsolutePath(); + } + } } catch (Exception e) { } diff --git a/src/jalview/fts/core/FTSRestClient.java b/src/jalview/fts/core/FTSRestClient.java index 076e212..f94d455 100644 --- a/src/jalview/fts/core/FTSRestClient.java +++ b/src/jalview/fts/core/FTSRestClient.java @@ -284,7 +284,8 @@ public abstract class FTSRestClient implements FTSRestClientI public boolean equals(Object otherObject) { FTSDataColumnI that = (FTSDataColumnI) otherObject; - return this.getCode().equals(that.getCode()) + return otherObject == null ? false + : this.getCode().equals(that.getCode()) && this.getName().equals(that.getName()) && this.getGroup().equals(that.getGroup()); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index bcb8423..d52aa97 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -141,10 +141,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Deque; import java.util.Enumeration; -import java.util.HashMap; import java.util.Hashtable; import java.util.List; -import java.util.Map; import java.util.Scanner; import java.util.Vector; @@ -168,9 +166,6 @@ import javax.swing.SwingUtilities; public class AlignFrame extends GAlignFrame implements DropTargetListener, IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener { - - Map distribution = new HashMap<>(); // temporary - public static final int DEFAULT_WIDTH = 700; public static final int DEFAULT_HEIGHT = 500; @@ -1155,7 +1150,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } String path = openFileChooser(false); - if (new File(path).exists()) + if (path != null && new File(path).exists()) { IdentifyFile identifier = new IdentifyFile(); FileFormatI format = identifier.identify(path, DataSourceType.FILE); @@ -1183,21 +1178,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, MessageManager.getString("warn.invalid_format")); } } - else - { - JOptionPane.showMessageDialog(this, - MessageManager.getString("label.not_enough_sequences")); - } } /** - * Opens a file chooser + * Opens a file chooser, optionally restricted to selecting folders + * (directories) only. Answers the path to the selected file or folder, or + * null if none is chosen. * - * @param forFolder + * @param * @return */ protected String openFileChooser(boolean forFolder) { + // TODO duplicates GPreferences method - relocate to JalviewFileChooser? String choice = null; JFileChooser chooser = new JFileChooser(); if (forFolder) diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 153f70c..384635b 100644 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -459,4 +459,11 @@ public class AnnotationColourChooser extends AnnotationRowFilter } } + @Override + protected void sliderDragReleased() + { + super.sliderDragReleased(); + ap.paintAlignment(true, true); + } + } diff --git a/src/jalview/gui/AnnotationRowFilter.java b/src/jalview/gui/AnnotationRowFilter.java index 71ad6a5..f13cb10 100644 --- a/src/jalview/gui/AnnotationRowFilter.java +++ b/src/jalview/gui/AnnotationRowFilter.java @@ -172,11 +172,7 @@ public abstract class AnnotationRowFilter extends JPanel @Override public void mouseReleased(MouseEvent evt) { - if (sliderDragging) - { - sliderDragging = false; - valueChanged(true); - } + sliderDragReleased(); } }); } @@ -523,4 +519,13 @@ public abstract class AnnotationRowFilter extends JPanel { this.annotations = anns; } + + protected void sliderDragReleased() + { + if (sliderDragging) + { + sliderDragging = false; + valueChanged(true); + } + } } diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index fef7451..6c934c8 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; -import javax.swing.JInternalFrame; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.SwingUtilities; @@ -58,7 +57,7 @@ public class AppJmol extends StructureViewerBase private static final String SPACE = " "; - private static final String BACKSLASH = "\""; + private static final String QUOTE = "\""; AppJmolBinding jmb; @@ -162,8 +161,9 @@ public class AppJmol extends StructureViewerBase { return progressBar; } + /** - * add a single PDB structure to a new or existing Jmol view + * display a single PDB structure in a new Jmol view * * @param pdbentry * @param seq @@ -174,33 +174,14 @@ public class AppJmol extends StructureViewerBase final AlignmentPanel ap) { progressBar = ap.alignFrame; - String pdbId = pdbentry.getId(); - /* - * If the PDB file is already loaded, the user may just choose to add to an - * existing viewer (or cancel) - */ - if (addAlreadyLoadedFile(seq, chains, ap, pdbId)) - { - return; - } - - /* - * Check if there are other Jmol views involving this alignment and prompt - * user about adding this molecule to one of them - */ - if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId)) - { - return; - } - - /* - * If the options above are declined or do not apply, open a new viewer - */ - openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq }); + openNewJmol(ap, alignAddedStructures, new PDBEntry[] { pdbentry }, + new SequenceI[][] + { seq }); } - private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys, + private void openNewJmol(AlignmentPanel ap, boolean alignAdded, + PDBEntry[] pdbentrys, SequenceI[][] seqs) { progressBar = ap.alignFrame; @@ -209,11 +190,9 @@ public class AppJmol extends StructureViewerBase addAlignmentPanel(ap); useAlignmentPanelForColourbyseq(ap); - if (pdbentrys.length > 1) - { - alignAddedStructures = true; - useAlignmentPanelForSuperposition(ap); - } + alignAddedStructures = alignAdded; + useAlignmentPanelForSuperposition(ap); + jmb.setColourBySequence(true); setSize(400, 400); // probably should be a configurable/dynamic default here initMenus(); @@ -234,41 +213,21 @@ public class AppJmol extends StructureViewerBase } /** - * create a new Jmol containing several structures superimposed using the - * given alignPanel. + * create a new Jmol containing several structures optionally superimposed + * using the given alignPanel. * * @param ap + * @param alignAdded + * - true to superimpose * @param pe * @param seqs */ - public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs) + public AppJmol(AlignmentPanel ap, boolean alignAdded, PDBEntry[] pe, + SequenceI[][] seqs) { - openNewJmol(ap, pe, seqs); + openNewJmol(ap, alignAdded, pe, seqs); } - /** - * Returns a list of any Jmol viewers. The list is restricted to those linked - * to the given alignment panel if it is not null. - */ - @Override - protected List getViewersFor(AlignmentPanel apanel) - { - List result = new ArrayList<>(); - JInternalFrame[] frames = Desktop.instance.getAllFrames(); - - for (JInternalFrame frame : frames) - { - if (frame instanceof AppJmol) - { - if (apanel == null - || ((StructureViewerBase) frame).isLinkedWith(apanel)) - { - result.add((StructureViewerBase) frame); - } - } - } - return result; - } void initJmol(String command) { @@ -300,8 +259,6 @@ public class AppJmol extends StructureViewerBase jmb.setFinishedInit(true); } - boolean allChainsSelected = false; - @Override void showSelectedChains() { @@ -368,8 +325,8 @@ public class AppJmol extends StructureViewerBase StringBuilder fileList = new StringBuilder(); for (String s : files) { - fileList.append(SPACE).append(BACKSLASH) - .append(Platform.escapeString(s)).append(BACKSLASH); + fileList.append(SPACE).append(QUOTE) + .append(Platform.escapeString(s)).append(QUOTE); } String filesString = fileList.toString(); @@ -444,7 +401,7 @@ public class AppJmol extends StructureViewerBase jmb.updateColours(ap); } // do superposition if asked to - if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures) + if (alignAddedStructures) { alignAddedStructures(); } @@ -478,7 +435,7 @@ public class AppJmol extends StructureViewerBase } } }); - alignAddedStructures = false; + } /** @@ -507,6 +464,7 @@ public class AppJmol extends StructureViewerBase String file = jmb.getPdbEntry(pi).getFile(); if (file == null) { + // todo: extract block as method and pull up (also ChimeraViewFrame) // retrieve the pdb and store it locally AlignmentI pdbseq = null; pdbid = jmb.getPdbEntry(pi).getId(); diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 89de2e8..d07a7c2 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -100,41 +100,34 @@ public class ChimeraViewFrame extends StructureViewerBase savemenu.setVisible(false); // not yet implemented viewMenu.add(fitToWindow); - /* - * exchange of Jalview features and Chimera attributes is for now - * an optionally enabled experimental feature - */ - if (Desktop.instance.showExperimental()) + JMenuItem writeFeatures = new JMenuItem( + MessageManager.getString("label.create_chimera_attributes")); + writeFeatures.setToolTipText(MessageManager + .getString("label.create_chimera_attributes_tip")); + writeFeatures.addActionListener(new ActionListener() { - JMenuItem writeFeatures = new JMenuItem( - MessageManager.getString("label.create_chimera_attributes")); - writeFeatures.setToolTipText(MessageManager - .getString("label.create_chimera_attributes_tip")); - writeFeatures.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - sendFeaturesToChimera(); - } - }); - viewerActionMenu.add(writeFeatures); - - final JMenu fetchAttributes = new JMenu( - MessageManager.getString("label.fetch_chimera_attributes")); - fetchAttributes.setToolTipText(MessageManager - .getString("label.fetch_chimera_attributes_tip")); - fetchAttributes.addMouseListener(new MouseAdapter() + @Override + public void actionPerformed(ActionEvent e) { + sendFeaturesToChimera(); + } + }); + viewerActionMenu.add(writeFeatures); - @Override - public void mouseEntered(MouseEvent e) - { - buildAttributesMenu(fetchAttributes); - } - }); - viewerActionMenu.add(fetchAttributes); - } + final JMenu fetchAttributes = new JMenu( + MessageManager.getString("label.fetch_chimera_attributes")); + fetchAttributes.setToolTipText( + MessageManager.getString("label.fetch_chimera_attributes_tip")); + fetchAttributes.addMouseListener(new MouseAdapter() + { + + @Override + public void mouseEntered(MouseEvent e) + { + buildAttributesMenu(fetchAttributes); + } + }); + viewerActionMenu.add(fetchAttributes); } /** @@ -202,7 +195,7 @@ public class ChimeraViewFrame extends StructureViewerBase } /** - * add a single PDB structure to a new or existing Chimera view + * open a single PDB structure in a new Chimera view * * @param pdbentry * @param seq @@ -213,30 +206,7 @@ public class ChimeraViewFrame extends StructureViewerBase String[] chains, final AlignmentPanel ap) { this(); - String pdbId = pdbentry.getId(); - - /* - * If the PDB file is already loaded, the user may just choose to add to an - * existing viewer (or cancel) - */ - if (addAlreadyLoadedFile(seq, chains, ap, pdbId)) - { - return; - } - /* - * Check if there are other Chimera views involving this alignment and give - * user the option to add and align this molecule to one of them (or cancel) - */ - if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId)) - { - return; - } - - /* - * If the options above are declined or do not apply, show the structure in - * a new viewer - */ openNewChimera(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq }); @@ -264,7 +234,6 @@ public class ChimeraViewFrame extends StructureViewerBase if (pdbentrys.length > 1) { - alignAddedStructures = true; useAlignmentPanelForSuperposition(ap); } jmb.setColourBySequence(true); @@ -323,17 +292,19 @@ public class ChimeraViewFrame extends StructureViewerBase } /** - * create a new viewer containing several structures superimposed using the - * given alignPanel. + * create a new viewer containing several structures, optionally superimposed + * using the given alignPanel. * * @param pe * @param seqs * @param ap */ - public ChimeraViewFrame(PDBEntry[] pe, SequenceI[][] seqs, + public ChimeraViewFrame(PDBEntry[] pe, boolean alignAdded, + SequenceI[][] seqs, AlignmentPanel ap) { this(); + setAlignAddedStructures(alignAdded); openNewChimera(ap, pe, seqs); } @@ -352,29 +323,6 @@ public class ChimeraViewFrame extends StructureViewerBase } /** - * Returns a list of any Chimera viewers in the desktop. The list is - * restricted to those linked to the given alignment panel if it is not null. - */ - @Override - protected List getViewersFor(AlignmentPanel ap) - { - List result = new ArrayList<>(); - JInternalFrame[] frames = Desktop.instance.getAllFrames(); - - for (JInternalFrame frame : frames) - { - if (frame instanceof ChimeraViewFrame) - { - if (ap == null || ((StructureViewerBase) frame).isLinkedWith(ap)) - { - result.add((StructureViewerBase) frame); - } - } - } - return result; - } - - /** * Launch Chimera. If we have a chimera session file name, send Chimera the * command to open its saved session file. */ @@ -641,7 +589,7 @@ public class ChimeraViewFrame extends StructureViewerBase jmb.updateColours(ap); } // do superposition if asked to - if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures) + if (alignAddedStructures) { new Thread(new Runnable() { @@ -651,7 +599,6 @@ public class ChimeraViewFrame extends StructureViewerBase alignStructs_withAllAlignPanels(); } }).start(); - alignAddedStructures = false; } addingStructures = false; } @@ -681,7 +628,6 @@ public class ChimeraViewFrame extends StructureViewerBase private String fetchPdbFile(PDBEntry processingEntry) throws Exception { - // FIXME: this is duplicated code with Jmol frame ? String filePath = null; Pdb pdbclient = new Pdb(); AlignmentI pdbseq = null; diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index b26a8af..be64c85 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -3397,4 +3397,41 @@ public class Desktop extends jalview.jbgui.GDesktop { Cache.setProperty(EXPERIMENTAL_FEATURES, Boolean.toString(selected)); } + + /** + * Answers a (possibly empty) list of any structure viewer frames (currently + * for either Jmol or Chimera) which are currently open. This may optionally + * be restricted to viewers of a specified class, or viewers linked to a + * specified alignment panel. + * + * @param apanel + * if not null, only return viewers linked to this panel + * @param structureViewerClass + * if not null, only return viewers of this class + * @return + */ + public List getStructureViewers( + AlignmentPanel apanel, + Class structureViewerClass) + { + List result = new ArrayList<>(); + JInternalFrame[] frames = Desktop.instance.getAllFrames(); + + for (JInternalFrame frame : frames) + { + if (frame instanceof StructureViewerBase) + { + if (structureViewerClass == null + || structureViewerClass.isInstance(frame)) + { + if (apanel == null + || ((StructureViewerBase) frame).isLinkedWith(apanel)) + { + result.add((StructureViewerBase) frame); + } + } + } + } + return result; + } } diff --git a/src/jalview/gui/JDatabaseTree.java b/src/jalview/gui/JDatabaseTree.java index 0a6b9d6..1018d6e 100644 --- a/src/jalview/gui/JDatabaseTree.java +++ b/src/jalview/gui/JDatabaseTree.java @@ -101,10 +101,10 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener * identical DB sources, and should be collapsed. */ DefaultMutableTreeNode tn = null, root = new DefaultMutableTreeNode(); - Hashtable source = new Hashtable(); + Hashtable source = new Hashtable<>(); sfetcher = sfetch; String dbs[] = sfetch.getSupportedDb(); - Hashtable ht = new Hashtable(); + Hashtable ht = new Hashtable<>(); for (int i = 0; i < dbs.length; i++) { tn = source.get(dbs[i]); @@ -370,7 +370,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener tsel = dbviews.getSelectionPaths(); boolean forcedFirstChild = false; - List srcs = new ArrayList(); + List srcs = new ArrayList<>(); if (tsel != null) { for (TreePath tp : tsel) @@ -489,7 +489,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener return null; } StringBuffer sb = new StringBuffer(); - HashSet hs = new HashSet(); + HashSet hs = new HashSet<>(); for (DbSourceProxy dbs : getSelectedSources()) { String tq = dbs.getTestQuery(); @@ -506,7 +506,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener return sb.toString(); } - List lstners = new Vector(); + List lstners = new Vector<>(); public void addActionListener(ActionListener actionListener) { @@ -596,4 +596,11 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener // TODO Auto-generated method stub } + + @Override + public void setVisible(boolean arg0) + { + System.out.println("setVisible: " + arg0); + super.setVisible(arg0); + } } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 3840597..aed73d6 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -30,6 +30,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.GraphLine; +import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.PDBEntry; import jalview.datamodel.RnaViewerModel; import jalview.datamodel.SequenceFeature; @@ -45,6 +46,7 @@ import jalview.ext.varna.RnaModel; import jalview.gui.StructureViewer.ViewerType; import jalview.io.DataSourceType; import jalview.io.FileFormat; +import jalview.io.HMMFile; import jalview.renderer.ResidueShaderI; import jalview.schemabinding.version2.AlcodMap; import jalview.schemabinding.version2.AlcodonFrame; @@ -52,7 +54,6 @@ import jalview.schemabinding.version2.Annotation; import jalview.schemabinding.version2.AnnotationColours; import jalview.schemabinding.version2.AnnotationElement; import jalview.schemabinding.version2.CalcIdParam; -import jalview.schemabinding.version2.Colour; import jalview.schemabinding.version2.CompoundMatcher; import jalview.schemabinding.version2.DBRef; import jalview.schemabinding.version2.Features; @@ -167,6 +168,8 @@ public class Jalview2XML private static final String RNA_PREFIX = "rna_"; + private static final String HMMER_PREFIX = "hmmer_"; + private static final String UTF_8 = "UTF-8"; // use this with nextCounter() to make unique names for entities @@ -867,73 +870,28 @@ public class Jalview2XML } } - // TODO: omit sequence features from each alignment view's XML dump if we - // are storing dataset - List sfs = jds - .getSequenceFeatures(); + /* + * save sequence features + * TODO: omit sequence features from each alignment view's + * XML dump if we are storing dataset + */ + List sfs = jds.getSequenceFeatures(); for (SequenceFeature sf : sfs) { - Features features = new Features(); - - features.setBegin(sf.getBegin()); - features.setEnd(sf.getEnd()); - features.setDescription(sf.getDescription()); - features.setType(sf.getType()); - features.setFeatureGroup(sf.getFeatureGroup()); - features.setScore(sf.getScore()); - if (sf.links != null) - { - for (int l = 0; l < sf.links.size(); l++) - { - OtherData keyValue = new OtherData(); - keyValue.setKey("LINK_" + l); - keyValue.setValue(sf.links.elementAt(l).toString()); - features.addOtherData(keyValue); - } - } - if (sf.otherDetails != null) - { - /* - * save feature attributes, which may be simple strings or - * map valued (have sub-attributes) - */ - for (Entry entry : sf.otherDetails.entrySet()) - { - String key = entry.getKey(); - Object value = entry.getValue(); - if (value instanceof Map) - { - for (Entry subAttribute : ((Map) value) - .entrySet()) - { - OtherData otherData = new OtherData(); - otherData.setKey(key); - otherData.setKey2(subAttribute.getKey()); - otherData.setValue(subAttribute.getValue().toString()); - features.addOtherData(otherData); - } - } - else - { - OtherData otherData = new OtherData(); - otherData.setKey(key); - otherData.setValue(value.toString()); - features.addOtherData(otherData); - } - } - } - + Features features = saveFeature(sf); jseq.addFeatures(features); } + /* + * save PDB entries for sequence + */ if (jdatasq.getAllPDBEntries() != null) { - Enumeration en = jdatasq.getAllPDBEntries().elements(); + Enumeration en = jdatasq.getAllPDBEntries().elements(); while (en.hasMoreElements()) { Pdbids pdb = new Pdbids(); - jalview.datamodel.PDBEntry entry = (jalview.datamodel.PDBEntry) en - .nextElement(); + PDBEntry entry = en.nextElement(); String pdbId = entry.getId(); pdb.setId(pdbId); @@ -1017,6 +975,11 @@ public class Jalview2XML saveRnaViewers(jout, jseq, jds, viewIds, ap, storeDS); + if (jds.hasHMMProfile()) + { + saveHmmerProfile(jout, jseq, jds); + } + jms.addJSeq(jseq); } @@ -1508,6 +1471,98 @@ public class Jalview2XML } /** + * Saves the HMMER profile associated with the sequence as a file in the jar, + * in HMMER format, and saves the name of the file as a child element of the + * XML sequence element + * + * @param jout + * @param xmlSeq + * @param seq + */ + protected void saveHmmerProfile(JarOutputStream jout, JSeq xmlSeq, + SequenceI seq) + { + HiddenMarkovModel profile = seq.getHMM(); + if (profile == null) + { + warn("Want to save HMM profile for " + seq.getName() + + " but none found"); + return; + } + HMMFile hmmFile = new HMMFile(profile); + String hmmAsString = hmmFile.print(); + String jarEntryName = HMMER_PREFIX + nextCounter(); + try + { + writeJarEntry(jout, jarEntryName, hmmAsString.getBytes()); + xmlSeq.setHmmerProfile(jarEntryName); + } catch (IOException e) + { + warn("Error saving HMM profile: " + e.getMessage()); + } + } + + /** + * Converts a Jalview SequenceFeature into the XML model of it to save + * + * @param sf + * @return + */ + protected Features saveFeature(SequenceFeature sf) + { + Features features = new Features(); + + features.setBegin(sf.getBegin()); + features.setEnd(sf.getEnd()); + features.setDescription(sf.getDescription()); + features.setType(sf.getType()); + features.setFeatureGroup(sf.getFeatureGroup()); + features.setScore(sf.getScore()); + if (sf.links != null) + { + for (int l = 0; l < sf.links.size(); l++) + { + OtherData keyValue = new OtherData(); + keyValue.setKey("LINK_" + l); + keyValue.setValue(sf.links.elementAt(l).toString()); + features.addOtherData(keyValue); + } + } + if (sf.otherDetails != null) + { + /* + * save feature attributes, which may be simple strings or + * map valued (have sub-attributes) + */ + for (Entry entry : sf.otherDetails.entrySet()) + { + String key = entry.getKey(); + Object value = entry.getValue(); + if (value instanceof Map) + { + for (Entry subAttribute : ((Map) value) + .entrySet()) + { + OtherData otherData = new OtherData(); + otherData.setKey(key); + otherData.setKey2(subAttribute.getKey()); + otherData.setValue(subAttribute.getValue().toString()); + features.addOtherData(otherData); + } + } + else + { + OtherData otherData = new OtherData(); + otherData.setKey(key); + otherData.setValue(value.toString()); + features.addOtherData(otherData); + } + } + } + return features; + } + + /** * Save any Varna viewers linked to this sequence. Writes an rnaViewer element * for each viewer, with *
      @@ -1708,9 +1763,8 @@ public class Jalview2XML } else if (!matchedFile.equals(pdbentry.getFile())) { - Cache.log.warn( - "Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): " - + pdbentry.getFile()); + warn("Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): " + + pdbentry.getFile()); } // record the // file so we @@ -2194,12 +2248,12 @@ public class Jalview2XML mpc.setDseqFor(jmpid); if (!seqRefIds.containsKey(mpc.getDseqFor())) { - jalview.bin.Cache.log.debug("creatign new DseqFor ID"); + debug("creating new DseqFor ID"); seqRefIds.put(mpc.getDseqFor(), ps); } else { - jalview.bin.Cache.log.debug("reusing DseqFor ID"); + debug("reusing DseqFor ID"); } mp.setMappingChoice(mpc); @@ -3014,24 +3068,26 @@ public class Jalview2XML // for (int i = 0; i < vamsasSeq.length; i++) { + SequenceI alignmentSeq = al.getSequenceAt(i); if (jseqs[i].getFeaturesCount() > 0) { Features[] features = jseqs[i].getFeatures(); for (int f = 0; f < features.length; f++) { - SequenceFeature sf = new SequenceFeature(features[f].getType(), - features[f].getDescription(), features[f].getBegin(), - features[f].getEnd(), features[f].getScore(), - features[f].getFeatureGroup()); - sf.setStatus(features[f].getStatus()); + Features feature = features[f]; + SequenceFeature sf = new SequenceFeature(feature.getType(), + feature.getDescription(), feature.getBegin(), + feature.getEnd(), feature.getScore(), + feature.getFeatureGroup()); + sf.setStatus(feature.getStatus()); /* * load any feature attributes - include map-valued attributes */ Map> mapAttributes = new HashMap<>(); - for (int od = 0; od < features[f].getOtherDataCount(); od++) + for (int od = 0; od < feature.getOtherDataCount(); od++) { - OtherData keyValue = features[f].getOtherData(od); + OtherData keyValue = feature.getOtherData(od); String attributeName = keyValue.getKey(); String attributeValue = keyValue.getValue(); if (attributeName.startsWith("LINK")) @@ -3065,16 +3121,15 @@ public class Jalview2XML } // adds feature to datasequence's feature set (since Jalview 2.10) - al.getSequenceAt(i).addSequenceFeature(sf); + alignmentSeq.addSequenceFeature(sf); } } if (vamsasSeq[i].getDBRefCount() > 0) { // adds dbrefs to datasequence's set (since Jalview 2.10) addDBRefs( - al.getSequenceAt(i).getDatasetSequence() == null - ? al.getSequenceAt(i) - : al.getSequenceAt(i).getDatasetSequence(), + alignmentSeq.getDatasetSequence() == null ? alignmentSeq + : alignmentSeq.getDatasetSequence(), vamsasSeq[i]); } if (jseqs[i].getPdbidsCount() > 0) @@ -3122,16 +3177,25 @@ public class Jalview2XML .getStructureSelectionManager(Desktop.instance) .registerPDBEntry(entry); // adds PDBEntry to datasequence's set (since Jalview 2.10) - if (al.getSequenceAt(i).getDatasetSequence() != null) + if (alignmentSeq.getDatasetSequence() != null) { - al.getSequenceAt(i).getDatasetSequence().addPDBId(entry); + alignmentSeq.getDatasetSequence().addPDBId(entry); } else { - al.getSequenceAt(i).addPDBId(entry); + alignmentSeq.addPDBId(entry); } } } + + /* + * load any HMMER profile + */ + String hmmJarFile = jseqs[i].getHmmerProfile(); + if (hmmJarFile != null) + { + loadHmmerProfile(jprovider, hmmJarFile, alignmentSeq); + } } } // end !multipleview @@ -3629,6 +3693,31 @@ public class Jalview2XML } /** + * Loads a HMMER profile from a file stored in the project, and associates it + * with the specified sequence + * + * @param jprovider + * @param hmmJarFile + * @param seq + */ + protected void loadHmmerProfile(jarInputStreamProvider jprovider, + String hmmJarFile, SequenceI seq) + { + try + { + String hmmFile = copyJarEntry(jprovider, hmmJarFile, "hmm", null); + HMMFile parser = new HMMFile(hmmFile, DataSourceType.FILE); + HiddenMarkovModel hmmModel = parser.getHMM(); + hmmModel = new HiddenMarkovModel(hmmModel, seq); + seq.setHMM(hmmModel); + } catch (IOException e) + { + warn("Error loading HMM profile for " + seq.getName() + ": " + + e.getMessage()); + } + } + + /** * Instantiate and link any saved RNA (Varna) viewers. The state of the Varna * panel is restored from separate jar entries, two (gapped and trimmed) per * sequence and secondary structure. @@ -5055,10 +5144,7 @@ public class Jalview2XML id = object.getJalviewModelSequence().getViewport()[0] .getSequenceSetId())) { - if (Cache.log != null && Cache.log.isDebugEnabled()) - { - Cache.log.debug("Skipping seuqence set id " + id); - } + debug("Skipping sequence set id " + id); return true; } return false; @@ -5432,7 +5518,7 @@ public class Jalview2XML seqRefIds.put(sqid, djs); } - jalview.bin.Cache.log.debug("about to recurse on addDBRefs."); + debug("about to recurse on addDBRefs."); addDBRefs(djs, ms); } @@ -5610,7 +5696,7 @@ public class Jalview2XML } else { - Cache.log.debug("Ignoring " + jvobj.getClass() + " (ID = " + id); + debug("Ignoring " + jvobj.getClass() + " (ID = " + id); } } } @@ -5942,7 +6028,10 @@ public class Jalview2XML maxcol = new Color(Integer.parseInt(colourModel.getRGB(), 16)); } catch (Exception e) { - Cache.log.warn("Couldn't parse out graduated feature color.", e); + if (Cache.log != null) + { + Cache.log.warn("Couldn't parse out graduated feature color.", e); + } } NoValueColour noCol = colourModel.getNoValueColour(); diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 34af13d..dcd07ef 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -101,7 +101,7 @@ public class OptsAndParamsPage public class OptionBox extends JPanel implements MouseListener, ActionListener { - JCheckBox enabled = new JCheckBox(); + JCheckBox enabled; final URL finfo; @@ -113,14 +113,13 @@ public class OptsAndParamsPage OptionI option; - JLabel optlabel = new JLabel(); - - JComboBox val = new JComboBox<>(); + JComboBox val; public OptionBox(OptionI opt) { option = opt; setLayout(new FlowLayout(FlowLayout.LEFT)); + enabled = new JCheckBox(); enabled.setSelected(opt.isRequired()); // TODO: lock required options enabled.setFont(new Font("Verdana", Font.PLAIN, 11)); enabled.setText(""); @@ -149,6 +148,9 @@ public class OptsAndParamsPage } } add(enabled); + + // todo combo or radio buttons? + val = new JComboBox<>(); for (String str : opt.getPossibleValues()) { val.addItem(str); @@ -366,7 +368,8 @@ public class OptsAndParamsPage * ensure slider has an integer range corresponding to * the min-max range of the parameter */ - if (validator.getMin() != null && !isIntegerParameter + if (validator.getMin() != null && validator.getMax() != null + // && !isIntegerParameter && !isStringParameter) { double min = validator.getMin().doubleValue(); @@ -380,10 +383,10 @@ public class OptsAndParamsPage // todo scaleMin, scaleMax could also be final fields } } - else - { - isChoiceParameter = parameter.getPossibleValues() != null; - } + + List possibleValues = parameter.getPossibleValues(); + isChoiceParameter = possibleValues != null + && !possibleValues.isEmpty(); if (compact) { @@ -549,13 +552,23 @@ public class OptsAndParamsPage */ private void checkIfModified() { - Object newValue = updateSliderFromValueField(); - boolean modified = true; - if (newValue.getClass() == lastVal.getClass()) + if (!adjusting) { - modified = !newValue.equals(lastVal); + try + { + adjusting = true; + Object newValue = updateSliderFromValueField(); + boolean modified = true; + if (newValue.getClass() == lastVal.getClass()) + { + modified = !newValue.equals(lastVal); + } + pmdialogbox.argSetModified(this, modified); + } finally + { + adjusting = false; + } } - pmdialogbox.argSetModified(this, modified); } @Override @@ -629,8 +642,13 @@ public class OptsAndParamsPage @Override public void stateChanged(ChangeEvent e) { - if (!adjusting) + if (adjusting) { + return; + } + try + { + adjusting = true; if (!isLogarithmicParameter) { /* @@ -648,6 +666,9 @@ public class OptsAndParamsPage valueField.setText(formatDouble(value)); } checkIfModified(); + } finally + { + adjusting = false; } } diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 9f52d26..7ceceee 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -464,7 +464,16 @@ public class PCAPanel extends GPCAPanel public void run() { PrinterJob printJob = PrinterJob.getPrinterJob(); - PageFormat pf = printJob.pageDialog(printJob.defaultPage()); + PageFormat defaultPage = printJob.defaultPage(); + PageFormat pf = printJob.pageDialog(defaultPage); + + if (defaultPage == pf) + { + /* + * user cancelled + */ + return; + } printJob.setPrintable(this, pf); diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 193d0ee..ce6bcbd 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -2292,4 +2292,13 @@ public class SeqPanel extends JPanel return true; } + + /** + * + * @return null or last search results handled by this panel + */ + public SearchResultsI getLastSearchResults() + { + return lastSearchResults; + } } diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 8d46792..f545e70 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -273,7 +273,7 @@ public class SequenceFetcher extends JPanel implements Runnable return Collections.emptyList(); } } - sf.newAlframes = new ArrayList(); + sf.newAlframes = new ArrayList<>(); sf.run(); return sf.newAlframes; } @@ -674,10 +674,10 @@ public class SequenceFetcher extends JPanel implements Runnable // TODO: Refactor to GUI independent code and write tests. // indicate if successive sources should be merged into one alignment. boolean addToLast = false; - List aresultq = new ArrayList(); - List presultTitle = new ArrayList(); - List presult = new ArrayList(); - List aresult = new ArrayList(); + List aresultq = new ArrayList<>(); + List presultTitle = new ArrayList<>(); + List presult = new ArrayList<>(); + List aresult = new ArrayList<>(); Iterator proxies = database.getSelectedSources() .iterator(); String[] qries; @@ -695,7 +695,7 @@ public class SequenceFetcher extends JPanel implements Runnable nqueries = nextFetch.size(); // save the remaining queries in the original array qries = nextFetch.toArray(new String[nqueries]); - nextFetch = new ArrayList(); + nextFetch = new ArrayList<>(); } DbSourceProxy proxy = proxies.next(); @@ -861,7 +861,7 @@ public class SequenceFetcher extends JPanel implements Runnable List aresult, List nextFetch) throws Exception { StringBuilder multiacc = new StringBuilder(); - List tosend = new ArrayList(); + List tosend = new ArrayList<>(); while (accessions.hasNext()) { String nel = accessions.next(); diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 198aa62..e18d6af 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -22,6 +22,7 @@ package jalview.gui; import jalview.api.structures.JalviewStructureDisplayI; +import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; @@ -68,6 +69,8 @@ import javax.swing.table.AbstractTableModel; public class StructureChooser extends GStructureChooser implements IProgressIndicator { + private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE"; + private static int MAX_QLENGTH = 7820; private SequenceI selectedSequence; @@ -88,6 +91,8 @@ public class StructureChooser extends GStructureChooser private boolean cachedPDBExists; + private static StructureViewer lastTargetedView = null; + public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq, AlignmentPanel ap) { @@ -101,13 +106,15 @@ public class StructureChooser extends GStructureChooser /** * Initializes parameters used by the Structure Chooser Panel */ - public void init() + protected void init() { if (!Jalview.isHeadlessMode()) { progressBar = new ProgressBar(this.statusPanel, this.statusBar); } + chk_superpose.setSelected(Cache.getDefault(AUTOSUPERIMPOSE, true)); + // ensure a filter option is in force for search populateFilterComboBox(true, cachedPDBExists); Thread discoverPDBStructuresThread = new Thread(new Runnable() @@ -125,6 +132,7 @@ public class StructureChooser extends GStructureChooser fetchStructuresMetaData(); // revise filter options if no results were found populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists); + discoverStructureViews(); updateProgressIndicator(null, startTime); mainFrame.setVisible(true); updateCurrentView(); @@ -134,6 +142,59 @@ public class StructureChooser extends GStructureChooser } /** + * Builds a drop-down choice list of existing structure viewers to which new + * structures may be added. If this list is empty then it, and the 'Add' + * button, are hidden. + */ + private void discoverStructureViews() + { + if (Desktop.instance != null) + { + targetView.removeAllItems(); + if (lastTargetedView != null && !lastTargetedView.isVisible()) + { + lastTargetedView = null; + } + int linkedViewsAt = 0; + for (StructureViewerBase view : Desktop.instance + .getStructureViewers(null, null)) + { + StructureViewer viewHandler = (lastTargetedView != null + && lastTargetedView.sview == view) ? lastTargetedView + : StructureViewer.reconfigure(view); + + if (view.isLinkedWith(ap)) + { + targetView.insertItemAt(viewHandler, + linkedViewsAt++); + } + else + { + targetView.addItem(viewHandler); + } + } + + /* + * show option to Add to viewer if at least 1 viewer found + */ + targetView.setVisible(false); + if (targetView.getItemCount() > 0) + { + targetView.setVisible(true); + if (lastTargetedView != null) + { + targetView.setSelectedItem(lastTargetedView); + } + else + { + targetView.setSelectedIndex(0); + } + } + btn_add.setVisible(targetView.isVisible()); + } + } + + /** * Updates the progress indicator with the specified message * * @param message @@ -141,7 +202,7 @@ public class StructureChooser extends GStructureChooser * @param id * unique handle for this indicator */ - public void updateProgressIndicator(String message, long id) + protected void updateProgressIndicator(String message, long id) { if (progressIndicator != null) { @@ -153,7 +214,7 @@ public class StructureChooser extends GStructureChooser * Retrieve meta-data for all the structure(s) for a given sequence(s) in a * selection group */ - public void fetchStructuresMetaData() + void fetchStructuresMetaData() { long startTime = System.currentTimeMillis(); pdbRestCleint = PDBFTSRestClient.getInstance(); @@ -224,7 +285,7 @@ public class StructureChooser extends GStructureChooser } } - public void loadLocalCachedPDBEntries() + protected void loadLocalCachedPDBEntries() { ArrayList entries = new ArrayList<>(); for (SequenceI seq : selectedSequences) @@ -255,7 +316,7 @@ public class StructureChooser extends GStructureChooser * @return the built query string */ - public static String buildQuery(SequenceI seq) + static String buildQuery(SequenceI seq) { boolean isPDBRefsFound = false; boolean isUniProtRefsFound = false; @@ -357,7 +418,7 @@ public class StructureChooser extends GStructureChooser * @param seqName * @return */ - public static boolean isValidSeqName(String seqName) + static boolean isValidSeqName(String seqName) { // System.out.println("seqName : " + seqName); String ignoreList = "pdb,uniprot,swiss-prot"; @@ -380,7 +441,7 @@ public class StructureChooser extends GStructureChooser return true; } - public static String getDBRefId(DBRefEntry dbRef) + static String getDBRefId(DBRefEntry dbRef) { String ref = dbRef.getAccessionId().replaceAll("GO:", ""); return ref; @@ -392,7 +453,7 @@ public class StructureChooser extends GStructureChooser * @param fieldToFilterBy * the field to filter by */ - public void filterResultSet(final String fieldToFilterBy) + void filterResultSet(final String fieldToFilterBy) { Thread filterThread = new Thread(new Runnable() { @@ -502,7 +563,7 @@ public class StructureChooser extends GStructureChooser * Handles action event for btn_pdbFromFile */ @Override - public void pdbFromFile_actionPerformed() + protected void pdbFromFile_actionPerformed() { jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY")); @@ -603,28 +664,37 @@ public class StructureChooser extends GStructureChooser } /** - * Validates user selection and activates the view button if all parameters - * are correct + * Validates user selection and enables the 'Add' and 'New View' buttons if + * all parameters are correct (the Add button will only be visible if there is + * at least one existing structure viewer open). This basically means at least + * one structure selected and no error messages. + *

      + * The 'Superpose Structures' option is enabled if either more than one + * structure is selected, or the 'Add' to existing view option is enabled, and + * disabled if the only option is to open a new view of a single structure. */ @Override - public void validateSelections() + protected void validateSelections() { FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption .getSelectedItem()); - btn_view.setEnabled(false); + btn_add.setEnabled(false); String currentView = selectedFilterOpt.getView(); + int selectedCount = 0; if (currentView == VIEWS_FILTER) { - if (getResultTable().getSelectedRows().length > 0) + selectedCount = getResultTable().getSelectedRows().length; + if (selectedCount > 0) { - btn_view.setEnabled(true); + btn_add.setEnabled(true); } } else if (currentView == VIEWS_LOCAL_PDB) { - if (tbl_local_pdb.getSelectedRows().length > 0) + selectedCount = tbl_local_pdb.getSelectedRows().length; + if (selectedCount > 0) { - btn_view.setEnabled(true); + btn_add.setEnabled(true); } } else if (currentView == VIEWS_ENTER_ID) @@ -635,12 +705,21 @@ public class StructureChooser extends GStructureChooser { validateAssociationFromFile(); } + + btn_newView.setEnabled(btn_add.isEnabled()); + + /* + * enable 'Superpose' option if more than one structure is selected, + * or there are view(s) available to add structure(s) to + */ + chk_superpose + .setEnabled(selectedCount > 1 || targetView.getItemCount() > 0); } /** * Validates inputs from the Manual PDB entry panel */ - public void validateAssociationEnterPdb() + protected void validateAssociationEnterPdb() { AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel .getCmb_assSeq().getSelectedItem(); @@ -666,7 +745,7 @@ public class StructureChooser extends GStructureChooser txt_search.setEnabled(true); if (isValidPBDEntry) { - btn_view.setEnabled(true); + btn_add.setEnabled(true); lbl_pdbManualFetchStatus.setToolTipText(""); lbl_pdbManualFetchStatus.setIcon(goodImage); } @@ -681,7 +760,7 @@ public class StructureChooser extends GStructureChooser /** * Validates inputs for the manual PDB file selection options */ - public void validateAssociationFromFile() + protected void validateAssociationFromFile() { AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel .getCmb_assSeq().getSelectedItem(); @@ -692,7 +771,7 @@ public class StructureChooser extends GStructureChooser btn_pdbFromFile.setEnabled(true); if (selectedPdbFileName != null && selectedPdbFileName.length() > 0) { - btn_view.setEnabled(true); + btn_add.setEnabled(true); lbl_fromFileStatus.setIcon(goodImage); } } @@ -704,7 +783,7 @@ public class StructureChooser extends GStructureChooser } @Override - public void cmbAssSeqStateChanged() + protected void cmbAssSeqStateChanged() { validateSelections(); } @@ -768,11 +847,22 @@ public class StructureChooser extends GStructureChooser } return found; } + + /** + * Handles the 'New View' action + */ + @Override + protected void newView_ActionPerformed() + { + targetView.setSelectedItem(null); + showStructures(false); + } + /** - * Handles action event for btn_ok + * Handles the 'Add to existing viewer' action */ @Override - public void ok_ActionPerformed() + protected void add_ActionPerformed() { showStructures(false); } @@ -957,6 +1047,30 @@ public class StructureChooser extends GStructureChooser return foundEntry; } + /** + * Answers a structure viewer (new or existing) configured to superimpose + * added structures or not according to the user's choice + * + * @param ssm + * @return + */ + StructureViewer getTargetedStructureViewer( + StructureSelectionManager ssm) + { + Object sv = targetView.getSelectedItem(); + + return sv == null ? new StructureViewer(ssm) : (StructureViewer) sv; + } + + /** + * Adds PDB structures to a new or existing structure viewer + * + * @param ssm + * @param pdbEntriesToView + * @param alignPanel + * @param sequences + * @return + */ private StructureViewer launchStructureViewer( StructureSelectionManager ssm, final PDBEntry[] pdbEntriesToView, @@ -965,9 +1079,17 @@ public class StructureChooser extends GStructureChooser long progressId = sequences.hashCode(); setProgressBar(MessageManager .getString("status.launching_3d_structure_viewer"), progressId); - final StructureViewer sViewer = new StructureViewer(ssm); - setProgressBar(null, progressId); + final StructureViewer theViewer = getTargetedStructureViewer(ssm); + boolean superimpose = chk_superpose.isSelected(); + theViewer.setSuperpose(superimpose); + + /* + * remember user's choice of superimpose or not + */ + Cache.setProperty(AUTOSUPERIMPOSE, + Boolean.valueOf(superimpose).toString()); + setProgressBar(null, progressId); if (SiftsSettings.isMapWithSifts()) { List seqsWithoutSourceDBRef = new ArrayList<>(); @@ -992,7 +1114,7 @@ public class StructureChooser extends GStructureChooser } } } - if (seq.getPrimaryDBRefs().size() == 0) + if (seq.getPrimaryDBRefs().isEmpty()) { seqsWithoutSourceDBRef.add(seq); continue; @@ -1004,13 +1126,8 @@ public class StructureChooser extends GStructureChooser setProgressBar(MessageManager.formatMessage( "status.fetching_dbrefs_for_sequences_without_valid_refs", y), progressId); - SequenceI[] seqWithoutSrcDBRef = new SequenceI[y]; - int x = 0; - for (SequenceI fSeq : seqsWithoutSourceDBRef) - { - seqWithoutSrcDBRef[x++] = fSeq; - } - + SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef + .toArray(new SequenceI[y]); DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef); dbRefFetcher.fetchDBRefs(true); @@ -1022,17 +1139,19 @@ public class StructureChooser extends GStructureChooser setProgressBar(MessageManager.getString( "status.fetching_3d_structures_for_selected_entries"), progressId); - sViewer.viewStructures(pdbEntriesToView, sequences, alignPanel); + theViewer.viewStructures(pdbEntriesToView, sequences, alignPanel); } else { setProgressBar(MessageManager.formatMessage( "status.fetching_3d_structures_for", pdbEntriesToView[0].getId()),progressId); - sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); + theViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); } setProgressBar(null, progressId); - return sViewer; + // remember the last viewer we used... + lastTargetedView = theViewer; + return theViewer; } /** @@ -1040,7 +1159,7 @@ public class StructureChooser extends GStructureChooser * a unique sequence when more than one sequence selection is made. */ @Override - public void populateCmbAssociateSeqOptions( + protected void populateCmbAssociateSeqOptions( JComboBox cmb_assSeq, JLabel lbl_associateSeq) { @@ -1065,17 +1184,12 @@ public class StructureChooser extends GStructureChooser } } - public boolean isStructuresDiscovered() + protected boolean isStructuresDiscovered() { return discoveredStructuresSet != null && !discoveredStructuresSet.isEmpty(); } - public Collection getDiscoveredStructuresSet() - { - return discoveredStructuresSet; - } - @Override protected void txt_search_ActionPerformed() { @@ -1125,7 +1239,7 @@ public class StructureChooser extends GStructureChooser } @Override - public void tabRefresh() + protected void tabRefresh() { if (selectedSequences != null) { diff --git a/src/jalview/gui/StructureViewer.java b/src/jalview/gui/StructureViewer.java index f37df71..0c8354b 100644 --- a/src/jalview/gui/StructureViewer.java +++ b/src/jalview/gui/StructureViewer.java @@ -49,6 +49,11 @@ public class StructureViewer StructureSelectionManager ssm; + /** + * decide if new structures are aligned to existing ones + */ + private boolean superposeAdded = true; + public enum ViewerType { JMOL, CHIMERA @@ -64,6 +69,27 @@ public class StructureViewer ssm = structureSelectionManager; } + /** + * Factory to create a proxy for modifying existing structure viewer + * + */ + public static StructureViewer reconfigure( + JalviewStructureDisplayI display) + { + StructureViewer sv = new StructureViewer(display.getBinding().getSsm()); + sv.sview = display; + return sv; + } + + @Override + public String toString() + { + if (sview != null) + { + return sview.toString(); + } + return "New View"; + } public ViewerType getViewerType() { String viewType = Cache.getDefault(Preferences.STRUCTURE_DISPLAY, @@ -104,14 +130,40 @@ public class StructureViewer new PDBEntry[seqsForPdbs.size()]); SequenceI[][] theSeqs = seqsForPdbs.values().toArray( new SequenceI[seqsForPdbs.size()][]); + if (sview != null) + { + sview.setAlignAddedStructures(superposeAdded); + new Thread(new Runnable() + { + @Override + public void run() + { + + for (int pdbep = 0; pdbep < pdbsForFile.length; pdbep++) + { + PDBEntry pdb = pdbsForFile[pdbep]; + if (!sview.addAlreadyLoadedFile(theSeqs[pdbep], null, ap, + pdb.getId())) + { + sview.addToExistingViewer(pdb, theSeqs[pdbep], null, ap, + pdb.getId()); + } + } + + sview.updateTitleAndMenus(); + } + }).start(); + return sview; + } if (viewerType.equals(ViewerType.JMOL)) { - sview = new AppJmol(ap, pdbsForFile, theSeqs); + sview = new AppJmol(ap, superposeAdded, pdbsForFile, theSeqs); } else if (viewerType.equals(ViewerType.CHIMERA)) { - sview = new ChimeraViewFrame(pdbsForFile, theSeqs, ap); + sview = new ChimeraViewFrame(pdbsForFile, superposeAdded, theSeqs, + ap); } else { @@ -232,6 +284,18 @@ public class StructureViewer public JalviewStructureDisplayI viewStructures(PDBEntry pdb, SequenceI[] seqsForPdb, AlignmentPanel ap) { + if (sview != null) + { + sview.setAlignAddedStructures(superposeAdded); + String pdbId = pdb.getId(); + if (!sview.addAlreadyLoadedFile(seqsForPdb, null, ap, pdbId)) + { + sview.addToExistingViewer(pdb, seqsForPdb, null, ap, pdbId); + } + sview.updateTitleAndMenus(); + sview.raiseViewer(); + return sview; + } ViewerType viewerType = getViewerType(); if (viewerType.equals(ViewerType.JMOL)) { @@ -299,4 +363,29 @@ public class StructureViewer return false; } + /** + * + * @param pDBid + * @return true if view is already showing PDBid + */ + public boolean hasPdbId(String pDBid) + { + if (sview == null) + { + return false; + } + + return sview.getBinding().hasPdbId(pDBid); + } + + public boolean isVisible() + { + return sview != null && sview.isVisible(); + } + + public void setSuperpose(boolean alignAddedStructures) + { + superposeAdded = alignAddedStructures; + } + } diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 93d675a..72b0bcc 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -20,6 +20,7 @@ */ package jalview.gui; +import jalview.api.AlignmentViewPanel; import jalview.bin.Cache; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; @@ -129,6 +130,26 @@ public abstract class StructureViewerBase extends GStructureViewer } /** + * @return true if added structures should be aligned to existing one(s) + */ + @Override + public boolean isAlignAddedStructures() + { + return alignAddedStructures; + } + + /** + * + * @param true + * if added structures should be aligned to existing one(s) + */ + @Override + public void setAlignAddedStructures(boolean alignAdded) + { + alignAddedStructures = alignAdded; + } + + /** * * @param ap2 * @return true if this Jmol instance is linked with the given alignPanel @@ -334,7 +355,7 @@ public abstract class StructureViewerBase extends GStructureViewer */ protected void addStructure(final PDBEntry pdbentry, final SequenceI[] seqs, final String[] chains, - final boolean align, final IProgressIndicator alignFrame) + final IProgressIndicator alignFrame) { if (pdbentry.getFile() == null) { @@ -358,7 +379,7 @@ public abstract class StructureViewerBase extends GStructureViewer } } // and call ourselves again. - addStructure(pdbentry, seqs, chains, align, alignFrame); + addStructure(pdbentry, seqs, chains, alignFrame); } }).start(); return; @@ -370,87 +391,42 @@ public abstract class StructureViewerBase extends GStructureViewer { seqs }, new String[][] { chains }); addingStructures = true; _started = false; - alignAddedStructures = align; worker = new Thread(this); worker.start(); return; } - /** - * Presents a dialog with the option to add an align a structure to an - * existing structure view - * - * @param pdbId - * @param view - * @return YES, NO or CANCEL JvOptionPane code - */ - protected int chooseAlignStructureToViewer(String pdbId, - StructureViewerBase view) - { - int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.formatMessage("label.add_pdbentry_to_view", - new Object[] - { pdbId, view.getTitle() }), - MessageManager - .getString("label.align_to_existing_structure_view"), - JvOptionPane.YES_NO_CANCEL_OPTION); - return option; - } - protected boolean hasPdbId(String pdbId) { return getBinding().hasPdbId(pdbId); } - protected abstract List getViewersFor( - AlignmentPanel alp); - /** - * Check for any existing views involving this alignment and give user the - * option to add and align this molecule to one of them - * - * @param pdbentry - * @param seq - * @param chains - * @param apanel - * @param pdbId - * @return true if user adds to a view, or cancels entirely, else false + * Returns a list of any viewer of the instantiated type. The list is + * restricted to those linked to the given alignment panel if it is not null. */ - protected boolean addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq, - String[] chains, final AlignmentPanel apanel, String pdbId) + protected List getViewersFor(AlignmentPanel alp) { - for (StructureViewerBase view : getViewersFor(apanel)) - { - // TODO: highlight the view somehow - /* - * JAL-1742 exclude view with this structure already mapped (don't offer - * to align chain B to chain A of the same structure) - */ - if (view.hasPdbId(pdbId)) - { - continue; - } - int option = chooseAlignStructureToViewer(pdbId, view); - if (option == JvOptionPane.CANCEL_OPTION) - { - return true; - } - else if (option == JvOptionPane.YES_OPTION) - { - view.useAlignmentPanelForSuperposition(apanel); - view.addStructure(pdbentry, seq, chains, true, apanel.alignFrame); - return true; - } - else - { - // NO_OPTION - offer the next viewer if any - } - } + return Desktop.instance.getStructureViewers(alp, this.getClass()); + } + @Override + public void addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq, + String[] chains, final AlignmentViewPanel apanel, String pdbId) + { /* - * nothing offered and selected + * JAL-1742 exclude view with this structure already mapped (don't offer + * to align chain B to chain A of the same structure); code may defend + * against this possibility before we reach here */ - return false; + if (hasPdbId(pdbId)) + { + return; + } + AlignmentPanel alignPanel = (AlignmentPanel) apanel; // Implementation error if this + // cast fails + useAlignmentPanelForSuperposition(alignPanel); + addStructure(pdbentry, seq, chains, alignPanel.alignFrame); } /** @@ -462,9 +438,12 @@ public abstract class StructureViewerBase extends GStructureViewer * @param apanel * @param pdbFilename */ - protected void addSequenceMappingsToStructure(SequenceI[] seq, - String[] chains, final AlignmentPanel apanel, String pdbFilename) + public void addSequenceMappingsToStructure(SequenceI[] seq, + String[] chains, final AlignmentViewPanel alpanel, + String pdbFilename) { + AlignmentPanel apanel = (AlignmentPanel) alpanel; + // TODO : Fix multiple seq to one chain issue here. /* * create the mappings @@ -511,47 +490,20 @@ public abstract class StructureViewerBase extends GStructureViewer } } - /** - * Check if the PDB file is already loaded, if so offer to add it to the - * existing viewer - * - * @param seq - * @param chains - * @param apanel - * @param pdbId - * @return true if the user chooses to add to a viewer, or to cancel entirely - */ - protected boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains, - final AlignmentPanel apanel, String pdbId) + @Override + public boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains, + final AlignmentViewPanel apanel, String pdbId) { - boolean finished = false; String alreadyMapped = apanel.getStructureSelectionManager() .alreadyMappedToFile(pdbId); - if (alreadyMapped != null) + if (alreadyMapped == null) { - /* - * the PDB file is already loaded - */ - int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.formatMessage( - "label.pdb_entry_is_already_displayed", new Object[] - { pdbId }), - MessageManager.formatMessage( - "label.map_sequences_to_visible_window", new Object[] - { pdbId }), - JvOptionPane.YES_NO_CANCEL_OPTION); - if (option == JvOptionPane.CANCEL_OPTION) - { - finished = true; - } - else if (option == JvOptionPane.YES_OPTION) - { - addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped); - finished = true; - } + return false; } - return finished; + + addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped); + return true; } void setChainMenuItems(List chainNames) @@ -831,11 +783,11 @@ public abstract class StructureViewerBase extends GStructureViewer int[] alm = new int[_alignwith.size()]; int a = 0; - for (AlignmentPanel ap : _alignwith) + for (AlignmentPanel alignPanel : _alignwith) { - als[a] = ap.av.getAlignment(); + als[a] = alignPanel.av.getAlignment(); alm[a] = -1; - alc[a++] = ap.av.getAlignment().getHiddenColumns(); + alc[a++] = alignPanel.av.getAlignment().getHiddenColumns(); } reply = getBinding().superposeStructures(als, alm, alc); if (reply != null) @@ -847,9 +799,9 @@ public abstract class StructureViewerBase extends GStructureViewer } catch (Exception e) { StringBuffer sp = new StringBuffer(); - for (AlignmentPanel ap : _alignwith) + for (AlignmentPanel alignPanel : _alignwith) { - sp.append("'" + ap.alignFrame.getTitle() + "' "); + sp.append("'" + alignPanel.alignFrame.getTitle() + "' "); } Cache.log.info("Couldn't align structures with the " + sp.toString() + "associated alignment panels.", e); @@ -913,9 +865,9 @@ public abstract class StructureViewerBase extends GStructureViewer } } // Set the colour using the current view for the associated alignframe - for (AlignmentPanel ap : _colourwith) + for (AlignmentPanel alignPanel : _colourwith) { - binding.colourBySequence(ap); + binding.colourBySequence(alignPanel); } seqColoursApplied = true; } @@ -997,6 +949,7 @@ public abstract class StructureViewerBase extends GStructureViewer /** * Configures the title and menu items of the viewer panel. */ + @Override public void updateTitleAndMenus() { AAStructureBindingModel binding = getBinding(); @@ -1039,6 +992,12 @@ public abstract class StructureViewerBase extends GStructureViewer } @Override + public String toString() + { + return getTitle(); + } + + @Override public boolean hasMapping() { if (worker != null && (addingStructures || _started)) @@ -1075,4 +1034,10 @@ public abstract class StructureViewerBase extends GStructureViewer return seqColoursApplied; } + @Override + public void raiseViewer() + { + toFront(); + } + } diff --git a/src/jalview/gui/WsParamSetManager.java b/src/jalview/gui/WsParamSetManager.java index d91775c..ab03d69 100644 --- a/src/jalview/gui/WsParamSetManager.java +++ b/src/jalview/gui/WsParamSetManager.java @@ -47,20 +47,21 @@ import java.util.StringTokenizer; */ public class WsParamSetManager implements ParamManager { - Hashtable paramparsers = new Hashtable(); + private static final String WS_PARAM_FILES = "WS_PARAM_FILES"; + Hashtable paramparsers = new Hashtable<>(); @Override public WsParamSetI[] getParameterSet(String name, String serviceUrl, boolean modifiable, boolean unmodifiable) { - String files = Cache.getProperty("WS_PARAM_FILES"); + String files = Cache.getProperty(WS_PARAM_FILES); if (files == null) { return null; } StringTokenizer st = new StringTokenizer(files, "|"); String pfile = null; - ArrayList params = new ArrayList(); + ArrayList params = new ArrayList<>(); while (st.hasMoreTokens()) { pfile = st.nextToken(); @@ -98,7 +99,8 @@ public class WsParamSetManager implements ParamManager } catch (IOException e) { Cache.log.info("Failed to parse parameter file " + pfile - + " (Check that all JALVIEW_WSPARAMFILES entries are valid!)", + + " (Check that all " + WS_PARAM_FILES + + " entries are valid!)", e); } } @@ -107,7 +109,7 @@ public class WsParamSetManager implements ParamManager private WsParamSetI[] parseParamFile(String filename) throws IOException { - List psets = new ArrayList(); + List psets = new ArrayList<>(); InputStreamReader is = new InputStreamReader( new java.io.FileInputStream(new File(filename)), "UTF-8"); @@ -202,7 +204,7 @@ public class WsParamSetManager implements ParamManager } if (outfile != null) { - String paramFiles = jalview.bin.Cache.getDefault("WS_PARAM_FILES", + String paramFiles = jalview.bin.Cache.getDefault(WS_PARAM_FILES, filename); if (paramFiles.indexOf(filename) == -1) { @@ -212,7 +214,7 @@ public class WsParamSetManager implements ParamManager } paramFiles = paramFiles.concat(filename); } - jalview.bin.Cache.setProperty("WS_PARAM_FILES", paramFiles); + jalview.bin.Cache.setProperty(WS_PARAM_FILES, paramFiles); jalview.schemabinding.version2.WebServiceParameterSet paramxml = new jalview.schemabinding.version2.WebServiceParameterSet(); @@ -266,7 +268,7 @@ public class WsParamSetManager implements ParamManager { return; } - String paramFiles = jalview.bin.Cache.getDefault("WS_PARAM_FILES", ""); + String paramFiles = jalview.bin.Cache.getDefault(WS_PARAM_FILES, ""); if (paramFiles.indexOf(filename) > -1) { String nparamFiles = new String(); @@ -279,7 +281,7 @@ public class WsParamSetManager implements ParamManager nparamFiles = nparamFiles.concat("|").concat(fl); } } - jalview.bin.Cache.setProperty("WS_PARAM_FILES", nparamFiles); + jalview.bin.Cache.setProperty(WS_PARAM_FILES, nparamFiles); } try diff --git a/src/jalview/hmmer/HMMBuild.java b/src/jalview/hmmer/HMMBuild.java index 3c3bd40..6de7029 100644 --- a/src/jalview/hmmer/HMMBuild.java +++ b/src/jalview/hmmer/HMMBuild.java @@ -96,11 +96,14 @@ public class HMMBuild extends HmmerCommand AlignViewportI viewport) { List runBuildFor = new ArrayList<>(); + boolean foundArg = false; + for (ArgumentI arg : params) { String name = arg.getName(); if (MessageManager.getString("label.hmmbuild_for").equals(name)) { + foundArg = true; String value = arg.getValue(); if (MessageManager.getString("label.alignment").equals(value)) { @@ -134,6 +137,15 @@ public class HMMBuild extends HmmerCommand } } } + + /* + * default is to build for the whole alignment + */ + if (!foundArg) + { + runBuildFor.add(alignment); + } + return runBuildFor; } diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index 6f1f51f..fbab7a9 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -9,6 +9,7 @@ import jalview.ws.params.ArgumentI; import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.WsParamSetI; import jalview.ws.params.simple.BooleanOption; +import jalview.ws.params.simple.DoubleParameter; import jalview.ws.params.simple.IntegerParameter; import jalview.ws.params.simple.LogarithmicParameter; import jalview.ws.params.simple.Option; @@ -16,6 +17,7 @@ import jalview.ws.params.simple.StringParameter; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Scanner; @@ -96,17 +98,16 @@ public final class HMMERParamStore implements ParamDatastoreI */ private void getHMMSearchParams(List args) { + /* + * 'Options' + */ addChoiceOfHmm(args); - args.add(new IntegerParameter( - MessageManager.getString("label.number_of_results"), - MessageManager.getString("label.number_of_results_desc"), true, - 100, 0, 100000)); String names = Cache.getProperty(Preferences.HMMSEARCH_DBS); if (names != null && !names.isEmpty()) { List databases = new ArrayList<>(); - databases.add(MessageManager.getString("label.this_alignment")); + databases.add(MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY)); Scanner nameScanner = new Scanner(names); if (nameScanner.hasNext()) @@ -126,45 +127,56 @@ public final class HMMERParamStore implements ParamDatastoreI } } nameScanner.close(); - args.add(new Option(MessageManager.getString("label.database"), + args.add(new StringParameter( + MessageManager.getString(HMMSearch.DATABASE_KEY), MessageManager.getString("label.database_for_hmmsearch"), - true, MessageManager.getString("label.this_alignment"), - MessageManager.getString("label.this_alignment"), databases, - null)); + true, MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY), + MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY), + databases)); } args.add(new BooleanOption( - MessageManager.getString("label.auto_align_seqs"), + MessageManager.getString(HMMSearch.AUTO_ALIGN_SEQS_KEY), MessageManager.getString("label.auto_align_seqs_desc"), false, false, true, null)); args.add(new BooleanOption( - MessageManager.getString("label.use_accessions"), + MessageManager.getString(HMMSearch.USE_ACCESSIONS_KEY), MessageManager.getString("label.use_accessions_desc"), false, false, true, null)); args.add(new BooleanOption( - MessageManager.getString("label.trim_termini"), + MessageManager.getString(HMMSearch.TRIM_TERMINI_KEY), MessageManager.getString("label.trim_termini_desc"), false, false, true, null)); + + /* + * 'Parameters' + */ + args.add(new IntegerParameter( + MessageManager.getString(HMMSearch.NUMBER_OF_RESULTS_KEY), + MessageManager.getString("label.number_of_results_desc"), true, + 100, 0, 100000)); + args.add(new StringParameter( + MessageManager.getString(HMMSearch.REPORTING_CUTOFF_KEY), null, + true, HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_NONE, + Arrays.asList(HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_EVALUE, + HMMSearch.CUTOFF_SCORE))); args.add(new LogarithmicParameter( - MessageManager.getString("label.seq_e_value"), + MessageManager.getString(HMMSearch.SEQ_EVALUE_KEY), MessageManager.getString("label.seq_e_value_desc"), false, 1D, - 1E-38, 10D, 10D)); - /* - args.add(new DoubleParameter( - MessageManager.getString("label.seq_score"), - MessageManager.getString("label.seq_score_desc"), false, - 0d, 0d, 10000d)); - */ + 1E-38, 10D)); args.add(new LogarithmicParameter( - MessageManager.getString("label.dom_e_value"), + MessageManager.getString(HMMSearch.DOM_EVALUE_KEY), MessageManager.getString("label.dom_e_value_desc"), false, 1D, - 1E-38, 10D, 10D)); - /* - args.add(new DoubleParameter( - MessageManager.getString("label.dom_score"), - MessageManager.getString("label.dom_score_desc"), false, 0d, - 0d, - 10000d)); - */ + 1E-38, 10D)); + args.add( + new DoubleParameter( + MessageManager.getString(HMMSearch.SEQ_SCORE_KEY), + MessageManager.getString("label.seq_score_desc"), false, + 0d, 0d, 1000d)); + args.add( + new DoubleParameter( + MessageManager.getString(HMMSearch.DOM_SCORE_KEY), + MessageManager.getString("label.dom_score_desc"), false, + 0d, 0d, 1000d)); } /** @@ -187,7 +199,7 @@ public final class HMMERParamStore implements ParamDatastoreI /** * Adds an argument representing the choice of HMM sequences (profiles) - * against which to perform align or search, provided more than one is found + * against which to perform align or search, provided at least one is found * * @param args */ @@ -202,9 +214,10 @@ public final class HMMERParamStore implements ParamDatastoreI options.add(hmmSeq.getName()); } String defseq = options.get(0); - Option option = new Option(MessageManager.getString("label.use_hmm"), - "", true, defseq, defseq, options, null); - args.add(option); + ArgumentI arg = new StringParameter( + MessageManager.getString("label.use_hmm"), null, true, defseq, + defseq, options); + args.add(arg); } } @@ -239,16 +252,20 @@ public final class HMMERParamStore implements ParamDatastoreI /* * choice of whether to compute HMM for alignment and/or group(s) + * - only if there are any groups */ - Collection options = new ArrayList<>(); - options.add(MessageManager.getString("label.alignment")); - options.add(MessageManager.getString("label.groups_and_alignment")); - options.add(MessageManager.getString("label.groups")); - options.add(MessageManager.getString("label.selected_group")); - args.add(new Option(MessageManager.getString("label.hmmbuild_for"), - MessageManager.getString("label.hmmbuild_for_desc"), true, - MessageManager.getString("label.alignment"), - MessageManager.getString("label.alignment"), options, null)); + if (!viewport.getAlignment().getGroups().isEmpty()) + { + Collection options = new ArrayList<>(); + options.add(MessageManager.getString("label.alignment")); + options.add(MessageManager.getString("label.groups_and_alignment")); + options.add(MessageManager.getString("label.groups")); + options.add(MessageManager.getString("label.selected_group")); + args.add(new Option(MessageManager.getString("label.hmmbuild_for"), + MessageManager.getString("label.hmmbuild_for_desc"), true, + MessageManager.getString("label.alignment"), + MessageManager.getString("label.alignment"), options, null)); + } } @Override diff --git a/src/jalview/hmmer/HMMSearch.java b/src/jalview/hmmer/HMMSearch.java index d4c9656..efc34ae 100644 --- a/src/jalview/hmmer/HMMSearch.java +++ b/src/jalview/hmmer/HMMSearch.java @@ -31,10 +31,39 @@ import javax.swing.JOptionPane; public class HMMSearch extends HmmerCommand { - private static final String PARAMNAME_NO_OF_RESULTS = MessageManager.getString("label.number_of_results"); - static final String HMMSEARCH = "hmmsearch"; + /* + * constants for i18n lookup of passed parameter names + */ + static final String DATABASE_KEY = "label.database"; + + static final String THIS_ALIGNMENT_KEY = "label.this_alignment"; + + static final String USE_ACCESSIONS_KEY = "label.use_accessions"; + + static final String AUTO_ALIGN_SEQS_KEY = "label.auto_align_seqs"; + + static final String NUMBER_OF_RESULTS_KEY = "label.number_of_results"; + + static final String TRIM_TERMINI_KEY = "label.trim_termini"; + + static final String REPORTING_CUTOFF_KEY = "label.reporting_cutoff"; + + static final String CUTOFF_NONE = "None"; + + static final String CUTOFF_SCORE = "Score"; + + static final String CUTOFF_EVALUE = "E-Value"; + + static final String SEQ_EVALUE_KEY = "label.seq_evalue"; + + static final String DOM_EVALUE_KEY = "label.dom_evalue"; + + static final String SEQ_SCORE_KEY = "label.seq_score"; + + static final String DOM_SCORE_KEY = "label.dom_score"; + boolean realign = false; boolean trim = false; @@ -138,57 +167,72 @@ public class HMMSearch extends HmmerCommand String dbPath = ""; File databaseFile = null; + boolean useEvalueCutoff = false; + boolean useScoreCutoff = false; + String seqEvalueCutoff = null; + String domEvalueCutoff = null; + String seqScoreCutoff = null; + String domScoreCutoff = null; + if (params != null) { for (ArgumentI arg : params) { String name = arg.getName(); - if (MessageManager.getString("label.number_of_results") + if (MessageManager.getString(NUMBER_OF_RESULTS_KEY) .equals(name)) { seqsToReturn = Integer.parseInt(arg.getValue()); } - else if (MessageManager.getString("label.auto_align_seqs") + else if (MessageManager.getString(AUTO_ALIGN_SEQS_KEY) .equals(name)) { realign = true; // TODO: not used } - else if (MessageManager.getString("label.use_accessions") + else if (MessageManager.getString(USE_ACCESSIONS_KEY) .equals(name)) { args.add("--acc"); } - else if (MessageManager.getString("label.seq_e_value").equals(name)) + else if (MessageManager.getString(REPORTING_CUTOFF_KEY) + .equals(name)) + { + if (CUTOFF_EVALUE.equals(arg.getValue())) + { + useEvalueCutoff = true; + } + else if (CUTOFF_SCORE.equals(arg.getValue())) + { + useScoreCutoff = true; + } + } + else if (MessageManager.getString(SEQ_EVALUE_KEY).equals(name)) { - args.add("-E"); - args.add(arg.getValue()); + seqEvalueCutoff = arg.getValue(); } - else if (MessageManager.getString("label.seq_score").equals(name)) + else if (MessageManager.getString(SEQ_SCORE_KEY).equals(name)) { - args.add("-incT"); - args.add(arg.getValue()); + seqScoreCutoff = arg.getValue(); } - else if (MessageManager.getString("label.dom_e_value") + else if (MessageManager.getString(DOM_EVALUE_KEY) .equals(name)) { - args.add("--domE"); - args.add(arg.getValue()); + domEvalueCutoff = arg.getValue(); } - else if (MessageManager.getString("label.dom_score").equals(name)) + else if (MessageManager.getString(DOM_SCORE_KEY).equals(name)) { - args.add("--incdomT"); - args.add(arg.getValue()); + domScoreCutoff = arg.getValue(); } - else if (MessageManager.getString("label.trim_termini") + else if (MessageManager.getString(TRIM_TERMINI_KEY) .equals(name)) { trim = true; } - else if (MessageManager.getString("label.database").equals(name)) + else if (MessageManager.getString(DATABASE_KEY).equals(name)) { dbFound = true; dbPath = arg.getValue(); - if (!MessageManager.getString("label.this_alignment") + if (!MessageManager.getString(THIS_ALIGNMENT_KEY) .equals(dbPath)) { databaseFile = new File(dbPath); @@ -197,7 +241,22 @@ public class HMMSearch extends HmmerCommand } } - if (!dbFound || MessageManager.getString("label.this_alignment") + if (useEvalueCutoff) + { + args.add("-E"); + args.add(seqEvalueCutoff); + args.add("--domE"); + args.add(domEvalueCutoff); + } + else if (useScoreCutoff) + { + args.add("-T"); + args.add(seqScoreCutoff); + args.add("--domT"); + args.add(domScoreCutoff); + } + + if (!dbFound || MessageManager.getString(THIS_ALIGNMENT_KEY) .equals(dbPath)) { /* @@ -214,12 +273,6 @@ public class HMMSearch extends HmmerCommand copy.deleteSequence(hmmSeq); } exportStockholm(copy.getSequencesArray(), databaseFile, null); - // StockholmFile stoFile = new StockholmFile(copy); - // stoFile.setSeqs(copy.getSequencesArray()); - // String alignmentString = stoFile.print(); - // PrintWriter writer = new PrintWriter(databaseFile); - // writer.print(alignmentString); - // writer.close(); } args.add(getFilePath(hmmFile)); @@ -273,7 +326,7 @@ public class HMMSearch extends HmmerCommand if (trim) { alignArgs.add(new BooleanOption( - MessageManager.getString("label.trim_termini"), + MessageManager.getString(TRIM_TERMINI_KEY), MessageManager.getString("label.trim_termini_desc"), true, true, true, null)); } diff --git a/src/jalview/io/HMMFile.java b/src/jalview/io/HMMFile.java index 2a17915..07f29c8 100644 --- a/src/jalview/io/HMMFile.java +++ b/src/jalview/io/HMMFile.java @@ -140,7 +140,6 @@ public class HMMFile extends AlignFile * Constructor for HMMFile used for exporting * * @param hmm - * @param exportImmediately */ public HMMFile(HiddenMarkovModel markov) { diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 9bcaa5a..a30be66 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -29,6 +29,7 @@ import jalview.fts.service.pdb.PDBFTSRestClient; import jalview.gui.AlignmentPanel; import jalview.gui.Desktop; import jalview.gui.JvSwingUtils; +import jalview.gui.StructureViewer; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -36,6 +37,7 @@ import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; @@ -70,6 +72,8 @@ import javax.swing.event.DocumentListener; import javax.swing.event.InternalFrameEvent; import javax.swing.table.TableColumn; +import net.miginfocom.swing.MigLayout; + @SuppressWarnings("serial") /** * GUI layout for structure chooser @@ -80,12 +84,23 @@ import javax.swing.table.TableColumn; public abstract class GStructureChooser extends JPanel implements ItemListener { + private static final Font VERDANA_12 = new Font("Verdana", 0, 12); + + protected static final String VIEWS_FILTER = "VIEWS_FILTER"; + + protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE"; + + protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID"; + + /* + * 'cached' structure view + */ + protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB"; + protected JPanel statusPanel = new JPanel(); public JLabel statusBar = new JLabel(); - private JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout()); - protected String frameTitle = MessageManager .getString("label.structure_chooser"); @@ -97,41 +112,22 @@ public abstract class GStructureChooser extends JPanel protected StringBuilder errorWarning = new StringBuilder(); - protected JLabel lbl_result = new JLabel( - MessageManager.getString("label.select")); - - protected JButton btn_view = new JButton(); + protected JButton btn_add; - protected JButton btn_cancel = new JButton(); + protected JButton btn_newView; protected JButton btn_pdbFromFile = new JButton(); - protected JTextField txt_search = new JTextField(14); - - private JPanel pnl_actions = new JPanel(); - - private JPanel pnl_main = new JPanel(); - - private JPanel pnl_idInput = new JPanel(new FlowLayout()); + protected JCheckBox chk_superpose = new JCheckBox( + MessageManager.getString("label.superpose_structures")); - private JPanel pnl_fileChooser = new JPanel(new FlowLayout()); - - private JPanel pnl_idInputBL = new JPanel(new BorderLayout()); - - private JPanel pnl_fileChooserBL = new JPanel(new BorderLayout()); - - private JPanel pnl_locPDB = new JPanel(new BorderLayout()); + protected JTextField txt_search = new JTextField(14); protected JPanel pnl_switchableViews = new JPanel(new CardLayout()); protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews .getLayout()); - private BorderLayout mainLayout = new BorderLayout(); - - protected JCheckBox chk_rememberSettings = new JCheckBox( - MessageManager.getString("label.dont_ask_me_again")); - protected JCheckBox chk_invertFilter = new JCheckBox( MessageManager.getString("label.invert")); @@ -147,33 +143,20 @@ public abstract class GStructureChooser extends JPanel protected ImageIcon warningImage = new ImageIcon( getClass().getResource("/images/warning.gif")); - protected JLabel lbl_warning = new JLabel(warningImage); - protected JLabel lbl_loading = new JLabel(loadingImage); protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage); protected JLabel lbl_fromFileStatus = new JLabel(errorImage); - protected AssciateSeqPanel idInputAssSeqPanel = new AssciateSeqPanel(); - - protected AssciateSeqPanel fileChooserAssSeqPanel = new AssciateSeqPanel(); - - protected static final String VIEWS_FILTER = "VIEWS_FILTER"; + protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel(); - protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE"; + protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel(); - protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID"; - - /** - * 'cached' structure view - */ - protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB"; + protected JComboBox targetView = new JComboBox<>(); protected JTable tbl_local_pdb = new JTable(); - protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb); - protected JTabbedPane pnl_filter = new JTabbedPane(); protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences( @@ -262,8 +245,6 @@ public abstract class GStructureChooser extends JPanel } }; - protected JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary); - public GStructureChooser() { try @@ -319,9 +300,9 @@ public abstract class GStructureChooser extends JPanel mainFrame.dispose(); break; case KeyEvent.VK_ENTER: // enter key - if (btn_view.isEnabled()) + if (btn_add.isEnabled()) { - ok_ActionPerformed(); + add_ActionPerformed(); } break; case KeyEvent.VK_TAB: // tab key @@ -331,7 +312,7 @@ public abstract class GStructureChooser extends JPanel } else { - btn_view.requestFocus(); + btn_add.requestFocus(); } evt.consume(); break; @@ -340,6 +321,30 @@ public abstract class GStructureChooser extends JPanel } } }); + + JButton btn_cancel = new JButton( + MessageManager.getString("action.cancel")); + btn_cancel.setFont(VERDANA_12); + btn_cancel.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + closeAction(pnl_filter.getHeight()); + } + }); + btn_cancel.addKeyListener(new KeyAdapter() + { + @Override + public void keyPressed(KeyEvent evt) + { + if (evt.getKeyCode() == KeyEvent.VK_ENTER) + { + closeAction(pnl_filter.getHeight()); + } + } + }); + tbl_local_pdb.setAutoCreateRowSorter(true); tbl_local_pdb.getTableHeader().setReorderingAllowed(false); tbl_local_pdb.addMouseListener(new MouseAdapter() @@ -368,9 +373,9 @@ public abstract class GStructureChooser extends JPanel mainFrame.dispose(); break; case KeyEvent.VK_ENTER: // enter key - if (btn_view.isEnabled()) + if (btn_add.isEnabled()) { - ok_ActionPerformed(); + add_ActionPerformed(); } break; case KeyEvent.VK_TAB: // tab key @@ -380,9 +385,9 @@ public abstract class GStructureChooser extends JPanel } else { - if (btn_view.isEnabled()) + if (btn_add.isEnabled()) { - btn_view.requestFocus(); + btn_add.requestFocus(); } else { @@ -396,51 +401,52 @@ public abstract class GStructureChooser extends JPanel } } }); - btn_view.setFont(new java.awt.Font("Verdana", 0, 12)); - btn_view.setText(MessageManager.getString("action.view")); - btn_view.addActionListener(new java.awt.event.ActionListener() + + btn_newView = new JButton(MessageManager.getString("action.new_view")); + btn_newView.setFont(VERDANA_12); + btn_newView.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { - ok_ActionPerformed(); + newView_ActionPerformed(); } }); - btn_view.addKeyListener(new KeyAdapter() + btn_newView.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { - ok_ActionPerformed(); + newView_ActionPerformed(); } } }); - btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12)); - btn_cancel.setText(MessageManager.getString("action.cancel")); - btn_cancel.addActionListener(new java.awt.event.ActionListener() + btn_add = new JButton(MessageManager.getString("action.add")); + btn_add.setFont(VERDANA_12); + btn_add.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { - closeAction(pnl_filter.getHeight()); + add_ActionPerformed(); } }); - btn_cancel.addKeyListener(new KeyAdapter() + btn_add.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { - closeAction(pnl_filter.getHeight()); + add_ActionPerformed(); } } }); - btn_pdbFromFile.setFont(new java.awt.Font("Verdana", 0, 12)); + btn_pdbFromFile.setFont(VERDANA_12); String btn_title = MessageManager.getString("label.select_pdb_file"); btn_pdbFromFile.setText(btn_title + " "); btn_pdbFromFile.addActionListener(new java.awt.event.ActionListener() @@ -463,20 +469,17 @@ public abstract class GStructureChooser extends JPanel } }); + JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary); scrl_foundStructures.setPreferredSize(new Dimension(width, height)); + JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb); scrl_localPDB.setPreferredSize(new Dimension(width, height)); scrl_localPDB.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - cmb_filterOption.setFont(new java.awt.Font("Verdana", 0, 12)); - chk_invertFilter.setFont(new java.awt.Font("Verdana", 0, 12)); - chk_rememberSettings.setFont(new java.awt.Font("Verdana", 0, 12)); - chk_rememberSettings.setVisible(false); + chk_invertFilter.setFont(VERDANA_12); txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.enter_pdb_id_tip"))); - cmb_filterOption.setToolTipText( - MessageManager.getString("info.select_filter_option")); txt_search.getDocument().addDocumentListener(new DocumentListener() { @Override @@ -498,8 +501,10 @@ public abstract class GStructureChooser extends JPanel } }); + cmb_filterOption.setFont(VERDANA_12); + cmb_filterOption.setToolTipText( + MessageManager.getString("info.select_filter_option")); cmb_filterOption.addItemListener(this); - // add CustomComboSeparatorsRenderer to filter option combo-box cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer( (ListCellRenderer) cmb_filterOption.getRenderer()) @@ -514,23 +519,33 @@ public abstract class GStructureChooser extends JPanel chk_invertFilter.addItemListener(this); - pnl_actions.add(chk_rememberSettings); - pnl_actions.add(btn_view); - pnl_actions.add(btn_cancel); + targetView.setVisible(false); - // pnl_filter.add(lbl_result); + JPanel actionsPanel = new JPanel(new MigLayout()); + actionsPanel.add(targetView, "left"); + actionsPanel.add(btn_add, "wrap"); + actionsPanel.add(chk_superpose, "left"); + actionsPanel.add(btn_newView); + actionsPanel.add(btn_cancel, "right"); + + JPanel pnl_main = new JPanel(); pnl_main.add(cmb_filterOption); pnl_main.add(lbl_loading); pnl_main.add(chk_invertFilter); lbl_loading.setVisible(false); + JPanel pnl_fileChooser = new JPanel(new FlowLayout()); pnl_fileChooser.add(btn_pdbFromFile); pnl_fileChooser.add(lbl_fromFileStatus); + JPanel pnl_fileChooserBL = new JPanel(new BorderLayout()); pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.NORTH); pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER); + JPanel pnl_idInput = new JPanel(new FlowLayout()); pnl_idInput.add(txt_search); pnl_idInput.add(lbl_pdbManualFetchStatus); + + JPanel pnl_idInputBL = new JPanel(new BorderLayout()); pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH); pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER); @@ -546,13 +561,15 @@ public abstract class GStructureChooser extends JPanel JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent .getSource(); int index = sourceTabbedPane.getSelectedIndex(); - btn_view.setVisible(true); + btn_add.setVisible(targetView.isVisible()); + btn_newView.setVisible(true); btn_cancel.setVisible(true); if (sourceTabbedPane.getTitleAt(index).equals(configureCols)) { - btn_view.setEnabled(false); + btn_add.setEnabled(false); btn_cancel.setEnabled(false); - btn_view.setVisible(false); + btn_add.setVisible(false); + btn_newView.setEnabled(false); btn_cancel.setVisible(false); previousWantedFields = pdbDocFieldPrefs .getStructureSummaryFields() @@ -578,6 +595,7 @@ public abstract class GStructureChooser extends JPanel pnl_filter.add(foundStructureSummary, scrl_foundStructures); pnl_filter.add(configureCols, pdbDocFieldPrefs); + JPanel pnl_locPDB = new JPanel(new BorderLayout()); pnl_locPDB.add(scrl_localPDB); pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE); @@ -585,12 +603,14 @@ public abstract class GStructureChooser extends JPanel pnl_switchableViews.add(pnl_filter, VIEWS_FILTER); pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB); - this.setLayout(mainLayout); + this.setLayout(new BorderLayout()); this.add(pnl_main, java.awt.BorderLayout.NORTH); this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER); // this.add(pnl_actions, java.awt.BorderLayout.SOUTH); statusPanel.setLayout(new GridLayout()); - pnl_actionsAndStatus.add(pnl_actions, BorderLayout.CENTER); + + JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout()); + pnl_actionsAndStatus.add(actionsPanel, BorderLayout.CENTER); pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH); statusPanel.add(statusBar, null); this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH); @@ -801,13 +821,13 @@ public abstract class GStructureChooser extends JPanel * @author tcnofoegbu * */ - public class AssciateSeqPanel extends JPanel implements ItemListener + public class AssociateSeqPanel extends JPanel implements ItemListener { private JComboBox cmb_assSeq = new JComboBox<>(); private JLabel lbl_associateSeq = new JLabel(); - public AssciateSeqPanel() + public AssociateSeqPanel() { this.setLayout(new FlowLayout()); this.add(cmb_assSeq); @@ -901,19 +921,21 @@ public abstract class GStructureChooser extends JPanel protected abstract void stateChanged(ItemEvent e); - protected abstract void ok_ActionPerformed(); + protected abstract void add_ActionPerformed(); + + protected abstract void newView_ActionPerformed(); protected abstract void pdbFromFile_actionPerformed(); protected abstract void txt_search_ActionPerformed(); - public abstract void populateCmbAssociateSeqOptions( + protected abstract void populateCmbAssociateSeqOptions( JComboBox cmb_assSeq, JLabel lbl_associateSeq); - public abstract void cmbAssSeqStateChanged(); + protected abstract void cmbAssSeqStateChanged(); - public abstract void tabRefresh(); + protected abstract void tabRefresh(); - public abstract void validateSelections(); + protected abstract void validateSelections(); } \ No newline at end of file diff --git a/src/jalview/schemabinding/version2/JSeq.java b/src/jalview/schemabinding/version2/JSeq.java index 7c6308e..8414e28 100644 --- a/src/jalview/schemabinding/version2/JSeq.java +++ b/src/jalview/schemabinding/version2/JSeq.java @@ -7,8 +7,8 @@ package jalview.schemabinding.version2; -//---------------------------------/ -//- Imported classes and packages -/ + //---------------------------------/ + //- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,1079 +19,1048 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class JSeq implements java.io.Serializable -{ - - // --------------------------/ - // - Class/Member Variables -/ - // --------------------------/ - - /** - * Field _colour. - */ - private int _colour; - - /** - * keeps track of state for field: _colour - */ - private boolean _has_colour; - - /** - * Field _start. - */ - private int _start; - - /** - * keeps track of state for field: _start - */ - private boolean _has_start; - - /** - * Field _end. - */ - private int _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - /** - * Field _id. - */ - private java.lang.String _id; - - /** - * Field _hidden. - */ - private boolean _hidden; - - /** - * keeps track of state for field: _hidden - */ - private boolean _has_hidden; - - /** - * Field _viewreference. - */ - private boolean _viewreference; - - /** - * keeps track of state for field: _viewreference - */ - private boolean _has_viewreference; - - /** - * Field _featuresList. - */ - private java.util.Vector _featuresList; - - /** - * Field _pdbidsList. - */ - private java.util.Vector _pdbidsList; - - /** - * Field _hiddenSequencesList. - */ - private java.util.Vector _hiddenSequencesList; - - /** - * Reference to a viewer showing RNA structure for this sequence. Schema - * supports one viewer showing multiple annotations for multiple sequences, - * though currently only one annotation for one sequence (gapped or trimmed) - * is used - * - */ - private java.util.Vector _rnaViewerList; - - // ----------------/ - // - Constructors -/ - // ----------------/ - - public JSeq() - { - super(); - this._featuresList = new java.util.Vector(); - this._pdbidsList = new java.util.Vector(); - this._hiddenSequencesList = new java.util.Vector(); - this._rnaViewerList = new java.util.Vector(); - } - - // -----------/ - // - Methods -/ - // -----------/ - - /** - * - * - * @param vFeatures - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addFeatures( - final jalview.schemabinding.version2.Features vFeatures) - throws java.lang.IndexOutOfBoundsException - { - this._featuresList.addElement(vFeatures); - } - - /** - * - * - * @param index - * @param vFeatures - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addFeatures(final int index, - final jalview.schemabinding.version2.Features vFeatures) - throws java.lang.IndexOutOfBoundsException - { - this._featuresList.add(index, vFeatures); - } - - /** - * - * - * @param vHiddenSequences - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addHiddenSequences(final int vHiddenSequences) - throws java.lang.IndexOutOfBoundsException - { - this._hiddenSequencesList.addElement(new java.lang.Integer( - vHiddenSequences)); - } - - /** - * - * - * @param index - * @param vHiddenSequences - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addHiddenSequences(final int index, final int vHiddenSequences) - throws java.lang.IndexOutOfBoundsException - { - this._hiddenSequencesList.add(index, new java.lang.Integer( - vHiddenSequences)); - } - - /** - * - * - * @param vPdbids - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids) - throws java.lang.IndexOutOfBoundsException - { - this._pdbidsList.addElement(vPdbids); - } - - /** - * - * - * @param index - * @param vPdbids - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addPdbids(final int index, - final jalview.schemabinding.version2.Pdbids vPdbids) - throws java.lang.IndexOutOfBoundsException - { - this._pdbidsList.add(index, vPdbids); - } - - /** - * - * - * @param vRnaViewer - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addRnaViewer( - final jalview.schemabinding.version2.RnaViewer vRnaViewer) - throws java.lang.IndexOutOfBoundsException - { - this._rnaViewerList.addElement(vRnaViewer); - } - - /** - * - * - * @param index - * @param vRnaViewer - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void addRnaViewer(final int index, - final jalview.schemabinding.version2.RnaViewer vRnaViewer) - throws java.lang.IndexOutOfBoundsException - { - this._rnaViewerList.add(index, vRnaViewer); - } - - /** - */ - public void deleteColour() - { - this._has_colour = false; - } - - /** - */ - public void deleteEnd() - { - this._has_end = false; - } - - /** - */ - public void deleteHidden() - { - this._has_hidden = false; - } - - /** - */ - public void deleteStart() - { - this._has_start = false; - } - - /** - */ - public void deleteViewreference() - { - this._has_viewreference = false; - } - - /** - * Method enumerateFeatures. - * - * @return an Enumeration over all jalview.schemabinding.version2.Features - * elements - */ - public java.util.Enumeration enumerateFeatures() - { - return this._featuresList.elements(); - } - - /** - * Method enumerateHiddenSequences. - * - * @return an Enumeration over all int elements - */ - public java.util.Enumeration enumerateHiddenSequences() - { - return this._hiddenSequencesList.elements(); - } - - /** - * Method enumeratePdbids. - * - * @return an Enumeration over all jalview.schemabinding.version2.Pdbids - * elements - */ - public java.util.Enumeration enumeratePdbids() - { - return this._pdbidsList.elements(); - } - - /** - * Method enumerateRnaViewer. - * - * @return an Enumeration over all jalview.schemabinding.version2.RnaViewer - * elements - */ - public java.util.Enumeration enumerateRnaViewer() - { - return this._rnaViewerList.elements(); - } - - /** - * Returns the value of field 'colour'. - * - * @return the value of field 'Colour'. - */ - public int getColour() - { - return this._colour; - } - - /** - * Returns the value of field 'end'. - * - * @return the value of field 'End'. - */ - public int getEnd() - { - return this._end; - } - - /** - * Method getFeatures. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - * @return the value of the jalview.schemabinding.version2.Features at the - * given index - */ - public jalview.schemabinding.version2.Features getFeatures(final int index) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._featuresList.size()) - { - throw new IndexOutOfBoundsException("getFeatures: Index value '" - + index + "' not in range [0.." - + (this._featuresList.size() - 1) + "]"); - } - - return (jalview.schemabinding.version2.Features) _featuresList - .get(index); - } - - /** - * Method getFeatures.Returns the contents of the collection in an Array. - *

      - * Note: Just in case the collection contents are changing in another thread, - * we pass a 0-length Array of the correct type into the API call. This way we - * know that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.schemabinding.version2.Features[] getFeatures() - { - jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0]; - return (jalview.schemabinding.version2.Features[]) this._featuresList - .toArray(array); - } - - /** - * Method getFeaturesCount. - * - * @return the size of this collection - */ - public int getFeaturesCount() - { - return this._featuresList.size(); - } - - /** - * Returns the value of field 'hidden'. - * - * @return the value of field 'Hidden'. - */ - public boolean getHidden() - { - return this._hidden; - } - - /** - * Method getHiddenSequences. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - * @return the value of the int at the given index - */ - public int getHiddenSequences(final int index) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._hiddenSequencesList.size()) - { - throw new IndexOutOfBoundsException( - "getHiddenSequences: Index value '" + index - + "' not in range [0.." - + (this._hiddenSequencesList.size() - 1) + "]"); - } - - return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue(); - } - - /** - * Method getHiddenSequences.Returns the contents of the collection in an - * Array. - * - * @return this collection as an Array - */ - public int[] getHiddenSequences() - { - int size = this._hiddenSequencesList.size(); - int[] array = new int[size]; - java.util.Iterator iter = _hiddenSequencesList.iterator(); - for (int index = 0; index < size; index++) - { - array[index] = ((java.lang.Integer) iter.next()).intValue(); - } - return array; - } - - /** - * Method getHiddenSequencesCount. - * - * @return the size of this collection - */ - public int getHiddenSequencesCount() - { - return this._hiddenSequencesList.size(); - } - - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public java.lang.String getId() - { - return this._id; - } - - /** - * Method getPdbids. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - * @return the value of the jalview.schemabinding.version2.Pdbids at the given - * index - */ - public jalview.schemabinding.version2.Pdbids getPdbids(final int index) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._pdbidsList.size()) - { - throw new IndexOutOfBoundsException("getPdbids: Index value '" - + index + "' not in range [0.." - + (this._pdbidsList.size() - 1) + "]"); - } - - return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index); - } - - /** - * Method getPdbids.Returns the contents of the collection in an Array. - *

      - * Note: Just in case the collection contents are changing in another thread, - * we pass a 0-length Array of the correct type into the API call. This way we - * know that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.schemabinding.version2.Pdbids[] getPdbids() - { - jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0]; - return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList - .toArray(array); - } - - /** - * Method getPdbidsCount. - * - * @return the size of this collection - */ - public int getPdbidsCount() - { - return this._pdbidsList.size(); - } - - /** - * Method getRnaViewer. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - * @return the value of the jalview.schemabinding.version2.RnaViewer at the - * given index - */ - public jalview.schemabinding.version2.RnaViewer getRnaViewer( - final int index) throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._rnaViewerList.size()) - { - throw new IndexOutOfBoundsException("getRnaViewer: Index value '" - + index + "' not in range [0.." - + (this._rnaViewerList.size() - 1) + "]"); - } - - return (jalview.schemabinding.version2.RnaViewer) _rnaViewerList - .get(index); - } - - /** - * Method getRnaViewer.Returns the contents of the collection in an Array. - *

      - * Note: Just in case the collection contents are changing in another thread, - * we pass a 0-length Array of the correct type into the API call. This way we - * know that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.schemabinding.version2.RnaViewer[] getRnaViewer() - { - jalview.schemabinding.version2.RnaViewer[] array = new jalview.schemabinding.version2.RnaViewer[0]; - return (jalview.schemabinding.version2.RnaViewer[]) this._rnaViewerList - .toArray(array); - } - - /** - * Method getRnaViewerCount. - * - * @return the size of this collection - */ - public int getRnaViewerCount() - { - return this._rnaViewerList.size(); - } - - /** - * Returns the value of field 'start'. - * - * @return the value of field 'Start'. - */ - public int getStart() - { - return this._start; - } - - /** - * Returns the value of field 'viewreference'. - * - * @return the value of field 'Viewreference'. - */ - public boolean getViewreference() - { - return this._viewreference; - } - - /** - * Method hasColour. - * - * @return true if at least one Colour has been added - */ - public boolean hasColour() - { - return this._has_colour; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd() - { - return this._has_end; - } - - /** - * Method hasHidden. - * - * @return true if at least one Hidden has been added - */ - public boolean hasHidden() - { - return this._has_hidden; - } - - /** - * Method hasStart. - * - * @return true if at least one Start has been added - */ - public boolean hasStart() - { - return this._has_start; - } - - /** - * Method hasViewreference. - * - * @return true if at least one Viewreference has been added - */ - public boolean hasViewreference() - { - return this._has_viewreference; - } - - /** - * Returns the value of field 'hidden'. - * - * @return the value of field 'Hidden'. - */ - public boolean isHidden() - { - return this._hidden; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid() - { - try - { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) - { - return false; - } - return true; - } - - /** - * Returns the value of field 'viewreference'. - * - * @return the value of field 'Viewreference'. - */ - public boolean isViewreference() - { - return this._viewreference; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException - * if object is null or if any SAXException is thrown during - * marshaling - * @throws org.exolab.castor.xml.ValidationException - * if this object is an invalid instance according to the schema - */ - public void marshal(final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, - org.exolab.castor.xml.ValidationException - { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException - * if an IOException occurs during marshaling - * @throws org.exolab.castor.xml.ValidationException - * if this object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException - * if object is null or if any SAXException is thrown during - * marshaling - */ - public void marshal(final org.xml.sax.ContentHandler handler) - throws java.io.IOException, - org.exolab.castor.xml.MarshalException, - org.exolab.castor.xml.ValidationException - { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllFeatures() - { - this._featuresList.clear(); - } - - /** - */ - public void removeAllHiddenSequences() - { - this._hiddenSequencesList.clear(); - } - - /** - */ - public void removeAllPdbids() - { - this._pdbidsList.clear(); - } - - /** - */ - public void removeAllRnaViewer() - { - this._rnaViewerList.clear(); - } - - /** - * Method removeFeatures. - * - * @param vFeatures - * @return true if the object was removed from the collection. - */ - public boolean removeFeatures( - final jalview.schemabinding.version2.Features vFeatures) - { - boolean removed = _featuresList.remove(vFeatures); - return removed; - } - - /** - * Method removeFeaturesAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.schemabinding.version2.Features removeFeaturesAt( - final int index) - { - java.lang.Object obj = this._featuresList.remove(index); - return (jalview.schemabinding.version2.Features) obj; - } - - /** - * Method removeHiddenSequences. - * - * @param vHiddenSequences - * @return true if the object was removed from the collection. - */ - public boolean removeHiddenSequences(final int vHiddenSequences) - { - boolean removed = _hiddenSequencesList.remove(new java.lang.Integer( - vHiddenSequences)); - return removed; - } - - /** - * Method removeHiddenSequencesAt. - * - * @param index - * @return the element removed from the collection - */ - public int removeHiddenSequencesAt(final int index) - { - java.lang.Object obj = this._hiddenSequencesList.remove(index); - return ((java.lang.Integer) obj).intValue(); - } - - /** - * Method removePdbids. - * - * @param vPdbids - * @return true if the object was removed from the collection. - */ - public boolean removePdbids( - final jalview.schemabinding.version2.Pdbids vPdbids) - { - boolean removed = _pdbidsList.remove(vPdbids); - return removed; - } - - /** - * Method removePdbidsAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.schemabinding.version2.Pdbids removePdbidsAt( - final int index) - { - java.lang.Object obj = this._pdbidsList.remove(index); - return (jalview.schemabinding.version2.Pdbids) obj; - } - - /** - * Method removeRnaViewer. - * - * @param vRnaViewer - * @return true if the object was removed from the collection. - */ - public boolean removeRnaViewer( - final jalview.schemabinding.version2.RnaViewer vRnaViewer) - { - boolean removed = _rnaViewerList.remove(vRnaViewer); - return removed; - } - - /** - * Method removeRnaViewerAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.schemabinding.version2.RnaViewer removeRnaViewerAt( - final int index) - { - java.lang.Object obj = this._rnaViewerList.remove(index); - return (jalview.schemabinding.version2.RnaViewer) obj; - } - - /** - * Sets the value of field 'colour'. - * - * @param colour - * the value of field 'colour'. - */ - public void setColour(final int colour) - { - this._colour = colour; - this._has_colour = true; - } - - /** - * Sets the value of field 'end'. - * - * @param end - * the value of field 'end'. - */ - public void setEnd(final int end) - { - this._end = end; - this._has_end = true; - } - - /** - * - * - * @param index - * @param vFeatures - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void setFeatures(final int index, - final jalview.schemabinding.version2.Features vFeatures) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._featuresList.size()) - { - throw new IndexOutOfBoundsException("setFeatures: Index value '" - + index + "' not in range [0.." - + (this._featuresList.size() - 1) + "]"); - } - - this._featuresList.set(index, vFeatures); - } - - /** - * - * - * @param vFeaturesArray - */ - public void setFeatures( - final jalview.schemabinding.version2.Features[] vFeaturesArray) - { - // -- copy array - _featuresList.clear(); - - for (int i = 0; i < vFeaturesArray.length; i++) - { - this._featuresList.add(vFeaturesArray[i]); - } - } - - /** - * Sets the value of field 'hidden'. - * - * @param hidden - * the value of field 'hidden'. - */ - public void setHidden(final boolean hidden) - { - this._hidden = hidden; - this._has_hidden = true; - } - - /** - * - * - * @param index - * @param vHiddenSequences - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void setHiddenSequences(final int index, final int vHiddenSequences) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._hiddenSequencesList.size()) - { - throw new IndexOutOfBoundsException( - "setHiddenSequences: Index value '" + index - + "' not in range [0.." - + (this._hiddenSequencesList.size() - 1) + "]"); - } - - this._hiddenSequencesList.set(index, new java.lang.Integer( - vHiddenSequences)); - } - - /** - * - * - * @param vHiddenSequencesArray - */ - public void setHiddenSequences(final int[] vHiddenSequencesArray) - { - // -- copy array - _hiddenSequencesList.clear(); - - for (int i = 0; i < vHiddenSequencesArray.length; i++) - { - this._hiddenSequencesList.add(new java.lang.Integer( - vHiddenSequencesArray[i])); - } - } - - /** - * Sets the value of field 'id'. - * - * @param id - * the value of field 'id'. - */ - public void setId(final java.lang.String id) - { - this._id = id; - } - - /** - * - * - * @param index - * @param vPdbids - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void setPdbids(final int index, - final jalview.schemabinding.version2.Pdbids vPdbids) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._pdbidsList.size()) - { - throw new IndexOutOfBoundsException("setPdbids: Index value '" - + index + "' not in range [0.." - + (this._pdbidsList.size() - 1) + "]"); - } - - this._pdbidsList.set(index, vPdbids); - } - - /** - * - * - * @param vPdbidsArray - */ - public void setPdbids( - final jalview.schemabinding.version2.Pdbids[] vPdbidsArray) - { - // -- copy array - _pdbidsList.clear(); - - for (int i = 0; i < vPdbidsArray.length; i++) - { - this._pdbidsList.add(vPdbidsArray[i]); - } - } - - /** - * - * - * @param index - * @param vRnaViewer - * @throws java.lang.IndexOutOfBoundsException - * if the index given is outside the bounds of the collection - */ - public void setRnaViewer(final int index, - final jalview.schemabinding.version2.RnaViewer vRnaViewer) - throws java.lang.IndexOutOfBoundsException - { - // check bounds for index - if (index < 0 || index >= this._rnaViewerList.size()) - { - throw new IndexOutOfBoundsException("setRnaViewer: Index value '" - + index + "' not in range [0.." - + (this._rnaViewerList.size() - 1) + "]"); - } - - this._rnaViewerList.set(index, vRnaViewer); - } - - /** - * - * - * @param vRnaViewerArray - */ - public void setRnaViewer( - final jalview.schemabinding.version2.RnaViewer[] vRnaViewerArray) - { - // -- copy array - _rnaViewerList.clear(); - - for (int i = 0; i < vRnaViewerArray.length; i++) - { - this._rnaViewerList.add(vRnaViewerArray[i]); - } - } - - /** - * Sets the value of field 'start'. - * - * @param start - * the value of field 'start'. - */ - public void setStart(final int start) - { - this._start = start; - this._has_start = true; - } - - /** - * Sets the value of field 'viewreference'. - * - * @param viewreference - * the value of field 'viewreference'. - */ - public void setViewreference(final boolean viewreference) - { - this._viewreference = viewreference; - this._has_viewreference = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException - * if object is null or if any SAXException is thrown during - * marshaling - * @throws org.exolab.castor.xml.ValidationException - * if this object is an invalid instance according to the schema - * @return the unmarshaled jalview.schemabinding.version2.JSeq - */ - public static jalview.schemabinding.version2.JSeq unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, - org.exolab.castor.xml.ValidationException - { - return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal( - jalview.schemabinding.version2.JSeq.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException - * if this object is an invalid instance according to the schema - */ - public void validate() throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class JSeq implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _colour. + */ + private int _colour; + + /** + * keeps track of state for field: _colour + */ + private boolean _has_colour; + + /** + * Field _start. + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end. + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _id. + */ + private java.lang.String _id; + + /** + * Field _hidden. + */ + private boolean _hidden; + + /** + * keeps track of state for field: _hidden + */ + private boolean _has_hidden; + + /** + * Field _viewreference. + */ + private boolean _viewreference; + + /** + * keeps track of state for field: _viewreference + */ + private boolean _has_viewreference; + + /** + * Field _featuresList. + */ + private java.util.Vector _featuresList; + + /** + * Field _pdbidsList. + */ + private java.util.Vector _pdbidsList; + + /** + * Field _hiddenSequencesList. + */ + private java.util.Vector _hiddenSequencesList; + + /** + * Reference to a viewer showing RNA structure + * for this sequence. Schema supports one viewer showing + * multiple + * annotations for multiple sequences, though currently only + * one + * annotation for one sequence (gapped or trimmed) is used + * + */ + private java.util.Vector _rnaViewerList; + + /** + * name of the project jar entry that holds the HMM file with + * the profile for the sequence + */ + private java.lang.String _hmmerProfile; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public JSeq() { + super(); + this._featuresList = new java.util.Vector(); + this._pdbidsList = new java.util.Vector(); + this._hiddenSequencesList = new java.util.Vector(); + this._rnaViewerList = new java.util.Vector(); + } + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * + * + * @param vFeatures + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addFeatures( + final jalview.schemabinding.version2.Features vFeatures) + throws java.lang.IndexOutOfBoundsException { + this._featuresList.addElement(vFeatures); + } + + /** + * + * + * @param index + * @param vFeatures + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addFeatures( + final int index, + final jalview.schemabinding.version2.Features vFeatures) + throws java.lang.IndexOutOfBoundsException { + this._featuresList.add(index, vFeatures); + } + + /** + * + * + * @param vHiddenSequences + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addHiddenSequences( + final int vHiddenSequences) + throws java.lang.IndexOutOfBoundsException { + this._hiddenSequencesList.addElement(new java.lang.Integer(vHiddenSequences)); + } + + /** + * + * + * @param index + * @param vHiddenSequences + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addHiddenSequences( + final int index, + final int vHiddenSequences) + throws java.lang.IndexOutOfBoundsException { + this._hiddenSequencesList.add(index, new java.lang.Integer(vHiddenSequences)); + } + + /** + * + * + * @param vPdbids + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addPdbids( + final jalview.schemabinding.version2.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException { + this._pdbidsList.addElement(vPdbids); + } + + /** + * + * + * @param index + * @param vPdbids + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addPdbids( + final int index, + final jalview.schemabinding.version2.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException { + this._pdbidsList.add(index, vPdbids); + } + + /** + * + * + * @param vRnaViewer + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addRnaViewer( + final jalview.schemabinding.version2.RnaViewer vRnaViewer) + throws java.lang.IndexOutOfBoundsException { + this._rnaViewerList.addElement(vRnaViewer); + } + + /** + * + * + * @param index + * @param vRnaViewer + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addRnaViewer( + final int index, + final jalview.schemabinding.version2.RnaViewer vRnaViewer) + throws java.lang.IndexOutOfBoundsException { + this._rnaViewerList.add(index, vRnaViewer); + } + + /** + */ + public void deleteColour( + ) { + this._has_colour= false; + } + + /** + */ + public void deleteEnd( + ) { + this._has_end= false; + } + + /** + */ + public void deleteHidden( + ) { + this._has_hidden= false; + } + + /** + */ + public void deleteStart( + ) { + this._has_start= false; + } + + /** + */ + public void deleteViewreference( + ) { + this._has_viewreference= false; + } + + /** + * Method enumerateFeatures. + * + * @return an Enumeration over all + * jalview.schemabinding.version2.Features elements + */ + public java.util.Enumeration enumerateFeatures( + ) { + return this._featuresList.elements(); + } + + /** + * Method enumerateHiddenSequences. + * + * @return an Enumeration over all int elements + */ + public java.util.Enumeration enumerateHiddenSequences( + ) { + return this._hiddenSequencesList.elements(); + } + + /** + * Method enumeratePdbids. + * + * @return an Enumeration over all + * jalview.schemabinding.version2.Pdbids elements + */ + public java.util.Enumeration enumeratePdbids( + ) { + return this._pdbidsList.elements(); + } + + /** + * Method enumerateRnaViewer. + * + * @return an Enumeration over all + * jalview.schemabinding.version2.RnaViewer elements + */ + public java.util.Enumeration enumerateRnaViewer( + ) { + return this._rnaViewerList.elements(); + } + + /** + * Returns the value of field 'colour'. + * + * @return the value of field 'Colour'. + */ + public int getColour( + ) { + return this._colour; + } + + /** + * Returns the value of field 'end'. + * + * @return the value of field 'End'. + */ + public int getEnd( + ) { + return this._end; + } + + /** + * Method getFeatures. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + * @return the value of the + * jalview.schemabinding.version2.Features at the given index + */ + public jalview.schemabinding.version2.Features getFeatures( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._featuresList.size()) { + throw new IndexOutOfBoundsException("getFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]"); + } + + return (jalview.schemabinding.version2.Features) _featuresList.get(index); + } + + /** + * Method getFeatures.Returns the contents of the collection in + * an Array.

      Note: Just in case the collection contents + * are changing in another thread, we pass a 0-length Array of + * the correct type into the API call. This way we know + * that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.schemabinding.version2.Features[] getFeatures( + ) { + jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0]; + return (jalview.schemabinding.version2.Features[]) this._featuresList.toArray(array); + } + + /** + * Method getFeaturesCount. + * + * @return the size of this collection + */ + public int getFeaturesCount( + ) { + return this._featuresList.size(); + } + + /** + * Returns the value of field 'hidden'. + * + * @return the value of field 'Hidden'. + */ + public boolean getHidden( + ) { + return this._hidden; + } + + /** + * Method getHiddenSequences. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + * @return the value of the int at the given index + */ + public int getHiddenSequences( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._hiddenSequencesList.size()) { + throw new IndexOutOfBoundsException("getHiddenSequences: Index value '" + index + "' not in range [0.." + (this._hiddenSequencesList.size() - 1) + "]"); + } + + return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue(); + } + + /** + * Method getHiddenSequences.Returns the contents of the + * collection in an Array. + * + * @return this collection as an Array + */ + public int[] getHiddenSequences( + ) { + int size = this._hiddenSequencesList.size(); + int[] array = new int[size]; + java.util.Iterator iter = _hiddenSequencesList.iterator(); + for (int index = 0; index < size; index++) { + array[index] = ((java.lang.Integer) iter.next()).intValue(); + } + return array; + } + + /** + * Method getHiddenSequencesCount. + * + * @return the size of this collection + */ + public int getHiddenSequencesCount( + ) { + return this._hiddenSequencesList.size(); + } + + /** + * Returns the value of field 'hmmerProfile'. The field + * 'hmmerProfile' has the following description: name of the + * project jar entry that holds the HMM file with the profile + * for the sequence + * + * @return the value of field 'HmmerProfile'. + */ + public java.lang.String getHmmerProfile( + ) { + return this._hmmerProfile; + } + + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public java.lang.String getId( + ) { + return this._id; + } + + /** + * Method getPdbids. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + * @return the value of the + * jalview.schemabinding.version2.Pdbids at the given index + */ + public jalview.schemabinding.version2.Pdbids getPdbids( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._pdbidsList.size()) { + throw new IndexOutOfBoundsException("getPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]"); + } + + return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index); + } + + /** + * Method getPdbids.Returns the contents of the collection in + * an Array.

      Note: Just in case the collection contents + * are changing in another thread, we pass a 0-length Array of + * the correct type into the API call. This way we know + * that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.schemabinding.version2.Pdbids[] getPdbids( + ) { + jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0]; + return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList.toArray(array); + } + + /** + * Method getPdbidsCount. + * + * @return the size of this collection + */ + public int getPdbidsCount( + ) { + return this._pdbidsList.size(); + } + + /** + * Method getRnaViewer. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + * @return the value of the + * jalview.schemabinding.version2.RnaViewer at the given index + */ + public jalview.schemabinding.version2.RnaViewer getRnaViewer( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._rnaViewerList.size()) { + throw new IndexOutOfBoundsException("getRnaViewer: Index value '" + index + "' not in range [0.." + (this._rnaViewerList.size() - 1) + "]"); + } + + return (jalview.schemabinding.version2.RnaViewer) _rnaViewerList.get(index); + } + + /** + * Method getRnaViewer.Returns the contents of the collection + * in an Array.

      Note: Just in case the collection contents + * are changing in another thread, we pass a 0-length Array of + * the correct type into the API call. This way we know + * that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.schemabinding.version2.RnaViewer[] getRnaViewer( + ) { + jalview.schemabinding.version2.RnaViewer[] array = new jalview.schemabinding.version2.RnaViewer[0]; + return (jalview.schemabinding.version2.RnaViewer[]) this._rnaViewerList.toArray(array); + } + + /** + * Method getRnaViewerCount. + * + * @return the size of this collection + */ + public int getRnaViewerCount( + ) { + return this._rnaViewerList.size(); + } + + /** + * Returns the value of field 'start'. + * + * @return the value of field 'Start'. + */ + public int getStart( + ) { + return this._start; + } + + /** + * Returns the value of field 'viewreference'. + * + * @return the value of field 'Viewreference'. + */ + public boolean getViewreference( + ) { + return this._viewreference; + } + + /** + * Method hasColour. + * + * @return true if at least one Colour has been added + */ + public boolean hasColour( + ) { + return this._has_colour; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd( + ) { + return this._has_end; + } + + /** + * Method hasHidden. + * + * @return true if at least one Hidden has been added + */ + public boolean hasHidden( + ) { + return this._has_hidden; + } + + /** + * Method hasStart. + * + * @return true if at least one Start has been added + */ + public boolean hasStart( + ) { + return this._has_start; + } + + /** + * Method hasViewreference. + * + * @return true if at least one Viewreference has been added + */ + public boolean hasViewreference( + ) { + return this._has_viewreference; + } + + /** + * Returns the value of field 'hidden'. + * + * @return the value of field 'Hidden'. + */ + public boolean isHidden( + ) { + return this._hidden; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid( + ) { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * Returns the value of field 'viewreference'. + * + * @return the value of field 'Viewreference'. + */ + public boolean isViewreference( + ) { + return this._viewreference; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException if object is + * null or if any SAXException is thrown during marshaling + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema + */ + public void marshal( + final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException if an IOException occurs during + * marshaling + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException if object is + * null or if any SAXException is thrown during marshaling + */ + public void marshal( + final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllFeatures( + ) { + this._featuresList.clear(); + } + + /** + */ + public void removeAllHiddenSequences( + ) { + this._hiddenSequencesList.clear(); + } + + /** + */ + public void removeAllPdbids( + ) { + this._pdbidsList.clear(); + } + + /** + */ + public void removeAllRnaViewer( + ) { + this._rnaViewerList.clear(); + } + + /** + * Method removeFeatures. + * + * @param vFeatures + * @return true if the object was removed from the collection. + */ + public boolean removeFeatures( + final jalview.schemabinding.version2.Features vFeatures) { + boolean removed = _featuresList.remove(vFeatures); + return removed; + } + + /** + * Method removeFeaturesAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.schemabinding.version2.Features removeFeaturesAt( + final int index) { + java.lang.Object obj = this._featuresList.remove(index); + return (jalview.schemabinding.version2.Features) obj; + } + + /** + * Method removeHiddenSequences. + * + * @param vHiddenSequences + * @return true if the object was removed from the collection. + */ + public boolean removeHiddenSequences( + final int vHiddenSequences) { + boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(vHiddenSequences)); + return removed; + } + + /** + * Method removeHiddenSequencesAt. + * + * @param index + * @return the element removed from the collection + */ + public int removeHiddenSequencesAt( + final int index) { + java.lang.Object obj = this._hiddenSequencesList.remove(index); + return ((java.lang.Integer) obj).intValue(); + } + + /** + * Method removePdbids. + * + * @param vPdbids + * @return true if the object was removed from the collection. + */ + public boolean removePdbids( + final jalview.schemabinding.version2.Pdbids vPdbids) { + boolean removed = _pdbidsList.remove(vPdbids); + return removed; + } + + /** + * Method removePdbidsAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.schemabinding.version2.Pdbids removePdbidsAt( + final int index) { + java.lang.Object obj = this._pdbidsList.remove(index); + return (jalview.schemabinding.version2.Pdbids) obj; + } + + /** + * Method removeRnaViewer. + * + * @param vRnaViewer + * @return true if the object was removed from the collection. + */ + public boolean removeRnaViewer( + final jalview.schemabinding.version2.RnaViewer vRnaViewer) { + boolean removed = _rnaViewerList.remove(vRnaViewer); + return removed; + } + + /** + * Method removeRnaViewerAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.schemabinding.version2.RnaViewer removeRnaViewerAt( + final int index) { + java.lang.Object obj = this._rnaViewerList.remove(index); + return (jalview.schemabinding.version2.RnaViewer) obj; + } + + /** + * Sets the value of field 'colour'. + * + * @param colour the value of field 'colour'. + */ + public void setColour( + final int colour) { + this._colour = colour; + this._has_colour = true; + } + + /** + * Sets the value of field 'end'. + * + * @param end the value of field 'end'. + */ + public void setEnd( + final int end) { + this._end = end; + this._has_end = true; + } + + /** + * + * + * @param index + * @param vFeatures + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setFeatures( + final int index, + final jalview.schemabinding.version2.Features vFeatures) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._featuresList.size()) { + throw new IndexOutOfBoundsException("setFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]"); + } + + this._featuresList.set(index, vFeatures); + } + + /** + * + * + * @param vFeaturesArray + */ + public void setFeatures( + final jalview.schemabinding.version2.Features[] vFeaturesArray) { + //-- copy array + _featuresList.clear(); + + for (int i = 0; i < vFeaturesArray.length; i++) { + this._featuresList.add(vFeaturesArray[i]); + } + } + + /** + * Sets the value of field 'hidden'. + * + * @param hidden the value of field 'hidden'. + */ + public void setHidden( + final boolean hidden) { + this._hidden = hidden; + this._has_hidden = true; + } + + /** + * + * + * @param index + * @param vHiddenSequences + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setHiddenSequences( + final int index, + final int vHiddenSequences) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._hiddenSequencesList.size()) { + throw new IndexOutOfBoundsException("setHiddenSequences: Index value '" + index + "' not in range [0.." + (this._hiddenSequencesList.size() - 1) + "]"); + } + + this._hiddenSequencesList.set(index, new java.lang.Integer(vHiddenSequences)); + } + + /** + * + * + * @param vHiddenSequencesArray + */ + public void setHiddenSequences( + final int[] vHiddenSequencesArray) { + //-- copy array + _hiddenSequencesList.clear(); + + for (int i = 0; i < vHiddenSequencesArray.length; i++) { + this._hiddenSequencesList.add(new java.lang.Integer(vHiddenSequencesArray[i])); + } + } + + /** + * Sets the value of field 'hmmerProfile'. The field + * 'hmmerProfile' has the following description: name of the + * project jar entry that holds the HMM file with the profile + * for the sequence + * + * @param hmmerProfile the value of field 'hmmerProfile'. + */ + public void setHmmerProfile( + final java.lang.String hmmerProfile) { + this._hmmerProfile = hmmerProfile; + } + + /** + * Sets the value of field 'id'. + * + * @param id the value of field 'id'. + */ + public void setId( + final java.lang.String id) { + this._id = id; + } + + /** + * + * + * @param index + * @param vPdbids + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setPdbids( + final int index, + final jalview.schemabinding.version2.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._pdbidsList.size()) { + throw new IndexOutOfBoundsException("setPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]"); + } + + this._pdbidsList.set(index, vPdbids); + } + + /** + * + * + * @param vPdbidsArray + */ + public void setPdbids( + final jalview.schemabinding.version2.Pdbids[] vPdbidsArray) { + //-- copy array + _pdbidsList.clear(); + + for (int i = 0; i < vPdbidsArray.length; i++) { + this._pdbidsList.add(vPdbidsArray[i]); + } + } + + /** + * + * + * @param index + * @param vRnaViewer + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setRnaViewer( + final int index, + final jalview.schemabinding.version2.RnaViewer vRnaViewer) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._rnaViewerList.size()) { + throw new IndexOutOfBoundsException("setRnaViewer: Index value '" + index + "' not in range [0.." + (this._rnaViewerList.size() - 1) + "]"); + } + + this._rnaViewerList.set(index, vRnaViewer); + } + + /** + * + * + * @param vRnaViewerArray + */ + public void setRnaViewer( + final jalview.schemabinding.version2.RnaViewer[] vRnaViewerArray) { + //-- copy array + _rnaViewerList.clear(); + + for (int i = 0; i < vRnaViewerArray.length; i++) { + this._rnaViewerList.add(vRnaViewerArray[i]); + } + } + + /** + * Sets the value of field 'start'. + * + * @param start the value of field 'start'. + */ + public void setStart( + final int start) { + this._start = start; + this._has_start = true; + } + + /** + * Sets the value of field 'viewreference'. + * + * @param viewreference the value of field 'viewreference'. + */ + public void setViewreference( + final boolean viewreference) { + this._viewreference = viewreference; + this._has_viewreference = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException if object is + * null or if any SAXException is thrown during marshaling + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema + * @return the unmarshaled jalview.schemabinding.version2.JSeq + */ + public static jalview.schemabinding.version2.JSeq unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(jalview.schemabinding.version2.JSeq.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema + */ + public void validate( + ) + throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/schemabinding/version2/descriptors/JSeqDescriptor.java b/src/jalview/schemabinding/version2/descriptors/JSeqDescriptor.java index 28f23b26..b6becc0 100644 --- a/src/jalview/schemabinding/version2/descriptors/JSeqDescriptor.java +++ b/src/jalview/schemabinding/version2/descriptors/JSeqDescriptor.java @@ -7,8 +7,8 @@ package jalview.schemabinding.version2.descriptors; -//---------------------------------/ -//- Imported classes and packages -/ + //---------------------------------/ + //- Imported classes and packages -/ //---------------------------------/ import jalview.schemabinding.version2.JSeq; @@ -18,697 +18,607 @@ import jalview.schemabinding.version2.JSeq; * * @version $Revision$ $Date$ */ -public class JSeqDescriptor extends - org.exolab.castor.xml.util.XMLClassDescriptorImpl -{ - - // --------------------------/ - // - Class/Member Variables -/ - // --------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - // ----------------/ - // - Constructors -/ - // ----------------/ - - public JSeqDescriptor() - { - super(); - _nsURI = "www.jalview.org"; - _xmlName = "JSeq"; - _elementDefinition = true; - - // -- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - // -- initialize attribute descriptors - - // -- _colour - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.Integer.TYPE, "_colour", "colour", - org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - if (!target.hasColour()) - { - return null; +public class JSeqDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public JSeqDescriptor() { + super(); + _nsURI = "www.jalview.org"; + _xmlName = "JSeq"; + _elementDefinition = true; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _colour + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_colour", "colour", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + if (!target.hasColour()) { return null; } + return new java.lang.Integer(target.getColour()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteColour(); + return; + } + target.setColour( ((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _colour + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } - return new java.lang.Integer(target.getColour()); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - // if null, use delete method for optional primitives - if (value == null) - { - target.deleteColour(); - return; - } - target.setColour(((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); + desc.setValidator(fieldValidator); + //-- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + if (!target.hasStart()) { return null; } + return new java.lang.Integer(target.getStart()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + // ignore null values for non optional primitives + if (value == null) { return; } + + target.setStart( ((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - // -- validation code for: _colour - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { // -- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); - } - desc.setValidator(fieldValidator); - // -- _start - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.Integer.TYPE, "_start", "start", - org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - if (!target.hasStart()) - { - return null; + desc.setValidator(fieldValidator); + //-- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + if (!target.hasEnd()) { return null; } + return new java.lang.Integer(target.getEnd()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + // ignore null values for non optional primitives + if (value == null) { return; } + + target.setEnd( ((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } - return new java.lang.Integer(target.getStart()); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - // ignore null values for non optional primitives - if (value == null) - { - return; - } - - target.setStart(((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); + desc.setValidator(fieldValidator); + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + target.setId( (java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - // -- validation code for: _start - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { // -- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); - } - desc.setValidator(fieldValidator); - // -- _end - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.Integer.TYPE, "_end", "end", - org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - if (!target.hasEnd()) - { - return null; + desc.setValidator(fieldValidator); + //-- _hidden + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_hidden", "hidden", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + if (!target.hasHidden()) { return null; } + return (target.getHidden() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteHidden(); + return; + } + target.setHidden( ((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _hidden + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); } - return new java.lang.Integer(target.getEnd()); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - // ignore null values for non optional primitives - if (value == null) - { - return; - } - - target.setEnd(((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); + desc.setValidator(fieldValidator); + //-- _viewreference + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_viewreference", "viewreference", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + if (!target.hasViewreference()) { return null; } + return (target.getViewreference() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteViewreference(); + return; + } + target.setViewreference( ((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _viewreference + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - // -- validation code for: _end - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { // -- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); - } - desc.setValidator(fieldValidator); - // -- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.String.class, "_id", "id", - org.exolab.castor.xml.NodeType.Attribute); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - return target.getId(); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.setId((java.lang.String) value); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _featuresList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(jalview.schemabinding.version2.Features.class, "_featuresList", "features", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + return target.getFeatures(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + target.addFeatures( (jalview.schemabinding.version2.Features) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { + try { + JSeq target = (JSeq) object; + target.removeAllFeatures(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return new jalview.schemabinding.version2.Features(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("www.jalview.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _featuresList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - // -- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { // -- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - // -- _hidden - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.Boolean.TYPE, "_hidden", "hidden", - org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - if (!target.hasHidden()) - { - return null; + desc.setValidator(fieldValidator); + //-- _pdbidsList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(jalview.schemabinding.version2.Pdbids.class, "_pdbidsList", "pdbids", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + return target.getPdbids(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + target.addPdbids( (jalview.schemabinding.version2.Pdbids) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { + try { + JSeq target = (JSeq) object; + target.removeAllPdbids(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return new jalview.schemabinding.version2.Pdbids(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("www.jalview.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _pdbidsList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope } - return (target.getHidden() ? java.lang.Boolean.TRUE - : java.lang.Boolean.FALSE); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - // if null, use delete method for optional primitives - if (value == null) - { - target.deleteHidden(); - return; - } - target.setHidden(((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); + desc.setValidator(fieldValidator); + //-- _hiddenSequencesList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_hiddenSequencesList", "hiddenSequences", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + return target.getHiddenSequences(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + // ignore null values for non optional primitives + if (value == null) { return; } + + target.addHiddenSequences( ((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { + try { + JSeq target = (JSeq) object; + target.removeAllHiddenSequences(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("www.jalview.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _hiddenSequencesList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - // -- validation code for: _hidden - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { // -- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - // -- _viewreference - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.Boolean.TYPE, "_viewreference", "viewreference", - org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - if (!target.hasViewreference()) - { - return null; + desc.setValidator(fieldValidator); + //-- _rnaViewerList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(jalview.schemabinding.version2.RnaViewer.class, "_rnaViewerList", "rnaViewer", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + return target.getRnaViewer(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + target.addRnaViewer( (jalview.schemabinding.version2.RnaViewer) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { + try { + JSeq target = (JSeq) object; + target.removeAllRnaViewer(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return new jalview.schemabinding.version2.RnaViewer(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("www.jalview.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _rnaViewerList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope } - return (target.getViewreference() ? java.lang.Boolean.TRUE - : java.lang.Boolean.FALSE); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - // if null, use delete method for optional primitives - if (value == null) - { - target.deleteViewreference(); - return; - } - target.setViewreference(((java.lang.Boolean) value) - .booleanValue()); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); + desc.setValidator(fieldValidator); + //-- _hmmerProfile + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_hmmerProfile", "hmmerProfile", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + JSeq target = (JSeq) object; + return target.getHmmerProfile(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + JSeq target = (JSeq) object; + target.setHmmerProfile( (java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("www.jalview.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _hmmerProfile + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - // -- validation code for: _viewreference - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { // -- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); + desc.setValidator(fieldValidator); } - desc.setValidator(fieldValidator); - // -- initialize element descriptors - // -- _featuresList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - jalview.schemabinding.version2.Features.class, "_featuresList", - "features", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - return target.getFeatures(); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.addFeatures((jalview.schemabinding.version2.Features) value); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - - public void resetValue(Object object) throws IllegalStateException, - IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.removeAllFeatures(); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) - { - return new jalview.schemabinding.version2.Features(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("www.jalview.org"); - desc.setMultivalued(true); - addFieldDescriptor(desc); + //-----------/ + //- Methods -/ + //-----------/ - // -- validation code for: _featuresList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { // -- local scope + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode( + ) { + return null; } - desc.setValidator(fieldValidator); - // -- _pdbidsList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - jalview.schemabinding.version2.Pdbids.class, "_pdbidsList", - "pdbids", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - return target.getPdbids(); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.addPdbids((jalview.schemabinding.version2.Pdbids) value); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - - public void resetValue(Object object) throws IllegalStateException, - IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.removeAllPdbids(); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) - { - return new jalview.schemabinding.version2.Pdbids(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("www.jalview.org"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - // -- validation code for: _pdbidsList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { // -- local scope + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no + * identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity( + ) { + return super.getIdentity(); } - desc.setValidator(fieldValidator); - // -- _hiddenSequencesList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - java.lang.Integer.TYPE, "_hiddenSequencesList", - "hiddenSequences", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - return target.getHiddenSequences(); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - // ignore null values for non optional primitives - if (value == null) - { - return; - } - - target.addHiddenSequences(((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, - IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.removeAllHiddenSequences(); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return null; - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("www.jalview.org"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - // -- validation code for: _hiddenSequencesList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { // -- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass( + ) { + return jalview.schemabinding.version2.JSeq.class; } - desc.setValidator(fieldValidator); - // -- _rnaViewerList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( - jalview.schemabinding.version2.RnaViewer.class, - "_rnaViewerList", "rnaViewer", - org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() - { - public java.lang.Object getValue(java.lang.Object object) - throws IllegalStateException - { - JSeq target = (JSeq) object; - return target.getRnaViewer(); - } - - public void setValue(java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.addRnaViewer((jalview.schemabinding.version2.RnaViewer) value); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - - public void resetValue(Object object) throws IllegalStateException, - IllegalArgumentException - { - try - { - JSeq target = (JSeq) object; - target.removeAllRnaViewer(); - } catch (java.lang.Exception ex) - { - throw new IllegalStateException(ex.toString()); - } - } - - public java.lang.Object newInstance(java.lang.Object parent) - { - return new jalview.schemabinding.version2.RnaViewer(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("www.jalview.org"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - // -- validation code for: _rnaViewerList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { // -- local scope + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix( + ) { + return _nsPrefix; } - desc.setValidator(fieldValidator); - } - // -----------/ - // - Methods -/ - // -----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode() - { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity() - { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass() - { - return jalview.schemabinding.version2.JSeq.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix() - { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI() - { - return _nsURI; - } + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and + * unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI( + ) { + return _nsURI; + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator() - { - return this; - } + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator( + ) { + return this; + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName() - { - return _xmlName; - } + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName( + ) { + return _xmlName; + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition() - { - return _elementDefinition; - } + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that + * of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition( + ) { + return _elementDefinition; + } } diff --git a/src/jalview/structure/StructureMapping.java b/src/jalview/structure/StructureMapping.java index fcf322d..4174f5b 100644 --- a/src/jalview/structure/StructureMapping.java +++ b/src/jalview/structure/StructureMapping.java @@ -30,6 +30,12 @@ import java.util.List; public class StructureMapping { + public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE; + + private static final int PDB_RES_NUM_INDEX = 0; + + private static final int PDB_ATOM_NUM_INDEX = 1; + String mappingDetails; SequenceI sequence; @@ -40,17 +46,12 @@ public class StructureMapping String pdbchain; - public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE; - - private static final int PDB_RES_NUM_INDEX = 0; - - private static final int PDB_ATOM_NUM_INDEX = 1; - // Mapping key is residue index while value is an array containing PDB resNum, // and atomNo HashMap mapping; jalview.datamodel.Mapping seqToPdbMapping = null; + /** * Constructor * @@ -145,7 +146,7 @@ public class StructureMapping */ public List getPDBResNumRanges(int fromSeqPos, int toSeqPos) { - List result = new ArrayList(); + List result = new ArrayList<>(); int startRes = -1; int endRes = -1; @@ -263,4 +264,105 @@ public class StructureMapping { return seqToPdbMapping; } + + /** + * A hash function that satisfies the contract that if two mappings are + * equal(), they have the same hashCode + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + + ((mappingDetails == null) ? 0 : mappingDetails.hashCode()); + result = prime * result + + ((pdbchain == null) ? 0 : pdbchain.hashCode()); + result = prime * result + ((pdbfile == null) ? 0 : pdbfile.hashCode()); + result = prime * result + ((pdbid == null) ? 0 : pdbid.hashCode()); + result = prime * result + + ((seqToPdbMapping == null) ? 0 : seqToPdbMapping.hashCode()); + result = prime * result + + ((sequence == null) ? 0 : sequence.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + StructureMapping other = (StructureMapping) obj; + if (mappingDetails == null) + { + if (other.mappingDetails != null) + { + return false; + } + } + else if (!mappingDetails.equals(other.mappingDetails)) + { + return false; + } + if (pdbchain == null) + { + if (other.pdbchain != null) + { + return false; + } + } + else if (!pdbchain.equals(other.pdbchain)) + { + return false; + } + if (pdbfile == null) + { + if (other.pdbfile != null) + { + return false; + } + } + else if (!pdbfile.equals(other.pdbfile)) + { + return false; + } + if (pdbid == null) + { + if (other.pdbid != null) + { + return false; + } + } + else if (!pdbid.equals(other.pdbid)) + { + return false; + } + if (seqToPdbMapping == null) + { + if (other.seqToPdbMapping != null) + { + return false; + } + } + else if (!seqToPdbMapping.equals(other.seqToPdbMapping)) + { + return false; + } + if (sequence != other.sequence) + { + return false; + } + + return true; + } } diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 10fe836..ad259fd 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -285,7 +285,8 @@ public class StructureSelectionManager } /** - * Returns the file name for a mapped PDB id (or null if not mapped). + * Returns the filename the PDB id is already mapped to if known, or null if + * it is not mapped * * @param pdbid * @return @@ -294,7 +295,7 @@ public class StructureSelectionManager { for (StructureMapping sm : mappings) { - if (sm.getPdbId().equals(pdbid)) + if (sm.getPdbId().equalsIgnoreCase(pdbid)) { return sm.pdbfile; } @@ -572,6 +573,13 @@ public class StructureSelectionManager { System.err.println(e.getMessage()); } + catch (Exception e) + { + System.err + .println( + "Unexpected exception during SIFTS mapping - falling back to NW for this sequence/structure pair"); + System.err.println(e.getMessage()); + } } if (!foundSiftsMappings.isEmpty()) { @@ -605,7 +613,10 @@ public class StructureSelectionManager } if (forStructureView) { - mappings.addAll(seqToStrucMapping); + for (StructureMapping sm : seqToStrucMapping) + { + addStructureMapping(sm); // not addAll! + } } if (progress != null) { @@ -657,7 +668,10 @@ public class StructureSelectionManager public void addStructureMapping(StructureMapping sm) { - mappings.add(sm); + if (!mappings.contains(sm)) + { + mappings.add(sm); + } } /** diff --git a/src/jalview/util/MapList.java b/src/jalview/util/MapList.java index 81b9964..60054f1 100644 --- a/src/jalview/util/MapList.java +++ b/src/jalview/util/MapList.java @@ -116,8 +116,17 @@ public class MapList { int hashCode = 31 * fromRatio; hashCode = 31 * hashCode + toRatio; - hashCode = 31 * hashCode + fromShifts.toArray().hashCode(); - hashCode = 31 * hashCode + toShifts.toArray().hashCode(); + for (int[] shift : fromShifts) + { + hashCode = 31 * hashCode + shift[0]; + hashCode = 31 * hashCode + shift[1]; + } + for (int[] shift : toShifts) + { + hashCode = 31 * hashCode + shift[0]; + hashCode = 31 * hashCode + shift[1]; + } + return hashCode; } diff --git a/src/jalview/workers/InformationThread.java b/src/jalview/workers/InformationThread.java index cf42425..d719189 100644 --- a/src/jalview/workers/InformationThread.java +++ b/src/jalview/workers/InformationThread.java @@ -44,6 +44,10 @@ public class InformationThread extends AlignCalcWorker @Override public void run() { + if (alignViewport.getAlignment().getHmmSequences().isEmpty()) + { + return; + } if (calcMan.isPending(this)) { return; diff --git a/src/jalview/ws/params/simple/LogarithmicParameter.java b/src/jalview/ws/params/simple/LogarithmicParameter.java index 01744e7..af80181 100644 --- a/src/jalview/ws/params/simple/LogarithmicParameter.java +++ b/src/jalview/ws/params/simple/LogarithmicParameter.java @@ -17,8 +17,6 @@ public class LogarithmicParameter extends Option implements ParameterI final double max; - final double base; // todo is this even needed? - @Override public ValueConstrainI getValidValue() { @@ -51,31 +49,27 @@ public class LogarithmicParameter extends Option implements ParameterI max = parm.max; min = parm.min; defval = 0D; - base = parm.base; } public LogarithmicParameter(String name, String description, - boolean required, Double defValue, double min, double max, - double base) + boolean required, Double defValue, double min, double max) { super(name, description, required, String.valueOf(defValue), null, null, null); defval = defValue; this.min = min; this.max = max; - this.base = base; } public LogarithmicParameter(String name, String description, boolean required, Double defValue, double value, double min, - double max, double base) + double max) { super(name, description, required, String.valueOf(defValue), String.valueOf(value), null, null); defval = defValue; this.min = min; this.max = max; - this.base = base; } @Override @@ -83,9 +77,4 @@ public class LogarithmicParameter extends Option implements ParameterI { return new LogarithmicParameter(this); } - - public double getBase() - { - return base; - } } diff --git a/src/jalview/ws/params/simple/StringChoiceParameter.java b/src/jalview/ws/params/simple/StringChoiceParameter.java index d613d58..254eb80 100644 --- a/src/jalview/ws/params/simple/StringChoiceParameter.java +++ b/src/jalview/ws/params/simple/StringChoiceParameter.java @@ -20,7 +20,25 @@ */ package jalview.ws.params.simple; +import java.util.List; + +/** + * A parameter with options intended to be rendered as radio buttons + */ public class StringChoiceParameter extends Option { + /** + * Constructor + * + * @param name + * @param description + * @param options + * @param def + */ + public StringChoiceParameter(String name, String description, + List options, String def) + { + super(name, description, true, def, def, options, null); + } } diff --git a/src/jalview/ws/params/simple/StringParameter.java b/src/jalview/ws/params/simple/StringParameter.java index 1d6a37e..b61836a 100644 --- a/src/jalview/ws/params/simple/StringParameter.java +++ b/src/jalview/ws/params/simple/StringParameter.java @@ -3,65 +3,13 @@ package jalview.ws.params.simple; import jalview.ws.params.ParameterI; import jalview.ws.params.ValueConstrainI; -import java.net.URL; -import java.util.List; +import java.util.Collection; public class StringParameter extends Option implements ParameterI { - - @Override - public URL getFurtherDetails() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isRequired() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public String getDescription() - { - // TODO Auto-generated method stub - return description; - } - - @Override - public List getPossibleValues() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getName() - { - // TODO Auto-generated method stub - return name; - } - - @Override - public String getValue() - { - // TODO Auto-generated method stub - return value; - } - - @Override - public void setValue(String selectedItem) - { - value = selectedItem; - - } - @Override public ValueConstrainI getValidValue() { - // TODO Auto-generated method stub return new StringValueConstrain(); } @@ -115,4 +63,22 @@ public class StringParameter extends Option implements ParameterI String.valueOf(value), null, null); this.defvalue = defValue; } + + /** + * Constructor for a parameter with a list of possible values + * + * @param name2 + * @param description2 + * @param isrequired + * @param defValue + * @param value + * @param possibleVals + */ + public StringParameter(String name2, String description2, + boolean isrequired, String defValue, String value, + Collection possibleVals) + { + super(name2, description2, isrequired, defValue, value, possibleVals, + null); + } } diff --git a/test/MCview/PDBChainTest.java b/test/MCview/PDBChainTest.java index defcdbc..533c0af 100644 --- a/test/MCview/PDBChainTest.java +++ b/test/MCview/PDBChainTest.java @@ -91,7 +91,7 @@ public class PDBChainTest a3.resName = "ASP"; a3.resNumber = 41; - Vector v = new Vector(); + Vector v = new Vector<>(); v.add(new Bond(a1, a2)); v.add(new Bond(a2, a3)); v.add(new Bond(a3, a1)); @@ -234,7 +234,7 @@ public class PDBChainTest @Test(groups = { "Functional" }) public void testMakeResidueList_noAnnotation() { - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; c.isNa = true; atoms.add(makeAtom(4, "N", "MET")); @@ -292,7 +292,7 @@ public class PDBChainTest @Test(groups = { "Functional" }) public void testMakeResidueList_withTempFactor() { - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "MET")); atoms.get(atoms.size() - 1).tfactor = 1f; @@ -307,7 +307,7 @@ public class PDBChainTest atoms.add(makeAtom(5, "CA", "LYS")); atoms.get(atoms.size() - 1).tfactor = 9f; atoms.add(makeAtom(6, "O", "LEU")); - atoms.get(atoms.size() - 1).tfactor = 4f; + atoms.get(atoms.size() - 1).tfactor = -4f; atoms.add(makeAtom(6, "N", "LEU")); atoms.get(atoms.size() - 1).tfactor = 5f; atoms.add(makeAtom(6, "CA", "LEU")); @@ -320,7 +320,7 @@ public class PDBChainTest /* * Verify annotations; note the tempFactor is read from the first atom in - * each residue i.e. we expect values 1, 7, 4 for the residues + * each residue i.e. we expect values 1, 7, -4 for the residues */ AlignmentAnnotation[] ann = c.sequence.getAnnotation(); assertEquals(1, ann.length); @@ -328,12 +328,12 @@ public class PDBChainTest assertEquals("Temperature Factor for 1gaqA", ann[0].description); assertSame(c.sequence, ann[0].sequenceRef); assertEquals(AlignmentAnnotation.LINE_GRAPH, ann[0].graph); - assertEquals(0f, ann[0].graphMin, 0.001f); + assertEquals(-4f, ann[0].graphMin, 0.001f); assertEquals(7f, ann[0].graphMax, 0.001f); assertEquals(3, ann[0].annotations.length); assertEquals(1f, ann[0].annotations[0].value, 0.001f); assertEquals(7f, ann[0].annotations[1].value, 0.001f); - assertEquals(4f, ann[0].annotations[2].value, 0.001f); + assertEquals(-4f, ann[0].annotations[2].value, 0.001f); } /** @@ -344,7 +344,7 @@ public class PDBChainTest public void testMakeCaBondList() { c.isNa = true; - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "MET")); atoms.add(makeAtom(4, "CA", "MET")); @@ -375,7 +375,7 @@ public class PDBChainTest public void testMakeCaBondList_nucleotide() { c.isNa = false; - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "G")); atoms.add(makeAtom(4, "P", "G")); @@ -406,7 +406,7 @@ public class PDBChainTest @Test(groups = { "Functional" }) public void testMakeExactMapping() { - Vector atoms = new Vector(); + Vector atoms = new Vector<>(); c.atoms = atoms; atoms.add(makeAtom(4, "N", "MET")); atoms.add(makeAtom(4, "CA", "MET")); diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index 5a14514..79bb2bb 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -247,7 +247,9 @@ public class SequenceTest sq.sequenceChanged(); assertEquals(6, sq.findIndex(9)); - sq = new Sequence("test/8-13", "-A--B-C-D-E-F--"); + final String aligned = "-A--B-C-D-E-F--"; + assertEquals(15, aligned.length()); + sq = new Sequence("test/8-13", aligned); assertEquals(2, sq.findIndex(8)); sq.sequenceChanged(); assertEquals(5, sq.findIndex(9)); @@ -263,6 +265,29 @@ public class SequenceTest // beyond end returns last residue column sq.sequenceChanged(); assertEquals(13, sq.findIndex(99)); + + /* + * residue before sequence 'end' but beyond end of sequence returns + * length of sequence (last column) (rightly or wrongly!) + */ + sq = new Sequence("test/8-15", "A-B-C-"); // trailing gap case + assertEquals(6, sq.getLength()); + sq.sequenceChanged(); + assertEquals(sq.getLength(), sq.findIndex(14)); + sq = new Sequence("test/8-99", "-A--B-C-D"); // trailing residue case + sq.sequenceChanged(); + assertEquals(sq.getLength(), sq.findIndex(65)); + + /* + * residue after sequence 'start' but before first residue returns + * zero (before first column) (rightly or wrongly!) + */ + sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case + sq.sequenceChanged(); + assertEquals(0, sq.findIndex(3)); + sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case + sq.sequenceChanged(); + assertEquals(0, sq.findIndex(2)); } /** @@ -1402,14 +1427,61 @@ public class SequenceTest { Sequence sq = new Sequence("test/8-13", "-A--BCD-EF--"); - // find F given A + // find F given A, check cursor is now at the found position assertEquals(10, sq.findIndex(13, new SequenceCursor(sq, 8, 2, 0))); + SequenceCursor cursor = (SequenceCursor) PA.getValue(sq, "cursor"); + assertEquals(13, cursor.residuePosition); + assertEquals(10, cursor.columnPosition); // find A given F assertEquals(2, sq.findIndex(8, new SequenceCursor(sq, 13, 10, 0))); + cursor = (SequenceCursor) PA.getValue(sq, "cursor"); + assertEquals(8, cursor.residuePosition); + assertEquals(2, cursor.columnPosition); - // find C given C + // find C given C (no cursor update is done for this case) assertEquals(6, sq.findIndex(10, new SequenceCursor(sq, 10, 6, 0))); + SequenceCursor cursor2 = (SequenceCursor) PA.getValue(sq, "cursor"); + assertSame(cursor2, cursor); + + /* + * sequence 'end' beyond end of sequence returns length of sequence + * (for compatibility with pre-cursor code) + * - also verify the cursor is left in a valid state + */ + sq = new Sequence("test/8-99", "-A--B-C-D-E-F--"); // trailing gap case + assertEquals(7, sq.findIndex(10)); // establishes a cursor + cursor = (SequenceCursor) PA.getValue(sq, "cursor"); + assertEquals(10, cursor.residuePosition); + assertEquals(7, cursor.columnPosition); + assertEquals(sq.getLength(), sq.findIndex(65)); + cursor2 = (SequenceCursor) PA.getValue(sq, "cursor"); + assertSame(cursor, cursor2); // not updated for this case! + + sq = new Sequence("test/8-99", "-A--B-C-D-E-F"); // trailing residue case + sq.findIndex(10); // establishes a cursor + cursor = (SequenceCursor) PA.getValue(sq, "cursor"); + assertEquals(sq.getLength(), sq.findIndex(65)); + cursor2 = (SequenceCursor) PA.getValue(sq, "cursor"); + assertSame(cursor, cursor2); // not updated for this case! + + /* + * residue after sequence 'start' but before first residue should return + * zero (for compatibility with pre-cursor code) + */ + sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case + sq.findIndex(10); // establishes a cursor + cursor = (SequenceCursor) PA.getValue(sq, "cursor"); + assertEquals(0, sq.findIndex(3)); + cursor2 = (SequenceCursor) PA.getValue(sq, "cursor"); + assertSame(cursor, cursor2); // not updated for this case! + + sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case + sq.findIndex(10); // establishes a cursor + cursor = (SequenceCursor) PA.getValue(sq, "cursor"); + assertEquals(0, sq.findIndex(2)); + cursor2 = (SequenceCursor) PA.getValue(sq, "cursor"); + assertSame(cursor, cursor2); // not updated for this case! } @Test(groups = { "Functional" }) diff --git a/test/jalview/datamodel/features/FeatureAttributesTest.java b/test/jalview/datamodel/features/FeatureAttributesTest.java index e47c787..686cd2f 100644 --- a/test/jalview/datamodel/features/FeatureAttributesTest.java +++ b/test/jalview/datamodel/features/FeatureAttributesTest.java @@ -23,7 +23,7 @@ public class FeatureAttributesTest /** * clear down attributes map before tests */ - @BeforeClass + @BeforeClass(alwaysRun = true) public void setUp() { FeatureAttributes fa = FeatureAttributes.getInstance(); @@ -33,7 +33,7 @@ public class FeatureAttributesTest /** * clear down attributes map after tests */ - @AfterMethod + @AfterMethod(alwaysRun = true) public void tearDown() { FeatureAttributes fa = FeatureAttributes.getInstance(); diff --git a/test/jalview/ext/jmol/JmolViewerTest.java b/test/jalview/ext/jmol/JmolViewerTest.java index 792f7ad..e451ed2 100644 --- a/test/jalview/ext/jmol/JmolViewerTest.java +++ b/test/jalview/ext/jmol/JmolViewerTest.java @@ -20,11 +20,15 @@ */ package jalview.ext.jmol; +import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.assertEquals; import static org.testng.AssertJUnit.assertTrue; import jalview.api.structures.JalviewStructureDisplayI; import jalview.bin.Cache; import jalview.bin.Jalview; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.JvOptionPane; @@ -32,6 +36,10 @@ import jalview.gui.Preferences; import jalview.gui.StructureViewer; import jalview.gui.StructureViewer.ViewerType; import jalview.io.DataSourceType; +import jalview.io.FileFormat; +import jalview.io.FileLoader; + +import java.lang.reflect.InvocationTargetException; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -54,8 +62,10 @@ public class JmolViewerTest @BeforeClass(alwaysRun = true) public static void setUpBeforeClass() throws Exception { - Jalview.main(new String[] { "-noquestionnaire", "-nonews", "-props", - "test/jalview/ext/rbvi/chimera/testProps.jvprops" }); + Jalview.main( + new String[] + { "-noquestionnaire", "-nonews", "-props", + "test/jalview/ext/rbvi/chimera/testProps.jvprops" }); } /** @@ -70,10 +80,11 @@ public class JmolViewerTest @Test(groups = { "Functional" }) public void testSingleSeqViewJMol() { - Cache.setProperty(Preferences.STRUCTURE_DISPLAY, ViewerType.JMOL.name()); + Cache.setProperty(Preferences.STRUCTURE_DISPLAY, + ViewerType.JMOL.name()); String inFile = "examples/1gaq.txt"; - AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded( - inFile, DataSourceType.FILE); + AlignFrame af = new jalview.io.FileLoader() + .LoadFileWaitTillLoaded(inFile, DataSourceType.FILE); assertTrue("Didn't read input file " + inFile, af != null); for (SequenceI sq : af.getViewport().getAlignment().getSequences()) { @@ -87,13 +98,13 @@ public class JmolViewerTest { for (int q = 0; q < dsq.getAllPDBEntries().size(); q++) { - final StructureViewer structureViewer = new StructureViewer(af - .getViewport().getStructureSelectionManager()); + final StructureViewer structureViewer = new StructureViewer( + af.getViewport().getStructureSelectionManager()); structureViewer.setViewerType(ViewerType.JMOL); JalviewStructureDisplayI jmolViewer = structureViewer .viewStructures(dsq.getAllPDBEntries().elementAt(q), - new SequenceI[] { sq }, af.getCurrentView() - .getAlignPanel()); + new SequenceI[] + { sq }, af.getCurrentView().getAlignPanel()); /* * Wait for viewer load thread to complete */ @@ -116,5 +127,86 @@ public class JmolViewerTest } } + @Test(groups = { "Functional" }) + public void testAddStrToSingleSeqViewJMol() + throws InvocationTargetException, InterruptedException + { + Cache.setProperty(Preferences.STRUCTURE_DISPLAY, + ViewerType.JMOL.name()); + String inFile = "examples/1gaq.txt"; + AlignFrame af = new jalview.io.FileLoader(true) + .LoadFileWaitTillLoaded(inFile, DataSourceType.FILE); + assertTrue("Didn't read input file " + inFile, af != null); + // show a structure for 4th Sequence + SequenceI sq1 = af.getViewport().getAlignment().getSequences().get(0); + final StructureViewer structureViewer = new StructureViewer( + af.getViewport().getStructureSelectionManager()); + structureViewer.setViewerType(ViewerType.JMOL); + JalviewStructureDisplayI jmolViewer = structureViewer.viewStructures( + sq1.getDatasetSequence().getAllPDBEntries().elementAt(0), + new SequenceI[] + { sq1 }, af.getCurrentView().getAlignPanel()); + /* + * Wait for viewer load thread to complete + */ + try + { + while (!jmolViewer.getBinding().isFinishedInit()) + { + Thread.sleep(500); + } + } catch (InterruptedException e) + { + } + + assertTrue(jmolViewer.isVisible()); + + // add another pdb file and add it to view + final String _inFile = "examples/3W5V.pdb"; + inFile = _inFile; + FileLoader fl = new FileLoader(); + fl.LoadFile(af.getCurrentView(), _inFile, DataSourceType.FILE, + FileFormat.PDB); + try + { + int time = 0; + do + { + Thread.sleep(50); // hope we can avoid race condition + + } while (++time < 30 + && af.getViewport().getAlignment().getHeight() == 3); + } catch (Exception q) + { + } + ; + assertTrue("Didn't paste additional structure" + inFile, + af.getViewport().getAlignment().getHeight() > 3); + SequenceI sq2 = af.getViewport().getAlignment().getSequenceAt(3); + PDBEntry pdbe = sq2.getDatasetSequence().getAllPDBEntries().get(0); + assertTrue(pdbe.getFile().contains(inFile)); + structureViewer.viewStructures(pdbe, new SequenceI[] { sq2 }, + af.alignPanel); + /* + * Wait for viewer load thread to complete + */ + try + { + while (structureViewer.isBusy()) + { + Thread.sleep(500); + } + } catch (InterruptedException e) + { + } + assertEquals(jmolViewer.getBinding().getPdbCount(), 2); + String mouseOverTest = "[GLY]293:A.CA/2.1 #2164"; + ((JalviewJmolBinding) jmolViewer.getBinding()).mouseOverStructure(2164, + mouseOverTest); + SearchResultsI highlight = af.alignPanel.getSeqPanel() + .getLastSearchResults(); + assertNotNull("Didn't find highlight from second structure mouseover", + highlight.getResults(sq2, sq2.getStart(), sq2.getEnd())); + } } diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index 91fe602..f69e6b5 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -21,6 +21,7 @@ package jalview.gui; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; import jalview.datamodel.DBRefEntry; @@ -28,8 +29,10 @@ import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; +import jalview.fts.api.FTSData; import jalview.jbgui.GStructureChooser.FilterOption; +import java.util.Collection; import java.util.Vector; import org.testng.annotations.AfterMethod; @@ -37,6 +40,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import junit.extensions.PA; + public class StructureChooserTest { @@ -142,8 +147,10 @@ public class StructureChooserTest SequenceI[] selectedSeqs = new SequenceI[] { seq }; StructureChooser sc = new StructureChooser(selectedSeqs, seq, null); sc.fetchStructuresMetaData(); - assertTrue(sc.getDiscoveredStructuresSet() != null); - assertTrue(sc.getDiscoveredStructuresSet().size() > 0); + Collection ss = (Collection) PA.getValue(sc, + "discoveredStructuresSet"); + assertNotNull(ss); + assertTrue(ss.size() > 0); } diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index 41a6b89..3a727b4 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -33,7 +33,9 @@ import jalview.api.FeatureColourI; import jalview.api.ViewStyleI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.HiddenSequences; +import jalview.datamodel.Mapping; import jalview.datamodel.PDBEntry; import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceCollectionI; @@ -78,6 +80,8 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import junit.extensions.PA; + @Test(singleThreaded = true) public class Jalview2xmlTests extends Jalview2xmlBase { @@ -256,6 +260,31 @@ public class Jalview2xmlTests extends Jalview2xmlBase } + /** + * Test for JAL-2223 - multiple mappings in View Mapping report + * + * @throws Exception + */ + @Test(groups = { "Functional" }) + public void noDuplicatePdbMappingsMade() throws Exception + { + StructureImportSettings.setProcessSecondaryStructure(true); + StructureImportSettings.setVisibleChainAnnotation(true); + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + "examples/exampleFile_2_7.jar", DataSourceType.FILE); + assertNotNull(af, "Didn't read in the example file correctly."); + + // locate Jmol viewer + // count number of PDB mappings the structure selection manager holds - + String pdbFile = af.getCurrentView().getStructureSelectionManager() + .findFileForPDBId("1A70"); + assertEquals( + af.getCurrentView().getStructureSelectionManager() + .getMapping(pdbFile).length, + 2, "Expected only two mappings for 1A70"); + + } + @Test(groups = { "Functional" }) public void viewRefPdbAnnotation() throws Exception { @@ -857,7 +886,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase * @throws IOException */ @Test(groups = { "Functional" }) - public void testSaveLoadFeatureColoursAndFilters() throws IOException + public void testStoreAndRecoverFeatureColoursAndFilters() + throws IOException { AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( ">Seq1\nACDEFGHIKLM", DataSourceType.PASTE); @@ -1009,4 +1039,57 @@ public class Jalview2xmlTests extends Jalview2xmlBase addFeature(seq, featureType, score++); addFeature(seq, featureType, score); } + + /** + * Load an HMM profile to an alignment, and confirm it is correctly restored + * when reloaded from project + * + * @throws IOException + */ + @Test(groups = { "Functional" }) + public void testStoreAndRecoverHmmProfile() throws IOException + { + Desktop.instance.closeAll_actionPerformed(null); + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + "examples/uniref50.fa", DataSourceType.FILE); + + AlignViewportI av = af.getViewport(); + AlignmentI al = av.getAlignment(); + + /* + * mimic drag and drop of hmm file on to alignment + */ + AlignFrame af2 = new FileLoader().LoadFileWaitTillLoaded( + "examples/uniref50.hmm", DataSourceType.FILE); + al.insertSequenceAt(0, + af2.getViewport().getAlignment().getSequenceAt(0)); + + /* + * check it loaded in + */ + SequenceI hmmSeq = al.getSequenceAt(0); + assertTrue(hmmSeq.hasHMMProfile()); + HiddenMarkovModel hmm = hmmSeq.getHMM(); + assertSame(hmm.getConsensusSequence(), hmmSeq); + + /* + * save project, close windows, reload project, verify + */ + File tfile = File.createTempFile("testStoreAndRecoverHmmProfile", + ".jvp"); + tfile.deleteOnExit(); + new Jalview2XML(false).saveState(tfile); + Desktop.instance.closeAll_actionPerformed(null); + af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), + DataSourceType.FILE); + Assert.assertNotNull(af, "Failed to reload project"); + + hmmSeq = al.getSequenceAt(0); + assertTrue(hmmSeq.hasHMMProfile()); + assertSame(hmm.getConsensusSequence(), hmmSeq); + Mapping mapToHmmConsensus = (Mapping) PA.getValue(hmm, + "mapToHmmConsensus"); + assertNotNull(mapToHmmConsensus); + assertSame(mapToHmmConsensus.getTo(), hmmSeq.getDatasetSequence()); + } } diff --git a/test/jalview/structure/StructureMappingTest.java b/test/jalview/structure/StructureMappingTest.java index f26c5f1..036aeaa 100644 --- a/test/jalview/structure/StructureMappingTest.java +++ b/test/jalview/structure/StructureMappingTest.java @@ -1,8 +1,14 @@ package jalview.structure; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import jalview.datamodel.Mapping; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceI; +import jalview.util.MapList; + import java.util.HashMap; import java.util.List; @@ -11,9 +17,9 @@ import org.testng.annotations.Test; public class StructureMappingTest { @Test(groups = "Functional") - public void testgetPDBResNumRanges() + public void testGetPDBResNumRanges() { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); StructureMapping mapping = new StructureMapping(null, null, null, null, map, null); @@ -43,4 +49,75 @@ public class StructureMappingTest assertEquals(ranges.get(1)[0], 15); assertEquals(ranges.get(1)[1], 15); } + + @Test(groups = "Functional") + public void testEquals() + { + SequenceI seq1 = new Sequence("seq1", "ABCDE"); + SequenceI seq2 = new Sequence("seq1", "ABCDE"); + String pdbFile = "a/b/file1.pdb"; + String pdbId = "1a70"; + String chain = "A"; + String mappingDetails = "these are the mapping details, honest"; + HashMap map = new HashMap<>(); + + Mapping seqToPdbMapping = new Mapping(seq1, + new MapList(new int[] + { 1, 5 }, new int[] { 2, 6 }, 1, 1)); + StructureMapping sm1 = new StructureMapping(seq1, pdbFile, pdbId, chain, + map, mappingDetails, seqToPdbMapping); + assertFalse(sm1.equals(null)); + assertFalse(sm1.equals("x")); + + StructureMapping sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, + map, mappingDetails, seqToPdbMapping); + assertTrue(sm1.equals(sm2)); + assertTrue(sm2.equals(sm1)); + assertEquals(sm1.hashCode(), sm2.hashCode()); + + // with different sequence + sm2 = new StructureMapping(seq2, pdbFile, pdbId, chain, map, + mappingDetails, seqToPdbMapping); + assertFalse(sm1.equals(sm2)); + assertFalse(sm2.equals(sm1)); + + // with different file + sm2 = new StructureMapping(seq1, "a/b/file2.pdb", pdbId, chain, map, + mappingDetails, seqToPdbMapping); + assertFalse(sm1.equals(sm2)); + assertFalse(sm2.equals(sm1)); + + // with different pdbid (case sensitive) + sm2 = new StructureMapping(seq1, pdbFile, "1A70", chain, map, + mappingDetails, seqToPdbMapping); + assertFalse(sm1.equals(sm2)); + assertFalse(sm2.equals(sm1)); + + // with different chain + sm2 = new StructureMapping(seq1, pdbFile, pdbId, "B", map, + mappingDetails, seqToPdbMapping); + assertFalse(sm1.equals(sm2)); + assertFalse(sm2.equals(sm1)); + + // map is ignore for this test + sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, null, + mappingDetails, seqToPdbMapping); + assertTrue(sm1.equals(sm2)); + assertTrue(sm2.equals(sm1)); + + // with different mapping details + sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map, + "different details!", seqToPdbMapping); + assertFalse(sm1.equals(sm2)); + assertFalse(sm2.equals(sm1)); + + // with different seq to pdb mapping + Mapping map2 = new Mapping(seq1, + new MapList(new int[] + { 1, 5 }, new int[] { 3, 7 }, 1, 1)); + sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map, + mappingDetails, map2); + assertFalse(sm1.equals(sm2)); + assertFalse(sm2.equals(sm1)); + } } diff --git a/test/jalview/util/MapListTest.java b/test/jalview/util/MapListTest.java index fd68e96..cd3e124 100644 --- a/test/jalview/util/MapListTest.java +++ b/test/jalview/util/MapListTest.java @@ -391,7 +391,9 @@ public class MapListTest MapList ml7 = new MapList(codons, protein, 3, 1); // toShifts differ assertTrue(ml.equals(ml)); + assertEquals(ml.hashCode(), ml.hashCode()); assertTrue(ml.equals(ml1)); + assertEquals(ml.hashCode(), ml1.hashCode()); assertTrue(ml1.equals(ml)); assertFalse(ml.equals(null)); diff --git a/utils/InstallAnywhere/Jalview.iap_xml b/utils/InstallAnywhere/Jalview.iap_xml index a649cb4..20726f5 100755 --- a/utils/InstallAnywhere/Jalview.iap_xml +++ b/utils/InstallAnywhere/Jalview.iap_xml @@ -2320,6 +2320,58 @@ and any path to a file to save to the file]]>

      + + + false + + + true + + + true + + + + + + + + + + + + false + + + + + + true + + + true + + + true + + + + + + 1355141 + + + false + + + 0 + + + + + + + false @@ -7230,6 +7282,7 @@ and any path to a file to read from that file]]> + false @@ -7981,6 +8034,7 @@ and any path to a file to read from that file]]> +