X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fanalysis%2FAncestralTaxonomyInference.java;h=94453ff5834713b749ea89852981a135a932e406;hb=2320da44a171273ec44c0adcaf991687a4780b6e;hp=9f18f8185d1bccc9c258a24724dae109e62076df;hpb=656be28debec520e0e35a8b311114398a40ea366;p=jalview.git diff --git a/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java b/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java index 9f18f81..94453ff 100644 --- a/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java +++ b/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java @@ -40,7 +40,7 @@ import org.forester.ws.seqdb.UniProtTaxonomy; public final class AncestralTaxonomyInference { public static void inferTaxonomyFromDescendents( final Phylogeny phy ) throws IOException, - AncestralTaxonomyInferenceException { + AncestralTaxonomyInferenceException { TaxonomyDataManager.clearCachesIfTooLarge(); for( final PhylogenyNodeIterator iter = phy.iteratorPostorder(); iter.hasNext(); ) { final PhylogenyNode node = iter.next(); @@ -51,7 +51,7 @@ public final class AncestralTaxonomyInference { } private static void inferTaxonomyFromDescendents( final PhylogenyNode n ) throws IOException, - AncestralTaxonomyInferenceException { + AncestralTaxonomyInferenceException { if ( n.isExternal() ) { throw new IllegalArgumentException( "attempt to infer taxonomy from descendants of external node" ); } @@ -67,7 +67,7 @@ public final class AncestralTaxonomyInference { || !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getTaxonomyCode() ) || !ForesterUtil .isEmpty( desc.getNodeData().getTaxonomy().getCommonName() ) ) ) { final UniProtTaxonomy up_tax = TaxonomyDataManager.obtainUniProtTaxonomy( desc.getNodeData() - .getTaxonomy(), null, null ); + .getTaxonomy(), null, null ); if ( ( up_tax == null ) && ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getLineage() ) ) { String desc_str = ""; if ( !ForesterUtil.isEmpty( desc.getName() ) ) { @@ -78,9 +78,9 @@ public final class AncestralTaxonomyInference { } System.out.println( desc.getNodeData().getTaxonomy().toString() ); System.out.println( ForesterUtil.stringListToString( desc.getNodeData().getTaxonomy().getLineage(), - " > " ) ); + " > " ) ); throw new AncestralTaxonomyInferenceException( "a taxonomy for node " + desc_str - + " could not be established from the database" ); + + " could not be established from the database" ); } String[] lineage = ForesterUtil.stringListToArray( desc.getNodeData().getTaxonomy().getLineage() ); if ( ( lineage == null ) || ( lineage.length < 1 ) ) { @@ -104,7 +104,7 @@ public final class AncestralTaxonomyInference { node = "[" + desc.getId() + "]"; } throw new AncestralTaxonomyInferenceException( "node " + node - + " has no or inappropriate taxonomic information" ); + + " has no or inappropriate taxonomic information" ); } } final List last_common_lineage = new ArrayList(); @@ -124,6 +124,7 @@ public final class AncestralTaxonomyInference { if ( last_common_lineage.isEmpty() ) { boolean saw_viruses = false; boolean saw_cellular_organism = false; + boolean saw_x = false; for( final String[] lineage : lineages ) { if ( lineage.length > 0 ) { if ( lineage[ 0 ].equalsIgnoreCase( UniProtTaxonomy.VIRUSES ) ) { @@ -132,14 +133,17 @@ public final class AncestralTaxonomyInference { else if ( lineage[ 0 ].equalsIgnoreCase( UniProtTaxonomy.CELLULAR_ORGANISMS ) ) { saw_cellular_organism = true; } - if ( saw_cellular_organism && saw_viruses ) { + else if ( lineage[ 0 ].equalsIgnoreCase( UniProtTaxonomy.X ) ) { + saw_x = true; + } + if ( ( saw_cellular_organism && saw_viruses ) || saw_x ) { break; } } } - if ( saw_cellular_organism && saw_viruses ) { - last_common_lineage.add( UniProtTaxonomy.CELLULAR_ORGANISMS ); - last_common = UniProtTaxonomy.CELLULAR_ORGANISMS; + if ( ( saw_cellular_organism && saw_viruses ) || saw_x ) { + last_common_lineage.add( UniProtTaxonomy.X ); + last_common = UniProtTaxonomy.X; } else { String msg = "no common lineage for:\n";