final BasicDescriptiveStatistics stats = rio.getDuplicationsStatistics();
final java.text.DecimalFormat df = new java.text.DecimalFormat( "0.#" );
System.out.println( "Mean number of duplications : " + df.format( stats.arithmeticMean() ) + " (sd: "
- + df.format( stats.sampleStandardDeviation() ) + ")" );
+ + df.format( stats.sampleStandardDeviation() ) + ") ("
+ + df.format( 100.0 * stats.arithmeticMean() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
if ( stats.getN() > 3 ) {
- System.out.println( "Median number of duplications: " + df.format( stats.median() ) );
+ System.out.println( "Median number of duplications: " + df.format( stats.median() ) + " ("
+ + df.format( 100.0 * stats.median() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
}
- System.out.println( "Minimum duplications : " + ( int ) stats.getMin() );
- System.out.println( "Maximum duplications : " + ( int ) stats.getMax() );
+ System.out.println( "Minimum duplications : " + ( int ) stats.getMin() + " ("
+ + df.format( 100.0 * stats.getMin() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+ System.out.println( "Maximum duplications : " + ( int ) stats.getMax() + " ("
+ + df.format( 100.0 * stats.getMax() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+ System.out.println( "Gene tree internal nodes : " + rio.getIntNodesOfAnalyzedGeneTrees() );
+ System.out.println( "Gene tree external nodes : " + rio.getExtNodesOfAnalyzedGeneTrees() );
}
catch ( final RIOException e ) {
ForesterUtil.fatalError( e.getLocalizedMessage() );
final static void unexpectedError( final Error e ) {
System.err.println();
- e.printStackTrace( System.err );
+ e.printStackTrace( System.err );
System.err.println();
final StringBuffer sb = new StringBuffer();
for( final StackTraceElement s : e.getStackTrace() ) {
JOptionPane
.showMessageDialog( null,
"An unexpected (possibly severe) error has occured - terminating. \nPlease contact: "
- + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n" + sb,
+ + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n"
+ + sb,
"Unexpected Severe Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
JOptionPane.ERROR_MESSAGE );
System.exit( -1 );
}
-
+
final static void outOfMemoryError( final OutOfMemoryError e ) {
System.err.println();
System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" );
System.err.println();
e.printStackTrace();
System.err.println();
-
- JOptionPane
- .showMessageDialog( null,
- "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
- + "\n\nError: " + e.getLocalizedMessage(),
- "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
- JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog( null,
+ "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
+ + "\n\nError: " + e.getLocalizedMessage(),
+ "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
+ JOptionPane.ERROR_MESSAGE );
System.exit( -1 );
}
final static void unexpectedException( final Exception e ) {
System.err.println();
- e.printStackTrace( System.err );
+ e.printStackTrace( System.err );
System.err.println();
final StringBuffer sb = new StringBuffer();
for( final StackTraceElement s : e.getStackTrace() ) {
sb.append( s + "\n" );
}
- JOptionPane.showMessageDialog( null, "An unexpected exception has occured. \nPlease contact: "
- + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage() + "\n" + sb, "Unexpected Exception ["
- + Constants.PRG_NAME + Constants.VERSION + "]", JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog( null,
+ "An unexpected exception has occured. \nPlease contact: "
+ + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage()
+ + "\n" + sb,
+ "Unexpected Exception [" + Constants.PRG_NAME + Constants.VERSION + "]",
+ JOptionPane.ERROR_MESSAGE );
}
final static String writePhylogenyToGraphicsByteArrayOutputStream( final ByteArrayOutputStream baos,
catch ( final IllegalAccessException e ) {
AptxUtil.dieWithSystemError( "illegal access exception: " + e.toString() );
}
-
if ( ( current_dir != null ) && current_dir.canRead() && current_dir.isDirectory() ) {
setCurrentDir( current_dir );
}
import org.forester.io.parsers.util.PhylogenyParserException;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Taxonomy;
import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
import org.forester.phylogeny.factories.PhylogenyFactory;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
node.setName( getTaxlabels().get( i - 1 ).replaceAll( "['\"]+", "" ) );
}
}
+ if ( !isReplaceUnderscores() && ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) ) {
+ final String tax = ParserUtils.extractTaxonomyCodeFromNodeName( node.getName(),
+ getTaxonomyExtraction() );
+ if ( !ForesterUtil.isEmpty( tax ) ) {
+ if ( !node.getNodeData().isHasTaxonomy() ) {
+ node.getNodeData().setTaxonomy( new Taxonomy() );
+ }
+ node.getNodeData().getTaxonomy().setTaxonomyCode( tax );
+ }
+ }
}
}
getPhylogenies().add( p );
return c;
}
+ public int getNumberOfInternalNodes() {
+ if ( isEmpty() ) {
+ return 0;
+ }
+ int c = 0;
+ for( final PhylogenyNodeIterator iter = iteratorPreorder(); iter.hasNext(); ) {
+ if ( iter.next().isInternal() ) {
+ ++c;
+ }
+ }
+ if ( !isRooted() ) {
+ --c;
+ }
+ return c;
+ }
+
/**
* Returns the sum of external Nodes of this Phylogeny (int).
*/
private Phylogeny[] _analyzed_gene_trees;
private List<PhylogenyNode> _removed_gene_tree_nodes;
private int _ext_nodes;
+ private int _int_nodes;
private TaxonomyComparisonBase _gsdir_tax_comp_base;
private final StringBuilder _log;
private final BasicDescriptiveStatistics _duplications_stats;
_verbose = verbose;
_rerooting = rerooting;
_ext_nodes = -1;
+ _int_nodes = -1;
_log = new StringBuilder();
_gsdir_tax_comp_base = null;
_analyzed_gene_trees = null;
return _ext_nodes;
}
+ /**
+ * Returns the numbers of number of int nodes in gene trees analyzed (after
+ * stripping).
+ *
+ * @return number of int nodes in gene trees analyzed (after stripping)
+ */
+ public final int getIntNodesOfAnalyzedGeneTrees() {
+ return _int_nodes;
+ }
+
public final TaxonomyComparisonBase getGSDIRtaxCompBase() {
return _gsdir_tax_comp_base;
}
}
if ( i == 0 ) {
_ext_nodes = assigned_tree.getNumberOfExternalNodes();
+ _int_nodes = assigned_tree.getNumberOfInternalNodes();
}
else if ( _ext_nodes != assigned_tree.getNumberOfExternalNodes() ) {
throw new RIOException( "after stripping gene tree #" + ( i + 1 )
final java.text.DecimalFormat df = new java.text.DecimalFormat( "0.#" );
log( "Gene trees analyzed : " + _duplications_stats.getN() );
log( "Mean number of duplications : " + df.format( _duplications_stats.arithmeticMean() )
- + " (sd: " + df.format( _duplications_stats.sampleStandardDeviation() ) + ")" );
+ + " (sd: " + df.format( _duplications_stats.sampleStandardDeviation() ) + ")" + " ("
+ + df.format( 100.0 * _duplications_stats.arithmeticMean() / getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
if ( _duplications_stats.getN() > 3 ) {
- log( "Median number of duplications : " + df.format( _duplications_stats.median() ) );
- }
- log( "Minimum duplications : " + ( int ) _duplications_stats.getMin() );
- log( "Maximum duplications : " + ( int ) _duplications_stats.getMax() );
+ log( "Median number of duplications : " + df.format( _duplications_stats.median() )
+ + " (" + df.format( 100.0 * _duplications_stats.median() / getIntNodesOfAnalyzedGeneTrees() )
+ + "%)" );
+ }
+ log( "Minimum duplications : " + ( int ) _duplications_stats.getMin() + " ("
+ + df.format( 100.0 * _duplications_stats.getMin() / getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+ log( "Maximum duplications : " + ( int ) _duplications_stats.getMax() + " ("
+ + df.format( 100.0 * _duplications_stats.getMax() / getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+ log( "Gene tree internal nodes : " + getIntNodesOfAnalyzedGeneTrees() );
+ log( "Gene tree external nodes : " + getExtNodesOfAnalyzedGeneTrees() );
}
private final void preLog( final Phylogeny[] gene_trees,
final String outgroup,
final int first,
final int last ) {
- log( "Number of gene tree (total) : " + gene_trees.length );
+ log( "Number of gene trees (total) : " + gene_trees.length );
log( "Algorithm : " + algorithm );
log( "Species tree external nodes (prior to stripping): " + species_tree.getNumberOfExternalNodes() );
log( "Species tree polytomies (prior to stripping) : "
System.err.println();
System.exit( -1 );
}
-
+
final public static void unexpectedFatalError( final Error e ) {
System.err.println();
System.err.println( "unexpected error: should not have occured! Please contact program author(s)." );