private PhylogenyNode( final String nhx,
final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction,
final boolean replace_underscores ) throws NHXFormatException, PhyloXmlDataFormatException {
- NHXParser.parseNHX( nhx, this, taxonomy_extraction, replace_underscores, false );
+ NHXParser.parseNHX( nhx, this, taxonomy_extraction, replace_underscores, false, false );
setId( PhylogenyNode.getNodeCount() );
PhylogenyNode.increaseNodeCount();
setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!).
// ---------------------------------------------------------
// Writing of Nodes to Strings
// ---------------------------------------------------------
- final public String toNewHampshire( final boolean simple_nh,
- final boolean write_distance_to_parent,
+ final public String toNewHampshire( final boolean write_distance_to_parent,
final NH_CONVERSION_SUPPORT_VALUE_STYLE svs ) {
- final StringBuilder sb = new StringBuilder();
String data = "";
if ( ( svs == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES ) && !isExternal() ) {
if ( getBranchData().isHasConfidences()
else if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getCommonName() ) ) {
data = getNodeData().getTaxonomy().getCommonName();
}
- else if ( getNodeData().getTaxonomy().getTaxonomyCode() != null ) {
- data = getNodeData().getTaxonomy().getTaxonomyCode();
- }
}
else if ( getNodeData().isHasSequence() ) {
if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getName() ) ) {
data = getNodeData().getSequence().getName();
}
- }
- if ( data.length() > 0 ) {
- data = ForesterUtil.replaceIllegalNhCharacters( data );
- if ( simple_nh && ( data.length() > 10 ) ) {
- data = data.substring( 0, 11 );
- }
- if ( ForesterUtil.isContainsParanthesesableNhCharacter( data ) ) {
- sb.append( '\'' );
- sb.append( data );
- sb.append( '\'' );
+ else if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getSymbol() ) ) {
+ data = getNodeData().getSequence().getSymbol();
}
- else {
- sb.append( data );
+ else if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getGeneName() ) ) {
+ data = getNodeData().getSequence().getGeneName();
}
}
+ final StringBuilder sb = ForesterUtil.santitizeStringForNH( data );
if ( write_distance_to_parent && ( getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
sb.append( ":" );
sb.append( getDistanceToParent() );
* representation.
*/
final public String toNewHampshireX() {
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
final StringBuffer s_nhx = new StringBuffer();
if ( !ForesterUtil.isEmpty( getName() ) ) {
- final String name = ForesterUtil.replaceIllegalNhCharacters( getName() );
- if ( ForesterUtil.isContainsParanthesesableNhCharacter( name ) ) {
- sb.append( '\'' );
- sb.append( name );
- sb.append( '\'' );
- }
- else {
- sb.append( name );
- }
+ sb.append( ForesterUtil.santitizeStringForNH( getName() ) );
}
if ( getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
sb.append( ":" );