- final List<UniProtTaxonomy> up_taxonomies = getTaxonomiesFromScientificName( sn );
- if ( ( up_taxonomies != null ) && ( up_taxonomies.size() == 1 ) ) {
- up_tax = up_taxonomies.get( 0 );
- getSnTaxCacheMap().put( sn, up_tax );
+ final List<UniProtTaxonomy> up_taxonomies = getTaxonomiesFromScientificName( lineage
+ .get( lineage.size() - 1 ) );
+ if ( ( up_taxonomies != null ) && ( up_taxonomies.size() > 0 ) ) {
+ for( final UniProtTaxonomy up_taxonomy : up_taxonomies ) {
+ boolean match = true;
+ I: for( int i = 0; i < lineage.size(); ++i ) {
+ if ( !lineage.get( i ).equalsIgnoreCase( up_taxonomy.getLineage().get( i ) ) ) {
+ match = false;
+ break I;
+ }
+ }
+ if ( match ) {
+ if ( up_tax != null ) {
+ throw new AncestralTaxonomyInferenceException( "lineage \""
+ + ForesterUtil.stringListToString( lineage, " > " ) + "\" is not unique" );
+ }
+ up_tax = up_taxonomy;
+ }
+ }
+ if ( up_tax == null ) {
+ throw new AncestralTaxonomyInferenceException( "lineage \""
+ + ForesterUtil.stringListToString( lineage, " > " ) + "\" not found" );
+ }
+ getLineageTaxCacheMap().put( lineage_str, up_tax );
+ if ( !ForesterUtil.isEmpty( up_tax.getScientificName() ) ) {
+ getSnTaxCacheMap().put( up_tax.getScientificName(), up_tax );
+ }