Merge branch 'kjvdh/features/PhylogenyViewer_tabbedsupport' into merge/2_11_2/kjvdh...
authorJim Procter <j.procter@dundee.ac.uk>
Thu, 2 Jun 2022 15:05:51 +0000 (16:05 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Thu, 2 Jun 2022 15:05:51 +0000 (16:05 +0100)
Update from Release 2.11.2 develop branch JAL-1953
 Conflicts:
.classpath
.project
resources/lang/Messages.properties
src/jalview/bin/Jalview.java
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/fts/core/GFTSPanel.java
src/jalview/fts/service/pdb/PDBFTSPanel.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/DasSourceBrowser.java
src/jalview/gui/Desktop.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/SplashScreen.java
src/jalview/gui/StructureViewerBase.java
src/jalview/gui/TreePanel.java
src/jalview/gui/WebserviceInfo.java
src/jalview/io/BioJsHTMLOutput.java
src/jalview/io/FileLoader.java
src/jalview/io/HtmlSvgOutput.java
src/jalview/io/NewickFile.java
src/jalview/math/Matrix.java
src/jalview/math/MatrixI.java
src/jalview/util/MappingUtils.java
src/jalview/ws/DBRefFetcher.java
src/jalview/ws/DasSequenceFeatureFetcher.java
src/jalview/ws/jws2/Jws2Discoverer.java
utils/eclipse/org.eclipse.jdt.core.jalview.prefs
utils/eclipse/org.eclipse.jdt.ui.prefs

71 files changed:
.gitmodules [new file with mode: 0644]
_aptx_jalview_configuration_file.txt [new file with mode: 0644]
forester [new submodule]
resources/lang/Messages.properties
src/jalview/analysis/TreeAlgorithm.java [new file with mode: 0644]
src/jalview/analysis/TreeBuilder.java
src/jalview/analysis/TreeCalculator.java [new file with mode: 0644]
src/jalview/analysis/TreeModel.java
src/jalview/appletgui/OverviewPanel.java
src/jalview/appletgui/PCAPanel.java
src/jalview/appletgui/RedundancyPanel.java
src/jalview/appletgui/TreePanel.java
src/jalview/bin/Jalview.java
src/jalview/ext/archaeopteryx/Aptx.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/AptxInit.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/AptxTreeBuilder.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/AptxTreePanel.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/JalviewBinding.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/LoadedTreeAssociation.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/Tree.java [new file with mode: 0644]
src/jalview/ext/archaeopteryx/TreeNode.java [new file with mode: 0644]
src/jalview/ext/forester/DataConversions.java [new file with mode: 0644]
src/jalview/ext/forester/ForesterMatrix.java [new file with mode: 0644]
src/jalview/ext/forester/io/SupportedTreeFileFilter.java [new file with mode: 0644]
src/jalview/ext/forester/io/TreeDatabaseMenuBuilder.java [new file with mode: 0644]
src/jalview/ext/forester/io/TreeParser.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalLoadedTreeAssociationI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreeBuilderI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreeI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreeNodeI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreePanelI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreeParserI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreeViewerBindingI.java [new file with mode: 0644]
src/jalview/ext/treeviewer/ExternalTreeViewerI.java [new file with mode: 0644]
src/jalview/fts/service/pdb/PDBFTSPanel.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AppJmol.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/Console.java
src/jalview/gui/Desktop.java
src/jalview/gui/JalviewDialog.java
src/jalview/gui/OverviewPanel.java
src/jalview/gui/PaintRefresher.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/StructureViewerBase.java
src/jalview/gui/TreeCanvas.java
src/jalview/gui/TreePanel.java
src/jalview/gui/TreeParams.java [new file with mode: 0644]
src/jalview/gui/VamsasApplication.java
src/jalview/gui/WebserviceInfo.java
src/jalview/gui/WsPreferences.java
src/jalview/io/BioJsHTMLOutput.java
src/jalview/io/FileLoader.java
src/jalview/io/NewickFile.java
src/jalview/javascript/JSFunctionExec.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/math/Matrix.java
src/jalview/math/MatrixI.java
src/jalview/util/AWTConsole.java
src/jalview/util/MappingUtils.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/ws/DBRefFetcher.java
src/jalview/ws/jws1/Discoverer.java
src/jalview/ws/jws2/Jws2Discoverer.java
test/jalview/ext/archaeopteryx/AptxJalviewSequenceTreeTest.java [new file with mode: 0644]
test/jalview/ext/archaeopteryx/AptxPhylogenyTreeTest.java [new file with mode: 0644]
test/jalview/ext/archaeopteryx/TreeViewTest.java [new file with mode: 0644]
test/jalview/gui/FreeUpMemoryTest.java
test/jalview/io/NewickFileTests.java
utils/eclipse/org.eclipse.jdt.core.jalview.prefs

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..e9167c0
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "forester"]
+       path = forester
+       url = file:////Users/kjvanderheide/Documents/Archae/forester
diff --git a/_aptx_jalview_configuration_file.txt b/_aptx_jalview_configuration_file.txt
new file mode 100644 (file)
index 0000000..447f9a4
--- /dev/null
@@ -0,0 +1,503 @@
+#  PLEASE DON'T MOVE ME
+#  User Interface Look and Feel
+#  ----------------------------
+#  Possible values for 'native_ui'
+#    'yes' to use native (system) "look and feel"
+#    'no'  to use Archaeopteryx-style "look and feel", can set GUI colors via this file (see below)
+#    '?'   to use native (system) "look and feel" if Mac OS X with Java 1.5 is detected,
+#          Archaeopteryx-style "look and feel" otherwise
+
+native_ui: yes
+
+
+
+#  Default Values for Options
+#  --------------------------
+#  Minimal confidence value to be displayed: 'min_confidence_value':
+#     Example: 'min_confidence_value: 50.0' (a commonly used 
+#     value for bootstrap support)
+#
+#  Font family name: 'font_family':
+#     Example: 'font_family: Arial_Unicode_MS,Dialog,SansSerif,Sans,Arial,Helvetica'
+#     It is advisable to use more than one value for font_family (in
+#     decreasing order of preference). Font family names have to be
+#     comma separated (no spaces). Spaces in font names have to be
+#     replaced by underscores (e.g. 'Arial_Unicode_MS').
+#
+#  Font size: 'font_size':
+#     Example: 'font_size: 10'
+#
+#  Screen antialias: 'antialias_screen': values: 'yes'/'no'
+#
+#  Show Scale: 'show_scale': values: 'yes'/'no'
+#
+#  Show branch length branch values: 'show_branch_length_values': values: 'yes'/'no'
+#
+#  Cladogram display type: 'cladogram_type'
+#     Example: 'cladogram_type: non_lined_up'
+#     The three possible values are: lined_up
+#                                    non_lined_up
+#
+#  Default line width for PDF export: 'pdf_export_line_wdith':
+#     Example: 'pdf_export_line_width: 0.5'
+#
+#  Show overview: 'show_overview': values: 'yes'/'no'
+#
+#  Phylogeny graphics type: 'phylogeny_graphics_type':
+#     Example: 'phylogeny_graphics_type: euro_style'
+#     The eight possible values are: rectangular
+#                                    euro_style
+#                                    rounded
+#                                    curved
+#                                    triangular
+#                                    convex
+#                                    unrooted
+#                                    circular
+#
+#  Node label direction for circular and unrooted type: 'node_label_direction':
+#     Example: 'node_label_direction: horizontal'
+#     The two possible values are: horizontal
+#                                  radial
+#
+#  Show default node shape for internal nodes: 'show_default_node_shapes_internal': values: 'yes'/'no'
+#
+#  Show default node shape for external nodes: 'show_default_node_shapes_external': values: 'yes'/'no'
+#
+#  Default node shape size: 'default_node_size'
+#     Example: 'default_node_size: 6'
+#
+#  Default node shape type: 'default_node_shape'
+#     Example: 'default_node_shape: '
+#     Possible values: circle
+#                      rectangle
+#
+#  Default node shape fill: 'default_node_fill'
+#     Example: 'default_node_fill: '
+#     Possible values: solid
+#                      gradient
+#                      none
+#
+#  To determine what data field to return by clicking on "List Node Data": 'list_node_data_field'
+#     Possible values: node_name
+#                      sequence_name
+#                      gene_name
+#                      sequence_acc
+#                      sequence_mol_seq_fasta
+#                      sequence_symbol
+#                      taxonomy_scientific_name
+#                      taxonomy_code
+#                      domains
+#                      domains_collapsed
+#                      seq_annotations
+#                      go_term_ids
+#                      user_selected
+#
+#  To determine where to return data selected by user clicking on "List Node Data": 'list_node_data_in'
+#     Contents of buffer can be obtained with method 'getCurrentExternalNodesDataBuffer()' of
+#     classes org.forester.archaeopteryx.MainFrame and org.forester.archaeopteryx.ArchaeopteryxE
+#     Possible values: window (for output to window and buffer)
+#                      console (for output to console and buffer)
+#                      buffer_only (for output to buffer only)
+#
+#  To override label for menu item to return data of external nodes (default "List Node Data"): 'list_node_data_custom_label'
+#     Example: 'list_node_data_custom_label: Get_Node_Data'
+# 
+#  Taxonomy colorization of nodes (shapes) instead of labels: 'taxonomy_colorize_node_shapes': values: 'yes'/'no'
+#
+#  Do/not color labels same as branch length values: 'color_labels_same_as_branch_length_values': values: 'yes'/'no'
+#
+#  Do/not show domain labels: 'show_domain_labels': values: 'yes'/'no'
+#
+#  Do/not show reference sources for sequence annotation: 'show_seq_annotation_ref_sources': values: 'yes'/'no'
+#
+#  Number of fraction digits for branch length values: 'branch_length_value_digits'
+#
+#  Number of fraction digits for confidence values: 'confidence_value_digits'
+#
+#  To turn on/off background color gradient: background_gradient
+#     Example: 'background_gradient: yes'
+#
+#  To allow/not allow editing (cut, copy, and paste): allow_editing
+#     Example: 'allow_editing: yes'
+#
+#  To allow/not allow thicker strokes for very small trees: allow_thick_strokes
+#     Example: 'allow_thick_strokes: yes'
+#
+#  NH/NHX/Nexus file parsing
+#  -------------------------
+#  To replace underscores with spaces during NH/NHX/Nexus file parsing:
+#     'replace_underscores_in_nh_parsing', possible values are 'yes', 'no'
+#
+#  To extract UniProt taxonomy codes (e.g. CAEEL) or UniProt identifiers (or scientific names)
+#  from node names during NH/NHX/Nexus file parsing: 'taxonomy_extraction_in_nh_parsing'
+#     possible values are:
+#     'no'
+#     'pfam_strict'  (for e.g. MOUSE from BCL2_MOUSE/23-453, or [uniprot] 10090 from BCL2_10090/23-453)
+#     'pfam_relaxed' (for e.g. MOUSE from bax_MOUSE, or [uniprot] 10090 from bax_10090)
+#     'aggressive'   (for e.g. MOUSE from MOUSE, or [uniprot] 10090 from 10090, or Nematostella vectensis from xyz_Nematostella_vectensis)
+#
+#  Internal node labels are confidence values during NH/NHX/Nexus file parsing:
+#     'internal_labels_are_confidence_values', possible values are 'yes', 'no'
+#
+#  phyloXML parsing
+#  ----------------
+#  To ensure compatibility with all current and future 
+#  phyloXML applications and to detect malformatted and
+#  possibly erroneous data, it is strongly recommended
+#  to enable validation of all phyloXML files
+#  against the XSD Schema (see: http://www.phyloxml.org/),
+#  with:
+#  'validate_against_phyloxml_xsd_schema: true'
+
+
+min_confidence_value:                      0.0
+font_family:                               Arial_Unicode_MS,Dialog,SansSerif,Sans,Arial,Helvetica
+font_size:                                 12
+font_size_min:                             2
+font_size_max:                             20
+antialias_screen:                          yes
+show_scale:                                yes
+cladogram_type:                            lined_up
+phylogeny_graphics_type:                   rectangular
+node_label_direction:                      horizontal
+show_default_node_shapes_internal:         yes
+show_default_node_shapes_external:         yes
+show_node_shapes_for_nodes_with_vis_data:  yes 
+default_node_size:                         5
+default_node_shape:                        rectangle
+default_node_fill:                         solid
+pdf_export_line_width:                     0.5
+show_overview:                             yes
+overview_width:                            120
+overview_height:                           120
+overview_placement_type:                   upper_right
+color_labels_same_as_branch_length_values: no
+display_sequence_relations:                no
+show_domain_labels:                        yes
+line_up_renderable_data:                   yes
+right_align_domain_architectures:          no
+show_seq_annotation_ref_sources:           yes
+branch_length_value_digits:                3
+confidence_value_digits:                   2
+background_gradient:                       no
+allow_editing:                             yes
+allow_thick_strokes:                       no
+list_node_data_in:                         window
+list_node_data_field:                      user_selected
+list_node_data_custom_label:         
+#  NH/NHX/Nexus file parsing:
+internal_labels_are_confidence_values:     no
+replace_underscores_in_nh_parsing:         no
+taxonomy_extraction_in_nh_parsing:         no
+#  phyloXML parsing:
+validate_against_phyloxml_xsd_schema:      true
+
+
+#  Checkbox Display Selection
+#  --------------------------
+#  This is used to select which checkboxes to display
+#  and what their initial values should be.
+#  Format: 'name: display|nodisplay yes|no'
+#  Note: if an option is not displayed, it will not be enabled
+#
+#  For the following use '?' to let Archaeopteryx decide (depending on tree):
+#  - 'phylogram'
+#  - 'write_confidence_values'
+#  - 'write_events'
+
+phylogram:                      display   ?
+rollover:                       display   yes
+color_according_to_sequence:    display   no
+color_according_to_species:     display   no
+color_according_to_annotation:  display   no
+show_node_names:                display   yes
+show_seq_names:                 display   yes
+show_seq_symbols:               display   yes
+show_seq_acc:                   display   no
+show_gene_names:                display   yes
+show_taxonomy_code:             display   yes
+show_taxonomy_scientific_names: display   yes
+show_taxonomy_rank:             display   no
+show_taxonomy_common_names:     display   no
+show_taxonomy_images:           display   no
+show_annotations:               display   no
+write_confidence_values:        display   ?
+write_branch_length_values:     display   yes
+write_events:                   display   ?
+use_visual_styles:              display   no
+width_branches:                 display   no
+show_domain_architectures:      display   no
+show_msa:                       display   no
+show_binary_characters:         display   no
+show_binary_character_counts:   display   no
+display_internal_data:          display   yes
+dynamically_hide_data:          display   yes
+show_relation_confidence:       display   no
+show_properties:                display   no
+show_vector_data:               display   no
+
+
+
+#  Combo-box Display Selection
+#  ---------------------------
+#  Format: 'name: display/nodisplay'
+click_to: display_node_data        display
+click_to: collapse_uncollapse      display
+click_to: uncollapse_all           display
+click_to: reroot                   display
+click_to: subtree                  display
+click_to: swap                     display
+click_to: order_subtree            display
+click_to: sort_descendants         display
+click_to: color_subtree            display
+click_to: change_node_font         display
+click_to: color_node_font          display
+click_to: open_seq_web             display
+click_to: open_pdb_web             display
+click_to: open_tax_web             display
+click_to: blast                    display
+click_to: cut_subtree              display
+click_to: copy_subtree             display
+click_to: paste_subtree            display
+click_to: delete                   display
+click_to: add_new_node             display
+click_to: edit_node_data           display
+click_to: select_nodes             display
+click_to: get_ext_descendents_data display
+
+#   Default click-to option (any of the above if set to "display")
+default_click_to: select_nodes
+
+
+
+#  Default Tree Display Colors
+#  ---------------------------
+
+display_color: background                 0xFFFFFF
+display_color: background_gradient_bottom 0xFFFFFF
+display_color: sequence                   0x111111
+display_color: taxonomy                   0x8D8D8D
+display_color: confidence                 0xAEAEAE
+display_color: branch_length              0x3A3A3A
+display_color: branch                     0x000000
+display_color: node_box                   0x000000
+display_color: collapsed                  0x000000
+display_color: matching_a                 0xCC6600
+display_color: matching_b                 0xCC70CC
+display_color: matching_a_and_b           0x0000CC
+display_color: duplication                0xFF00FF
+display_color: speciation                 0xFFFF00
+display_color: duplication_or_specation   0xFFAA20
+display_color: domain_label               0x939393
+display_color: domain_base                0x505050
+display_color: binary_domain_combinations 0x4169FF
+display_color: annotation                 0xFFCC00
+display_color: overview                   0x828282
+
+
+
+#  GUI (graphical user interface) Colors
+#  -------------------------------------
+#
+#  These are ignored if native (system) "look and feel"
+#  is being used ('native_ui: yes').
+
+gui_background_color:                 0x202020
+gui_checkbox_text_color:              0xDCDCDC
+gui_checkbox_and_button_active_color: 0xFF0000
+gui_button_text_color:                0xFFFFFF
+gui_button_background_color:          0x404040
+gui_menu_background_color:            0x000000
+gui_menu_text_color:                  0xFFFFFF
+gui_button_border_color:              0x000000
+
+
+#  Vector Data Display Colors and Sizes
+#  ------------------------------------
+vector_data_min_color:                0x0000FF
+vector_data_max_color:                0xFFFF00
+vector_data_mean_color:               0x000000
+vector_data_width:                    120
+vector_data_height:                   12
+
+
+#  Settings Specific for Archaeopteryx Applets (E and A)
+#  -----------------------------------------------------
+#  To automatically midpoint reroot trees upon loading: 'midpoint_reroot: yes'
+
+midpoint_reroot: yes
+
+
+
+#  Settings Specific for ArchaeopteryxE Applets
+#  --------------------------------------------
+#  To hide controls and menus: 'hide_controls_and_menus: yes'
+#  To use tabbed display     : 'use_tabbed_display: yes'
+
+hide_controls_and_menus: no
+use_tabbed_display:      yes
+
+
+
+#  Settings For Phylogenetic Inference
+#  -----------------------------------
+#  EXPERIMENTAL: DO NOT USE!!
+
+default_number_of_bootstrap_resamples: 100
+mafft_local:                            /bin/mafft
+fastme_local:                           /bin/fastme
+raxml_local:                            /bin/raxml
+
+
+
+#  Sequence colors
+#  ---------------
+#  Format: species_color: sequencename hexcolor
+sequence_color: Tubulin-alpha        0xEE0000
+sequence_color: Tubulin-beta         0x00EE00
+
+
+#  Species colors
+#  --------------
+#  Format: species_color: speciesname hexcolor
+species_color: BRAFL        0x00FFFF
+species_color: SPHGR        0x9620F0
+species_color: STRPU        0x9620F0
+species_color: CIOIN        0xFF1CAE
+species_color: CIOSA        0xFF2CAE
+species_color: BOVIN        0x5C3317
+species_color: CANFA        0x8B2323
+species_color: HUMAN        0xFF2400
+species_color: PANTR        0xCC2400
+species_color: MOUSE        0xFF7F00
+species_color: RAT          0xFFEF00
+species_color: MONDO        0xEE9A49
+species_color: ORNAN        0xCD853F
+species_color: XENLA        0x6BAA23
+species_color: XENTR        0x6BAA23
+species_color: CHICK        0xFFC125
+species_color: FUGRU        0x0000FF
+species_color: BRARE        0x0000DD
+species_color: DANRE        0x0000BB
+species_color: TETNG        0x0000AA
+species_color: ORYLA        0x000088
+species_color: GASAC        0x000066
+species_color: CAEEL        0x666699
+species_color: CAEBR        0xB0B0B0
+species_color: DROME        0x663366
+species_color: DROPS        0x996699
+species_color: APIME        0x7A7700
+species_color: AEDAE        0x8C5900
+species_color: TRICA        0x918E00
+species_color: NEMVE        0x0066CC
+species_color: HYDAT        0x3399FF
+species_color: HYDVU        0x3399FF
+species_color: LUBBA        0xF7B5CB
+species_color: GEOCY        0xF5A0BD
+species_color: AMPQE        0x009966
+species_color: SUBDO        0xC790B9
+species_color: MONBE        0xFC0FC0
+species_color: DICPU        0xFFCC33
+species_color: DICDI        0xFFCC00
+species_color: ENTHI        0x5959AB
+species_color: ARATH        0x00FF00
+species_color: POPTR        0x006400
+species_color: VITVI        0x00CD00
+species_color: GLYMA        0x00FF7F
+species_color: ORYSA        0x008B00
+species_color: ORYSJ        0x008C00
+species_color: SORBI        0x00EE76
+species_color: SELMO        0x238E23
+species_color: PHYPA        0x09F911
+species_color: OSTLU        0x7FFF00
+species_color: OSTTA        0x7FFF00
+species_color: OSTRC        0x7FFF00
+species_color: MICPU        0x66CD00
+species_color: MIC99        0x66CD00
+species_color: CHLRE        0xB3EE3A
+species_color: VOLCA        0xC0FF3E
+species_color: CHLSP        0x6B8E23
+species_color: CYAME        0xD02090
+species_color: YEAST        0xAAAAAA
+species_color: BACFR        0xFF0000
+species_color: BACTN        0xFFFF00
+species_color: MYXXD        0x0000FF
+species_color: STIAU        0x00FFFF
+species_color: BACOV        0x8C5900
+species_color: BACUN        0x66CD00
+species_color: PORGI        0x918E00
+# rank: Class
+species_color: Mammalia       0xFF0000
+species_color: mammals        0xFF0000
+# rank: Phylum
+species_color: Chordata       0x8470FF
+species_color: Echinodermata  0x6495ED
+species_color: Hemichordata   0x7EC0EE
+species_color: Arthropoda     0x7AC5CD
+species_color: Nematoda       0x7171C6
+species_color: Tardigrada     0x388E8E
+species_color: Annelida       0xC67171
+species_color: Mollusca       0x00F5FF
+species_color: Ctenophora     0xBBFFFF
+species_color: Cnidaria       0xFF83FA
+species_color: Placozoa       0xEED2EE
+species_color: Porifera       0xFF3E96
+species_color: Microsporidia  0x8B8378
+species_color: Ascomycota     0xFF6347
+species_color: Basidiomycota  0xFFD700
+species_color: Chlorophyta    0x00C78C
+species_color: Streptophyta   0x00C957
+# rank: Kingdom
+species_color: Viridiplantae  0x00FF00
+species_color: plants         0x00FF00
+species_color: Metazoa        0x0000FF
+species_color: animals        0x0000FF
+species_color: Fungi          0xFF9912
+# rank: Superkingdom
+species_color: Viruses        0xFFD700
+species_color: Bacteria       0x00FF00
+species_color: Archaea        0x0000FF
+species_color: Eukaryota      0xFF0000
+species_color: eukaryotes     0xFF0000
+
+
+
+#  Domain colors
+#  -------------
+domain_color: Cofilin_ADF     0xFC0FC0
+domain_color: TIR             0x900000
+domain_color: NACHT           0x202020
+domain_color: CARD            0xFF0000
+domain_color: Peptidase_C14   0x00FF00
+domain_color: Death           0x0000FF
+domain_color: DED             0x00FFFF
+domain_color: BIR             0xCCFF33
+domain_color: PAAD_DAPIN      0x9999CC
+domain_color: NB-ARC          0x500050
+domain_color: WD40            0x888888
+domain_color: RVT_1           0x999900
+domain_color: CBM_48          0xFF0000
+domain_color: Alpha-amylase   0x0000FF
+domain_color: Alpha-amylase_C 0x0080FF
+domain_color: CBM_48          0xFF0000
+domain_color: Alpha-amylase   0x0000FF
+domain_color: Alpha-amylase_C 0x0080FF
+domain_color: GDE_N           0x009000
+domain_color: GDE_C           0x00FF00
+domain_color: hGDE_N          0x990099
+domain_color: GDE_N_bis       0x007000
+domain_color: hGDE_central    0xFF8000
+domain_color: hGDE_amylase    0x0000EE
+domain_color: hDGE_amylase    0x0000EE
+
+
+
+#  Annotation colors
+#  -----------------
+annotation_color: dehydrogenase 0x0000FF
+annotation_color: kinase        0xFF00FF
+annotation_color: protease      0x009900
+annotation_color: transcription 0xAAAA00
+
+
+# END
\ No newline at end of file
diff --git a/forester b/forester
new file mode 160000 (submodule)
index 0000000..642ccb7
--- /dev/null
+++ b/forester
@@ -0,0 +1 @@
+Subproject commit 642ccb75fc1e4cb7def346cb2f56191907f82a34
index 9ce5a63..291052a 100644 (file)
@@ -302,7 +302,7 @@ label.show_distances = Show distances
 label.mark_unassociated_leaves = Mark Unassociated Leaves
 label.fit_to_window = Fit To Window
 label.newick_format = Newick Format
-label.select_newick_like_tree_file = Select a newick-like tree file
+label.select_tree_file = Select a tree file
 label.colours = Colours
 label.view_mapping = View Mapping
 label.wireframe = Wireframe
@@ -387,6 +387,9 @@ label.selected_region_to_tree_may_only_contain_residues_or_gaps =  The selected
 label.sequences_selection_not_aligned = Sequences in selection are not aligned
 label.problem_reading_tree_file =  Problem reading tree file
 label.possible_problem_with_tree_file = Possible problem with tree file
+label.tree_url_example = Please enter a complete URL, for example \"http://www.jalview.org/examples/ferredoxin.nw\"
+label.from_database = From Database...
+label.load_tree_url = Tree from URL
 label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation = Please select at least three bases in at least one sequence in order to perform a cDNA translation.
 label.translation_failed = Translation Failed
 label.error_when_translating_sequences_submit_bug_report = Unfortunately, something went wrong when translating your sequences.\nPlease take a look in the Jalview java console\nand submit a bug report including the stacktrace.
@@ -557,7 +560,7 @@ label.select_copy_raw_html = Select this if you want to copy raw html
 label.from_url = from URL
 label.any_trees_calculated_or_loaded_alignment_automatically_sort = When selected, any trees calculated or loaded onto the alignment will automatically sort the alignment
 label.sort_with_new_tree = Sort With New Tree
-label.from_textbox = from Textbox
+label.from_textbox = From Textbox
 label.window = Window
 label.preferences = Preferences
 label.tools = Tools
@@ -1047,6 +1050,7 @@ exception.couldnt_parse_sequence_line = Could not parse sequence line: {0}
 exception.unknown_annotation_detected = Unknown annotation detected: {0} {1}
 exception.couldnt_store_sequence_mappings = Couldn''t store sequence mappings for {0}
 exception.matrix_too_many_iteration = Too many iterations in {0} (max is {1})
+exception.invalid_matrix_identifier = Sequence identifier {0} not found in distance matrix.
 exception.browser_not_found = Exception in finding browser: {0}
 exception.browser_unable_to_launch = Unable to launch browser: {0}
 exception.browser_unable_to_locate = Unable to locate browser: {0}
diff --git a/src/jalview/analysis/TreeAlgorithm.java b/src/jalview/analysis/TreeAlgorithm.java
new file mode 100644 (file)
index 0000000..7aaa913
--- /dev/null
@@ -0,0 +1,31 @@
+package jalview.analysis;
+
+public enum TreeAlgorithm
+{
+  NEIGHBOUR_JOINING("NJ", "Neighbour Joining"),
+  AVERAGE_DISTANCE("AV", "Average Distance (UPGMA)"),
+  MAXIMUM_PARSIMONY("MP", ("Maximum Parsimony")),
+  MAXIMUM_LIKELIHOOD("ML", "Maximum Likelihood"),
+  BAYESIAN("BY", "Bayesian Inference");
+
+  private final String abbreviation;
+
+  private final String name;
+
+  TreeAlgorithm(String abbreviatedName, String fullName)
+  {
+    this.abbreviation = abbreviatedName;
+    this.name = fullName;
+  }
+
+  public String getAbbreviation()
+  {
+    return abbreviation;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+}
index 0601dd9..c4a94eb 100644 (file)
@@ -67,13 +67,19 @@ public abstract class TreeBuilder
 
   double maxDistValue;
 
-  double maxheight;
+  double maxHeight;
 
   int ycount;
 
   Vector<SequenceNode> node;
 
-  private AlignmentView seqStrings;
+  protected ScoreModelI scoreModel;
+
+  protected SimilarityParamsI scoreParams;
+
+  private AlignmentViewport avport;
+
+  private AlignmentView seqStrings; // redundant? (see seqData)
 
   /**
    * Constructor
@@ -86,6 +92,7 @@ public abstract class TreeBuilder
           SimilarityParamsI scoreParameters)
   {
     int start, end;
+    avport = av;
     boolean selview = av.getSelectionGroup() != null
             && av.getSelectionGroup().getSize() > 1;
     seqStrings = av.getAlignmentView(selview);
@@ -125,20 +132,20 @@ public abstract class TreeBuilder
   {
     if (nd == null)
     {
-      return maxheight;
+      return maxHeight;
     }
 
     if ((nd.left() == null) && (nd.right() == null))
     {
       nd.height = ((SequenceNode) nd.parent()).height + nd.dist;
 
-      if (nd.height > maxheight)
+      if (nd.height > maxHeight)
       {
         return nd.height;
       }
       else
       {
-        return maxheight;
+        return maxHeight;
       }
     }
     else
@@ -149,15 +156,15 @@ public abstract class TreeBuilder
       }
       else
       {
-        maxheight = 0;
+        maxHeight = 0;
         nd.height = (float) 0.0;
       }
 
-      maxheight = findHeight((SequenceNode) (nd.left()));
-      maxheight = findHeight((SequenceNode) (nd.right()));
+      maxHeight = findHeight((SequenceNode) (nd.left()));
+      maxHeight = findHeight((SequenceNode) (nd.right()));
     }
 
-    return maxheight;
+    return maxHeight;
   }
 
   /**
@@ -295,7 +302,11 @@ public abstract class TreeBuilder
    */
   protected void computeTree(ScoreModelI sm, SimilarityParamsI scoreOptions)
   {
-    distances = sm.findDistances(seqData, scoreOptions);
+
+    this.scoreModel = sm;
+    this.scoreParams = scoreOptions;
+
+    distances = scoreModel.findDistances(seqData, scoreParams);
 
     makeLeaves();
 
@@ -364,7 +375,7 @@ public abstract class TreeBuilder
 
   protected void init(AlignmentView seqView, int start, int end)
   {
-    this.node = new Vector<SequenceNode>();
+    this.node = new Vector<>();
     if (seqView != null)
     {
       this.seqData = seqView;
@@ -458,7 +469,7 @@ public abstract class TreeBuilder
    */
   void makeLeaves()
   {
-    clusters = new Vector<BitSet>();
+    clusters = new Vector<>();
 
     for (int i = 0; i < noseqs; i++)
     {
@@ -467,6 +478,7 @@ public abstract class TreeBuilder
       sn.setElement(sequences[i]);
       sn.setName(sequences[i].getName());
       node.addElement(sn);
+
       BitSet bs = new BitSet();
       bs.set(i);
       clusters.addElement(bs);
@@ -478,4 +490,24 @@ public abstract class TreeBuilder
     return seqStrings;
   }
 
+  public MatrixI getDistances()
+  {
+    return distances;
+  }
+
+  public ScoreModelI getScoreModel()
+  {
+    return scoreModel;
+  }
+
+  public SimilarityParamsI getScoreParams()
+  {
+    return scoreParams;
+  }
+
+  public AlignmentViewport getAvport()
+  {
+    return avport;
+  }
+
 }
diff --git a/src/jalview/analysis/TreeCalculator.java b/src/jalview/analysis/TreeCalculator.java
new file mode 100644 (file)
index 0000000..84deba2
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($Version-Rel$)
+ * Copyright (C) $Year-Rel$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.analysis;
+
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.analysis.ScoreModelI;
+import jalview.api.analysis.SimilarityParamsI;
+import jalview.gui.AlignViewport;
+
+/**
+ * @author kjvanderheide
+ *
+ */
+public class TreeCalculator extends Thread// add threading
+{
+  SimilarityParamsI similarityParams;
+
+  String treeType;
+
+  String scoreModelName; // if tree computed
+
+  /**
+   * 
+   * @param treeAlgo
+   * @param substitutionMatrix
+   * @param calculateParams
+   */
+  public TreeCalculator(String treeAlgo, String substitutionMatrix,
+          SimilarityParamsI calculateParams)
+  {
+    this.treeType = treeAlgo;
+    this.scoreModelName = substitutionMatrix;
+    this.similarityParams = calculateParams;
+  }
+
+  /**
+   * 
+   * @param alignViewport
+   * @return
+   */
+  public TreeBuilder makeTree(AlignViewport alignViewport)
+  {
+    ScoreModelI sm = ScoreModels.getInstance().getScoreModel(scoreModelName,
+            alignViewport.getAlignPanel());
+
+    TreeBuilder builtTree = treeType.equals(TreeBuilder.NEIGHBOUR_JOINING)
+            ? new NJTree(alignViewport, sm, similarityParams)
+            : new AverageDistanceTree(alignViewport, sm, similarityParams);
+
+    return builtTree;
+
+  }
+
+  public SimilarityParamsI getSimilarityParams()
+  {
+    return similarityParams;
+  }
+
+  public void setSimilarityParams(SimilarityParamsI similarityParams)
+  {
+    this.similarityParams = similarityParams;
+  }
+
+  public String getTreeType()
+  {
+    return treeType;
+  }
+
+  public void setTreeType(String treeType)
+  {
+    this.treeType = treeType;
+  }
+
+  public String getScoreModelName()
+  {
+    return scoreModelName;
+  }
+
+  public void setScoreModelName(String scoreModelName)
+  {
+    this.scoreModelName = scoreModelName;
+  }
+
+
+
+
+}
index 4d5e4b2..11ca778 100644 (file)
@@ -81,8 +81,8 @@ public class TreeModel
   public TreeModel(SequenceI[] seqs, AlignmentView odata,
           NewickFile treefile)
   {
-    this(seqs, treefile.getTree(), treefile.HasDistances(),
-            treefile.HasBootstrap(), treefile.HasRootDistance());
+    this(seqs, treefile.getTree(), treefile.hasDistances(),
+            treefile.hasBootstrap(), treefile.hasRootDistance());
     seqData = odata;
 
     associateLeavesToSequences(seqs);
@@ -131,29 +131,27 @@ public class TreeModel
 
     Vector<SequenceNode> leaves = findLeaves(top);
 
-    int i = 0;
     int namesleft = seqs.length;
 
-    SequenceNode j;
-    SequenceI nam;
-    String realnam;
-    Vector<SequenceI> one2many = new Vector<SequenceI>();
+    SequenceI nodeSequence;
+    String nodeSequenceName;
+    Vector<SequenceI> one2many = new Vector<>();
     // int countOne2Many = 0;
-    while (i < leaves.size())
+
+    for (SequenceNode sn : leaves)
     {
-      j = leaves.elementAt(i++);
-      realnam = j.getName();
-      nam = null;
+      nodeSequenceName = sn.getName();
+      nodeSequence = null;
 
       if (namesleft > -1)
       {
-        nam = algnIds.findIdMatch(realnam);
+        nodeSequence = algnIds.findIdMatch(nodeSequenceName);
       }
 
-      if (nam != null)
+      if (nodeSequence != null)
       {
-        j.setElement(nam);
-        if (one2many.contains(nam))
+        sn.setElement(nodeSequence);
+        if (one2many.contains(nodeSequence))
         {
           // countOne2Many++;
           // if (Cache.isDebugEnabled())
@@ -162,14 +160,14 @@ public class TreeModel
         }
         else
         {
-          one2many.addElement(nam);
+          one2many.addElement(nodeSequence);
           namesleft--;
         }
       }
       else
       {
-        j.setElement(new Sequence(realnam, "THISISAPLACEHLDER"));
-        j.setPlaceholder(true);
+        sn.setElement(new Sequence(nodeSequenceName, "THISISAPLACEHLDER"));
+        sn.setPlaceholder(true);
       }
     }
     // if (Cache.isDebugEnabled() && countOne2Many>0) {
@@ -296,7 +294,7 @@ public class TreeModel
    */
   public Vector<SequenceNode> findLeaves(SequenceNode nd)
   {
-    Vector<SequenceNode> leaves = new Vector<SequenceNode>();
+    Vector<SequenceNode> leaves = new Vector<>();
     findLeaves(nd, leaves);
     return leaves;
   }
@@ -390,7 +388,7 @@ public class TreeModel
    */
   public List<SequenceNode> groupNodes(float threshold)
   {
-    List<SequenceNode> groups = new ArrayList<SequenceNode>();
+    List<SequenceNode> groups = new ArrayList<>();
     _groupNodes(groups, getTopNode(), threshold);
     return groups;
   }
index 71b3ac7..09e54e7 100755 (executable)
@@ -244,7 +244,7 @@ public class OverviewPanel extends Panel implements Runnable,
 
       updateRunning = true;
     }
-    Thread thread = new Thread(this);
+    Thread thread = new Thread(this, "OverviewUpdateThread");
     thread.start();
     repaint();
     updateRunning = false;
index 7c0dfa9..fe9d69b 100644 (file)
@@ -117,7 +117,7 @@ public class PCAPanel extends EmbmenuFrame
             MessageManager.getString("label.principal_component_analysis"),
             475, 400);
 
-    Thread worker = new Thread(this);
+    Thread worker = new Thread(this, "PCACalcThread");
     worker.start();
   }
 
@@ -218,7 +218,7 @@ public class PCAPanel extends EmbmenuFrame
         ScoreModelI scoreModel = ScoreModels.getInstance()
                 .getDefaultModel(false);
         pcaModel.setScoreModel(scoreModel);
-        new Thread(this).start();
+        new Thread(this, "PCARecalcThread").start();
       }
     }
     else if (evt.getSource() == protSetting)
@@ -229,7 +229,7 @@ public class PCAPanel extends EmbmenuFrame
         ScoreModelI scoreModel = ScoreModels.getInstance()
                 .getDefaultModel(true);
         pcaModel.setScoreModel(scoreModel);
-        new Thread(this).start();
+        new Thread(this, "PCARecalcThread").start();
       }
     }
   }
index bd36b0d..c7d8157 100644 (file)
@@ -89,7 +89,7 @@ public class RedundancyPanel extends SliderPanel
 
     frame.addWindowListener(this);
 
-    Thread worker = new Thread(this);
+    Thread worker = new Thread(this, "RedundancyCalcThread");
     worker.start();
   }
 
index 671fee1..e07984f 100644 (file)
@@ -207,12 +207,12 @@ public class TreePanel extends EmbmenuFrame
       {
         // Set default view, paying lip service to any overriding tree view
         // parameter settings
-        boolean showDist = newtree.HasDistances()
+        boolean showDist = newtree.hasDistances()
                 && av.applet.getDefaultParameter("showTreeDistances",
-                        newtree.HasDistances());
-        boolean showBoots = newtree.HasBootstrap()
+                        newtree.hasDistances());
+        boolean showBoots = newtree.hasBootstrap()
                 && av.applet.getDefaultParameter("showTreeBootstraps",
-                        newtree.HasBootstrap());
+                        newtree.hasBootstrap());
         distanceMenu.setState(showDist);
         bootstrapMenu.setState(showBoots);
         treeCanvas.setShowBootstrap(showBoots);
index fc4c821..efa5d6f 100755 (executable)
@@ -76,6 +76,9 @@ import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.ws.jws2.Jws2Discoverer;
 
+import groovy.lang.Binding;
+import groovy.util.GroovyScriptEngine;
+
 /**
  * Main class for Jalview Application <br>
  * <br>
@@ -188,7 +191,7 @@ public class Jalview
             running--;
           }
         }
-      }).start();
+      }, "FeatureFetcherThread").start();
     }
 
     public synchronized boolean allFinished()
diff --git a/src/jalview/ext/archaeopteryx/Aptx.java b/src/jalview/ext/archaeopteryx/Aptx.java
new file mode 100644 (file)
index 0000000..640dd31
--- /dev/null
@@ -0,0 +1,17 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreeViewerI;
+
+import org.forester.archaeopteryx.MainFrame;
+
+public class Aptx implements ExternalTreeViewerI
+{
+  private final MainFrame aptxApp;
+
+  public Aptx(MainFrame aptx)
+  {
+    aptxApp = aptx;
+
+
+  }
+}
diff --git a/src/jalview/ext/archaeopteryx/AptxInit.java b/src/jalview/ext/archaeopteryx/AptxInit.java
new file mode 100644 (file)
index 0000000..e58a38d
--- /dev/null
@@ -0,0 +1,199 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.TreeBuilder;
+import jalview.datamodel.SequenceI;
+import jalview.ext.treeviewer.ExternalTreeBuilderI;
+import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
+import jalview.gui.Desktop;
+import jalview.viewmodel.AlignmentViewport;
+
+import java.awt.Dimension;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
+import org.forester.archaeopteryx.AptxUtil;
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.archaeopteryx.Configuration;
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.io.parsers.nhx.NHXParser;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+
+/**
+ * Static class for creating Archaeopteryx tree viewer instances from calculated
+ * trees and letting them be bound to Jalview.
+ * 
+ * @author kjvanderheide
+ *
+ */
+public final class AptxInit
+{
+
+  private final static Configuration APTX_CONFIG = new Configuration(
+          "_aptx_jalview_configuration_file", false, false, false);
+
+  private final static boolean VALIDATE_PHYLOXML_XSD = APTX_CONFIG
+          .isValidatePhyloXmlAgainstSchema();
+
+  private final static boolean REPLACE_NHX_UNDERSCORES = APTX_CONFIG
+          .isReplaceUnderscoresInNhParsing();
+
+  private final static boolean INTERNAL_NUMBERS_AS_CONFIDENCE = APTX_CONFIG
+          .isInternalNumberAreConfidenceForNhParsing();
+
+  private final static boolean MIDPOINT_REROOT = APTX_CONFIG
+          .isMidpointReroot();
+
+  private final static NHXParser.TAXONOMY_EXTRACTION TAXONOMY_EXTRACTION = APTX_CONFIG
+          .getTaxonomyExtraction();
+
+  /**
+   * Test method, should generally not be used as it does not bind the tree to
+   * its alignment
+   * 
+   * @param aptxTrees
+   * @return
+   */
+  public static MainFrame createUnboundInstance(final Phylogeny aptxTree)
+  {
+    Phylogeny[] aptxTrees = { aptxTree };
+    return createAptxFrame(aptxTrees);
+  }
+
+  // public static MainFrame createInstance(final Phylogeny[] aptxTrees,
+  // AlignmentViewport jalviewAlignmentView)
+  // {
+  // return createAptxFrameInJalview(aptxTrees);
+  //
+  // }
+  //
+  // public static MainFrame createInstance(final Phylogeny aptxTree,
+  // final AlignmentViewport jalviewAlignmentView)
+  // {
+  // Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
+  // // several trees simultaneously
+  // return createAptxFrameInJalview(aptxTrees);
+  //
+  // }
+
+  public static MainFrame createInstance(
+          final TreeBuilder calculatedTree) // very dense method, to be split up
+  {
+    ExternalTreeBuilderI<Phylogeny, PhylogenyNode> aptxTreeBuilder = new AptxTreeBuilder(
+            calculatedTree);
+
+    Phylogeny aptxTree = aptxTreeBuilder.buildTree();
+    Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
+                                          // several trees simultaneously
+
+    MainFrame aptxApp = createAptxFrame(aptxTrees);
+            
+    bindNodesToJalviewSequences(aptxApp, calculatedTree.getAvport(),
+            aptxTreeBuilder.getAlignmentBoundNodes(),
+            aptxTreeBuilder.getNodesBoundAlignment());
+
+    return bindFrameToJalview(aptxApp);
+
+  }
+
+  public static MainFrame createInstanceFromFile(String filePath,
+          AlignmentViewport viewport)
+  {
+    String[] AptxArgs = new String[] { "-c",
+        APTX_CONFIG.getConfigFilename(), filePath };
+    MainFrame aptxApp = Archaeopteryx.main(AptxArgs);
+
+    int tabCount = aptxApp.getMainPanel().getTabbedPane().getTabCount();
+
+    for (int i = 0; i < tabCount; i++)
+    {
+      // roundabout way to select each tree because getComponentAt(i) requires
+      // casting to TreePanel which doesn't work
+      aptxApp.getMainPanel().getTabbedPane().setSelectedIndex(i);
+      Phylogeny tree = aptxApp.getMainPanel().getCurrentTreePanel()
+              .getPhylogeny();
+
+    LoadedTreeAssociation bindAptxNodes = new LoadedTreeAssociation(
+            viewport.getAlignment().getSequencesArray(),
+              tree);
+
+    bindAptxNodes.associateLeavesToSequences();
+
+    bindNodesToJalviewSequences(aptxApp, viewport,
+            bindAptxNodes.getAlignmentWithNodes(),
+            bindAptxNodes.getNodesWithAlignment());
+    }
+    return bindFrameToJalview(aptxApp);
+  }
+
+  public static MainFrame createInstanceFromUrl(URL treeUrl,
+          AlignmentViewport viewport)
+          throws FileNotFoundException, IOException, RuntimeException
+  {
+    String treeTitle = treeUrl.getFile();
+    Phylogeny[] trees = AptxUtil.readPhylogeniesFromUrl(treeUrl,
+            VALIDATE_PHYLOXML_XSD,
+             REPLACE_NHX_UNDERSCORES, INTERNAL_NUMBERS_AS_CONFIDENCE,
+            TAXONOMY_EXTRACTION, MIDPOINT_REROOT);
+    MainFrame aptxApp = Archaeopteryx.createApplication(trees, APTX_CONFIG,
+            treeTitle);
+
+    for (Phylogeny tree : trees)
+    {
+      LoadedTreeAssociation bindAptxNodes = new LoadedTreeAssociation(
+              viewport.getAlignment().getSequencesArray(), tree);
+
+      bindAptxNodes.associateLeavesToSequences();
+      bindNodesToJalviewSequences(aptxApp, viewport,
+              bindAptxNodes.getAlignmentWithNodes(),
+              bindAptxNodes.getNodesWithAlignment());
+
+    }
+
+    return bindFrameToJalview(aptxApp);
+
+  }
+
+
+
+
+  public static MainFrame createAptxFrame(
+          final Phylogeny[] aptxTrees)
+  {
+    MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees,
+            APTX_CONFIG, null);
+    return aptxApp;
+  }
+
+
+  public static ExternalTreeViewerBindingI<?> bindNodesToJalviewSequences(
+          final MainFrame aptxApp,
+          final AlignmentViewport jalviewAlignViewport,
+          final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
+          final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
+  {
+    return new JalviewBinding(aptxApp, jalviewAlignViewport,
+            alignMappedToNodes, nodesMappedToAlign);
+  }
+
+
+  public static MainFrame bindFrameToJalview(final MainFrame aptxApp)
+  {
+    int width = 400;
+    int height = 550;
+    aptxApp.setMinimumSize(new Dimension(width, height));
+    // aptxApp.setFont(Desktop.instance.getFont());
+    // aptxApp.getMainPanel().setFont(Desktop.instance.getFont());
+
+    Desktop.addInternalFrame(aptxApp, "Archaeopteryx Tree View", true,
+            width, height, true, true);
+
+    return aptxApp;
+
+  }
+
+
+
+}
diff --git a/src/jalview/ext/archaeopteryx/AptxTreeBuilder.java b/src/jalview/ext/archaeopteryx/AptxTreeBuilder.java
new file mode 100644 (file)
index 0000000..74d89d2
--- /dev/null
@@ -0,0 +1,170 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.TreeBuilder;
+import jalview.datamodel.SequenceI;
+import jalview.ext.forester.DataConversions;
+import jalview.ext.forester.ForesterMatrix;
+import jalview.ext.treeviewer.ExternalTreeBuilderI;
+import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.forester.evoinference.matrix.distance.DistanceMatrix;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.NodeData;
+import org.forester.phylogeny.data.Sequence;
+
+/**
+ * Class for converting trees made in Jalview (through TreeBuilder) to trees
+ * compatible with Forester (Phylogeny objects).
+ * 
+ * Note that this currently demands a 1:1 relationship between tree nodes and
+ * the sequences used for generating them.
+ * 
+ * @author kjvanderheide
+ *
+ */
+public class AptxTreeBuilder
+        implements ExternalTreeBuilderI<Phylogeny, PhylogenyNode>
+{
+  protected final SequenceI[] sequences;
+
+  protected final DistanceMatrix distances;
+  
+  protected final TreeBuilder jalviewTree;
+  
+  public String treeTitle;
+
+  private final Phylogeny aptxTree;
+
+  private PhylogenyNode rootNode;
+
+  private final Map<SequenceI, PhylogenyNode> alignmentWithNodes;
+
+  private final Map<PhylogenyNode, SequenceI> nodesWithAlignment;
+
+  public AptxTreeBuilder(final TreeBuilder calculatedTree)
+  {
+    jalviewTree = calculatedTree;
+    sequences = jalviewTree.getSequences();
+    distances = ForesterMatrix.convertJalviewToForester(
+            jalviewTree.getDistances(), sequences);
+
+    aptxTree = new Phylogeny();
+    rootNode = new PhylogenyNode();
+
+    int amountOfSequences = distances.getSize();
+    alignmentWithNodes = new HashMap<>(amountOfSequences);
+    nodesWithAlignment = new HashMap<>(amountOfSequences);
+
+
+  }
+
+  @Override
+  public Phylogeny buildTree(final PhylogenyNode treeRoot)
+  {
+
+    if (treeRoot != null)
+    {
+      rootNode = treeRoot;
+    }
+
+    buildTree();
+
+    return aptxTree;
+
+  }
+
+
+  @Override
+  public Phylogeny buildTree()
+  {
+
+    for (SequenceI sequence : sequences)
+    {
+      Sequence seq = DataConversions
+              .createForesterSequence(sequence, true);
+      PhylogenyNode sequenceNode = new PhylogenyNode(sequence.getName());
+
+      NodeData nodeData = sequenceNode.getNodeData();
+      nodeData.setSequence(seq);
+
+      MappingUtils.putWithDuplicationCheck(nodesWithAlignment,
+              sequenceNode, sequence);
+      MappingUtils.putWithDuplicationCheck(alignmentWithNodes,
+              sequence, sequenceNode);
+      rootNode.addAsChild(sequenceNode);
+    }
+
+
+    aptxTree.setRoot(rootNode);
+
+    treeTitle = generateTreeName();
+    aptxTree.setName(treeTitle);
+
+    return aptxTree;
+
+  }
+
+  @Override
+  public Map<SequenceI, PhylogenyNode> getAlignmentBoundNodes()
+  {
+    return alignmentWithNodes;
+  }
+
+  @Override
+  public Map<PhylogenyNode, SequenceI> getNodesBoundAlignment()
+  {
+    return nodesWithAlignment;
+  }
+
+  private Phylogeny clusterNodes()
+  {
+    return aptxTree;
+
+  }
+  /**
+   * Formats a localised title for the tree panel, like
+   * <p>
+   * Neighbour Joining Using BLOSUM62
+   * <p>
+   * For a tree loaded from file, just uses the file name
+   * 
+   * @return
+   */
+  @Override
+  public String generateTreeName() // Move this and add selection region to the
+                                   // title when applicable
+  {
+    if (treeTitle != null) // will currently never happen, loaded tree file will
+                           // take a different path
+    {
+      return treeTitle;
+    }
+    else
+    {
+      /*
+      * i18n description of Neighbour Joining or Average Distance method
+      */
+      String treecalcnm = MessageManager
+              .getString("label.tree_calc_" + jalviewTree.getClass()
+                      .getSimpleName().substring(0, 2).toLowerCase());
+      /*
+      * short score model name (long description can be too long)
+      */
+      String smn = jalviewTree.getScoreModel().getName();
+
+      /*
+      * put them together as <method> Using <model>
+      */
+      final String ttl = MessageManager
+              .formatMessage("label.treecalc_title", treecalcnm, smn);
+      return ttl;
+    }
+  }
+  
+
+}
diff --git a/src/jalview/ext/archaeopteryx/AptxTreePanel.java b/src/jalview/ext/archaeopteryx/AptxTreePanel.java
new file mode 100644 (file)
index 0000000..631ff15
--- /dev/null
@@ -0,0 +1,14 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreePanelI;
+
+public class AptxTreePanel implements ExternalTreePanelI
+{
+  private final org.forester.archaeopteryx.TreePanel treeView;
+
+  public AptxTreePanel(org.forester.archaeopteryx.TreePanel aptxTreePanel)
+  {
+    treeView = aptxTreePanel;
+
+  }
+}
diff --git a/src/jalview/ext/archaeopteryx/JalviewBinding.java b/src/jalview/ext/archaeopteryx/JalviewBinding.java
new file mode 100644 (file)
index 0000000..7a0668d
--- /dev/null
@@ -0,0 +1,452 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
+import jalview.gui.PaintRefresher;
+import jalview.structure.SelectionSource;
+import jalview.structure.StructureSelectionManager;
+import jalview.viewmodel.AlignmentViewport;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyNode;
+
+/**
+ * Class for binding the Archaeopteryx tree viewer to the Jalview alignment that
+ * it originates from, meaning that selecting sequences in the tree viewer also
+ * selects them in the alignment view and vice versa.
+ * 
+ * @author kjvanderheide
+ *
+ */
+public final class JalviewBinding
+        implements ExternalTreeViewerBindingI<PhylogenyNode>
+{
+  private final MainFrame aptxFrame;
+
+  private org.forester.archaeopteryx.TreePanel currentTreeView;
+
+  private final AlignmentViewport parentAvport;
+
+  private JTabbedPane treeTabs;
+
+  private final StructureSelectionManager ssm;
+
+  private Map<SequenceI, PhylogenyNode> sequencesBoundToNodes;
+
+  private Map<PhylogenyNode, SequenceI> nodesBoundToSequences;
+
+  /**
+   * 
+   * @param archaeopteryx
+   * 
+   * @param jalviewAlignmentViewport
+   *          alignment viewport from which the tree was calculated.
+   * 
+   * @param alignMappedToNodes
+   *          map with sequences used to calculate the tree and matching tree
+   *          nodes as key, value pair respectively.
+   * 
+   * @param nodesMappedToAlign
+   *          map with tree nodes and matching sequences used to calculate the
+   *          tree as key, value pair respectively.
+   */
+  public JalviewBinding(final MainFrame archaeopteryx,
+          final AlignmentViewport jalviewAlignmentViewport,
+          final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
+          final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
+  {
+    // deal with/prohibit null values here as that will cause problems
+    aptxFrame = archaeopteryx;
+    parentAvport = jalviewAlignmentViewport;
+    sequencesBoundToNodes = alignMappedToNodes;
+    nodesBoundToSequences = nodesMappedToAlign;
+
+    treeTabs = aptxFrame.getMainPanel().getTabbedPane();
+    ssm = parentAvport.getStructureSelectionManager();
+
+    // archaeopteryx.getMainPanel().getControlPanel().setColorBranches(true);
+    
+    ssm.addSelectionListener(this);
+
+    int tabCount = treeTabs.getTabCount();
+
+    for (int i = 0; i < tabCount; i++)
+    {
+      // roundabout way to select each tree because getComponentAt(i) requires
+      // casting to TreePanel which doesn't work
+      treeTabs.setSelectedIndex(i);
+      currentTreeView = aptxFrame.getMainPanel().getCurrentTreePanel();
+      currentTreeView.addMouseListener(this);
+      PaintRefresher.Register(currentTreeView,
+              parentAvport.getSequenceSetId());
+    }
+
+
+    treeTabs.addChangeListener(new ChangeListener()
+    {
+
+      @Override
+      public void stateChanged(ChangeEvent e)
+      {
+
+        SwingUtilities.invokeLater(new Runnable()
+        {
+
+          @Override
+          /**
+           * Resend the selection to the tree view when tabs get switched, this
+           * has to be buried in invokeLater as Forester first resets the tree
+           * view on switching tabs, without invokeLater this would get called
+           * before Forester resets which would nullify the selection.
+           */
+          public void run()
+          {
+            currentTreeView = aptxFrame.getMainPanel()
+                    .getCurrentTreePanel();
+            parentAvport.sendSelection();
+
+          }
+        });
+
+      }
+      
+    });
+
+  }
+
+  @Override
+  public void actionPerformed(ActionEvent e)
+  {
+  }
+
+  @Override
+  public void mouseClicked(MouseEvent e)
+  {
+    SwingUtilities.invokeLater(new Runnable() {
+
+      @Override
+      /**
+       * invokeLater so that this always runs after Forester's mouseClicked
+       */
+      public void run()
+      {
+
+        final PhylogenyNode node = currentTreeView.findNode(e.getX(),
+                e.getY());
+        if (node != null)
+        {
+          if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) // clear previous
+          // selection if shift
+          // IS NOT pressed
+          {
+
+            parentAvport.setSelectionGroup(null);
+
+          }
+          showNodeSelectionOnAlign(node);
+        }
+        else
+        {
+          partitionTree(e);
+        
+        
+      }
+      
+      }
+    });
+
+
+  }
+
+  @Override
+  public void mousePressed(final MouseEvent e)
+  {
+
+  }
+  @Override
+  public void mouseReleased(MouseEvent e)
+  {
+  }
+
+  @Override
+  public void mouseEntered(MouseEvent e)
+  {
+  }
+
+  @Override
+  public void mouseExited(MouseEvent e)
+  {
+  }
+
+
+  @Override
+  public void selection(final SequenceGroup seqsel,
+          final ColumnSelection colsel, final HiddenColumns hidden,
+          final SelectionSource source)
+  {
+    if (source == parentAvport) // check if source is alignment from where the
+    // tree originates
+    {
+      currentTreeView.setFoundNodes0(
+              new HashSet<Long>(seqsel.getSequences().size()));
+
+      for (SequenceI selectedSequence : seqsel.getSequences())
+      {
+        PhylogenyNode matchingNode = sequencesBoundToNodes.get(selectedSequence);
+        if (matchingNode != null)
+        {
+          currentTreeView.getFoundNodes0().add(matchingNode.getId());
+        }
+
+      }
+      aptxFrame.repaint();
+
+    }
+
+
+  }
+
+  /**
+   * Partially refactored from TreeCanvas
+   */
+  public void partitionTree(final MouseEvent e)
+  {
+    int x = e.getX();
+    int lineLength = currentTreeView.getHeight();
+
+    Phylogeny tree = currentTreeView.getPhylogeny();
+    double treeHeight = tree.calculateHeight(true);
+
+
+
+    if (treeHeight != 0)
+    {
+      int viewWidth = currentTreeView.getWidth();
+
+      // treeView.validate();
+
+      // System.out.println("selection");
+      // System.out.println(x);
+      // System.out.println("-------------");
+      // System.out.println("width");
+      // System.out.println(viewWidth);
+
+    }
+
+
+  }
+  
+
+
+  @Override
+  public void showNodeSelectionOnAlign(final PhylogenyNode node)
+  {
+
+      if (node.isInternal())
+      {
+        showMatchingChildSequences(node);
+      }
+
+      else
+      {
+        showMatchingSequence(node);
+      }
+
+    }
+
+
+
+
+
+  @Override
+  public void showMatchingSequence(final PhylogenyNode nodeToMatch)
+  {
+    SequenceI matchingSequence = nodesBoundToSequences.get(nodeToMatch);
+    if (matchingSequence != null)
+    {
+      long nodeId = nodeToMatch.getId();
+      addOrRemoveInSet(currentTreeView.getFoundNodes0(), nodeId);
+      treeSelectionChanged(matchingSequence);
+      parentAvport.sendSelection();
+
+    }
+  }
+
+  @Override
+  public void showMatchingChildSequences(final PhylogenyNode parentNode)
+  {
+    List<PhylogenyNode> childNodes = PhylogenyMethods
+            .getAllDescendants(parentNode);
+
+
+    for (PhylogenyNode childNode : childNodes)
+    {
+      // childNode.getBranchData().setBranchColor(new BranchColor(Color.BLUE));
+
+      SequenceI matchingSequence = nodesBoundToSequences.get(childNode);
+      if (matchingSequence != null)
+      {
+        long nodeId = childNode.getId();
+        addOrRemoveInSet(currentTreeView.getFoundNodes0(), nodeId);
+
+        treeSelectionChanged(matchingSequence);
+
+      }
+
+    }
+    parentAvport.sendSelection();
+
+
+  }
+
+  /**
+   * Refactored from TreeCanvas.
+   * 
+   * @param sequence
+   *          of the node selected in the tree viewer.
+   */
+  @Override
+  public void treeSelectionChanged(final SequenceI sequence)
+  {
+    if (!parentAvport.isClosed()) // alignment view could be closed
+    {
+      SequenceGroup selected = parentAvport.getSelectionGroup();
+
+      if (selected == null)
+      {
+        selected = new SequenceGroup();
+        parentAvport.setSelectionGroup(selected);
+      }
+
+      selected.setEndRes(parentAvport.getAlignment().getWidth() - 1);
+        selected.addOrRemove(sequence, true);
+    }
+
+  }
+  public void sortByTree_actionPerformed() {
+    // parentAvport.mirrorCommand(command, undo, ssm, source);
+
+    // alignFrame
+    // .addHistoryItem(sortAlignmentIn(treeCanvas.ap));
+    
+  }
+  
+
+  /**
+   * sort the associated alignment view by the current tree.
+   * 
+   * @param e
+   */
+  // @Override
+  // public void sortByTree_actionPerformed()// modify for Aptx
+  // {
+  //
+  // // if (treeCanvas.applyToAllViews)
+  //
+  // final ArrayList<CommandI> commands = new ArrayList<>();
+  // for (AlignmentPanel ap : PaintRefresher
+  // .getAssociatedPanels(parentAvport.getSequenceSetId()))
+  // {
+  // commands.add(sortAlignmentIn(ap.av.getAlignPanel()));
+  // }
+  // av.getAlignPanel().alignFrame.addHistoryItem(new CommandI()
+  // {
+  //
+  // @Override
+  // public void undoCommand(AlignmentI[] views)
+  // {
+  // for (CommandI tsort : commands)
+  // {
+  // tsort.undoCommand(views);
+  // }
+  // }
+  //
+  // @Override
+  // public int getSize()
+  // {
+  // return commands.size();
+  // }
+  //
+  // @Override
+  // public String getDescription()
+  // {
+  // return "Tree Sort (many views)";
+  // }
+  //
+  // @Override
+  // public void doCommand(AlignmentI[] views)
+  // {
+  //
+  // for (CommandI tsort : commands)
+  // {
+  // tsort.doCommand(views);
+  // }
+  // }
+  // });
+  // for (AlignmentPanel ap : PaintRefresher
+  // .getAssociatedPanels(av.getSequenceSetId()))
+  // {
+  // // ensure all the alignFrames refresh their GI after adding an undo item
+  // ap.alignFrame.updateEditMenuBar();
+  // }
+  // }
+  // else
+  // {
+  // treeCanvas.ap.alignFrame
+  // .addHistoryItem(sortAlignmentIn(treeCanvas.ap));
+  // }
+
+
+
+  /**
+   * TO BE MOVED
+   * 
+   * @param set
+   * @param objectToCheck
+   */
+  public static <E> void addOrRemoveInSet(Set<E> set, E objectToCheck)
+  {
+    if (set.contains(objectToCheck))
+    {
+      set.remove(objectToCheck);
+    }
+    else
+    {
+      set.add(objectToCheck);
+    }
+
+  }
+
+  public AlignmentViewport getParentAvport()
+  {
+    return parentAvport;
+  }
+
+  public org.forester.archaeopteryx.TreePanel getTreeView()
+  {
+    return currentTreeView;
+  }
+
+}
+
+
+
+
diff --git a/src/jalview/ext/archaeopteryx/LoadedTreeAssociation.java b/src/jalview/ext/archaeopteryx/LoadedTreeAssociation.java
new file mode 100644 (file)
index 0000000..c869cd5
--- /dev/null
@@ -0,0 +1,163 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.SequenceIdMatcher;
+import jalview.datamodel.SequenceI;
+import jalview.ext.forester.DataConversions;
+import jalview.ext.treeviewer.ExternalLoadedTreeAssociationI;
+import jalview.util.MappingUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+
+public class LoadedTreeAssociation
+        implements ExternalLoadedTreeAssociationI
+{
+  SequenceI[] alignSequences;
+
+  Phylogeny tree;
+
+  Map<SequenceI, PhylogenyNode> alignmentWithNodes;
+
+  Map<PhylogenyNode, SequenceI> nodesWithAlignment;
+
+  public LoadedTreeAssociation(SequenceI[] alignmentSequences,
+          Phylogeny aptxTree)
+  {
+    alignSequences = alignmentSequences;
+    tree = aptxTree;
+    alignmentWithNodes = new HashMap<>(alignSequences.length);
+    nodesWithAlignment = new HashMap<>(alignSequences.length);
+
+  }
+
+
+
+  /**
+   * Tries to match sequences from Jalview with tree nodes in Archaeopteryx and
+   * fills in the tree node with sequence data if a match is found.
+   * 
+   * Partially refactored from the old Jalview TreeModel
+   * associateLeavesToSequences method.
+   *
+   * @param seqs
+   * @param aptxTree
+   */
+  @Override
+  public void associateLeavesToSequences()
+
+  {
+    SequenceIdMatcher algnIds = new SequenceIdMatcher(alignSequences);
+
+    List<PhylogenyNode> leaves = tree.getExternalNodes();
+    SequenceI nodeSequence;
+    String nodeSequenceName;
+
+    for (PhylogenyNode treeNode : leaves)
+    {
+      nodeSequenceName = treeNode.getName();
+
+      nodeSequence = algnIds.findIdMatch(nodeSequenceName);
+      if (nodeSequence != null)
+      {
+        org.forester.phylogeny.data.Sequence foresterNodeSeq = DataConversions
+                .createForesterSequence(nodeSequence, true);
+        treeNode.getNodeData().setSequence(foresterNodeSeq);
+
+        MappingUtils.putWithDuplicationCheck(alignmentWithNodes,
+                nodeSequence, treeNode);
+        MappingUtils.putWithDuplicationCheck(nodesWithAlignment,
+                treeNode, nodeSequence);
+
+
+      }
+
+    }
+
+  }
+
+
+
+  public Map<SequenceI, PhylogenyNode> getAlignmentWithNodes()
+  {
+    return alignmentWithNodes;
+  }
+
+  public Map<PhylogenyNode, SequenceI> getNodesWithAlignment()
+  {
+    return nodesWithAlignment;
+  }
+
+  // {
+  // SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
+  //
+  // List<PhylogenyNode> leaves = aptxTree.getExternalNodes();
+  //
+  // int namesleft = seqs.length;
+  // SequenceI nodeSequence;
+  // String nodeSequenceName;
+  // List<SequenceI> one2many = new ArrayList<>();
+  // int countOne2Many = 0;
+  //
+  // for (PhylogenyNode treeNode : leaves)
+  // {
+  // nodeSequenceName = treeNode.getName();
+  // nodeSequence = null;
+  //
+  // if (namesleft > -1)
+  // {
+  // nodeSequence = algnIds.findIdMatch(nodeSequenceName);
+  // }
+  //
+  // if (nodeSequence != null)
+  // {
+  // org.forester.phylogeny.data.Sequence foresterNodeSeq =
+  // ForesterDataConversions.createForesterSequence(nodeSequence, true);
+  //
+  // treeNode.getNodeData().setSequence(foresterNodeSeq);
+  // if (one2many.contains(nodeSequence))
+  // {
+  // countOne2Many++;
+  // if (jalview.bin.Cache.log.isDebugEnabled())
+  // {
+  // jalview.bin.Cache.log.debug("One 2 many relationship for"
+  // +nodeSequence.getName());
+  // }
+  // }
+  // else
+  // {
+  // one2many.add(nodeSequence);
+  // namesleft--;
+  // }
+  // }
+  // else
+  // {
+  // treeNode.setCollapse(true); // collapse nodes that couldn't be connected
+  // // to a sequence
+  //
+  //
+  // // treeNode.setElement( new Sequence(nodeSequenceName,
+  // "THISISAPLACEHOLDER"));
+  // // treeNode.setPlaceholder(true);
+  // }
+  // }
+  // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many > 0)
+  // {
+  // jalview.bin.Cache.log.debug("There were " + countOne2Many
+  // + "alignment sequence ids (out of" + one2many.size()
+  // + " unique ids) linked to two or more leaves.");
+  // }
+  // one2many.clear();
+  //
+  // }
+
+}
+
+
+
+
+
+
diff --git a/src/jalview/ext/archaeopteryx/Tree.java b/src/jalview/ext/archaeopteryx/Tree.java
new file mode 100644 (file)
index 0000000..884a359
--- /dev/null
@@ -0,0 +1,50 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeNodeI;
+
+import org.forester.phylogeny.Phylogeny;
+
+public class Tree implements ExternalTreeI
+{
+  private final Phylogeny tree;
+
+  public Tree(Phylogeny aptxTree)
+  {
+    tree = aptxTree;
+  }
+
+  @Override
+  public Phylogeny getOriginalTree()
+  {
+    return tree;
+
+  }
+
+  @Override
+  public ExternalTreeNodeI getRoot()
+  {
+    ExternalTreeNodeI root = new TreeNode(tree.getRoot());
+    return root;
+  }
+
+  @Override
+  public void setTreeName(String name)
+  {
+    tree.setName(name);
+
+  }
+
+  @Override
+  public ExternalTreeNodeI getNodeWithName(String name)
+  {
+    return new TreeNode(tree.getNode(name));
+
+  }
+
+  @Override
+  public String[] getAllLeafNames()
+  {
+    return tree.getAllExternalNodeNames();
+  }
+}
diff --git a/src/jalview/ext/archaeopteryx/TreeNode.java b/src/jalview/ext/archaeopteryx/TreeNode.java
new file mode 100644 (file)
index 0000000..8e06d6c
--- /dev/null
@@ -0,0 +1,38 @@
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreeNodeI;
+
+import java.util.List;
+
+import org.forester.phylogeny.PhylogenyNode;
+
+public class TreeNode implements ExternalTreeNodeI
+{
+  private final PhylogenyNode node;
+
+  public TreeNode(PhylogenyNode aptxNode)
+  {
+    node = aptxNode;
+  }
+
+  @Override
+  public PhylogenyNode getOriginalNode()
+  {
+    return node;
+  }
+
+  @Override
+  public String getNodeName()
+  {
+    return node.getName();
+  }
+
+  @Override
+  public List<ExternalTreeNodeI> getChildren()
+  {
+    // return node.getDescendants();
+    return null;
+  }
+
+
+}
diff --git a/src/jalview/ext/forester/DataConversions.java b/src/jalview/ext/forester/DataConversions.java
new file mode 100644 (file)
index 0000000..be97e0e
--- /dev/null
@@ -0,0 +1,76 @@
+package jalview.ext.forester;
+
+import jalview.datamodel.SequenceI;
+import jalview.math.MatrixI;
+
+import org.forester.evoinference.matrix.distance.DistanceMatrix;
+import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
+
+public final class DataConversions
+{
+  public static org.forester.phylogeny.data.Sequence createForesterSequence(
+          final SequenceI jalviewSequence, final boolean sequenceIsAligned)
+  {
+    org.forester.phylogeny.data.Sequence foresterSeq = new org.forester.phylogeny.data.Sequence();
+
+    if (jalviewSequence.getDescription() != null)
+    {
+      foresterSeq.setName(jalviewSequence.getDescription());
+    }
+    foresterSeq.setMolecularSequenceAligned(sequenceIsAligned); // all tree
+                                                                // sequences
+                                                                // should
+                                                                // be aligned
+                                                                // already
+    foresterSeq.setMolecularSequence(jalviewSequence.getSequenceAsString());
+    if (jalviewSequence.isProtein()) // add checks for DNA or RNA (infer from
+                                     // forester itself?)
+    {
+      try
+      {
+        foresterSeq.setType("protein");
+      } catch (final PhyloXmlDataFormatException ignore)
+      {
+        // do nothing
+      }
+
+    }
+
+    return foresterSeq;
+
+  }
+
+
+  // public static org.forester.phylogeny.data.Accession
+  // createForesterAccession(
+  // SequenceI jalviewSequence)
+  // {
+  //
+  //
+  // org.forester.phylogeny.data.Accession foresterAcs = new
+  // org.forester.phylogeny.data.Accession();
+  //
+  // return foresterAcs;
+  // }
+
+  public static DistanceMatrix createForesterDistanceMatrix(
+          final MatrixI jalviewInputMatrix,
+          final String[] matrixIdentifiers)
+  {
+
+    DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix,
+            matrixIdentifiers);
+    return foresterMatrix;
+
+  }
+
+  public static DistanceMatrix createForesterDistanceMatrix(
+          final MatrixI jalviewInputMatrix,
+          final SequenceI[] matrixSequences)
+  {
+    DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix,
+            matrixSequences);
+    return foresterMatrix;
+
+  }
+}
diff --git a/src/jalview/ext/forester/ForesterMatrix.java b/src/jalview/ext/forester/ForesterMatrix.java
new file mode 100644 (file)
index 0000000..a12dc1d
--- /dev/null
@@ -0,0 +1,184 @@
+package jalview.ext.forester;
+
+import jalview.datamodel.SequenceI;
+import jalview.math.MatrixI;
+import jalview.util.MessageManager;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.NoSuchElementException;
+import java.util.stream.IntStream;
+
+import org.forester.evoinference.matrix.distance.DistanceMatrix;
+import org.forester.util.ForesterUtil;
+import org.forester.util.IllegalFormatUseException;
+
+public class ForesterMatrix implements DistanceMatrix
+{
+  private final static NumberFormat PHYLIP_FORMATTER = new DecimalFormat(
+          "0.000000"); // straight from forester
+
+  private final MatrixI jalviewMatrix;
+
+  private final String[] identifiers;
+
+  public ForesterMatrix(final MatrixI jalviewInputMatrix,
+          final SequenceI[] matrixSequences)
+  {
+    this.jalviewMatrix = jalviewInputMatrix;
+    this.identifiers = new String[matrixSequences.length];
+
+    int i = 0;
+    for (SequenceI sequence : matrixSequences)
+    {
+      identifiers[i] = sequence.getName();
+      i++;
+    }
+
+  }
+
+  public ForesterMatrix(final MatrixI jalviewInputMatrix,
+          final String[] matrixIdentifiers)
+  {
+    this.jalviewMatrix = jalviewInputMatrix;
+    this.identifiers = matrixIdentifiers;
+
+  }
+
+  @Override
+  public String getIdentifier(final int i)
+  {
+    return identifiers[i]; // add handling if index is out of bounds
+  }
+
+
+  @Override
+  public int getIndex(final String identifier)
+  {
+    try {
+    return IntStream.range(0, identifiers.length)
+            .filter(x -> identifier.equals(identifiers[x])).findAny()
+              .getAsInt(); // stream to bypass otherwise having to duplicate the
+                           // list
+                           // with Arrays.aslist
+    }
+    catch (NoSuchElementException ex) {
+      throw new Error(MessageManager.formatMessage(
+              "exception.invalid_matrix_identifier", new String[]
+              { identifier }));
+    }
+  }
+
+  /**
+   * Returns the length of whichever is longest, columns or rows
+   */
+  @Override
+  public int getSize()
+  {
+    return jalviewMatrix.getValues().length;
+  }
+
+  /**
+   * See {@link MatrixI#getValue(int,int)} except that the order of column, row
+   * in the parameters is inverted here (as that is how forester demands it)
+   */
+  @Override
+  public double getValue(final int col, final int row)
+  {
+    return jalviewMatrix.getValue(row, col);
+  }
+
+  @Override
+  public void setIdentifier(final int i, final String identifier)
+  {
+    identifiers[i] = identifier;
+
+  }
+
+  /**
+   * See {@link MatrixI#setValue()} except that the order of column, row in the
+   * parameters is inverted here (as that is how forester demands it)
+   */
+  @Override
+  public void setValue(final int col, final int row, final double distance)
+  {
+    jalviewMatrix.setValue(row, col, distance);
+
+  }
+
+  @Override
+  public StringBuffer toStringBuffer(Format format)
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /**
+   * See {@link MatrixI#getValues()}
+   */
+  @Override
+  public double[][] getValues()
+  {
+    return jalviewMatrix.getValues();
+  }
+
+  @Override
+  public void write(final Writer w) throws IOException // directly copied from
+                                                 // forester
+  {
+    w.write("    ");
+    w.write(getSize() + "");
+    w.write(ForesterUtil.LINE_SEPARATOR);
+    for (int row = 0; row < getSize(); ++row)
+    {
+      if (!ForesterUtil.isEmpty(getIdentifier(row)))
+      {
+        w.write(ForesterUtil.pad(getIdentifier(row), 10, ' ', false)
+                .toString());
+        w.write(' ');
+        w.write(' ');
+      }
+      else
+      {
+        throw new IllegalFormatUseException(
+                "Phylip format does not allow empty identifiers");
+      }
+      for (int col = 0; col < getSize(); ++col)
+      {
+        w.write(PHYLIP_FORMATTER.format(getValue(col, row)));
+        if (col < (getSize() - 1))
+        {
+          w.write(' ');
+          w.write(' ');
+        }
+      }
+      if (row < (getSize() - 1))
+      {
+        w.write(ForesterUtil.LINE_SEPARATOR);
+      }
+    }
+
+  }
+
+  public static DistanceMatrix convertJalviewToForester(
+          final MatrixI jalviewInputMatrix,
+          final SequenceI[] matrixSequences)
+  {
+    return DataConversions.createForesterDistanceMatrix(
+            jalviewInputMatrix, matrixSequences);
+
+  }
+
+  public static DistanceMatrix convertJalviewToForester(
+          final MatrixI jalviewInputMatrix,
+          final String[] matrixIdentifiers)
+  {
+    return DataConversions.createForesterDistanceMatrix(
+            jalviewInputMatrix, matrixIdentifiers);
+
+  }
+
+
+}
\ No newline at end of file
diff --git a/src/jalview/ext/forester/io/SupportedTreeFileFilter.java b/src/jalview/ext/forester/io/SupportedTreeFileFilter.java
new file mode 100644 (file)
index 0000000..b077485
--- /dev/null
@@ -0,0 +1,37 @@
+package jalview.ext.forester.io;
+
+
+import javax.swing.filechooser.FileFilter;
+
+import org.forester.archaeopteryx.MainFrame;
+
+
+public enum SupportedTreeFileFilter
+{
+  NHFILTER(MainFrame.nhfilter), NHXFILTER(MainFrame.nhxfilter),
+  XMLFILTER(MainFrame.xmlfilter), TOLFILTER(MainFrame.tolfilter),
+  NEXUSFILTER(MainFrame.nexusfilter),
+  DEFAULTFILTER(MainFrame.defaultfilter);
+
+  private final FileFilter treeFilter;
+
+  SupportedTreeFileFilter(final FileFilter treeFilter)
+  {
+    this.treeFilter = treeFilter;
+
+  }
+
+  public void printSupportedFormats()
+  {
+    for (SupportedTreeFileFilter format : SupportedTreeFileFilter.values())
+    {
+      System.out.println(format.getTreeFilter().getDescription());
+    }
+  }
+
+  public FileFilter getTreeFilter()
+  {
+    return treeFilter;
+  }
+
+}
diff --git a/src/jalview/ext/forester/io/TreeDatabaseMenuBuilder.java b/src/jalview/ext/forester/io/TreeDatabaseMenuBuilder.java
new file mode 100644 (file)
index 0000000..45415d1
--- /dev/null
@@ -0,0 +1,40 @@
+package jalview.ext.forester.io;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient;
+import org.forester.archaeopteryx.webservices.WebservicesManager;
+
+public class TreeDatabaseMenuBuilder
+{
+  final WebservicesManager webservicesManager;
+
+  JMenuItem[] treeDatabaseMenuItems;
+
+  public TreeDatabaseMenuBuilder()
+
+  {
+    webservicesManager = WebservicesManager
+            .getInstance();
+
+  }
+
+  public JMenu fillMenu(JMenu treeDbMenu) {
+    treeDatabaseMenuItems = new JMenuItem[webservicesManager
+                                          .getAvailablePhylogeniesWebserviceClients().size()];
+    
+    for (int i = 0; i < treeDatabaseMenuItems.length; ++i)
+    {
+      final PhylogeniesWebserviceClient client = webservicesManager
+              .getAvailablePhylogeniesWebserviceClient(i);
+      treeDatabaseMenuItems[i] = new JMenuItem(
+              client.getMenuName());
+      treeDbMenu.add(treeDatabaseMenuItems[i]);
+
+    }
+    return treeDbMenu;
+    
+  }
+
+}
diff --git a/src/jalview/ext/forester/io/TreeParser.java b/src/jalview/ext/forester/io/TreeParser.java
new file mode 100644 (file)
index 0000000..43fd1fa
--- /dev/null
@@ -0,0 +1,198 @@
+package jalview.ext.forester.io;
+
+import jalview.ext.archaeopteryx.AptxInit;
+import jalview.gui.AlignViewport;
+//import jalview.ext.treeviewer.ExternalTreeParserI;
+import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.NewickFile;
+import jalview.util.MessageManager;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.forester.util.ForesterUtil;
+
+public class TreeParser // implements ExternalTreeParserI<MainFrame>
+{
+  private final String filePath;
+
+  private final File file;
+
+  public TreeParser(final String treeFilePath)
+  {
+    final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
+    if (possibleError != null)
+    {
+      JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
+              MessageManager.getString("label.problem_reading_tree_file"),
+              JvOptionPane.WARNING_MESSAGE);
+
+    }
+    filePath = treeFilePath;
+    file = new File(filePath);
+
+  }
+
+  public TreeParser(final File treeFile) throws IOException
+  {
+    final String possibleError = ForesterUtil.isReadableFile(treeFile);
+    if (possibleError != null)
+    {
+      JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
+              MessageManager.getString("label.problem_reading_tree_file"),
+              JvOptionPane.WARNING_MESSAGE);
+
+    }
+    file = treeFile;
+    filePath = file.getCanonicalPath();
+  }
+
+  public void loadTree(AlignViewport viewport)
+  {
+
+    NewickFile fin = null; // old tree
+      try
+      {
+        AptxInit.createInstanceFromFile(filePath, viewport);
+
+        fin = new NewickFile(filePath, DataSourceType.FILE);
+        viewport.setCurrentTree(viewport.getAlignPanel().alignFrame
+                .showNewickTree(fin, filePath).getTree());
+
+      } catch (Exception ex)
+      {
+        JvOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
+                MessageManager.getString("label.problem_reading_tree_file"),
+                JvOptionPane.WARNING_MESSAGE);
+        ex.printStackTrace();
+      }
+      if (fin != null && fin.hasWarningMessage())
+      {
+        JvOptionPane.showMessageDialog(Desktop.desktop,
+                fin.getWarningMessage(),
+                MessageManager
+                        .getString("label.possible_problem_with_tree_file"),
+                JvOptionPane.WARNING_MESSAGE);
+      }
+    }
+  }
+
+
+//
+// @Override
+// public MainFrame loadTreeFile(AlignmentViewport viewport)
+// {
+// String[] AptxArgs = new String[] { "-c",
+// "_aptx_jalview_configuration_file", filePath };
+// MainFrame aptx = Archaeopteryx.main(AptxArgs);
+//
+// LoadedTreeAssociation bindAptxNodes = new LoadedTreeAssociation(
+// viewport.getAlignment().getSequencesArray(),
+// aptx.getMainPanel().getCurrentTreePanel().getPhylogeny());
+//
+// bindAptxNodes.associateLeavesToSequences();
+//
+// new JalviewBinding(aptx, viewport, bindAptxNodes.getAlignmentWithNodes(),
+// bindAptxNodes.getNodesWithAlignment());
+//
+// AptxInit.bindFrameToJalview(aptx);
+//
+// return aptx;
+//
+//
+// }
+// //
+// void readPhylogeniesFromURL() {
+// URL url = null;
+// Phylogeny[] phys = null;
+// final String message = "Please enter a complete URL, for example
+// \"http://purl.org/phylo/treebase/phylows/study/TB2:S15480?format=nexus\"";
+// final String url_string = JOptionPane
+// .showInputDialog( this,
+// message,
+// "Use URL/webservice to obtain a phylogeny",
+// JOptionPane.QUESTION_MESSAGE );
+// boolean nhx_or_nexus = false;
+// if ( ( url_string != null ) && ( url_string.length() > 0 ) ) {
+// try {
+// url = new URL( url_string );
+// PhylogenyParser parser = null;
+// if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) {
+// parser = new TolParser();
+// }
+// else {
+// parser = ParserUtils
+// .createParserDependingOnUrlContents( url,
+// getConfiguration().isValidatePhyloXmlAgainstSchema() );
+// }
+// if ( parser instanceof NexusPhylogeniesParser ) {
+// nhx_or_nexus = true;
+// }
+// else if ( parser instanceof NHXParser ) {
+// nhx_or_nexus = true;
+// }
+// if ( _mainpanel.getCurrentTreePanel() != null ) {
+// _mainpanel.getCurrentTreePanel().setWaitCursor();
+// }
+// else {
+// _mainpanel.setWaitCursor();
+// }
+// final PhylogenyFactory factory =
+// ParserBasedPhylogenyFactory.getInstance();
+// phys = factory.create( url.openStream(), parser );
+// }
+// catch ( final MalformedURLException e ) {
+// JOptionPane.showMessageDialog( this,
+// "Malformed URL: " + url + "\n" + e.getLocalizedMessage(),
+// "Malformed URL",
+// JOptionPane.ERROR_MESSAGE );
+// }
+// catch ( final IOException e ) {
+// JOptionPane.showMessageDialog( this,
+// "Could not read from " + url + "\n"
+// + ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
+// "Failed to read URL",
+// JOptionPane.ERROR_MESSAGE );
+// }
+// catch ( final Exception e ) {
+// JOptionPane.showMessageDialog( this,
+// ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
+// "Unexpected Exception",
+// JOptionPane.ERROR_MESSAGE );
+// }
+// finally {
+// if ( _mainpanel.getCurrentTreePanel() != null ) {
+// _mainpanel.getCurrentTreePanel().setArrowCursor();
+// }
+// else {
+// _mainpanel.setArrowCursor();
+// }
+// }
+// if ( ( phys != null ) && ( phys.length > 0 ) ) {
+// if ( nhx_or_nexus &&
+// getOptions().isInternalNumberAreConfidenceForNhParsing() ) {
+// for( final Phylogeny phy : phys ) {
+// PhylogenyMethods.transferInternalNodeNamesToConfidence( phy, "" );
+// }
+// }
+// AptxUtil.addPhylogeniesToTabs( phys,
+// new File( url.getFile() ).getName(),
+// new File( url.getFile() ).toString(),
+// getConfiguration(),
+// getMainPanel() );
+// _mainpanel.getControlPanel().showWhole();
+// }
+// }
+// activateSaveAllIfNeeded();
+// System.gc();
+// }
+//
+// }
+//
+//
+//
+//
+//
+//
diff --git a/src/jalview/ext/treeviewer/ExternalLoadedTreeAssociationI.java b/src/jalview/ext/treeviewer/ExternalLoadedTreeAssociationI.java
new file mode 100644 (file)
index 0000000..83ffac6
--- /dev/null
@@ -0,0 +1,14 @@
+package jalview.ext.treeviewer;
+
+/**
+ * Interface for associating the leaves of a loaded in (not calculated) tree to
+ * the alignment sequences in Jalview.
+ * 
+ * @author kjvanderheide
+ *
+ * 
+ */
+public interface ExternalLoadedTreeAssociationI
+{
+  public void associateLeavesToSequences();
+}
diff --git a/src/jalview/ext/treeviewer/ExternalTreeBuilderI.java b/src/jalview/ext/treeviewer/ExternalTreeBuilderI.java
new file mode 100644 (file)
index 0000000..8fd1d1d
--- /dev/null
@@ -0,0 +1,31 @@
+package jalview.ext.treeviewer;
+
+import jalview.datamodel.SequenceI;
+
+import java.util.Map;
+
+/**
+ * Note that this will take anything as a Tree or TreeNode object as no
+ * assumptions can be made about the inheritance structure of Tree or TreeNode
+ * (besides being Objects).
+ * 
+ * @author kjvanderheide
+ *
+ * @param <T>
+ *          Tree object that the tree viewer requires.
+ * @param <N>
+ *          Tree node object that the tree viewer requires.
+ */
+public interface ExternalTreeBuilderI<T, N>
+{
+  public T buildTree(N treeRoot);
+
+  public T buildTree();
+
+  public Map<SequenceI, N> getAlignmentBoundNodes();
+
+  public Map<N, SequenceI> getNodesBoundAlignment();
+
+  public String generateTreeName();
+
+}
diff --git a/src/jalview/ext/treeviewer/ExternalTreeI.java b/src/jalview/ext/treeviewer/ExternalTreeI.java
new file mode 100644 (file)
index 0000000..0184227
--- /dev/null
@@ -0,0 +1,15 @@
+package jalview.ext.treeviewer;
+
+public interface ExternalTreeI
+{
+  public void setTreeName(String name);
+
+  public <T> T getOriginalTree();
+
+  public ExternalTreeNodeI getRoot();
+
+  public ExternalTreeNodeI getNodeWithName(String name);
+
+  public String[] getAllLeafNames();
+
+}
diff --git a/src/jalview/ext/treeviewer/ExternalTreeNodeI.java b/src/jalview/ext/treeviewer/ExternalTreeNodeI.java
new file mode 100644 (file)
index 0000000..34f45bd
--- /dev/null
@@ -0,0 +1,12 @@
+package jalview.ext.treeviewer;
+
+import java.util.List;
+
+public interface ExternalTreeNodeI
+{
+  public <N> N getOriginalNode();
+
+  public String getNodeName();
+
+  public List<ExternalTreeNodeI> getChildren();
+}
diff --git a/src/jalview/ext/treeviewer/ExternalTreePanelI.java b/src/jalview/ext/treeviewer/ExternalTreePanelI.java
new file mode 100644 (file)
index 0000000..c488683
--- /dev/null
@@ -0,0 +1,6 @@
+package jalview.ext.treeviewer;
+
+public interface ExternalTreePanelI
+{
+
+}
diff --git a/src/jalview/ext/treeviewer/ExternalTreeParserI.java b/src/jalview/ext/treeviewer/ExternalTreeParserI.java
new file mode 100644 (file)
index 0000000..47960f9
--- /dev/null
@@ -0,0 +1,18 @@
+// package jalview.ext.treeviewer;
+//
+// import jalview.viewmodel.AlignmentViewport;
+//
+/// **
+// *
+// * Interface for loading in existing trees to an external tree viewer.
+// *
+// * @author kjvanderheide
+// *
+// */
+// public interface ExternalTreeParserI
+// {
+// public ExternalTreeI loadTreeFile(AlignmentViewport viewport);
+//
+// public ExternalTreeI loadTreeUrl(AlignmentViewport viewport);
+//
+// }
diff --git a/src/jalview/ext/treeviewer/ExternalTreeViewerBindingI.java b/src/jalview/ext/treeviewer/ExternalTreeViewerBindingI.java
new file mode 100644 (file)
index 0000000..a4ec9b2
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.ext.treeviewer;
+
+import jalview.datamodel.SequenceI;
+import jalview.structure.SelectionListener;
+import jalview.structure.SelectionSource;
+
+import java.awt.event.ActionListener;
+import java.awt.event.MouseListener;
+
+/**
+ * 
+ * Interface for binding a tree viewer to Jalview alignments. Assumes a tree
+ * viewer will both want to receive and send selection events. Note that this
+ * will take anything as a TreeNode object as no assumptions can be made about
+ * the inheritance structure of the TreeNode (besides being an Object).
+ * 
+ * @author kjvanderheide
+ *
+ * @param <N>
+ *          Tree node object.
+ */
+public interface ExternalTreeViewerBindingI<N>
+        extends ActionListener, MouseListener, SelectionListener,
+        SelectionSource
+{
+  /**
+   * If a node is selected in the tree panel this method highlights the
+   * corresponding sequence in the Jalview alignment view. If an internal node
+   * is selected all child sequences get highlighted as well.
+   */
+  public void showNodeSelectionOnAlign(N node);
+
+  public void treeSelectionChanged(SequenceI sequence);
+
+  public void showMatchingSequence(N nodeToMatch);
+
+  public void showMatchingChildSequences(N parentNode);
+
+}
diff --git a/src/jalview/ext/treeviewer/ExternalTreeViewerI.java b/src/jalview/ext/treeviewer/ExternalTreeViewerI.java
new file mode 100644 (file)
index 0000000..20c47f6
--- /dev/null
@@ -0,0 +1,6 @@
+package jalview.ext.treeviewer;
+
+public interface ExternalTreeViewerI
+{
+
+}
index 33c1b6c..15a68e6 100644 (file)
@@ -224,7 +224,7 @@ public class PDBFTSPanel extends GFTSPanel
 
     String ids = selectedIds.toString();
     seqFetcher.setQuery(ids);
-    Thread worker = new Thread(seqFetcher);
+    Thread worker = new Thread(seqFetcher, "PDBFTSSeqFetcherThread");
     worker.start();
     delayAndEnableActionButtons();
   }
@@ -302,4 +302,4 @@ public class PDBFTSPanel extends GFTSPanel
       e1.printStackTrace();
     }
   }
-}
\ No newline at end of file
+}
index e24cbea..a71d75f 100644 (file)
 package jalview.gui;
 
 import java.util.Locale;
+import jalview.analysis.AlignmentSorter;
+import jalview.analysis.AlignmentUtils;
+import jalview.analysis.CrossRef;
+import jalview.analysis.Dna;
+import jalview.analysis.ParseProperties;
+import jalview.analysis.SequenceIdMatcher;
+import jalview.analysis.TreeModel;
+import jalview.api.AlignExportSettingI;
+import jalview.api.AlignViewControllerGuiI;
+import jalview.api.AlignViewControllerI;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.api.FeatureSettingsControllerI;
+import jalview.api.SplitContainerI;
+import jalview.api.ViewStyleI;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.commands.CommandI;
+import jalview.commands.EditCommand;
+import jalview.commands.EditCommand.Action;
+import jalview.commands.OrderCommand;
+import jalview.commands.RemoveGapColCommand;
+import jalview.commands.RemoveGapsCommand;
+import jalview.commands.SlideSequencesCommand;
+import jalview.commands.TrimRegionCommand;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentExportData;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentOrder;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.HiddenSequences;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.ext.archaeopteryx.AptxInit;
+import jalview.ext.forester.io.SupportedTreeFileFilter;
+import jalview.ext.forester.io.TreeParser;
+import jalview.gui.ColourMenuHelper.ColourChangeListener;
+import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.io.AlignmentProperties;
+import jalview.io.AnnotationFile;
+import jalview.io.BioJsHTMLOutput;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
+import jalview.io.FileLoader;
+import jalview.io.FileParse;
+import jalview.io.FormatAdapter;
+import jalview.io.HtmlSvgOutput;
+import jalview.io.IdentifyFile;
+import jalview.io.JPredFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.io.JnetAnnotationMaker;
+import jalview.io.NewickFile;
+import jalview.io.ScoreMatrixFile;
+import jalview.io.TCoffeeScoreFile;
+import jalview.jbgui.GAlignFrame;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemes;
+import jalview.schemes.ResidueColourScheme;
+import jalview.schemes.TCoffeeColourScheme;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.ViewportRanges;
+import jalview.ws.DBRefFetcher;
+import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
+import jalview.ws.jws1.Discoverer;
+import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridLayout;
 import java.awt.Rectangle;
 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
@@ -59,11 +139,13 @@ import java.util.Deque;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.StringTokenizer;
 import java.util.Vector;
 
 import javax.swing.ButtonGroup;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComponent;
+import javax.swing.JComboBox;
 import javax.swing.JEditorPane;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
@@ -3746,15 +3828,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   /**
    * Constructs a tree panel and adds it to the desktop
    * 
-   * @param type
-   *          tree type (NJ or AV)
-   * @param modelName
-   *          name of score model used to compute the tree
-   * @param options
-   *          parameters for the distance or similarity calculation
+   * @param params
+   * @param treeAlgo
+   * 
+   * @param tree
+   * 
+   * 
    */
-  void newTreePanel(String type, String modelName,
-          SimilarityParamsI options)
+  void newTreePanel(TreeModel tree, String treeAlgo,
+          String substitutionMatrix)
   {
     String frameTitle = "";
     TreePanel tp;
@@ -3766,7 +3848,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       SequenceGroup sg = viewport.getSelectionGroup();
 
       /* Decide if the selection is a column region */
-      for (SequenceI _s : sg.getSequences())
+      for (SequenceI _s : sg.getSequences()) // port this to Archaeopteryx?
       {
         if (_s.getLength() < sg.getEndRes())
         {
@@ -3790,7 +3872,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
     }
 
-    tp = new TreePanel(alignPanel, type, modelName, options);
+    tp = new TreePanel(alignPanel, tree, treeAlgo, substitutionMatrix);
     frameTitle = tp.getPanelTitle() + (onSelection ? " on region" : "");
 
     frameTitle += " from ";
@@ -3958,6 +4040,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         @Override
         public void actionPerformed(ActionEvent e)
         {
+          // adapt to Aptx
           tp.sortByTree_actionPerformed();
           addHistoryItem(tp.sortAlignmentIn(alignPanel));
 
@@ -4067,14 +4150,66 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
   {
+    chooseTreeFile();
+  }
+
+  @Override
+  protected void loadTreeUrlItem_actionPerformed(ActionEvent e)
+  {
+    chooseTreeUrl();
+  }
+
+  @Override
+  protected void loadTreeBaseStudy_actionPerformed(ActionEvent e)
+  {
+    chooseTreeDb();
+
+  }
+
+  @Override
+  protected void loadTreeOfLife_actionPerformed(ActionEvent e)
+  {
+    chooseTreeDb();
+
+  }
+
+  @Override
+  protected void loadTreeFam_actionPerformed(ActionEvent e)
+  {
+    chooseTreeDb();
+
+  }
+
+  @Override
+  protected void loadTreePfam_actionPerformed(ActionEvent e)
+  {
+    chooseTreeDb();
+
+  }
+
+  @Override
+  protected void loadTreeBase_actionPerformed(ActionEvent e)
+  {
+    chooseTreeDb();
+
+  }
+
+
+  public void chooseTreeFile()
+  {
     // Pick the tree file
     JalviewFileChooser chooser = new JalviewFileChooser(
             Cache.getProperty("LAST_DIRECTORY"));
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(
-            MessageManager.getString("label.select_newick_like_tree_file"));
+            MessageManager.getString("label.select_tree_file")); // modify
     chooser.setToolTipText(
-            MessageManager.getString("label.load_tree_file"));
+            MessageManager.getString("label.load_tree_for_sequence_set"));
+    for (SupportedTreeFileFilter treeFormat : SupportedTreeFileFilter
+            .values())
+    {
+      chooser.setFileFilter(treeFormat.getTreeFilter());
+    }
 
     chooser.setResponseHandler(0, new Runnable()
     {
@@ -4083,12 +4218,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         String filePath = chooser.getSelectedFile().getPath();
         Cache.setProperty("LAST_DIRECTORY", filePath);
-        NewickFile fin = null;
-        try
-        {
-          fin = new NewickFile(new FileParse(chooser.getSelectedFile(),
-                  DataSourceType.FILE));
-          viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
+       TreeParser treeParser = null;
+       try {
+         treeParser = new TreeParser(filePath);
+         treeParser.loadTree(viewport);        
         } catch (Exception ex)
         {
           JvOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
@@ -4108,6 +4241,78 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
     });
     chooser.showOpenDialog(this);
+    }
+  }
+
+  /**
+   * Break up and move to TreeParser?
+   */
+  public void chooseTreeUrl()
+  {
+
+    JLabel label = new JLabel(
+            MessageManager.getString("label.tree_url_example"));
+    // add "example" button
+    final JComboBox<String> history = new JComboBox<>();
+
+    JPanel panel = new JPanel(new GridLayout(2, 1));
+    panel.add(label);
+    panel.add(history);
+    history.setPreferredSize(new Dimension(400, 20));
+    history.setEditable(true);
+    history.addItem("http://www.");
+
+    String historyItems = jalview.bin.Cache.getProperty("RECENT_URL");
+
+    StringTokenizer st;
+
+    if (historyItems != null)
+      {
+      st = new StringTokenizer(historyItems, "\t");
+
+      while (st.hasMoreTokens())
+      {
+        history.addItem(st.nextToken());
+      }
+      }
+
+    int reply = JvOptionPane.showInternalConfirmDialog(this, panel,
+            MessageManager.getString("label.load_tree_url"),
+            JvOptionPane.OK_CANCEL_OPTION);
+
+    if (reply == JvOptionPane.OK_OPTION)
+    {
+
+      String urlString = history.getSelectedItem().toString();
+      URL treeUrl;
+
+      try
+      {
+        FileFormatI format = null;
+
+        format = new IdentifyFile().identify(urlString, DataSourceType.URL);
+        // add actual use for the format identification (jalview .jar files)
+        treeUrl = new URL(urlString);
+        AptxInit.createInstanceFromUrl(treeUrl, viewport);
+
+      } catch (IOException | RuntimeException e)
+      {
+        JvOptionPane.showMessageDialog(this, MessageManager.formatMessage(
+                "exception.failed_to_read_data_from_source", new String[]
+                { urlString }),
+                MessageManager.getString("label.url_not_found"),
+                JvOptionPane.ERROR_MESSAGE);
+        e.printStackTrace();
+      }
+    }
+    else
+    {
+
+    }
+  }
+
+  public void chooseTreeDb()
+  {
   }
 
   public TreePanel showNewickTree(NewickFile nf, String treeTitle)
@@ -4225,6 +4430,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
           final JMenu analymenu = new JMenu("Analysis");
           final JMenu dismenu = new JMenu("Protein Disorder");
+          final JMenu phylogenmenu = new JMenu("Phylogenetic inference");
+
           // JAL-940 - only show secondary structure prediction services from
           // the legacy server
           if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
@@ -4264,6 +4471,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           wsmenu.add(secstrmenu);
           wsmenu.add(dismenu);
           wsmenu.add(analymenu);
+          wsmenu.add(phylogenmenu);
           // No search services yet
           // wsmenu.add(seqsrchmenu);
 
@@ -4371,7 +4579,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         }
         buildingMenu = false;
       }
-    }).start();
+    }, "BuildWebServiceThread").start();
 
   }
 
@@ -4479,7 +4687,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   protected void showProductsFor(final SequenceI[] sel, final boolean _odna,
           final String source)
   {
-    new Thread(CrossRefAction.getHandlerFor(sel, _odna, source, this))
+    new Thread(CrossRefAction.getHandlerFor(sel, _odna, source, this),
+            "CrossReferencesThread")
             .start();
   }
 
@@ -4788,7 +4997,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             ex.printStackTrace();
           }
         }
-      }).start();
+      }, "DropFileThread").start();
     }
   }
 
@@ -5187,7 +5396,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             });
             dbRefFetcher.fetchDBRefs(false);
           }
-        }).start();
+        }, "BuildFetchDBMenuThread").start();
 
       }
 
index 2447a2f..8447faf 100644 (file)
@@ -202,7 +202,7 @@ public class AppJmol extends StructureViewerBase
     setSize(400, 400); // probably should be a configurable/dynamic default here
     initMenus();
     addingStructures = false;
-    worker = new Thread(this);
+    worker = new Thread(this, "OpenJmolThread");
     worker.start();
 
     this.addInternalFrameListener(new InternalFrameAdapter()
index f7e5413..c43d59b 100644 (file)
 package jalview.gui;
 
 import jalview.analysis.TreeBuilder;
+import jalview.analysis.TreeCalculator;
+import jalview.analysis.TreeModel;
 import jalview.analysis.scoremodels.ScoreModels;
 import jalview.analysis.scoremodels.SimilarityParams;
 import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
 import jalview.bin.Cache;
 import jalview.datamodel.SequenceGroup;
+import jalview.ext.archaeopteryx.AptxInit;
 import jalview.util.MessageManager;
 
 import java.awt.BorderLayout;
@@ -424,7 +427,6 @@ public class CalculationChooser extends JPanel
     Object curSel = comboBox.getSelectedItem();
     toolTips.clear();
     DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
-
     /*
      * select the score models applicable to the alignment type
      */
@@ -514,34 +516,54 @@ public class CalculationChooser extends JPanel
   protected void calculate_actionPerformed()
   {
     boolean doPCA = pca.isSelected();
-    String modelName = modelNames.getSelectedItem().toString();
+    String substitutionMatrix = modelNames.getSelectedItem().toString();
     SimilarityParamsI params = getSimilarityParameters(doPCA);
 
     if (doPCA)
     {
-      openPcaPanel(modelName, params);
+      openPcaPanel(substitutionMatrix, params);
     }
     else
     {
-      openTreePanel(modelName, params);
+      createTree(substitutionMatrix, params);
+
+
+
+
+
+
     }
 
     // closeFrame();
   }
 
-  /**
-   * Open a new Tree panel on the desktop
-   * 
-   * @param modelName
-   * @param params
-   */
-  protected void openTreePanel(String modelName, SimilarityParamsI params)
+  protected void createTree(String substitutionMatrix,
+          SimilarityParamsI params)
+  {
+    String treeAlgo = determineTreeAlgo();
+    TreeCalculator treeCalculator = new TreeCalculator(treeAlgo,
+            substitutionMatrix, params);
+    TreeBuilder calculatedTree = treeCalculator.makeTree(af.getViewport());
+
+    AptxInit.createInstance(calculatedTree);
+
+    TreeModel tree = new TreeModel(calculatedTree);
+    openTreePanel(tree, treeAlgo, substitutionMatrix);
+  }
+
+
+  protected String determineTreeAlgo() // to be modified & expanded
+  {
+    String treeAlgorithm = neighbourJoining.isSelected()
+            ? TreeBuilder.NEIGHBOUR_JOINING
+            : TreeBuilder.AVERAGE_DISTANCE;
+
+    return treeAlgorithm;
+
+  }
+
+  protected void checkEnoughSequences(AlignViewport viewport)
   {
-    /*
-     * gui validation shouldn't allow insufficient sequences here, but leave
-     * this check in in case this method gets exposed programmatically in future
-     */
-    AlignViewport viewport = af.getViewport();
     SequenceGroup sg = viewport.getSelectionGroup();
     if (sg != null && sg.getSize() < MIN_TREE_SELECTION)
     {
@@ -553,11 +575,25 @@ public class CalculationChooser extends JPanel
               JvOptionPane.WARNING_MESSAGE);
       return;
     }
+  }
 
-    String treeType = neighbourJoining.isSelected()
-            ? TreeBuilder.NEIGHBOUR_JOINING
-            : TreeBuilder.AVERAGE_DISTANCE;
-    af.newTreePanel(treeType, modelName, params);
+  /**
+   * Open a new Tree panel on the desktop
+   * 
+   * @param tree
+   * @param params
+   * @param treeAlgo
+   */
+  protected void openTreePanel(TreeModel tree, String treeAlgo,
+          String substitutionMatrix)
+  {
+    /*
+     * gui validation shouldn't allow insufficient sequences here, but leave
+     * this check in in case this method gets exposed programmatically in future
+     */
+    checkEnoughSequences(af.getViewport());
+
+    af.newTreePanel(tree, treeAlgo, substitutionMatrix);
   }
 
   /**
index cc6a785..367ca7f 100644 (file)
@@ -216,7 +216,7 @@ public class ChimeraViewFrame extends StructureViewerBase
     initMenus();
 
     addingStructures = false;
-    worker = new Thread(this);
+    worker = new Thread(this, "OpenChimeraThread");
     worker.start();
 
     this.addInternalFrameListener(new InternalFrameAdapter()
index 9cf2cc9..592f666 100644 (file)
@@ -279,15 +279,15 @@ public class Console extends WindowAdapter
 
     // Starting two seperate threads to read from the PipedInputStreams
     //
-    reader = new Thread(this);
+    reader = new Thread(this, "ConsoleReader1Thread");
     reader.setDaemon(true);
     reader.start();
     //
-    reader2 = new Thread(this);
+    reader2 = new Thread(this, "ConsoleReader2Thread");
     reader2.setDaemon(true);
     reader2.start();
     // and a thread to append text to the textarea
-    textAppender = new Thread(this);
+    textAppender = new Thread(this, "ConsoleTextAppendThread");
     textAppender.setDaemon(true);
     textAppender.start();
 
@@ -446,7 +446,7 @@ public class Console extends WindowAdapter
     // We do it with a seperate Thread becasue we don't wan't to break a Thread
     // used by the Console.
     System.out.println("\nLets throw an error on this console");
-    errorThrower = new Thread(this);
+    errorThrower = new Thread(this, "ConsoleErrorLogThread");
     errorThrower.setDaemon(true);
     errorThrower.start();
   }
index aeb0fac..1a42f58 100644 (file)
@@ -721,7 +721,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           Desktop.instance.setProgressBar(null, now);
           jvnews.showNews();
         }
-      }).start();
+        }, "ShowNewsWindowThread").start();
     }
   }
 
@@ -1429,7 +1429,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       {
         new SplashScreen(false);
       }
-    }).start();
+    }, "ShowAboutMenuThread").start();
   }
 
   /**
@@ -1797,7 +1797,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           }
           setProgressBar(null, chosenFile.hashCode());
         }
-      }).start();
+      }, "SaveJalviewProjectThread").start();
     }
   }
 
@@ -2170,7 +2170,6 @@ public class Desktop extends jalview.jbgui.GDesktop
     {
       source.showFeatureSettingsUI();
     }
-
   }
 
   public JInternalFrame[] getAllFrames()
@@ -2188,7 +2187,7 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     UserQuestionnaireCheck jvq = new UserQuestionnaireCheck(url);
     // javax.swing.SwingUtilities.invokeLater(jvq);
-    new Thread(jvq).start();
+    new Thread(jvq, "CheckQuestionnaireThread").start();
   }
 
   public void checkURLLinks()
@@ -2300,7 +2299,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       this.showMemoryUsage = showMemory;
       if (showMemory)
       {
-        Thread worker = new Thread(this);
+        Thread worker = new Thread(this, "ShowMemoryUsageThread");
         worker.start();
       }
       repaint();
@@ -2754,7 +2753,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
       // JAL-940 - disabled JWS1 service configuration - always start discoverer
       // until we phase out completely
-      (t0 = new Thread(discoverer)).start();
+      (t0 = new Thread(discoverer, "DiscovererThread")).start();
     }
 
     if (ignore_SHOW_JWS2_SERVICES_preference
@@ -2906,7 +2905,7 @@ public class Desktop extends jalview.jbgui.GDesktop
           progress.setProgressBar(null, this.hashCode());
         }
       }
-    }).start();
+    }, "OpenURLThread").start();
   }
 
   public static WsParamSetManager wsparamManager = null;
index 1d7bf3d..b1f868e 100644 (file)
@@ -66,7 +66,7 @@ public abstract class JalviewDialog extends JPanel
           frame.setVisible(true);
         }
 
-      }).start();
+      }, "UnblockedDialogThread").start();
     }
     else
     {
index adde919..d7ef76a 100755 (executable)
@@ -333,7 +333,7 @@ public class OverviewPanel extends JPanel
       return;
     }
 
-    Thread thread = new Thread(this);
+    Thread thread = new Thread(this, "UpdateOverviewThread");
     thread.start();
     repaint();
 
index 953fdc5..f56c61c 100755 (executable)
@@ -244,7 +244,7 @@ public class PaintRefresher
     }
   }
 
-  static AlignmentPanel[] getAssociatedPanels(String id)
+  public static AlignmentPanel[] getAssociatedPanels(String id)
   {
     List<Component> comps = components.get(id);
     if (comps == null)
index 6ed3248..b248ec4 100755 (executable)
@@ -96,7 +96,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     slider.setMaximum(100);
     slider.setValue(100);
 
-    Thread worker = new Thread(this);
+    Thread worker = new Thread(this, "CreateRedundancyPanelThread");
     worker.start();
 
     frame = new JInternalFrame();
index ec5579c..474b63c 100644 (file)
@@ -403,7 +403,7 @@ public abstract class StructureViewerBase extends GStructureViewer
             // and call ourselves again.
             addStructure(pdbentry, seqs, chains, alignFrame);
           }
-        }).start();
+        }, "Adding3DStructureQueueThread").start();
         return;
       }
     }
@@ -413,7 +413,7 @@ public abstract class StructureViewerBase extends GStructureViewer
             { seqs }, new String[][] { chains });
     addingStructures = true;
     _started = false;
-    worker = new Thread(this);
+    worker = new Thread(this, "Adding3DStructureThread");
     worker.start();
     return;
   }
index 0012888..06b06fa 100755 (executable)
@@ -525,7 +525,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
    */
   void startPrinting()
   {
-    Thread thread = new Thread(this);
+    Thread thread = new Thread(this, "PrintTreeCanvasThread");
     thread.start();
   }
 
index d735402..042147f 100755 (executable)
@@ -23,13 +23,7 @@ package jalview.gui;
 import java.util.Locale;
 
 import jalview.analysis.AlignmentSorter;
-import jalview.analysis.AverageDistanceTree;
-import jalview.analysis.NJTree;
-import jalview.analysis.TreeBuilder;
 import jalview.analysis.TreeModel;
-import jalview.analysis.scoremodels.ScoreModels;
-import jalview.api.analysis.ScoreModelI;
-import jalview.api.analysis.SimilarityParamsI;
 import jalview.bin.Cache;
 import jalview.bin.Console;
 import jalview.commands.CommandI;
@@ -67,8 +61,6 @@ import java.util.List;
 import javax.swing.ButtonGroup;
 import javax.swing.JMenuItem;
 import javax.swing.JRadioButtonMenuItem;
-import javax.swing.event.InternalFrameAdapter;
-import javax.swing.event.InternalFrameEvent;
 
 import org.jibble.epsgraphics.EpsGraphics2D;
 
@@ -80,15 +72,15 @@ import org.jibble.epsgraphics.EpsGraphics2D;
  */
 public class TreePanel extends GTreePanel
 {
-  String treeType;
+  String substitutionMatrix;
 
-  String scoreModelName; // if tree computed
+  String treeType;
 
   String treeTitle; // if tree loaded
 
   SimilarityParamsI similarityParams;
 
-  private TreeCanvas treeCanvas;
+  TreeCanvas treeCanvas;
 
   TreeModel tree;
 
@@ -98,28 +90,38 @@ public class TreePanel extends GTreePanel
    * Creates a new TreePanel object.
    * 
    * @param ap
-   * @param type
-   * @param modelName
-   * @param options
+   * @param tree
+   * @param treeType
+   * @param substitutionMatrix
    */
-  public TreePanel(AlignmentPanel ap, String type, String modelName,
-          SimilarityParamsI options)
+  public TreePanel(AlignmentPanel ap, TreeModel tree, String treeType,
+          String substitutionMatrix)
   {
     super();
-    this.similarityParams = options;
-    initTreePanel(ap, type, modelName, null, null);
+    this.treeType = treeType;
+    this.substitutionMatrix = substitutionMatrix;
+    this.tree = tree;
+    initTreePanel(ap, tree);
 
     // We know this tree has distances. JBPNote TODO: prolly should add this as
     // a userdefined default
     // showDistances(true);
   }
 
+  /**
+   * Creates a new TreePanel object.
+   * 
+   * @param alignPanel
+   * @param newtree
+   * @param theTitle
+   * @param inputData
+   */
   public TreePanel(AlignmentPanel alignPanel, NewickFile newtree,
           String theTitle, AlignmentView inputData)
   {
     super();
     this.treeTitle = theTitle;
-    initTreePanel(alignPanel, null, null, newtree, inputData);
+    initTreePanel(alignPanel, newtree, inputData);
   }
 
   public AlignmentI getAlignment()
@@ -133,62 +135,49 @@ public class TreePanel extends GTreePanel
     return getTreeCanvas().getViewport();
   }
 
-  void initTreePanel(AlignmentPanel ap, String type, String modelName,
-          NewickFile newTree, AlignmentView inputData)
+  /**
+   * Initialize a tree panel based on a calculated tree
+   * 
+   * @param ap
+   * @param tree
+   */
+  void initTreePanel(AlignmentPanel ap, TreeModel tree)
   {
+    buildTreeCanvas(ap);
 
-    av = ap.av;
-    this.treeType = type;
-    this.scoreModelName = modelName;
-
-    treeCanvas = new TreeCanvas(this, ap, scrollPane);
-    scrollPane.setViewportView(treeCanvas);
-
-    PaintRefresher.Register(this, ap.av.getSequenceSetId());
-
-    buildAssociatedViewMenu();
-
-    final PropertyChangeListener listener = addAlignmentListener();
-
-    /*
-     * remove listener when window is closed, so that this
-     * panel can be garbage collected
-     */
-    addInternalFrameListener(new InternalFrameAdapter()
-    {
-      @Override
-      public void internalFrameClosed(InternalFrameEvent evt)
-      {
-        if (av != null)
-        {
-          av.removePropertyChangeListener(listener);
-        }
-        releaseReferences();
-      }
-    });
-
-    TreeLoader tl = new TreeLoader(newTree, inputData);
+    TreeLoader tl = new TreeLoader(null, null);
     tl.start();
 
   }
 
   /**
-   * Ensure any potentially large object references are nulled
+   * Initialize a tree panel based on a loaded in tree file.
+   * 
+   * @param ap
+   * @param loadedTree
+   * @param inputData
    */
-  public void releaseReferences()
+  void initTreePanel(AlignmentPanel ap, 
+          NewickFile loadedTree, AlignmentView inputData)
   {
-    this.tree = null;
-    this.treeCanvas.tree = null;
-    this.treeCanvas.nodeHash = null;
-    this.treeCanvas.nameHash = null;
+    buildTreeCanvas(ap);
+
+    TreeLoader tl = new TreeLoader(loadedTree, inputData);
+    tl.start();
   }
 
-  /**
-   * @return
-   */
-  protected PropertyChangeListener addAlignmentListener()
-  {
-    final PropertyChangeListener listener = new PropertyChangeListener()
+public void buildTreeCanvas(AlignmentPanel ap) { 
+     av = ap.av;
+
+    treeCanvas = new TreeCanvas(this, ap, scrollPane);
+    scrollPane.setViewportView(treeCanvas);
+
+
+    PaintRefresher.Register(this, ap.av.getSequenceSetId());
+
+    buildAssociatedViewMenu();
+
+    av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
     {
       @Override
       public void propertyChange(PropertyChangeEvent evt)
@@ -215,9 +204,11 @@ public class TreePanel extends GTreePanel
           repaint();
         }
       }
-    };
-    av.addPropertyChangeListener(listener);
-    return listener;
+    });
+
+
+  
+
   }
 
   @Override
@@ -289,57 +280,56 @@ public class TreePanel extends GTreePanel
 
   class TreeLoader extends Thread
   {
-    private NewickFile newtree;
+    private NewickFile newTree;
 
     private AlignmentView odata = null;
 
     public TreeLoader(NewickFile newickFile, AlignmentView inputData)
     {
-      this.newtree = newickFile;
+      this.newTree = newickFile;
       this.odata = inputData;
 
-      if (newickFile != null)
+      if (newTree != null)
       {
         // Must be outside run(), as Jalview2XML tries to
         // update distance/bootstrap visibility at the same time
-        showBootstrap(newickFile.HasBootstrap());
-        showDistances(newickFile.HasDistances());
+        showBootstrap(newTree.hasBootstrap());
+        showDistances(newTree.hasDistances());
+
       }
+
     }
 
     @Override
     public void run()
     {
 
-      if (newtree != null)
+      if (newTree != null)
       {
         tree = new TreeModel(av.getAlignment().getSequencesArray(), odata,
-                newtree);
+                newTree);
         if (tree.getOriginalData() == null)
         {
           originalSeqData.setVisible(false);
         }
       }
-      else
-      {
-        ScoreModelI sm = ScoreModels.getInstance().getScoreModel(
-                scoreModelName, treeCanvas.getAssociatedPanel());
-        TreeBuilder njtree = treeType.equals(TreeBuilder.NEIGHBOUR_JOINING)
-                ? new NJTree(av, sm, similarityParams)
-                : new AverageDistanceTree(av, sm, similarityParams);
-        tree = new TreeModel(njtree);
-        showDistances(true);
-      }
+      showTree(tree);
 
+    }
+      
+    public void showTree(TreeModel tree)
+    {
       tree.reCount(tree.getTopNode());
       tree.findHeight(tree.getTopNode());
       treeCanvas.setTree(tree);
       treeCanvas.repaint();
+
       av.setCurrentTree(tree);
       if (av.getSortByTree())
       {
         sortByTree_actionPerformed();
       }
+
     }
   }
 
@@ -535,7 +525,7 @@ public class TreePanel extends GTreePanel
    * @param e
    */
   @Override
-  public void sortByTree_actionPerformed()
+  public void sortByTree_actionPerformed()// modify for Aptx
   {
 
     if (treeCanvas.applyToAllViews)
@@ -778,12 +768,19 @@ public class TreePanel extends GTreePanel
    * 
    * @return
    */
-  public String getPanelTitle()
+  public String getPanelTitle() // to be moved/fixed
   {
     if (treeTitle != null)
     {
       return treeTitle;
     }
+    else
+    {
+      /*
+       * i18n description of Neighbour Joining or Average Distance method
+       */
+      String treecalcnm = MessageManager
+              .getString("label.tree_calc_" + treeType.toLowerCase());
 
     /*
      * i18n description of Neighbour Joining or Average Distance method
@@ -801,7 +798,8 @@ public class TreePanel extends GTreePanel
      */
     final String ttl = MessageManager.formatMessage("label.calc_title",
             treecalcnm, smn);
-    return ttl;
+      return ttl;
+    }
   }
 
   /**
diff --git a/src/jalview/gui/TreeParams.java b/src/jalview/gui/TreeParams.java
new file mode 100644 (file)
index 0000000..4f481d9
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($Version-Rel$)
+ * Copyright (C) $Year-Rel$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+/**
+ * @author kjvanderheide
+ *
+ */
+public class TreeParams implements OptsParametersContainerI
+{
+
+  @Override
+  public void refreshParamLayout()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void argSetModified(Object modifiedElement, boolean b)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+}
index 8a8ba8d..df63be1 100644 (file)
@@ -325,7 +325,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
         Console.info("Jalview finished updating to the Vamsas Session.");
       }
 
-    });
+    }, "UpdateVamsasThread");
     udthread.start();
   }
 
index ee1b473..034cbad 100644 (file)
@@ -351,7 +351,7 @@ public class WebserviceInfo extends GWebserviceInfo
     titlePanel.add(titleText, BorderLayout.CENTER);
     setStatus(currentStatus);
 
-    Thread thread = new Thread(ap);
+    Thread thread = new Thread(ap, "AnimatedPanelThread");
     thread.start();
     final WebserviceInfo thisinfo = this;
     frame.addInternalFrameListener(new InternalFrameAdapter()
index e37f77c..7b8bc51 100644 (file)
@@ -67,12 +67,12 @@ public class WsPreferences extends GWsPreferences
     wsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
     if (!wsUrls.isEmpty())
     {
-      oldUrls = new Vector<String>(wsUrls);
+      oldUrls = new Vector<>(wsUrls);
     }
     else
     {
       oldUrls = null;
-      wsUrls = new Vector<String>();
+      wsUrls = new Vector<>();
     }
     wsList.setDefaultRenderer(Integer.class, new JabaWSStatusRenderer());
     wsList.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
@@ -80,12 +80,12 @@ public class WsPreferences extends GWsPreferences
     rsbsUrls = jalview.ws.rest.RestClient.getRsbsDescriptions();
     if (rsbsUrls != null)
     {
-      oldRsbsUrls = new Vector<String>(rsbsUrls);
+      oldRsbsUrls = new Vector<>(rsbsUrls);
     }
     else
     {
       oldRsbsUrls = null;
-      rsbsUrls = new Vector<String>();
+      rsbsUrls = new Vector<>();
     }
     updateRsbsList();
     enableEnfinServices.setSelected(
@@ -567,7 +567,7 @@ public class WsPreferences extends GWsPreferences
         updateWsMenuConfig(false);
         refreshWsMenu(true);
       }
-    }).start();
+    }, "RefreshWebServicesThread").start();
 
   }
 
@@ -603,7 +603,7 @@ public class WsPreferences extends GWsPreferences
           progressBar.setVisible(false);
           validate();
         }
-      }).start();
+      }, "RefreshWebServicesMenuProgressBarThread").start();
 
     }
     else
@@ -626,7 +626,7 @@ public class WsPreferences extends GWsPreferences
           Desktop.instance.setProgressBar(null, ct);
         }
 
-      }).start();
+      }, "RefreshWebServicesMenuThread").start();
     }
   }
 
@@ -677,7 +677,7 @@ public class WsPreferences extends GWsPreferences
         updateWsMenuConfig(false);
         refreshWsMenu(showProgressInDialog);
       }
-    }).start();
+    }, "UpdateAndRefreshWebServicesMenuThread").start();
 
   }
 }
index c88d8eb..5c19f94 100644 (file)
@@ -66,7 +66,7 @@ public class BioJsHTMLOutput extends HTMLOutput
     File directory = new File(BJS_TEMPLATES_LOCAL_DIRECTORY);
     Objects.requireNonNull(dirName, "dirName MUST not be null!");
     Objects.requireNonNull(directory, "directory MUST not be null!");
-    TreeMap<String, File> versionFileMap = new TreeMap<String, File>();
+    TreeMap<String, File> versionFileMap = new TreeMap<>();
 
     for (File file : directory.listFiles())
     {
index 4016e71..fec0b3a 100755 (executable)
@@ -111,7 +111,7 @@ public class FileLoader implements Runnable
     this.protocol = protocol;
     this.format = format;
 
-    final Thread loader = new Thread(this);
+    final Thread loader = new Thread(this, "LoadFileThread");
 
     SwingUtilities.invokeLater(new Runnable()
     {
@@ -209,7 +209,6 @@ public class FileLoader implements Runnable
   protected AlignFrame _LoadFileWaitTillLoaded()
   {
     this.run();
-
     return alignFrame;
   }
 
index 4a30d73..a283691 100755 (executable)
@@ -80,14 +80,14 @@ public class NewickFile extends FileParse
 {
   SequenceNode root;
 
-  private boolean HasBootstrap = false;
+  private boolean hasBootstrap = false;
 
-  private boolean HasDistances = false;
+  private boolean hasDistances = false;
 
-  private boolean RootHasDistance = false;
+  private boolean rootHasDistance = false;
 
   // File IO Flags
-  boolean ReplaceUnderscores = false;
+  boolean replaceUnderscores = false;
 
   boolean printRootInfo = true;
 
@@ -160,7 +160,7 @@ public class NewickFile extends FileParse
    */
   public NewickFile(SequenceNode newtree, boolean bootstrap)
   {
-    HasBootstrap = bootstrap;
+    hasBootstrap = bootstrap;
     root = newtree;
   }
 
@@ -178,8 +178,8 @@ public class NewickFile extends FileParse
           boolean distances)
   {
     root = newtree;
-    HasBootstrap = bootstrap;
-    HasDistances = distances;
+    hasBootstrap = bootstrap;
+    hasDistances = distances;
   }
 
   /**
@@ -198,9 +198,9 @@ public class NewickFile extends FileParse
           boolean distances, boolean rootdistance)
   {
     root = newtree;
-    HasBootstrap = bootstrap;
-    HasDistances = distances;
-    RootHasDistance = rootdistance;
+    hasBootstrap = bootstrap;
+    hasDistances = distances;
+    rootHasDistance = rootdistance;
   }
 
   /**
@@ -230,9 +230,9 @@ public class NewickFile extends FileParse
 
   // @tree annotations
   // These are set automatically by the reader
-  public boolean HasBootstrap()
+  public boolean hasBootstrap()
   {
-    return HasBootstrap;
+    return hasBootstrap;
   }
 
   /**
@@ -240,14 +240,14 @@ public class NewickFile extends FileParse
    * 
    * @return DOCUMENT ME!
    */
-  public boolean HasDistances()
+  public boolean hasDistances()
   {
-    return HasDistances;
+    return hasDistances;
   }
 
-  public boolean HasRootDistance()
+  public boolean hasRootDistance()
   {
-    return RootHasDistance;
+    return rootHasDistance;
   }
 
   /**
@@ -439,7 +439,7 @@ public class NewickFile extends FileParse
         {
           if (nodename == null)
           {
-            if (ReplaceUnderscores)
+            if (replaceUnderscores)
             {
               nodename = uqnodename.stringMatched(1).replace('_', ' ');
             }
@@ -472,7 +472,7 @@ public class NewickFile extends FileParse
             {
               bootstrap = (Integer.valueOf(nbootstrap.stringMatched(1)))
                       .intValue();
-              HasBootstrap = true;
+              hasBootstrap = true;
             } catch (Exception e)
             {
               Error = ErrorStringrange(Error, "Can't parse bootstrap value",
@@ -503,12 +503,12 @@ public class NewickFile extends FileParse
           // Write node info here
           c.setName(nodename);
           // Trees without distances still need a render distance
-          c.dist = (HasDistances) ? distance : DefDistance;
+          c.dist = (hasDistances) ? distance : DefDistance;
           // be consistent for internal bootstrap defaults too
-          c.setBootstrap((HasBootstrap) ? bootstrap : DefBootstrap);
+          c.setBootstrap((hasBootstrap) ? bootstrap : DefBootstrap);
           if (c == realroot)
           {
-            RootHasDistance = nodehasdistance; // JBPNote This is really
+            rootHasDistance = nodehasdistance; // JBPNote This is really
             // UGLY!!! Ensure root node gets
             // its given distance
           }
@@ -519,8 +519,8 @@ public class NewickFile extends FileParse
         {
           // Find a place to put the leaf
           SequenceNode newnode = new SequenceNode(null, c, nodename,
-                  (HasDistances) ? distance : DefDistance,
-                  (HasBootstrap) ? bootstrap : DefBootstrap, false);
+                  (hasDistances) ? distance : DefDistance,
+                  (hasBootstrap) ? bootstrap : DefBootstrap, false);
           parseNHXNodeProps(c, commentString2);
           commentString2 = null;
 
@@ -539,7 +539,7 @@ public class NewickFile extends FileParse
               // Insert a dummy node for polytomy
               // dummy nodes have distances
               SequenceNode newdummy = new SequenceNode(null, c, null,
-                      (HasDistances ? 0 : DefDistance), 0, true);
+                      (hasDistances ? 0 : DefDistance), 0, true);
               newdummy.SetChildren(c.left(), newnode);
               c.setLeft(newdummy);
             }
@@ -617,9 +617,9 @@ public class NewickFile extends FileParse
     // (root.right()!=null && root.isDummy())
     root = (SequenceNode) root.right().detach(); // remove the imaginary root.
 
-    if (!RootHasDistance)
+    if (!rootHasDistance)
     {
-      root.dist = (HasDistances) ? 0 : DefDistance;
+      root.dist = (hasDistances) ? 0 : DefDistance;
     }
   }
 
@@ -658,7 +658,7 @@ public class NewickFile extends FileParse
               v = iv.intValue(); // jalview only does integer bootstraps
               // currently
               c.setBootstrap(v);
-              HasBootstrap = true;
+              hasBootstrap = true;
             }
             // more codes here.
           } catch (Exception e)
@@ -715,11 +715,11 @@ public class NewickFile extends FileParse
   {
     synchronized (this)
     {
-      boolean boots = this.HasBootstrap;
-      this.HasBootstrap = withbootstraps;
+      boolean boots = this.hasBootstrap;
+      this.hasBootstrap = withbootstraps;
 
       String rv = print();
-      this.HasBootstrap = boots;
+      this.hasBootstrap = boots;
 
       return rv;
     }
@@ -741,11 +741,11 @@ public class NewickFile extends FileParse
   {
     synchronized (this)
     {
-      boolean dists = this.HasDistances;
-      this.HasDistances = withdists;
+      boolean dists = this.hasDistances;
+      this.hasDistances = withdists;
 
       String rv = print(withbootstraps);
-      this.HasDistances = dists;
+      this.hasDistances = dists;
 
       return rv;
     }
@@ -835,10 +835,10 @@ public class NewickFile extends FileParse
   private String printNodeField(SequenceNode c)
   {
     return ((c.getName() == null) ? "" : nodeName(c.getName()))
-            + ((HasBootstrap) ? ((c.getBootstrap() > -1)
+            + ((hasBootstrap) ? ((c.getBootstrap() > -1)
                     ? ((c.getName() != null ? " " : "") + c.getBootstrap())
                     : "") : "")
-            + ((HasDistances) ? (":" + c.dist) : "");
+            + ((hasDistances) ? (":" + c.dist) : "");
   }
 
   /**
@@ -853,13 +853,13 @@ public class NewickFile extends FileParse
   {
     return (printRootInfo)
             ? (((root.getName() == null) ? "" : nodeName(root.getName()))
-                    + ((HasBootstrap)
+                    + ((hasBootstrap)
                             ? ((root.getBootstrap() > -1)
                                     ? ((root.getName() != null ? " " : "")
                                             + +root.getBootstrap())
                                     : "")
                             : "")
-                    + ((RootHasDistance) ? (":" + root.dist) : ""))
+                    + ((rootHasDistance) ? (":" + root.dist) : ""))
             : "";
   }
 
index 29f3fa9..33da111 100644 (file)
@@ -248,7 +248,8 @@ public class JSFunctionExec implements Runnable
     {
       if (executor == null)
       {
-        executor = new Thread(new JSFunctionExec(jvlite));
+        executor = new Thread(new JSFunctionExec(jvlite),
+                "JavaScriptThread");
         executor.start();
       }
       synchronized (jsExecQueue)
index 71b6b9e..4d2850b 100755 (executable)
@@ -1124,11 +1124,10 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    JMenuItem loadTreeMenuItem = new JMenuItem(
-            MessageManager.getString("label.load_associated_tree"));
-    loadTreeMenuItem.setActionCommand(
-            MessageManager.getString("label.load_tree_for_sequence_set"));
-    loadTreeMenuItem.addActionListener(new ActionListener()
+    JMenuItem loadTreeFile = new JMenuItem(
+            MessageManager.getString("label.from_file"));
+
+    loadTreeFile.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1137,6 +1136,89 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
+    JMenuItem loadTreeUrl = new JMenuItem(
+            MessageManager.getString("label.from_url"));
+    loadTreeUrl.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadTreeUrlItem_actionPerformed(e);
+      }
+    });
+
+
+
+    JMenuItem loadTreeBaseStudy = new JMenuItem(
+            MessageManager.getString("treebase study"));
+    loadTreeBaseStudy.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadTreeBaseStudy_actionPerformed(e);
+
+      }    });
+
+
+
+    JMenuItem loadTreeBase = new JMenuItem(
+            MessageManager.getString("treebase"));
+    loadTreeBase.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadTreeBase_actionPerformed(e);
+
+      }
+
+
+    });
+    JMenuItem loadTreePfam = new JMenuItem(
+            MessageManager.getString("pfam"));
+    loadTreePfam.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadTreePfam_actionPerformed(e);
+
+      }
+
+    });
+    JMenuItem loadTreeFam = new JMenuItem(
+            MessageManager.getString("treefam"));
+    loadTreeFam.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadTreeFam_actionPerformed(e);
+
+      }
+
+    });
+
+    JMenuItem loadTreeOfLife = new JMenuItem(
+            MessageManager.getString("tree_of_life"));
+    loadTreeOfLife.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        loadTreeOfLife_actionPerformed(e);
+
+      }
+
+
+    });
+
     scaleAbove.setVisible(false);
     scaleAbove.setText(MessageManager.getString("action.scale_above"));
     scaleAbove.addActionListener(new ActionListener()
@@ -1763,7 +1845,27 @@ public class GAlignFrame extends JInternalFrame
 
     JMenu exportImageMenu = new JMenu(
             MessageManager.getString("label.export_image"));
+
+    JMenu loadTreeDb = new JMenu(
+            MessageManager.getString("label.from_database"));
+
+    JMenu loadTreeMenu = new JMenu(
+            MessageManager.getString("label.load_associated_tree"));
+    // loadTreeMenu.setToolTipText(
+    // MessageManager.getString("label.load_tree_for_sequence_set"));
+    
     JMenu fileMenu = new JMenu(MessageManager.getString("action.file"));
+
+    loadTreeDb.add(loadTreeBaseStudy);
+    loadTreeDb.add(loadTreeBase);
+    loadTreeDb.add(loadTreePfam);
+    loadTreeDb.add(loadTreeFam);
+    loadTreeDb.add(loadTreeOfLife);
+
+    loadTreeMenu.add(loadTreeFile);
+    loadTreeMenu.add(loadTreeUrl);
+    loadTreeMenu.add(loadTreeDb);
+
     alignFrameMenuBar.add(fileMenu);
     alignFrameMenuBar.add(editMenu);
     alignFrameMenuBar.add(selectMenu);
@@ -1791,7 +1893,7 @@ public class GAlignFrame extends JInternalFrame
     fileMenu.add(exportImageMenu);
     fileMenu.add(exportFeatures);
     fileMenu.add(exportAnnotations);
-    fileMenu.add(loadTreeMenuItem);
+    fileMenu.add(loadTreeMenu);
     fileMenu.add(associatedData);
     if (!Platform.isJS())
     {
@@ -1949,6 +2051,38 @@ public class GAlignFrame extends JInternalFrame
     // JAL-574
     // selectMenu.addSeparator();
     // selectMenu.add(listenToViewSelections);
+
+
+  }
+
+  protected void loadTreeOfLife_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void loadTreeFam_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void loadTreePfam_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void loadTreeBase_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void loadTreeBaseStudy_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
   }
 
   protected void loadVcf_actionPerformed()
@@ -2469,6 +2603,13 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
+  protected void loadTreeUrlItem_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+
+
   /**
    * Template method to handle the 'load T-Coffee scores' menu event.
    * <p>
index b22bf4e..b5a2b33 100755 (executable)
@@ -1022,4 +1022,10 @@ public class Matrix implements MatrixI
     }
     return true;
   }
+
+  @Override
+  public double[][] getValues()
+  {
+    return value;
+  }
 }
index e98007e..4fe31ea 100644 (file)
@@ -52,7 +52,7 @@ public interface MatrixI
   double getValue(int i, int j);
 
   /**
-   * Sets the value at row i, colum j
+   * Sets the value at row i, column j
    * 
    * @param i
    * @param j
@@ -75,6 +75,14 @@ public interface MatrixI
   MatrixI copy();
 
   /**
+   * Answers all values present in the Matrix ordered by row,column
+   * 
+   * @return the double array containing the values ordered in {row values} per
+   *         column
+   */
+  double[][] getValues();
+
+  /**
    * Returns a new matrix which is the transpose of this one
    * 
    * @return
index 9286794..64c8e89 100644 (file)
@@ -125,11 +125,11 @@ public class AWTConsole extends WindowAdapter
 
     // Starting two seperate threads to read from the PipedInputStreams
     //
-    reader = new Thread(this);
+    reader = new Thread(this, "AWTConsoleReader1Thread");
     reader.setDaemon(true);
     reader.start();
     //
-    reader2 = new Thread(this);
+    reader2 = new Thread(this, "AWTConsoleReader2Thread");
     reader2.setDaemon(true);
     reader2.start();
 
@@ -150,7 +150,7 @@ public class AWTConsole extends WindowAdapter
     // We do it with a seperate Thread becasue we don't wan't to break a Thread
     // used by the Console.
     System.out.println("\nLets throw an error on this console");
-    errorThrower = new Thread(this);
+    errorThrower = new Thread(this, "AWTConsoleErrorLogThread");
     errorThrower.setDaemon(true);
     errorThrower.start();
   }
index 25cb810..05fc1c6 100644 (file)
@@ -1109,4 +1109,21 @@ public final class MappingUtils
 
     return foundStart && to >= from ? new int[] { from, to } : null;
   }
+    
+  public static <K, V> Map<K, V> putWithDuplicationCheck(Map<K, V> map, K key,
+          V value)
+  {
+    if (!map.containsKey(key))
+    {
+      map.put(key, value);
+    }
+    else
+    {
+      jalview.bin.Cache.log.warn(
+              "Attempt to add duplicate entry detected for map with key: "
+                      + key.toString() + " and value: " + value.toString());
+    }
+  
+    return map;
+  }
 }
index 08af2ec..d7ba417 100644 (file)
@@ -2973,7 +2973,7 @@ public abstract class AlignmentViewport
   }
 
   @Override
-  public void setCurrentTree(TreeModel tree)
+  public void setCurrentTree(TreeModel tree) // adapt to Aptx
   {
     currentTree = tree;
   }
index d8858a9..eb66016 100644 (file)
@@ -816,7 +816,9 @@ public class DBRefFetcher implements Runnable
   {
     int n;
     if (sequencesArray == null || (n = sequencesArray.length) == 0)
+    {
       return sequencesArray;
+    }
     ArrayList<SequenceI> nseq = new ArrayList<>();
     for (int i = 0; i < n; i++)
     {
index 69e47a3..6caf563 100644 (file)
@@ -374,7 +374,7 @@ public class Discoverer implements Runnable
   public void run()
   {
     final Discoverer discoverer = this;
-    Thread discoverThread = new Thread()
+    Thread discoverThread = new Thread() // no function?
     {
       @Override
       public void run()
index b6b4b2e..7bf5a97 100644 (file)
@@ -238,7 +238,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
 
       }
       qrys.add(squery);
-      new Thread(squery).start();
+      new Thread(squery, "JabaQueryThread").start();
     }
     boolean finished = true;
     do
@@ -457,9 +457,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
                           sv.action, sv);
                   changeSupport.firePropertyChange("services",
                           new Vector<Jws2Instance>(), services);
-                }
-              }).start();
-
+                };
+              }, "LoadPreferredServiceThread").start();
             }
           });
         }
@@ -735,7 +734,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
 
   public Vector<Jws2Instance> getServices()
   {
-    return (services == null) ? new Vector<>() : new Vector<>(services);
+    return (services == null) ? new Vector<Jws2Instance>()
+            : new Vector<>(services);
   }
 
   /**
diff --git a/test/jalview/ext/archaeopteryx/AptxJalviewSequenceTreeTest.java b/test/jalview/ext/archaeopteryx/AptxJalviewSequenceTreeTest.java
new file mode 100644 (file)
index 0000000..e7324eb
--- /dev/null
@@ -0,0 +1,134 @@
+package jalview.ext.archaeopteryx;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import jalview.analysis.NJTree;
+import jalview.analysis.TreeBuilder;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.analysis.ScoreModelI;
+import jalview.api.analysis.SimilarityParamsI;
+import jalview.bin.Jalview;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
+
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.archaeopteryx.TreePanel;
+import org.forester.phylogeny.Phylogeny;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AptxJalviewSequenceTreeTest extends TreeViewTest
+{
+  TreeBuilder jalviewTree;
+
+  TreePanel treePanel;
+
+  Phylogeny tree;
+
+  MainFrame aptx;
+
+  Jalview jalview;
+  
+  @Override
+  @BeforeClass(alwaysRun = true)
+  public void setUpTree()
+  {
+    SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
+    SequenceI seq2 = new Sequence("Seq2", "ABCDEFTHIJ");
+    SequenceI seq3 = new Sequence("Seq3", "BCFWDHIJ");
+    SequenceI seq4 = new Sequence("Seq4", "WTHISTHIS");
+
+    AlignmentI al = new Alignment(
+            new SequenceI[]
+            { seq1, seq2, seq3, seq4 });
+    AlignViewport alignViewport = new AlignViewport(al);
+
+    ScoreModelI scoreModel = ScoreModels.getInstance().getBlosum62();
+    SimilarityParamsI similarityParams = new SimilarityParams(true, true,
+            true, false);
+
+    jalviewTree = new NJTree(alignViewport, scoreModel,
+            similarityParams);
+  }
+
+  @Override
+  @BeforeClass(dependsOnMethods = { "setUpTree" })
+  public void createTreeView()
+  {
+    treeView = AptxInit.createInstance(jalviewTree);
+    aptx = (MainFrame) treeView; // still pretty ugly
+
+    treePanel = aptx.getMainPanel().getCurrentTreePanel();
+    tree = treePanel.getPhylogeny();
+
+  }
+
+  @Override
+  public void testTreeLoaded()
+  {
+    assertTrue(tree != null);
+
+  }
+
+  @Override
+  public void testTreeTitle()
+  {
+    assertTrue(tree.getName().contains("Neighbour Joining Using BLOSUM62"));
+
+  }
+
+  @Override
+  public void testChildNodesCount()
+  {
+    assertEquals(
+            tree.getNode("Seq2").getParent().getNumberOfExternalNodes(), 2);
+
+  }
+
+  @Override
+  public void testExistingBranchName()
+  {
+    tree.getNode("Seq4");
+
+  }
+
+  @Override
+  public void testChildToParentBranchLength()
+  {
+    assertEquals(tree.getNode("Seq1").getDistanceToParent(), 5.25);
+
+  }
+
+  @Test(
+    groups = "Functional",
+    expectedExceptions = IllegalArgumentException.class)
+  public void testInvalidBranchName()
+  {
+    tree.getNode("I shouldn't exist");
+
+  }
+
+  @Override
+  public void testNodeToRootBranchLength()
+  {
+    assertEquals(tree.getNode("Seq3").calculateDistanceToRoot(), 19.13);
+
+  }
+
+  @Override
+  public void testDistantNodeToRootBranchLength()
+  {
+    assertEquals(tree.getNode("Seq2").calculateDistanceToRoot(),
+            3.75 + 35.75 + 19.13);
+
+  }
+
+
+
+
+}
diff --git a/test/jalview/ext/archaeopteryx/AptxPhylogenyTreeTest.java b/test/jalview/ext/archaeopteryx/AptxPhylogenyTreeTest.java
new file mode 100644 (file)
index 0000000..9d62eb1
--- /dev/null
@@ -0,0 +1,148 @@
+package jalview.ext.archaeopteryx;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.archaeopteryx.TreePanel;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AptxPhylogenyTreeTest extends TreeViewTest
+{
+  final Phylogeny inputTree = new Phylogeny();
+
+  final PhylogenyNode rootNode = new PhylogenyNode("root");
+
+  final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
+
+  final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
+
+  final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
+
+  final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
+
+  final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
+
+  Phylogeny tree;
+
+  TreePanel treePanel;
+
+  MainFrame aptx;
+
+
+  @Override
+  @BeforeClass(alwaysRun = true)
+  public void setUpTree()
+  {
+    ancestor1Node.addAsChild(leaf1aNode);
+    ancestor1Node.addAsChild(leaf1bNode);
+    ancestor1Node.addAsChild(leaf1cNode);
+
+    rootNode.addAsChild(ancestor1Node);
+    rootNode.addAsChild(ancestor2Node);
+
+    leaf1aNode.setDistanceToParent(2);
+    leaf1bNode.setDistanceToParent(3);
+    leaf1cNode.setDistanceToParent(4);
+
+    ancestor1Node.setDistanceToParent(36);
+    ancestor2Node.setDistanceToParent(42);
+
+    inputTree.setName("test");
+    inputTree.setRoot(rootNode);
+    inputTree.setRooted(true);
+
+  }
+
+  @Override
+  @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
+  public void createTreeView()
+  {
+    treeView = AptxInit.createUnboundInstance(inputTree);
+    aptx = (MainFrame) treeView; // pretty ugly
+    treePanel = aptx.getMainPanel().getCurrentTreePanel();
+    tree = treePanel.getPhylogeny();
+  }
+
+
+
+  @Test(groups = "Functional")
+  public void testMainPanelExists()
+  {
+    assertTrue(aptx.getMainPanel() != null);
+  }
+
+  @Test(groups = "Functional")
+  public void testTreePanelExists()
+  {
+    assertTrue(treePanel != null);
+  }
+
+  @Override
+  public void testTreeTitle()
+  {
+    assertTrue(tree.getName().equals("test"));
+
+  }
+
+  @Test(
+    groups = "Functional",
+    expectedExceptions = IllegalArgumentException.class)
+  public void testInvalidBranchName()
+  {
+    tree.getNode("I shouldn't exist");
+
+  }
+
+  @Override
+  public void testExistingBranchName()
+  {
+    tree.getNode("leaf 2");
+
+  }
+
+  @Override
+  public void testTreeLoaded()
+  {
+    assertTrue(tree != null);
+  }
+
+  @Override
+  public void testChildNodesCount()
+  {
+    assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
+
+  }
+
+  @Override
+  public void testChildToParentBranchLength()
+  {
+    assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
+
+  }
+
+  @Override
+  public void testNodeToRootBranchLength()
+  {
+    assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
+
+  }
+
+  @Override
+  public void testDistantNodeToRootBranchLength()
+  {
+    assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),
+            4.0 + 36.0);
+
+  }
+
+
+
+
+
+
+
+}
diff --git a/test/jalview/ext/archaeopteryx/TreeViewTest.java b/test/jalview/ext/archaeopteryx/TreeViewTest.java
new file mode 100644 (file)
index 0000000..4bbe140
--- /dev/null
@@ -0,0 +1,76 @@
+package jalview.ext.archaeopteryx;
+
+import static org.testng.Assert.assertTrue;
+
+import jalview.bin.Jalview;
+import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
+
+import javax.swing.JInternalFrame;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public abstract class TreeViewTest
+{
+  Jalview jalview;
+
+  JInternalFrame treeView;
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
+  public abstract void setUpTree();
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpJalview()
+  {
+    String[] args = new String[0];
+    Jalview.main(args);
+  }
+
+  public abstract void createTreeView();
+
+  @Test(groups = "Functional")
+  public void testTreeViewExists()
+  {
+    assertTrue(treeView != null);
+  }
+
+  @Test(groups = "Functional")
+  public void testTreeViewBoundToJalview()
+  {
+    assertTrue(treeView.getTopLevelAncestor() instanceof Desktop);
+  }
+
+  @Test(groups = "Functional")
+  public void testShowingTreeView()
+  {
+    assertTrue(treeView.isShowing());
+  }
+
+  @Test(groups = "Functional")
+  public abstract void testTreeLoaded();
+
+  @Test(groups = "Functional")
+  public abstract void testTreeTitle();
+
+  @Test(groups = "Functional")
+  public abstract void testExistingBranchName();
+
+  @Test(groups = "Functional")
+  public abstract void testChildNodesCount();
+
+  @Test(groups = "Functional")
+  public abstract void testChildToParentBranchLength();
+
+  @Test(groups = "Functional")
+  public abstract void testNodeToRootBranchLength();
+
+  @Test(groups = "Functional")
+  public abstract void testDistantNodeToRootBranchLength();
+}
index 81e37d8..8a6d688 100644 (file)
@@ -255,7 +255,7 @@ public class FreeUpMemoryTest
     af.openTreePcaDialog();
     CalculationChooser dialog = af.alignPanel.getCalculationDialog();
     dialog.openPcaPanel("BLOSUM62", dialog.getSimilarityParameters(true));
-    dialog.openTreePanel("BLOSUM62", dialog.getSimilarityParameters(false));
+    dialog.createTree("BLOSUM62",dialog.getSimilarityParameters(false));
 
     /*
      * wait until Tree and PCA have been computed
index beedb11..f1680e7 100644 (file)
@@ -108,8 +108,8 @@ public class NewickFileTests
       SequenceNode tree = nf.getTree();
       AssertJUnit.assertTrue(stage + "Null Tree", tree != null);
       stage = "Creating newick file from testTree " + treename;
-      String gentree = new NewickFile(tree).print(nf.HasBootstrap(),
-              nf.HasDistances());
+      String gentree = new NewickFile(tree).print(nf.hasBootstrap(),
+              nf.hasDistances());
       AssertJUnit.assertTrue(stage + "Empty string generated",
               gentree != null && gentree.trim().length() > 0);
       stage = "Parsing regenerated testTree " + treename;
index 4b7c545..d3f77b1 100644 (file)
@@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.source=11
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=52
@@ -23,8 +24,10 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
@@ -34,6 +37,8 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration
 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
 org.eclipse.jdt.core.formatter.blank_lines_after_package=1
@@ -60,6 +65,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
 org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
 org.eclipse.jdt.core.formatter.comment.format_block_comments=false
 org.eclipse.jdt.core.formatter.comment.format_header=false
 org.eclipse.jdt.core.formatter.comment.format_html=true
@@ -92,6 +98,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
 org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
 org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
 org.eclipse.jdt.core.formatter.indentation.size=8
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
@@ -286,13 +293,24 @@ org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
 org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
 org.eclipse.jdt.core.formatter.tabulation.char=space
 org.eclipse.jdt.core.formatter.tabulation.size=2
 org.eclipse.jdt.core.formatter.use_on_off_tags=true
 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
 org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
 org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
 org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
 org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-