final static private String MAPPING_FILE_SEPARATOR_OPTION = "s";
final static private String MAPPING_FILE_SEPARATOR_DEFAULT = ": ";
final static private String PRG_NAME = "decorator";
- final static private String PRG_VERSION = "1.12";
- final static private String PRG_DATE = "2012.12.21";
+ final static private String PRG_VERSION = "1.13";
+ final static private String PRG_DATE = "2013.01.19";
public static void main( final String args[] ) {
ForesterUtil.printProgramInformation( decorator.PRG_NAME, decorator.PRG_VERSION, decorator.PRG_DATE );
for( final PhylogenyNodeIterator iter = phylogeny.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
String name = node.getName();
+ String tilde_annotation = null;
if ( trim_after_tilde && ( name.indexOf( '~' ) > 0 ) ) {
- name = name.substring( 0, name.indexOf( '~' ) );
+ final int ti = name.indexOf( '~' );
+ name = name.substring( 0, ti );
+ tilde_annotation = name.substring( ti );
}
if ( !ForesterUtil.isEmpty( name ) ) {
if ( intermediate_map != null ) {
node.getNodeData().getTaxonomy().setScientificName( new_value );
break;
case SEQUENCE_NAME:
+ if ( trim_after_tilde ) {
+ new_value = addTildeAnnotation( tilde_annotation, new_value );
+ }
if ( PhylogenyDecorator.VERBOSE ) {
System.out.println( name + ": " + new_value );
}
if ( PhylogenyDecorator.SANITIZE ) {
new_value = PhylogenyDecorator.sanitize( new_value );
}
+ if ( trim_after_tilde ) {
+ new_value = addTildeAnnotation( tilde_annotation, new_value );
+ }
if ( PhylogenyDecorator.VERBOSE ) {
System.out.println( new_value );
}
}
}
+ private final static String addTildeAnnotation( final String tilde_annotation, final String new_value ) {
+ if ( ForesterUtil.isEmpty( tilde_annotation ) ) {
+ return new_value;
+ }
+ return new_value + tilde_annotation;
+ }
+
public static void decorate( final Phylogeny[] phylogenies,
final Map<String, Map<String, String>> map,
final boolean picky,
private static String extractBracketedTaxCodes( final PhylogenyNode node, final String new_value ) {
final int i = new_value.lastIndexOf( "[" );
- final String tc = new_value.substring( i + 1, new_value.length() - 1 );
+ String tc = new_value.substring( i + 1, new_value.length() - 1 );
+ if ( tc.length() == 6 ) {
+ tc = tc.substring( 0, 5 );
+ }
ForesterUtil.ensurePresenceOfTaxonomy( node );
try {
node.getNodeData().getTaxonomy().setTaxonomyCode( tc );