+ void executeGSDI() {
+ if ( !isOKforSDI( false, true ) ) {
+ return;
+ }
+ if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
+ JOptionPane.showMessageDialog( this,
+ "Gene tree is not rooted.",
+ "Cannot execute GSDI",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
+ gene_tree.setAllNodesToNotCollapse();
+ gene_tree.recalculateNumberOfExternalDescendants( false );
+ GSDI gsdi = null;
+ final Phylogeny species_tree = _species_tree.copy();
+ try {
+ gsdi = new GSDI( gene_tree, species_tree, false, true, true );
+ }
+ catch ( final SDIException e ) {
+ JOptionPane.showMessageDialog( this,
+ e.getLocalizedMessage(),
+ "Error during GSDI",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ catch ( final Exception e ) {
+ AptxUtil.unexpectedException( e );
+ return;
+ }
+ gene_tree.setRerootable( false );
+ gene_tree.clearHashIdToNodeMap();
+ gene_tree.recalculateNumberOfExternalDescendants( true );
+ _mainpanel.addPhylogenyInNewTab( gene_tree, getConfiguration(), "gene tree", null );
+ getMainPanel().getControlPanel().setShowEvents( true );
+ showWhole();
+ final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
+ _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
+ showWhole();
+ _mainpanel.getTabbedPane().setSelectedIndex( selected );
+ showWhole();
+ _mainpanel.getCurrentTreePanel().setEdited( true );
+ final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
+ if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
+ JOptionPane.showMessageDialog( this,
+ "Duplications: " + gsdi.getDuplicationsSum() + "\n"
+ + "Potential duplications: "
+ + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
+ + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
+ + "Stripped gene tree nodes: "
+ + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
+ + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
+ + "Number of polytomies in species tree used: " + poly + "\n",
+ "GSDI successfully completed",
+ JOptionPane.WARNING_MESSAGE );
+ }
+ else {
+ JOptionPane.showMessageDialog( this,
+ "Duplications: " + gsdi.getDuplicationsSum() + "\n"
+ + "Potential duplications: "
+ + gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
+ + "Speciations: " + gsdi.getSpeciationsSum() + "\n"
+ + "Stripped gene tree nodes: "
+ + gsdi.getStrippedExternalGeneTreeNodes().size() + "\n"
+ + "Taxonomy linkage based on: " + gsdi.getTaxCompBase() + "\n"
+ + "Number of polytomies in species tree used: " + poly + "\n",
+ "GSDI successfully completed",
+ JOptionPane.INFORMATION_MESSAGE );
+ }
+ }
+
+ void executeGSDIR() {
+ if ( !isOKforSDI( false, false ) ) {
+ return;
+ }
+ final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
+ if ( ( p > 0 )
+ && !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
+ JOptionPane.showMessageDialog( this,
+ "Gene tree is not completely binary",
+ "Cannot execute GSDI",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
+ gene_tree.setAllNodesToNotCollapse();
+ gene_tree.recalculateNumberOfExternalDescendants( false );
+ GSDIR gsdir = null;
+ final Phylogeny species_tree = _species_tree.copy();
+ try {
+ gsdir = new GSDIR( gene_tree, species_tree, true, true );
+ }
+ catch ( final SDIException e ) {
+ JOptionPane.showMessageDialog( this,
+ e.getLocalizedMessage(),
+ "Error during GSDIR",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ catch ( final Exception e ) {
+ AptxUtil.unexpectedException( e );
+ return;
+ }
+ final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree();
+ result_gene_tree.setRerootable( false );
+ result_gene_tree.clearHashIdToNodeMap();
+ result_gene_tree.recalculateNumberOfExternalDescendants( true );
+ _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
+ getMainPanel().getControlPanel().setShowEvents( true );
+ showWhole();
+ final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
+ _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
+ showWhole();
+ _mainpanel.getTabbedPane().setSelectedIndex( selected );
+ showWhole();
+ _mainpanel.getCurrentTreePanel().setEdited( true );
+ final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
+ if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
+ JOptionPane.showMessageDialog( this,
+ "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
+ + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
+ + "Stripped gene tree nodes: "
+ + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
+ + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
+ + "Number of polytomies in species tree used: " + poly + "\n",
+ "GSDIR successfully completed",
+ JOptionPane.WARNING_MESSAGE );
+ }
+ else {
+ JOptionPane.showMessageDialog( this,
+ "Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
+ + "Speciations: " + gsdir.getSpeciationsSum() + "\n"
+ + "Stripped gene tree nodes: "
+ + gsdir.getStrippedExternalGeneTreeNodes().size() + "\n"
+ + "Taxonomy linkage based on: " + gsdir.getTaxCompBase() + "\n"
+ + "Number of polytomies in species tree used: " + poly + "\n",
+ "GSDIR successfully completed",
+ JOptionPane.INFORMATION_MESSAGE );
+ }
+ }
+