From: cmzmasek@gmail.com Date: Fri, 29 Jun 2012 06:42:35 +0000 (+0000) Subject: cleanup X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=39ad4632ee57d8ab720a7ad08c2ba4cccffa05bb;p=jalview.git cleanup --- diff --git a/forester/java/src/org/forester/application/gsdi.java b/forester/java/src/org/forester/application/gsdi.java index 0f77e5c..c137638 100644 --- a/forester/java/src/org/forester/application/gsdi.java +++ b/forester/java/src/org/forester/application/gsdi.java @@ -69,9 +69,9 @@ public final class gsdi { final static private String GUESS_FORMAT_OF_SPECIES_TREE = "q"; final static private String HELP_OPTION_1 = "help"; final static private String HELP_OPTION_2 = "h"; - final static private String DEFAULT_OUTFILE_SUFFIX = "_gsdi_out.xml"; final static private String SUFFIX_FOR_SPECIES_TREE_USED = "_species_tree_used.xml"; final static private String LOGFILE_SUFFIX = "_gsdi_log.txt"; + final static private String REMAPPED_SUFFIX = "_gsdi_remapped.txt"; final static private String PRG_NAME = "gsdi"; final static private String PRG_VERSION = "1.000"; final static private String PRG_DATE = "120608"; @@ -100,7 +100,7 @@ public final class gsdi { gsdi.print_help(); System.exit( 0 ); } - else if ( ( args.length < 2 ) || ( cla.getNumberOfNames() < 2 ) || ( cla.getNumberOfNames() > 3 ) ) { + else if ( ( args.length < 2 ) || ( cla.getNumberOfNames() != 3 ) ) { System.out.println(); System.out.println( "Wrong number of arguments." ); System.out.println(); @@ -152,12 +152,7 @@ public final class gsdi { try { gene_tree_file = cla.getFile( 0 ); species_tree_file = cla.getFile( 1 ); - if ( cla.getNumberOfNames() == 3 ) { - out_file = cla.getFile( 2 ); - } - else { - out_file = new File( ForesterUtil.removeSuffix( gene_tree_file.toString() ) + DEFAULT_OUTFILE_SUFFIX ); - } + out_file = cla.getFile( 2 ); log_file = new File( ForesterUtil.removeSuffix( out_file.toString() ) + LOGFILE_SUFFIX ); } catch ( final IllegalArgumentException e ) { @@ -186,8 +181,9 @@ public final class gsdi { gene_tree = factory.create( gene_tree_file, new PhyloXmlParser() )[ 0 ]; } catch ( final IOException e ) { - ForesterUtil.fatalError( gsdi.PRG_NAME, - "Failed to read gene tree from [" + gene_tree_file + "]: " + e.getMessage() ); + fatalError( "ERROR", + "Failed to read gene tree from [" + gene_tree_file + "]: " + e.getMessage(), + log_writer ); } try { final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); @@ -210,9 +206,8 @@ public final class gsdi { true ); } catch ( final PhyloXmlDataFormatException e ) { - ForesterUtil.fatalError( gsdi.PRG_NAME, - "Failed to transfer general node name to scientific name, in [" - + species_tree_file + "]: " + e.getMessage() ); + fatalError( "USER ERROR", "Failed to transfer general node name to scientific name, in [" + + species_tree_file + "]: " + e.getMessage(), log_writer ); } break; case CODE: @@ -223,9 +218,8 @@ public final class gsdi { true ); } catch ( final PhyloXmlDataFormatException e ) { - ForesterUtil.fatalError( gsdi.PRG_NAME, - "Failed to transfer general node name to taxonomy code, in [" - + species_tree_file + "]: " + e.getMessage() ); + fatalError( "USER ERROR", "Failed to transfer general node name to taxonomy code, in [" + + species_tree_file + "]: " + e.getMessage(), log_writer ); } break; case ID: @@ -235,32 +229,28 @@ public final class gsdi { true ); } catch ( final PhyloXmlDataFormatException e ) { - ForesterUtil.fatalError( gsdi.PRG_NAME, - "Failed to transfer general node name to taxonomy id, in [" - + species_tree_file + "]: " + e.getMessage() ); + fatalError( "USER ERROR", "Failed to transfer general node name to taxonomy id, in [" + + species_tree_file + "]: " + e.getMessage(), log_writer ); } break; default: - ForesterUtil.fatalError( gsdi.PRG_NAME, "unable to determine comparison base" ); + fatalError( "UNEXPECTED ERROR", "unable to determine comparison base", log_writer ); } } } catch ( final IOException e ) { - ForesterUtil.fatalError( gsdi.PRG_NAME, "Failed to read species tree from [" + species_tree_file + "]: " - + e.getMessage() ); + fatalError( "ERROR", + "Failed to read species tree from [" + species_tree_file + "]: " + e.getMessage(), + log_writer ); } gene_tree.setRooted( true ); species_tree.setRooted( true ); if ( !gene_tree.isCompletelyBinary() ) { - log_writer.println( "User Error: gene tree is not completely binary" ); - log_writer.close(); - ForesterUtil.fatalError( gsdi.PRG_NAME, "gene tree is not completely binary" ); + fatalError( "user error", "gene tree is not completely binary", log_writer ); } if ( base_algorithm != BASE_ALGORITHM.GSDI ) { if ( !species_tree.isCompletelyBinary() ) { - log_writer.println( "User Error: species tree is not completely binary, use GSDI instead" ); - log_writer.close(); - ForesterUtil.fatalError( gsdi.PRG_NAME, "species tree is not completely binary, use GSDI instead" ); + fatalError( "user error", "species tree is not completely binary, use GSDI instead", log_writer ); } } log_writer.println( PRG_NAME + " - " + PRG_DESC ); @@ -308,20 +298,14 @@ public final class gsdi { } } catch ( final SDIException e ) { - log_writer.println( "User Error: " + e.getLocalizedMessage() ); - log_writer.close(); - ForesterUtil.fatalError( PRG_NAME, e.getLocalizedMessage() ); + fatalError( "user error", e.getLocalizedMessage(), log_writer ); } catch ( final IOException e ) { - log_writer.println( "Error: " + e ); - log_writer.close(); - ForesterUtil.fatalError( PRG_NAME, e.toString() ); + fatalError( "error", e.toString(), log_writer ); } catch ( final Exception e ) { - log_writer.println( "Error: " + e ); - log_writer.close(); e.printStackTrace(); - System.exit( -1 ); + fatalError( "unexpected error", e.toString(), log_writer ); } System.out.println( "Running time (excluding I/O) : " + ( new Date().getTime() - start_time ) + "ms" ); @@ -363,6 +347,14 @@ public final class gsdi { + species_tree_used_file.getCanonicalPath() ); log_writer.println( "Wrote (stripped) species tree to : " + species_tree_used_file.getCanonicalPath() ); + if ( ( gsdi.getReMappedScientificNamesFromGeneTree() != null ) + && !gsdi.getReMappedScientificNamesFromGeneTree().isEmpty() ) { + System.out.println( "Number of gene tree species remapped : " + + gsdi.getReMappedScientificNamesFromGeneTree().size() ); + log_writer.println( "Number of gene tree species remapped : " + + gsdi.getReMappedScientificNamesFromGeneTree().size() ); + writeToRemappedFile( out_file, gsdi.getReMappedScientificNamesFromGeneTree(), log_writer ); + } } System.out.println( "Number of external nodes in gene tree : " + gene_tree.getNumberOfExternalNodes() ); log_writer.println( "Number of external nodes in gene tree : " + gene_tree.getNumberOfExternalNodes() ); @@ -400,8 +392,6 @@ public final class gsdi { printMappedNodesToLog( log_writer, gsdi ); log_writer.println(); printStrippedGeneTreeNodesToLog( log_writer, gsdi ); - log_writer.println(); - printStrippedSpeciesTreeNodesToLog( log_writer, gsdi ); } System.out.println(); System.out.println( "Wrote log to : " + log_file.getCanonicalPath() ); @@ -409,6 +399,19 @@ public final class gsdi { log_writer.close(); } + private static void writeToRemappedFile( final File out_file, + final SortedSet remapped, + final EasyWriter log_writer ) throws IOException { + final File file = new File( ForesterUtil.removeSuffix( out_file.toString() ) + REMAPPED_SUFFIX ); + final EasyWriter remapped_writer = ForesterUtil.createEasyWriter( file ); + for( final String s : remapped ) { + remapped_writer.println( s ); + } + remapped_writer.close(); + System.out.println( "Wrote remapped gene tree species to : " + file.getCanonicalPath() ); + log_writer.println( "Wrote remapped gene tree species to : " + file.getCanonicalPath() ); + } + private static void printMappedNodesToLog( final EasyWriter log_writer, final GSDI gsdi ) throws IOException { final SortedSet ss = new TreeSet(); for( final PhylogenyNode n : gsdi.getMappedExternalSpeciesTreeNodes() ) { @@ -420,6 +423,20 @@ public final class gsdi { } } + private static void fatalError( final String type, final String msg, final EasyWriter log_writer ) { + try { + log_writer.flush(); + log_writer.println(); + log_writer.print( type.toUpperCase() + ": " ); + log_writer.println( msg ); + log_writer.close(); + } + catch ( final IOException e ) { + e.printStackTrace(); + } + ForesterUtil.fatalError( gsdi.PRG_NAME, msg ); + } + private static void printStrippedGeneTreeNodesToLog( final EasyWriter log_writer, final GSDI gsdi ) throws IOException { final SortedMap sm = new TreeMap(); @@ -444,21 +461,9 @@ public final class gsdi { } } - private static void printStrippedSpeciesTreeNodesToLog( final EasyWriter log_writer, final GSDI gsdi ) - throws IOException { - final SortedSet ss = new TreeSet(); - for( final PhylogenyNode n : gsdi.getStrippedSpeciesTreeNodes() ) { - ss.add( n.toString() ); - } - log_writer.println( "The following " + ss.size() + " nodes were stripped from the species tree: " ); - for( final String n : ss ) { - log_writer.println( " " + n ); - } - } - private static void print_help() { System.out.println( "Usage: " + gsdi.PRG_NAME - + " [-options] [outfile]" ); + + " [-options] " ); System.out.println(); System.out.println( "Options:" ); System.out.println( " -" + gsdi.ALLOW_STRIPPING_OF_GENE_TREE_OPTION diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java index 45c1ada..32fec23 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java @@ -1061,16 +1061,12 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable _stripped_species_tree_nodes; private final Set _mapped_species_tree_nodes; private TaxonomyComparisonBase _tax_comp_base; + private final SortedSet _scientific_names_mapped_to_reduced_specificity; public GSDI( final Phylogeny gene_tree, final Phylogeny species_tree, @@ -88,6 +91,7 @@ public final class GSDI extends SDI { _stripped_gene_tree_nodes = new ArrayList(); _stripped_species_tree_nodes = new ArrayList(); _mapped_species_tree_nodes = new HashSet(); + _scientific_names_mapped_to_reduced_specificity = new TreeSet(); linkNodesOfG(); getSpeciesTree().preOrderReId(); geneTreePostOrderTraversal(); @@ -228,12 +232,14 @@ public final class GSDI extends SDI { for( final PhylogenyNodeIterator iter = _species_tree.iteratorExternalForward(); iter.hasNext(); ) { final PhylogenyNode s = iter.next(); species_tree_ext_nodes.add( s ); - final String tax_str = taxonomyToString( s, _tax_comp_base ); - if ( !ForesterUtil.isEmpty( tax_str ) ) { - if ( species_to_node_map.containsKey( tax_str ) ) { - throw new SDIException( "taxonomy \"" + s + "\" is not unique in species tree" ); + if ( s.getNodeData().isHasTaxonomy() ) { + final String tax_str = taxonomyToString( s, _tax_comp_base ); + if ( !ForesterUtil.isEmpty( tax_str ) ) { + if ( species_to_node_map.containsKey( tax_str ) ) { + throw new SDIException( "taxonomy \"" + s + "\" is not unique in species tree" ); + } + species_to_node_map.put( tax_str, s ); } - species_to_node_map.put( tax_str, s ); } } // Retrieve the reference to the node with a matching stringyfied taxonomy. @@ -261,7 +267,7 @@ public final class GSDI extends SDI { PhylogenyNode s = species_to_node_map.get( tax_str ); if ( ( _tax_comp_base == TaxonomyComparisonBase.SCIENTIFIC_NAME ) && ( s == null ) && ( ForesterUtil.countChars( tax_str, ' ' ) > 1 ) ) { - s = tryMapByRemovingOverlySpecificData( species_to_node_map, tax_str, s ); + s = tryMapByRemovingOverlySpecificData( species_to_node_map, tax_str ); } if ( s == null ) { if ( _strip_gene_tree ) { @@ -281,19 +287,25 @@ public final class GSDI extends SDI { } // for loop if ( _strip_gene_tree ) { stripGeneTree(); + if ( getGeneTree().isEmpty() || ( getGeneTree().getNumberOfExternalNodes() < 2 ) ) { + throw new SDIException( "species could not be mapped between gene tree and species tree" ); + } } if ( _strip_species_tree ) { stripSpeciesTree( species_tree_ext_nodes ); } } - private final static PhylogenyNode tryMapByRemovingOverlySpecificData( final Map species_to_node_map, - final String tax_str, - PhylogenyNode s ) { - s = tryMapByRemovingOverlySpecificData( species_to_node_map, tax_str, " (" ); + private final PhylogenyNode tryMapByRemovingOverlySpecificData( final Map species_to_node_map, + final String tax_str ) { + PhylogenyNode s = tryMapByRemovingOverlySpecificData( species_to_node_map, tax_str, " (" ); if ( s == null ) { if ( ForesterUtil.countChars( tax_str, ' ' ) == 2 ) { - s = species_to_node_map.get( tax_str.substring( 0, tax_str.lastIndexOf( ' ' ) ).trim() ); + final String new_tax_str = tax_str.substring( 0, tax_str.lastIndexOf( ' ' ) ).trim(); + s = species_to_node_map.get( new_tax_str ); + if ( s != null ) { + addScientificNamesMappedToReducedSpecificity( tax_str, new_tax_str ); + } } } if ( s == null ) { @@ -308,16 +320,29 @@ public final class GSDI extends SDI { return s; } - private final static PhylogenyNode tryMapByRemovingOverlySpecificData( final Map species_to_node_map, - final String tax_str, - final String term ) { + private final PhylogenyNode tryMapByRemovingOverlySpecificData( final Map species_to_node_map, + final String tax_str, + final String term ) { final int i = tax_str.indexOf( term ); if ( i > 4 ) { - return species_to_node_map.get( tax_str.substring( 0, i ).trim() ); + final String new_tax_str = tax_str.substring( 0, i ).trim(); + final PhylogenyNode s = species_to_node_map.get( new_tax_str ); + if ( s != null ) { + addScientificNamesMappedToReducedSpecificity( tax_str, new_tax_str ); + } + return s; } return null; } + private final void addScientificNamesMappedToReducedSpecificity( final String s1, final String s2 ) { + _scientific_names_mapped_to_reduced_specificity.add( s1 + " -> " + s2 ); + } + + public final SortedSet getReMappedScientificNamesFromGeneTree() { + return _scientific_names_mapped_to_reduced_specificity; + } + public TaxonomyComparisonBase getTaxCompBase() { return _tax_comp_base; } @@ -377,12 +402,12 @@ public final class GSDI extends SDI { else if ( max == 1 ) { throw new IllegalArgumentException( "gene tree has only one node with taxonomic data" ); } - else if ( max == with_sn_count ) { - return SDI.TaxonomyComparisonBase.SCIENTIFIC_NAME; - } else if ( max == with_id_count ) { return SDI.TaxonomyComparisonBase.ID; } + else if ( max == with_sn_count ) { + return SDI.TaxonomyComparisonBase.SCIENTIFIC_NAME; + } else { return SDI.TaxonomyComparisonBase.CODE; } diff --git a/forester/java/src/org/forester/sdi/SDI.java b/forester/java/src/org/forester/sdi/SDI.java index 59cc489..b1258f0 100644 --- a/forester/java/src/org/forester/sdi/SDI.java +++ b/forester/java/src/org/forester/sdi/SDI.java @@ -32,6 +32,7 @@ import java.util.Map; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; +import org.forester.phylogeny.data.Identifier; import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.util.ForesterUtil; @@ -288,14 +289,17 @@ public abstract class SDI { } static String taxonomyToString( final PhylogenyNode n, final TaxonomyComparisonBase base ) { - final Taxonomy tax = n.getNodeData().getTaxonomy(); switch ( base ) { case ID: - return tax.getIdentifier().getValue(); + final Identifier id = n.getNodeData().getTaxonomy().getIdentifier(); + if ( id == null ) { + return null; + } + return id.getValuePlusProvider(); case CODE: - return tax.getTaxonomyCode(); + return n.getNodeData().getTaxonomy().getTaxonomyCode(); case SCIENTIFIC_NAME: - return tax.getScientificName(); + return n.getNodeData().getTaxonomy().getScientificName(); default: throw new IllegalArgumentException( "unknown comparison base for taxonomies: " + base ); } diff --git a/forester/java/src/org/forester/sdi/TestGSDI.java b/forester/java/src/org/forester/sdi/TestGSDI.java index 0539759..91ac13a 100644 --- a/forester/java/src/org/forester/sdi/TestGSDI.java +++ b/forester/java/src/org/forester/sdi/TestGSDI.java @@ -27,7 +27,6 @@ package org.forester.sdi; import java.io.IOException; -import org.forester.archaeopteryx.Archaeopteryx; import org.forester.development.DevelopmentTools; import org.forester.io.parsers.nhx.NHXParser; import org.forester.io.parsers.util.ParserUtils; @@ -36,6 +35,7 @@ import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.data.Event; import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; import org.forester.phylogeny.factories.PhylogenyFactory; +import org.forester.sdi.SDI.TaxonomyComparisonBase; import org.forester.util.ForesterUtil; public final class TestGSDI { @@ -1222,7 +1222,6 @@ public final class TestGSDI { final Phylogeny gene_tree_tax_code_4_ = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + "gene_tree_tax_code_4.xml" )[ 0 ]; final GSDI gsdi_143_4_1 = new GSDI( gene_tree_tax_code_4_.copy(), tol_143_.copy(), false, true, true ); - Archaeopteryx.createApplication( gsdi_143_4_1.getGeneTree() ); if ( gsdi_143_4_1.getDuplicationsSum() != 21 ) { return false; } @@ -1232,6 +1231,162 @@ public final class TestGSDI { if ( gsdi_143_4_1.getSpeciationOrDuplicationEventsSum() != 6 ) { return false; } + //-- + final Phylogeny gsdi_test_gene_tree_sn_wnt = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + + "gsdi_test_gene_tree_sn_wnt.xml" )[ 0 ]; + gsdi_test_gene_tree_sn_wnt.setRooted( true ); + final GSDI a = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(), tol_143_.copy(), false, true, true ); + if ( a.getDuplicationsSum() != 33 ) { + return false; + } + if ( a.getSpeciationsSum() != 31 ) { + return false; + } + if ( a.getSpeciationOrDuplicationEventsSum() != 0 ) { + return false; + } + if ( a.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) { + return false; + } + if ( a.getMappedExternalSpeciesTreeNodes().size() != 26 ) { + return false; + } + if ( a.getReMappedScientificNamesFromGeneTree().size() != 0 ) { + return false; + } + //-- + final Phylogeny gsdi_test_species_tree_sn_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + + "gsdi_test_species_tree_sn.xml" )[ 0 ]; + final GSDI b = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(), + gsdi_test_species_tree_sn_xml.copy(), + false, + true, + true ); + if ( b.getDuplicationsSum() != 8 ) { + return false; + } + if ( b.getSpeciationsSum() != 2 ) { + return false; + } + if ( b.getSpeciationOrDuplicationEventsSum() != 0 ) { + return false; + } + if ( b.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) { + return false; + } + if ( b.getMappedExternalSpeciesTreeNodes().size() != 2 ) { + return false; + } + if ( b.getReMappedScientificNamesFromGeneTree().size() != 0 ) { + return false; + } + if ( b.getStrippedExternalGeneTreeNodes().size() != 87 ) { + return false; + } + if ( b.getStrippedSpeciesTreeNodes().size() != 17 ) { + return false; + } + //-- + final Phylogeny gsdi_test_species_tree_sn_nh = TestGSDI + .createPhylogeny( "((((((('Homo sapiens','Mus musculus')Euarchontoglires,'Petromyzon marinus')Vertebrata,'Nematostella vectensis')'Bilateria Cnidaria',(('Mycosphaerella graminicola','Mycosphaerella pini')Mycosphaerella,'Saccharomyces cerevisiae')'Pezizomycotina Saccharomycetales')Opisthokonta,('Plasmodium chabaudi','Plasmodium falciparum','Plasmodium yoelii yoelii')Plasmodium)Eukaryota,'Pyrococcus horikoshii')Neomura,(('Kineococcus radiotolerans','Kocuria rhizophila','Streptomyces coelicolor','Thermobifida fusca','Microlunatus phosphovorus'),'Bacteroides thetaiotaomicron'))'cellular organisms';" ); + PhylogenyMethods.transferNodeNameToField( gsdi_test_species_tree_sn_nh, + PhylogenyMethods.PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME, + true ); + final GSDI c = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(), + gsdi_test_species_tree_sn_nh.copy(), + false, + true, + true ); + if ( c.getDuplicationsSum() != 8 ) { + return false; + } + if ( c.getSpeciationsSum() != 2 ) { + return false; + } + if ( c.getSpeciationOrDuplicationEventsSum() != 0 ) { + return false; + } + if ( c.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) { + return false; + } + if ( c.getMappedExternalSpeciesTreeNodes().size() != 2 ) { + return false; + } + if ( c.getReMappedScientificNamesFromGeneTree().size() != 0 ) { + return false; + } + if ( c.getStrippedExternalGeneTreeNodes().size() != 87 ) { + return false; + } + if ( c.getStrippedSpeciesTreeNodes().size() != 15 ) { + return false; + } + //-- + final Phylogeny gsdi_test_gene_tree_codes_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + + "gsdi_test_gene_tree_codes.xml" )[ 0 ]; + final Phylogeny gsdi_test_species_tree_codes_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + + "gsdi_test_species_tree_codes.xml" )[ 0 ]; + final GSDI d = new GSDI( gsdi_test_gene_tree_codes_xml.copy(), + gsdi_test_species_tree_codes_xml.copy(), + false, + true, + true ); + if ( d.getDuplicationsSum() != 21 ) { + return false; + } + if ( d.getSpeciationsSum() != 28 ) { + return false; + } + if ( d.getSpeciationOrDuplicationEventsSum() != 6 ) { + return false; + } + if ( d.getTaxCompBase() != TaxonomyComparisonBase.CODE ) { + return false; + } + if ( d.getMappedExternalSpeciesTreeNodes().size() != 17 ) { + return false; + } + if ( d.getReMappedScientificNamesFromGeneTree().size() != 0 ) { + return false; + } + if ( d.getStrippedExternalGeneTreeNodes().size() != 12 ) { + return false; + } + if ( d.getStrippedSpeciesTreeNodes().size() != 3 ) { + return false; + } + //-- + final Phylogeny gsdi_test_gene_tree_sn_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + + "gsdi_test_gene_tree_sn.xml" )[ 0 ]; + final GSDI e = new GSDI( gsdi_test_gene_tree_sn_xml.copy(), + gsdi_test_species_tree_sn_xml.copy(), + false, + true, + true ); + if ( e.getDuplicationsSum() != 7 ) { + return false; + } + if ( e.getSpeciationsSum() != 9 ) { + return false; + } + if ( e.getSpeciationOrDuplicationEventsSum() != 1 ) { + return false; + } + if ( e.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) { + return false; + } + if ( e.getMappedExternalSpeciesTreeNodes().size() != 12 ) { + return false; + } + if ( e.getReMappedScientificNamesFromGeneTree().size() != 8 ) { + return false; + } + if ( e.getStrippedExternalGeneTreeNodes().size() != 3 ) { + return false; + } + if ( e.getStrippedSpeciesTreeNodes().size() != 7 ) { + return false; + } } catch ( final Exception e ) { e.printStackTrace( System.out );