X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Ftools%2FPhylogenyDecorator.java;h=57ef9f04a7acb3a10f76eb8abaff32ba904150b7;hb=d4d61f9d2969283e821f650d031c169899fb3870;hp=9d865e1ef6630955b9b1f286aea650b7c8b389ff;hpb=01d681ced8f186561a3dd76715d950bd0eabd82d;p=jalview.git diff --git a/forester/java/src/org/forester/tools/PhylogenyDecorator.java b/forester/java/src/org/forester/tools/PhylogenyDecorator.java index 9d865e1..57ef9f0 100644 --- a/forester/java/src/org/forester/tools/PhylogenyDecorator.java +++ b/forester/java/src/org/forester/tools/PhylogenyDecorator.java @@ -251,6 +251,9 @@ public final class PhylogenyDecorator { if ( ParserUtils.TAXOMONY_CODE_PATTERN_4.matcher( new_value ).find() ) { new_value = extractBracketedTaxCodes( node, new_value ); } + else if ( ParserUtils.TAXOMONY_CODE_PATTERN_6.matcher( new_value ).find() ) { + new_value = extractBracketedTaxCodes6( node, new_value ); + } else if ( picky ) { throw new IllegalArgumentException( " could not get taxonomy from \"" + new_value + "\"" ); @@ -264,7 +267,7 @@ public final class PhylogenyDecorator { if ( !node.getNodeData().isHasSequence() ) { node.getNodeData().setSequence( new Sequence() ); } - final Annotation annotation = new Annotation( "?" ); + final Annotation annotation = new Annotation(); annotation.setDesc( new_value ); node.getNodeData().getSequence().addAnnotation( annotation ); break; @@ -479,6 +482,30 @@ public final class PhylogenyDecorator { return new_value; //TODO //FIXME } + private static String extractBracketedTaxCodes6( final PhylogenyNode node, final String new_value ) { + final Matcher m = ParserUtils.TAXOMONY_CODE_PATTERN_6.matcher( new_value ); + String tc = "?"; + if ( m.find() ) { + tc = m.group( 1 ); + } + ForesterUtil.ensurePresenceOfTaxonomy( node ); + try { + if ( tc.length() == 6 ) { + final String t = tc.substring( 0, 5 ); + System.out.println( "WARNING: taxonomy code " + tc + " -> " + t ); + tc = t; + } + else { + throw new IllegalArgumentException(); + } + node.getNodeData().getTaxonomy().setTaxonomyCode( tc ); + } + catch ( final PhyloXmlDataFormatException e ) { + throw new IllegalArgumentException( "illegal format for taxonomy code: " + tc ); + } + return new_value; //TODO //FIXME + } + private static String extractIntermediate( final Map intermediate_map, final String name ) { String new_name = null; if ( PhylogenyDecorator.VERBOSE ) {