X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fio%2Fwriters%2FPhylogenyWriter.java;h=be4c24e428db9656fbf38d271006a819315bedcd;hb=89d7b6ec1ddc3a3c1e953cf389c24ba7aae7fbfe;hp=630f05717f4a976428a94078a7ea0387d474ca09;hpb=48f7a89be9d34f1930a1f863e608235cc27184c5;p=jalview.git diff --git a/forester/java/src/org/forester/io/writers/PhylogenyWriter.java b/forester/java/src/org/forester/io/writers/PhylogenyWriter.java index 630f057..be4c24e 100644 --- a/forester/java/src/org/forester/io/writers/PhylogenyWriter.java +++ b/forester/java/src/org/forester/io/writers/PhylogenyWriter.java @@ -5,7 +5,7 @@ // Copyright (C) 2008-2009 Christian M. Zmasek // Copyright (C) 2008-2009 Burnham Institute for Medical Research // All rights reserved -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -15,7 +15,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -73,6 +73,7 @@ public final class PhylogenyWriter { private Stack _stack; private boolean _simple_nh; private boolean _nh_write_distance_to_parent; + private boolean _write_conf_values_in_branckets_in_nh; private boolean _indent_phyloxml; private int _node_level; private int _phyloxml_level; @@ -80,6 +81,7 @@ public final class PhylogenyWriter { public PhylogenyWriter() { setIndentPhyloxml( INDENT_PHYLOXML_DEAFULT ); + setWriteConfidenceValuesInBracketsInNH( false ); } private void appendPhylogenyLevelPhyloXml( final Writer writer, final Phylogeny tree ) throws IOException { @@ -336,6 +338,17 @@ public final class PhylogenyWriter { public StringBuffer toNewHampshire( final Phylogeny tree, final boolean simple_nh, + final boolean nh_write_distance_to_parent, + final boolean write_conf_values_in_branckets_in_nh ) throws IOException { + setOutputFormt( FORMAT.NH ); + setWriteConfidenceValuesInBracketsInNH( write_conf_values_in_branckets_in_nh ); + setSimpleNH( simple_nh ); + setWriteDistanceToParentInNH( nh_write_distance_to_parent ); + return getOutput( tree ); + } + + public StringBuffer toNewHampshire( final Phylogeny tree, + final boolean simple_nh, final boolean nh_write_distance_to_parent ) throws IOException { setOutputFormt( FORMAT.NH ); setSimpleNH( simple_nh ); @@ -350,6 +363,14 @@ public final class PhylogenyWriter { writeToFile( toNewHampshire( tree, simple_nh, write_distance_to_parent ), out_file ); } + public void toNewHampshire( final Phylogeny tree, + final boolean simple_nh, + final boolean write_distance_to_parent, + final boolean use_brackets_for_confidence, + final File out_file ) throws IOException { + writeToFile( toNewHampshire( tree, simple_nh, write_distance_to_parent, use_brackets_for_confidence ), out_file ); + } + public void toNewHampshire( final Phylogeny[] trees, final boolean simple_nh, final boolean write_distance_to_parent, @@ -556,10 +577,20 @@ public final class PhylogenyWriter { getBuffer().append( node.toNewHampshireX() ); } else if ( getOutputFormt() == FORMAT.NH ) { - getBuffer().append( node.toNewHampshire( isSimpleNH(), isWriteDistanceToParentInNH() ) ); + getBuffer().append( node.toNewHampshire( isSimpleNH(), + isWriteDistanceToParentInNH(), + isWriteConfidenceValuesInBracketsInNH() ) ); } } + private boolean isWriteConfidenceValuesInBracketsInNH() { + return _write_conf_values_in_branckets_in_nh; + } + + private void setWriteConfidenceValuesInBracketsInNH( final boolean write_conf_values_in_branckets_in_nh ) { + _write_conf_values_in_branckets_in_nh = write_conf_values_in_branckets_in_nh; + } + private void writeOpenClade( final PhylogenyNode node ) throws IOException { if ( !isSawComma() ) { if ( !node.isRoot() && node.isFirstChildNode() ) {