case NHX:
return getMainPanel().getCurrentPhylogeny().toNewHampshireX();
case NEXUS:
- return getMainPanel().getCurrentPhylogeny().toNexus();
+ return getMainPanel().getCurrentPhylogeny().toNexus( false );
case PHYLOXML:
return getMainPanel().getCurrentPhylogeny().toPhyloXML( -1 );
default:
|| ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
return;
}
- _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNexus() );
+ _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNexus( false ) );
}
void viewAsNH() {
|| ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
return;
}
- _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNewHampshire( false ) );
+ _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNewHampshire( false, false ) );
}
void viewAsNHX() {
public final static boolean __SNAPSHOT_RELEASE = true; // TODO remove me
public final static boolean __SYNTH_LF = false; // TODO remove me
public final static String PRG_NAME = "Archaeopteryx";
- final static String VERSION = "0.965 beta T2P";
- final static String PRG_DATE = "2011.12.14";
+ final static String VERSION = "0.966 beta T2P";
+ final static String PRG_DATE = "2011.12.15";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = { "Verdana", "Tahoma",
"Arial", "Helvetica", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" };
void viewAsNexus() {
removeTextFrame();
if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
- || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
+ || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 20000 ) ) {
return;
}
- _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNexus() );
+ _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNexus( getOptions()
+ .isUseBracketsForConfInNhExport() ) );
}
void viewAsNH() {
removeTextFrame();
if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty()
- || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
+ || ( _mainpanel.getCurrentPhylogeny().getNumberOfExternalNodes() > 20000 ) ) {
return;
}
- _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny().toNewHampshire( false ) );
+ _textframe = TextFrame.instantiate( _mainpanel.getCurrentPhylogeny()
+ .toNewHampshire( false, getOptions().isUseBracketsForConfInNhExport() ) );
}
void viewAsNHX() {
private boolean writeAsNexus( final Phylogeny t, boolean exception, final File file ) {
try {
final PhylogenyWriter writer = new PhylogenyWriter();
- writer.toNexus( file, t );
+ writer.toNexus( file, t, getOptions().isUseBracketsForConfInNhExport() );
}
catch ( final Exception e ) {
exception = true;
&& ( ( c != '[' ) && ( c != '.' ) && ( ( c < 48 ) || ( c > 57 ) ) ) ) {
saw_colon = false;
}
- }
- if ( in_open_bracket && ( c == ']' ) ) {
- in_open_bracket = false;
+ if ( in_open_bracket && ( c == ']' ) ) {
+ in_open_bracket = false;
+ }
}
// \n\t is always ignored,
// as is " (34) and ' (39) (space is 32):
writeToFile( sb, out_file );
}
- public void toNexus( final File out_file, final List<Phylogeny> trees ) throws IOException {
- final Writer writer = new BufferedWriter( new PrintWriter( out_file ) );
- writeNexusStart( writer );
- writeNexusTaxaBlock( writer, trees.get( 0 ) );
- writeNexusTreesBlock( writer, trees );
- writer.flush();
- writer.close();
- }
-
- public void toNexus( final File out_file, final Phylogeny tree ) throws IOException {
+ public void toNexus( final File out_file, final Phylogeny tree, final boolean write_conf_values_in_branckets_in_nh )
+ throws IOException {
final Writer writer = new BufferedWriter( new PrintWriter( out_file ) );
final List<Phylogeny> trees = new ArrayList<Phylogeny>( 1 );
trees.add( tree );
writeNexusStart( writer );
writeNexusTaxaBlock( writer, tree );
- writeNexusTreesBlock( writer, trees );
+ writeNexusTreesBlock( writer, trees, write_conf_values_in_branckets_in_nh );
writer.flush();
writer.close();
}
- public StringBuffer toNexus( final Phylogeny tree ) throws IOException {
+ public StringBuffer toNexus( final Phylogeny tree, final boolean write_conf_values_in_branckets_in_nh )
+ throws IOException {
final StringWriter string_writer = new StringWriter();
final Writer writer = new BufferedWriter( string_writer );
final List<Phylogeny> trees = new ArrayList<Phylogeny>( 1 );
trees.add( tree );
writeNexusStart( writer );
writeNexusTaxaBlock( writer, tree );
- writeNexusTreesBlock( writer, trees );
+ writeNexusTreesBlock( writer, trees, write_conf_values_in_branckets_in_nh );
writer.flush();
writer.close();
return string_writer.getBuffer();
writer.write( ForesterUtil.LINE_SEPARATOR );
}
- public static void writeNexusTreesBlock( final Writer writer, final List<Phylogeny> trees ) throws IOException {
+ public static void writeNexusTreesBlock( final Writer writer,
+ final List<Phylogeny> trees,
+ final boolean write_conf_values_in_branckets_in_nh ) throws IOException {
writer.write( NexusConstants.BEGIN_TREES );
writer.write( ForesterUtil.LINE_SEPARATOR );
int i = 1;
else {
writer.write( "[&U]" );
}
- writer.write( phylogeny.toNewHampshire( false ) );
+ writer.write( phylogeny.toNewHampshire( false, write_conf_values_in_branckets_in_nh ) );
writer.write( ForesterUtil.LINE_SEPARATOR );
i++;
}
} // swapChildren( PhylogenyNode )
public String toNewHampshire() {
- return toNewHampshire( false );
+ return toNewHampshire( false, false );
}
- public String toNewHampshire( final boolean simple_nh ) {
+ public String toNewHampshire( final boolean simple_nh, final boolean write_conf_values_in_branckets_in_nh ) {
try {
- return new PhylogenyWriter().toNewHampshire( this, simple_nh, true ).toString();
+ return new PhylogenyWriter().toNewHampshire( this, simple_nh, true, write_conf_values_in_branckets_in_nh )
+ .toString();
}
catch ( final IOException e ) {
throw new Error( "this should not have happend: " + e.getMessage() );
}
}
- public String toNexus() {
+ public String toNexus( final boolean write_conf_values_in_branckets_in_nh ) {
try {
- return new PhylogenyWriter().toNexus( this ).toString();
+ return new PhylogenyWriter().toNexus( this, write_conf_values_in_branckets_in_nh ).toString();
}
catch ( final IOException e ) {
throw new Error( "this should not have happend: " + e.getMessage() );
sb.append( ":" );
sb.append( getDistanceToParent() );
}
- if ( write_support_values_in_brackets && !isExternal()
+ if ( write_support_values_in_brackets && !isExternal() && getBranchData().isHasConfidences()
&& ( getBranchData().getConfidence( 0 ).getValue() != Confidence.CONFIDENCE_DEFAULT_VALUE ) ) {
sb.append( "[" );
sb.append( getBranchData().getConfidence( 0 ).getValue() );
w.write( ForesterUtil.LINE_SEPARATOR );
my_matrix.writeNexusTaxaBlock( w );
my_matrix.writeNexusBinaryChractersBlock( w );
- PhylogenyWriter.writeNexusTreesBlock( w, phylogenies );
+ PhylogenyWriter.writeNexusTreesBlock( w, phylogenies, false );
w.flush();
w.close();
ForesterUtil.programMessage( surfacing.PRG_NAME, "Wrote Nexus file: \"" + outfile_name + "\"" );
if ( ( p46.length != 1 ) || !p46[ 0 ].isEmpty() ) {
return false;
}
+ final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
+ if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
+ return false;
+ }
+ final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
+ if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
+ return false;
+ }
+ final Phylogeny p49 = factory
+ .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
+ new NHXParser() )[ 0 ];
+ if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
+ return false;
+ }
+ final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
+ if ( p50.getNode( "A" ) == null ) {
+ return false;
+ }
+ if ( !p50.toNewHampshire( false, true ).equals( "((A,B)ab:2.0[88.0],C);" ) ) {
+ return false;
+ }
+ if ( !p50.toNewHampshire( false, false ).equals( "((A,B)ab:2.0,C);" ) ) {
+ return false;
+ }
+ final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
+ if ( p51.getNode( "A(A" ) == null ) {
+ return false;
+ }
+ final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
+ if ( p52.getNode( "A(A" ) == null ) {
+ return false;
+ }
+ final Phylogeny p53 = factory
+ .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
+ new NHXParser() )[ 0 ];
+ if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
+ return false;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );