* node name. Thus, use of this class in SortedSets might lead
* to unexpected behavior.
*
* node name. Thus, use of this class in SortedSets might lead
* to unexpected behavior.
*
private PhylogenyNode( final String nhx,
final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction,
final boolean replace_underscores ) throws NHXFormatException, PhyloXmlDataFormatException {
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 );
+ 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!!).
setId( PhylogenyNode.getNodeCount() );
PhylogenyNode.increaseNodeCount();
setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!).
* Returns a new PhylogenyNode which has its data copied from this
* PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT
* copied (e.g. _link to _parent). Field "_link" IS copied.
* Returns a new PhylogenyNode which has its data copied from this
* PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT
* copied (e.g. _link to _parent). Field "_link" IS copied.
* Returns a new PhylogenyNode which has the same data as this
* PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT
* copied (e.g. _link to _parent). Field "_link" IS copied.
* Returns a new PhylogenyNode which has the same data as this
* PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT
* copied (e.g. _link to _parent). Field "_link" IS copied.
* @return List of references to external Nodes
*/
final public List<PhylogenyNode> getAllExternalDescendants() {
* @return List of references to external Nodes
*/
final public List<PhylogenyNode> getAllExternalDescendants() {
/**
* Returns a List containing references to all names of the external
* children of this PhylogenyNode.
/**
* Returns a List containing references to all names of the external
* children of this PhylogenyNode.
* @return List of references to names of external Nodes
*/
final public List<String> getAllExternalDescendantsNames() {
* @return List of references to names of external Nodes
*/
final public List<String> getAllExternalDescendantsNames() {
* @return the child node index of this node
* @throws UnsupportedOperationException
* if this node is a root node
* @return the child node index of this node
* @throws UnsupportedOperationException
* if this node is a root node
* @return the child node index of this node
* @throws UnsupportedOperationException
* if this node is a root node
* @return the child node index of this node
* @throws UnsupportedOperationException
* if this node is a root node
* Convenience method. Returns the first child node of this node.
* <p>
* [last modified May 18, 2005 by CMZ]
* Convenience method. Returns the first child node of this node.
* <p>
* [last modified May 18, 2005 by CMZ]
* Convenience method. Returns the last child node of this node.
* <p>
* [last modified May 18, 2005 by CMZ]
* Convenience method. Returns the last child node of this node.
* <p>
* [last modified May 18, 2005 by CMZ]
* @return true if this PhylogenyNode is external, false otherwise
*/
final public boolean isExternal() {
* @return true if this PhylogenyNode is external, false otherwise
*/
final public boolean isExternal() {
* @return true if this PhylogenyNode is external, false otherwise
*/
final public boolean isInternal() {
* @return true if this PhylogenyNode is external, false otherwise
*/
final public boolean isInternal() {
* Returns true if this node is the last child node of its _parent.
* <p>
* [last modified June 01, 2005 by CMZ]
* Returns true if this node is the last child node of its _parent.
* <p>
* [last modified June 01, 2005 by CMZ]
* @return true if this PhylogenyNode is the root, false otherwise
*/
final public boolean isRoot() {
* @return true if this PhylogenyNode is the root, false otherwise
*/
final public boolean isRoot() {
* child nodes. This does not allow null slots in the list of child nodes:
* If i is larger than the number of child nodes, n is just added to the
* list, not place at index i.
* child nodes. This does not allow null slots in the list of child nodes:
* If i is larger than the number of child nodes, n is just added to the
* list, not place at index i.
}
if ( getNumberOfDescendants() != 2 ) {
throw new RuntimeException( "attempt to swap descendants of node with " + getNumberOfDescendants()
}
if ( getNumberOfDescendants() != 2 ) {
throw new RuntimeException( "attempt to swap descendants of node with " + getNumberOfDescendants()
// ---------------------------------------------------------
// Writing of Nodes to Strings
// ---------------------------------------------------------
// ---------------------------------------------------------
// 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,
String data = "";
if ( ( svs == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES ) && !isExternal() ) {
if ( getBranchData().isHasConfidences()
&& ( getBranchData().getConfidence( 0 ).getValue() != Confidence.CONFIDENCE_DEFAULT_VALUE ) ) {
data = Confidence.FORMATTER.format( ForesterUtil
String data = "";
if ( ( svs == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES ) && !isExternal() ) {
if ( getBranchData().isHasConfidences()
&& ( getBranchData().getConfidence( 0 ).getValue() != Confidence.CONFIDENCE_DEFAULT_VALUE ) ) {
data = Confidence.FORMATTER.format( ForesterUtil
- .round( getBranchData().getConfidence( 0 ).getValue(),
- PhyloXmlUtil.ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT ) );
+ .round( getBranchData().getConfidence( 0 ).getValue(),
+ PhyloXmlUtil.ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT ) );
else if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getCommonName() ) ) {
data = getNodeData().getTaxonomy().getCommonName();
}
else if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getCommonName() ) ) {
data = getNodeData().getTaxonomy().getCommonName();
}
}
else if ( getNodeData().isHasSequence() ) {
if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getName() ) ) {
data = getNodeData().getSequence().getName();
}
}
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();
if ( write_distance_to_parent && ( getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
sb.append( ":" );
sb.append( getDistanceToParent() );
if ( write_distance_to_parent && ( getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
sb.append( ":" );
sb.append( getDistanceToParent() );
&& ( getBranchData().getConfidence( 0 ).getValue() != Confidence.CONFIDENCE_DEFAULT_VALUE ) ) {
sb.append( "[" );
sb.append( Confidence.FORMATTER.format( ForesterUtil
&& ( getBranchData().getConfidence( 0 ).getValue() != Confidence.CONFIDENCE_DEFAULT_VALUE ) ) {
sb.append( "[" );
sb.append( Confidence.FORMATTER.format( ForesterUtil
- .round( getBranchData().getConfidence( 0 ).getValue(),
- PhyloXmlUtil.ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT ) ) );
+ .round( getBranchData().getConfidence( 0 ).getValue(),
+ PhyloXmlUtil.ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT ) ) );
if ( getNodeData().isHasTaxonomy() ) {
if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getScientificName() ) ) {
sb.append( getNodeData().getTaxonomy().getScientificName() );
if ( getNodeData().isHasTaxonomy() ) {
if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getScientificName() ) ) {
sb.append( getNodeData().getTaxonomy().getScientificName() );
- }
- if ( ( sb.length() <= 1 ) && !ForesterUtil.isEmpty( getName() ) ) {
- sb.append( getName() );
- sb.append( " " );
+ if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getMolecularSequence() ) ) {
+ sb.append( getNodeData().getSequence().getMolecularSequence() );
+ sb.append( " " );
+ }
return new PhylogenyNode( nhx, NHXParser.TAXONOMY_EXTRACTION.NO, false );
}
public static PhylogenyNode createInstanceFromNhxString( final String nhx,
final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction )
return new PhylogenyNode( nhx, NHXParser.TAXONOMY_EXTRACTION.NO, false );
}
public static PhylogenyNode createInstanceFromNhxString( final String nhx,
final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction )
return new PhylogenyNode( nhx, taxonomy_extraction, false );
}
public static PhylogenyNode createInstanceFromNhxString( final String nhx,
final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction,
final boolean replace_underscores )
return new PhylogenyNode( nhx, taxonomy_extraction, false );
}
public static PhylogenyNode createInstanceFromNhxString( final String nhx,
final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction,
final boolean replace_underscores )
return new PhylogenyNode( nhx, taxonomy_extraction, replace_underscores );
}
/**
* Returns the total number of all Nodes created so far.
return new PhylogenyNode( nhx, taxonomy_extraction, replace_underscores );
}
/**
* Returns the total number of all Nodes created so far.