private void writeCladeSeparator() { setSawComma( true ); if ( ( getOutputFormt() == FORMAT.NHX ) || ( getOutputFormt() == FORMAT.NH ) ) { getBuffer().append( "," ); } }
private void writeToFile( final StringBuffer sb, final File out_file ) throws IOException { if ( out_file.exists() ) { throw new IOException( "attempt to overwrite existing file \"" + out_file.getAbsolutePath() + "\"" ); } final PrintWriter out = new PrintWriter( new FileWriter( out_file ), true ); if ( getOutputFormt() == FORMAT.PHYLO_XML ) { out.print( PHYLO_XML_VERSION_ENCODING_LINE ); out.print( ForesterUtil.LINE_SEPARATOR ); out.print( PHYLO_XML_NAMESPACE_LINE ); out.print( ForesterUtil.LINE_SEPARATOR ); } out.print( sb ); if ( getOutputFormt() == FORMAT.PHYLO_XML ) { out.print( ForesterUtil.LINE_SEPARATOR ); out.print( PHYLO_XML_END ); } out.flush(); out.close(); }
private void writeCloseClade() throws IOException { decreaseNodeLevel(); if ( getOutputFormt() == FORMAT.PHYLO_XML ) { getWriter().write( ForesterUtil.LINE_SEPARATOR ); if ( isIndentPhyloxml() ) { getWriter().write( createIndentation().toString() ); } PhylogenyDataUtil.appendClose( getWriter(), PhyloXmlMapping.CLADE ); } else if ( ( getOutputFormt() == FORMAT.NHX ) || ( getOutputFormt() == FORMAT.NH ) ) { getBuffer().append( ")" ); } }
private StringBuffer getOutput( final Phylogeny tree ) throws IOException { if ( getOutputFormt() == FORMAT.PHYLO_XML ) { throw new RuntimeException( "method inappropriately called" ); } if ( tree != null ) { reset( tree ); while ( isHasNext() ) { next(); } if ( getOutputFormt() == FORMAT.NH ) { getBuffer().append( ';' ); } return getBuffer(); } else { return new StringBuffer( 0 ); } }
private void writeOpenClade( final PhylogenyNode node ) throws IOException { if ( !isSawComma() ) { if ( !node.isRoot() && node.isFirstChildNode() ) { increaseNodeLevel(); } if ( getOutputFormt() == FORMAT.PHYLO_XML ) { getWriter().write( ForesterUtil.LINE_SEPARATOR ); if ( isIndentPhyloxml() ) { getWriter().write( createIndentation().toString() ); } if ( node.isCollapse() ) { PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE, PhyloXmlMapping.NODE_COLLAPSE, "true" ); } else { PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE ); } } else if ( ( getOutputFormt() == FORMAT.NHX ) || ( getOutputFormt() == FORMAT.NH ) ) { getBuffer().append( "(" ); } } setSawComma( false ); }
private void writeNode( final PhylogenyNode node, final StringBuffer indentation ) throws IOException { if ( getOutputFormt() == FORMAT.PHYLO_XML ) { if ( node.isExternal() ) { getWriter().write( ForesterUtil.LINE_SEPARATOR ); if ( indentation != null ) { getWriter().write( indentation.toString() ); } PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE ); } PhyloXmlNodeWriter.toPhyloXml( getWriter(), node, getPhyloXmlLevel(), indentation != null ? indentation.toString() : "" ); if ( node.isExternal() ) { getWriter().write( ForesterUtil.LINE_SEPARATOR ); if ( indentation != null ) { getWriter().write( indentation.toString() ); } PhylogenyDataUtil.appendClose( getWriter(), PhyloXmlMapping.CLADE ); } } else if ( getOutputFormt() == FORMAT.NHX ) { getBuffer().append( node.toNewHampshireX() ); } else if ( getOutputFormt() == FORMAT.NH ) { getBuffer().append( node.toNewHampshire( isWriteDistanceToParentInNH(), getNhConversionSupportStyle() ) ); } }
if ( phase > node.getNumberOfDescendants() ) { setHasNext( node != getRoot() ); if ( ( getOutputFormt() != FORMAT.PHYLO_XML ) || node.isExternal() ) { if ( !node.isRoot() && node.isFirstChildNode() ) { increaseNodeLevel(); if ( getOutputFormt() == FORMAT.PHYLO_XML ) { writeNode( node, createIndentation() ); getStack().push( new PostOrderStackObject( node.getChildNode( phase - 1 ), 1 ) ); writeOpenClade( node ); if ( getOutputFormt() == FORMAT.PHYLO_XML ) { if ( phase == 1 ) { writeNode( node, createIndentation() );
private void writeOutput( final Writer writer, final Phylogeny tree ) throws IOException { if ( getOutputFormt() != FORMAT.PHYLO_XML ) { throw new RuntimeException( "method inappropriately called" );