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 writeCladeSeparator() { setSawComma( true ); if ( ( getOutputFormt() == FORMAT.NHX ) || ( getOutputFormt() == FORMAT.NH ) ) { getBuffer().append( "," ); } }
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 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() ) ); } }
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 ); }