throw new CloneNotSupportedException();
}
- public static void extractFastaInformation( final Phylogeny phy ) {
+ public static boolean extractFastaInformation( final Phylogeny phy ) {
+ boolean could_extract = false;
for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
if ( !ForesterUtil.isEmpty( node.getName() ) ) {
final Matcher name_m = FastaParser.FASTA_DESC_LINE.matcher( node.getName() );
if ( name_m.lookingAt() ) {
- System.out.println();
- // System.out.println( name_m.group( 1 ) );
- // System.out.println( name_m.group( 2 ) );
- // System.out.println( name_m.group( 3 ) );
- // System.out.println( name_m.group( 4 ) );
+ could_extract = true;
final String acc_source = name_m.group( 1 );
final String acc = name_m.group( 2 );
final String seq_name = name_m.group( 3 );
}
}
}
+ return could_extract;
}
public static DescriptiveStatistics calculatBranchLengthStatistics( final Phylogeny phy ) {
}
}
- final static public void transferInternalNodeNamesToConfidence( final Phylogeny phy, final String confidence_type ) {
+ final static public boolean isInternalNamesLookLikeConfidences( final Phylogeny phy ) {
final PhylogenyNodeIterator it = phy.iteratorPostorder();
while ( it.hasNext() ) {
final PhylogenyNode n = it.next();
- if ( !n.isExternal() && !n.getBranchData().isHasConfidences() ) {
+ if ( !n.isExternal() && !n.isRoot() ) {
if ( !ForesterUtil.isEmpty( n.getName() ) ) {
- double d = -1.0;
+ double value = -1;
try {
- d = Double.parseDouble( n.getName() );
+ value = Double.parseDouble( n.getName() );
}
- catch ( final Exception e ) {
- d = -1.0;
+ catch ( final NumberFormatException e ) {
+ return false;
}
- if ( d >= 0.0 ) {
- n.getBranchData().addConfidence( new Confidence( d, confidence_type ) );
- n.setName( "" );
+ if ( ( value < 0.0 ) || ( value > 100 ) ) {
+ return false;
}
}
}
}
+ return true;
+ }
+
+ final static public void transferInternalNodeNamesToConfidence( final Phylogeny phy, final String confidence_type ) {
+ final PhylogenyNodeIterator it = phy.iteratorPostorder();
+ while ( it.hasNext() ) {
+ transferInternalNodeNameToConfidence( confidence_type, it.next() );
+ }
+ }
+
+ private static void transferInternalNodeNameToConfidence( final String confidence_type, final PhylogenyNode n ) {
+ if ( !n.isExternal() && !n.getBranchData().isHasConfidences() ) {
+ if ( !ForesterUtil.isEmpty( n.getName() ) ) {
+ double d = -1.0;
+ try {
+ d = Double.parseDouble( n.getName() );
+ }
+ catch ( final Exception e ) {
+ d = -1.0;
+ }
+ if ( d >= 0.0 ) {
+ n.getBranchData().addConfidence( new Confidence( d, confidence_type ) );
+ n.setName( "" );
+ }
+ }
+ }
}
final static public void transferNodeNameToField( final Phylogeny phy,