+ if ( !ForesterUtil.isEmpty( str ) ) {
+ if ( taxonomy_extraction == TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY ) {
+ final Matcher m = TAXOMONY_CODE_PATTERN_PF.matcher( str );
+ if ( m.matches() ) {
+ return m.group( 1 );
+ }
+ }
+ else {
+ final Matcher m1 = TAXOMONY_CODE_PATTERN_1.matcher( str );
+ if ( m1.matches() ) {
+ return m1.group();
+ }
+ final Matcher m2 = TAXOMONY_CODE_PATTERN_2.matcher( str );
+ if ( m2.matches() ) {
+ return m2.group( 1 );
+ }
+ }
+ }
+ }
+ }
+ else if ( taxonomy_extraction == TAXONOMY_EXTRACTION.YES ) {
+ final Matcher m1 = TAXOMONY_CODE_PATTERN_1.matcher( name );
+ if ( m1.matches() ) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ public final static String extractScientificNameFromNodeName( final String name ) {
+ final Matcher m1 = TAXOMONY_SN_PATTERN.matcher( name );
+ if ( m1.matches() ) {
+ return m1.group( 1 ).replace( '_', ' ' );
+ }
+ return null;
+ }
+
+ public final static String extractTaxonomyDataFromNodeName( final PhylogenyNode node,
+ final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction )
+ throws PhyloXmlDataFormatException {
+ final String id = extractUniprotTaxonomyIdFromNodeName( node.getName(), taxonomy_extraction );
+ if ( !ForesterUtil.isEmpty( id ) ) {
+ if ( !node.getNodeData().isHasTaxonomy() ) {
+ node.getNodeData().setTaxonomy( new Taxonomy() );
+ }
+ if ( ( node.getNodeData().getTaxonomy().getIdentifier() == null )
+ || ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getIdentifier().getValue() ) ) {
+ node.getNodeData().getTaxonomy().setIdentifier( new Identifier( id, "uniprot" ) );
+ return id;
+ }
+ }
+ else {
+ final String code = extractTaxonomyCodeFromNodeName( node.getName(), taxonomy_extraction );
+ if ( !ForesterUtil.isEmpty( code ) ) {
+ if ( !node.getNodeData().isHasTaxonomy() ) {
+ node.getNodeData().setTaxonomy( new Taxonomy() );