From: cmzmasek Date: Sun, 20 Jan 2013 05:24:13 +0000 (+0000) Subject: keep tilde annotation X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=10aba63f0733a9f81c39a68d09538fd79e4b6f13;p=jalview.git keep tilde annotation --- diff --git a/forester/java/src/org/forester/application/decorator.java b/forester/java/src/org/forester/application/decorator.java index ba79613..d0197aa 100644 --- a/forester/java/src/org/forester/application/decorator.java +++ b/forester/java/src/org/forester/application/decorator.java @@ -71,8 +71,8 @@ public final class decorator { 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 ); diff --git a/forester/java/src/org/forester/tools/PhylogenyDecorator.java b/forester/java/src/org/forester/tools/PhylogenyDecorator.java index f4f6c1a..1502146 100644 --- a/forester/java/src/org/forester/tools/PhylogenyDecorator.java +++ b/forester/java/src/org/forester/tools/PhylogenyDecorator.java @@ -218,8 +218,11 @@ public final class PhylogenyDecorator { 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 ) { @@ -279,6 +282,9 @@ public final class PhylogenyDecorator { 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 ); } @@ -312,6 +318,9 @@ public final class PhylogenyDecorator { 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 ); } @@ -329,6 +338,13 @@ public final class PhylogenyDecorator { } } + 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> map, final boolean picky, @@ -438,7 +454,10 @@ public final class PhylogenyDecorator { 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 );