while ( qnode_pp.getNumberOfDescendants() == 1 ) {
qnode_pp = qnode_pp.getParent();
}
- final List<String> qnode_ext_nodes_names = new ArrayList<>();
+ final List<String> qnode_ext_nodes_names = new ArrayList<String>();
for( final PhylogenyNode qnode_ext_node : qnode_pp.getAllExternalDescendants() ) {
final String name = qnode_ext_node.getName();
final Matcher m = query.matcher( name );
final String separator,
final Pattern query ) {
final int child_index = child.getChildNodeIndex();
- final List<String> ext_nodes_names = new ArrayList<>();
+ final List<String> ext_nodes_names = new ArrayList<String>();
final List<PhylogenyNode> descs = parent.getDescendants();
for( int i = 0; i < descs.size(); ++i ) {
if ( i != child_index ) {
}
}
- public final static void performExtraProcessing1( final Pattern pattern,
+ public final static void performExtraProcessing1( final Pattern query_pattern,
final Phylogeny p,
final String extra_sep,
final boolean keep,
if ( ForesterUtil.isEmpty( name ) ) {
throw new UserException( "external node with empty name found" );
}
- final Matcher m = pattern.matcher( name );
- if ( !m.find() ) {
+ if ( !query_pattern.matcher( name ).find() ) {
final StringBuilder sb = new StringBuilder();
final int last_index = name.lastIndexOf( extra_sep );
if ( last_index >= 0 ) {
final String annotation = name.substring( last_index + 1 ).trim();
if ( ForesterUtil.isEmptyTrimmed( annotation ) ) {
- throw new UserException( "illegal format: " + name );
+ throw new UserException( "llegally formatted annotation: " + name );
}
if ( keep ) {
final String extra = name.substring( 0, last_index ).trim();
System.out.println();
}
}
-
- public final static void performSpecialProcessing1( final Pattern pattern,
+
+ public final static void performSpecialProcessing1( final Pattern query_pattern,
final Phylogeny p,
final String annotation_sep,
final Pattern special_pattern,
if ( ForesterUtil.isEmpty( name ) ) {
throw new UserException( "external node with empty name found" );
}
- final Matcher m = pattern.matcher( name );
- if ( !m.find() ) {
+ if ( !query_pattern.matcher( name ).find() ) {
final Matcher special_m = special_pattern.matcher( name );
if ( special_m.matches() ) {
final int c = special_m.groupCount();
- if ( c < 2 ) {
- throw new UserException( "illegal special pattern: " + special_pattern );
+ if ( c < 1 ) {
+ throw new UserException( "illegal special pattern: " + special_pattern
+ + " (need at least one capturing group)" );
}
final StringBuilder sb = new StringBuilder();
- for( int i = 1; i < c; ++i ) {
- if ( c > 1 ) {
- sb.append( annotation_sep );
+ for( int i = 1; i <= c; ++i ) {
+ final String g = special_m.group( i );
+ if ( !ForesterUtil.isEmpty( g ) ) {
+ if ( i > 1 ) {
+ sb.append( annotation_sep );
+ }
+ sb.append( special_m.group( i ) );
}
- sb.append( special_m.group( i ) );
}
node.setName( sb.toString() );
if ( verbose ) {
}
}
else {
- throw new UserException( "illegal format for special processing: " + name + " (expected pattern: "
- + special_pattern + ")" );
+ throw new UserException( "illegally formatted annotation for special processing: " + name
+ + " (expected pattern: " + special_pattern + ")" );
}
}
}