+ System.out.println( "Number of duplications : " + sdi.getDuplicationsSum() );
+ log_writer.println( "Number of duplications : " + sdi.getDuplicationsSum() );
+ if ( ( base_algorithm == BASE_ALGORITHM.GSDI ) ) {
+ final GSDI gsdi = ( GSDI ) sdi;
+ if ( !most_parsimonous_duplication_model ) {
+ final int u = gsdi.getSpeciationOrDuplicationEventsSum();
+ System.out.println( "Number of potential duplications : " + u );
+ log_writer.println( "Number of potential duplications : " + u );
+ }
+ System.out.println( "Number of speciations : " + gsdi.getSpeciationsSum() );
+ log_writer.println( "Number of speciations : " + gsdi.getSpeciationsSum() );
+ log_writer.println();
+ printMappedNodesToLog( log_writer, gsdi );
+ log_writer.println();
+ printStrippedGeneTreeNodesToLog( log_writer, gsdi );
+ }
+ System.out.println();
+ System.out.println( "Wrote log to : " + log_file.getCanonicalPath() );
+ System.out.println();
+ 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() ) {
+ ss.add( n.toString() );
+ }
+ log_writer.println( "The following " + ss.size() + " species were used: " );
+ for( final String s : ss ) {
+ log_writer.println( " " + s );
+ }
+ }
+
+ 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>();
+ for( final PhylogenyNode n : gsdi.getStrippedExternalGeneTreeNodes() ) {
+ final String s = n.toString();
+ if ( sm.containsKey( s ) ) {
+ sm.put( s, sm.get( s ) + 1 );
+ }
+ else {
+ sm.put( s, 1 );
+ }
+ }
+ log_writer.println( "The following " + sm.size() + " nodes were stripped from the gene tree: " );
+ for( final String s : sm.keySet() ) {
+ final int count = sm.get( s );
+ if ( count == 1 ) {
+ log_writer.println( " " + s );
+ }
+ else {
+ log_writer.println( " " + s + " [" + count + "]" );
+ }
+ }
+ }