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";
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();
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 ) {
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();
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:
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:
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 );
}
}
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" );
+ 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() );
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() );
log_writer.close();
}
+ private static void writeToRemappedFile( final File out_file,
+ final SortedSet<String> 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<String> ss = new TreeSet<String>();
for( final PhylogenyNode n : gsdi.getMappedExternalSpeciesTreeNodes() ) {
}
}
+ 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<String, Integer> sm = new TreeMap<String, Integer>();
}
}
- private static void printStrippedSpeciesTreeNodesToLog( final EasyWriter log_writer, final GSDI gsdi )
- throws IOException {
- final SortedSet<String> ss = new TreeSet<String>();
- 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] <gene tree in phyloXML format> <species tree> [outfile]" );
+ + " [-options] <gene tree in phyloXML format> <species tree> <outfile>" );
System.out.println();
System.out.println( "Options:" );
System.out.println( " -" + gsdi.ALLOW_STRIPPING_OF_GENE_TREE_OPTION
@Override
final public String toString() {
final StringBuilder sb = new StringBuilder();
- if ( !ForesterUtil.isEmpty( getName() ) ) {
- sb.append( getName() );
- sb.append( " " );
- }
if ( getNodeData().isHasTaxonomy() ) {
if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getScientificName() ) ) {
sb.append( getNodeData().getTaxonomy().getScientificName() );
sb.append( " " );
}
- else if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+ else if ( ( sb.length() <= 1 ) && !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
sb.append( getNodeData().getTaxonomy().getTaxonomyCode() );
sb.append( " " );
}
sb.append( " " );
}
}
+ if ( ( sb.length() <= 1 ) && !ForesterUtil.isEmpty( getName() ) ) {
+ sb.append( getName() );
+ sb.append( " " );
+ }
if ( sb.length() <= 1 ) {
sb.append( "[" );
sb.append( getId() );
return sb;
}
+ public String getValuePlusProvider() {
+ return _value_provider;
+ }
+
@Override
public PhylogenyData copy() {
return new Identifier( getValue(), getProvider() );
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
private final List<PhylogenyNode> _stripped_species_tree_nodes;
private final Set<PhylogenyNode> _mapped_species_tree_nodes;
private TaxonomyComparisonBase _tax_comp_base;
+ private final SortedSet<String> _scientific_names_mapped_to_reduced_specificity;
public GSDI( final Phylogeny gene_tree,
final Phylogeny species_tree,
_stripped_gene_tree_nodes = new ArrayList<PhylogenyNode>();
_stripped_species_tree_nodes = new ArrayList<PhylogenyNode>();
_mapped_species_tree_nodes = new HashSet<PhylogenyNode>();
+ _scientific_names_mapped_to_reduced_specificity = new TreeSet<String>();
linkNodesOfG();
getSpeciesTree().preOrderReId();
geneTreePostOrderTraversal();
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.
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 ) {
} // 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<String, PhylogenyNode> species_to_node_map,
- final String tax_str,
- PhylogenyNode s ) {
- s = tryMapByRemovingOverlySpecificData( species_to_node_map, tax_str, " (" );
+ private final PhylogenyNode tryMapByRemovingOverlySpecificData( final Map<String, PhylogenyNode> 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 ) {
return s;
}
- private final static PhylogenyNode tryMapByRemovingOverlySpecificData( final Map<String, PhylogenyNode> species_to_node_map,
- final String tax_str,
- final String term ) {
+ private final PhylogenyNode tryMapByRemovingOverlySpecificData( final Map<String, PhylogenyNode> 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<String> getReMappedScientificNamesFromGeneTree() {
+ return _scientific_names_mapped_to_reduced_specificity;
+ }
+
public TaxonomyComparisonBase getTaxCompBase() {
return _tax_comp_base;
}
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;
}
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;
}
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 );
}
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;
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 {
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;
}
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 );