// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.io.writers;
import org.forester.io.parsers.phyloxml.PhyloXmlMapping;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
-import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE;
+import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
import org.forester.phylogeny.data.PhylogenyDataUtil;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.phylogeny.iterators.PostOrderStackObject;
writer.close();
}
+ public void toPhyloXML( final Phylogeny phy, final int phyloxml_level, final File out_file ) throws IOException {
+ final Writer writer = new BufferedWriter( new PrintWriter( out_file ) );
+ toPhyloXML( writer, phy, phyloxml_level );
+ writer.flush();
+ writer.close();
+ }
+
public void toPhyloXML( final Writer writer,
final List<Phylogeny> trees,
final int phyloxml_level,
}
PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE );
}
- if ( indentation != null ) {
- PhyloXmlNodeWriter.toPhyloXml( getWriter(), node, getPhyloXmlLevel(), indentation.toString() );
- }
- else {
- PhyloXmlNodeWriter.toPhyloXml( getWriter(), node, getPhyloXmlLevel(), "" );
- }
+ PhyloXmlNodeWriter.toPhyloXml( getWriter(),
+ node,
+ getPhyloXmlLevel(),
+ indentation != null ? indentation.toString() : "" );
if ( node.isExternal() ) {
getWriter().write( ForesterUtil.LINE_SEPARATOR );
if ( indentation != null ) {
if ( isIndentPhyloxml() ) {
getWriter().write( createIndentation().toString() );
}
- PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE );
+ 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( "(" );
}
if ( tree != null ) {
reset( writer, tree );
- boolean rerootable = true;
String unit = "";
String type = "";
- String rooted = "false";
- if ( tree.isRooted() ) {
- rooted = "true";
- }
- if ( !tree.isRerootable() ) {
- rerootable = false;
- }
if ( !ForesterUtil.isEmpty( tree.getDistanceUnit() ) ) {
unit = tree.getDistanceUnit();
}
if ( !ForesterUtil.isEmpty( tree.getType() ) ) {
type = tree.getType();
}
- if ( rerootable ) {
- PhylogenyDataUtil.appendOpen( writer,
- PhyloXmlMapping.PHYLOGENY,
- PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR,
- rooted,
- PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR,
- unit,
- PhyloXmlMapping.PHYLOGENY_TYPE_ATTR,
- type );
- }
- else {
- PhylogenyDataUtil.appendOpen( writer,
- PhyloXmlMapping.PHYLOGENY,
- PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR,
- rooted,
- PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR,
- unit,
- PhyloXmlMapping.PHYLOGENY_TYPE_ATTR,
- type,
- PhyloXmlMapping.PHYLOGENY_IS_REROOTABLE_ATTR,
- "false" );
- }
+ PhylogenyDataUtil.appendOpen( writer,
+ PhyloXmlMapping.PHYLOGENY,
+ PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR,
+ tree.isRooted() + "",
+ PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR,
+ unit,
+ PhyloXmlMapping.PHYLOGENY_TYPE_ATTR,
+ type,
+ PhyloXmlMapping.PHYLOGENY_IS_REROOTABLE_ATTR,
+ tree.isRerootable() + "" );
appendPhylogenyLevelPhyloXml( writer, tree );
while ( isHasNext() ) {
next();