From 7bbe60fa14da3f582733162744740cd51c5e783c Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Fri, 15 Nov 2013 22:59:44 +0000 Subject: [PATCH] inprogress --- .../analysis/AncestralTaxonomyInference.java | 12 +++-- .../org/forester/analysis/TaxonomyDataManager.java | 9 ++-- .../src/org/forester/archaeopteryx/NodePanel.java | 4 +- .../org/forester/phylogeny/PhylogenyMethods.java | 7 ++- .../src/org/forester/phylogeny/data/Taxonomy.java | 34 +++++++------ forester/java/src/org/forester/test/Test.java | 2 +- .../src/org/forester/ws/seqdb/UniProtTaxonomy.java | 50 ++++++++++---------- 7 files changed, 61 insertions(+), 57 deletions(-) diff --git a/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java b/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java index 61b9465..11d678d 100644 --- a/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java +++ b/forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java @@ -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"; diff --git a/forester/java/src/org/forester/analysis/TaxonomyDataManager.java b/forester/java/src/org/forester/analysis/TaxonomyDataManager.java index 79ab713..31de4f9 100644 --- a/forester/java/src/org/forester/analysis/TaxonomyDataManager.java +++ b/forester/java/src/org/forester/analysis/TaxonomyDataManager.java @@ -184,16 +184,13 @@ public final class TaxonomyDataManager extends RunnableProcess { } private final static List getTaxonomiesFromScientificName( final String query ) throws IOException { - if ( query.equalsIgnoreCase( UniProtTaxonomy.BACTERIA ) || - query.equalsIgnoreCase( UniProtTaxonomy.ARCHAEA ) || - query.equalsIgnoreCase( UniProtTaxonomy.VIRUSES ) || - query.equalsIgnoreCase( UniProtTaxonomy.EUKARYOTA ) - ) { + if ( query.equalsIgnoreCase( UniProtTaxonomy.BACTERIA ) || query.equalsIgnoreCase( UniProtTaxonomy.ARCHAEA ) + || query.equalsIgnoreCase( UniProtTaxonomy.VIRUSES ) + || query.equalsIgnoreCase( UniProtTaxonomy.EUKARYOTA ) || query.equalsIgnoreCase( UniProtTaxonomy.X ) ) { final List l = new ArrayList(); l.add( UniProtTaxonomy.createSpecialFromScientificName( query ) ); return l; } - return SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( query, MAX_TAXONOMIES_TO_RETURN ); } diff --git a/forester/java/src/org/forester/archaeopteryx/NodePanel.java b/forester/java/src/org/forester/archaeopteryx/NodePanel.java index c861354..e39b580 100644 --- a/forester/java/src/org/forester/archaeopteryx/NodePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/NodePanel.java @@ -27,6 +27,7 @@ package org.forester.archaeopteryx; import java.awt.Color; import java.util.List; +import java.util.Map; import java.util.SortedMap; import java.util.SortedSet; @@ -207,8 +208,7 @@ class NodePanel extends JPanel implements TreeSelectionListener { addSubelement( category, "External children", String.valueOf( phylogeny_node.getAllExternalDescendants().size() ) ); - final SortedMap distinct_tax = PhylogenyMethods - .obtainDistinctTaxonomyCounts( phylogeny_node ); + final Map distinct_tax = PhylogenyMethods.obtainDistinctTaxonomyCounts( phylogeny_node ); if ( distinct_tax != null ) { final int no_tax = PhylogenyMethods.calculateNumberOfExternalNodesWithoutTaxonomy( phylogeny_node ); final int tax_count = distinct_tax.size(); diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java index 08fe7f0..b644e9e 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java @@ -36,9 +36,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; @@ -711,9 +710,9 @@ public class PhylogenyMethods { * null is returned. * */ - public static SortedMap obtainDistinctTaxonomyCounts( final PhylogenyNode node ) { + public static Map obtainDistinctTaxonomyCounts( final PhylogenyNode node ) { final List descs = node.getAllExternalDescendants(); - final SortedMap tax_map = new TreeMap(); + final Map tax_map = new HashMap(); for( final PhylogenyNode n : descs ) { if ( !n.getNodeData().isHasTaxonomy() || n.getNodeData().getTaxonomy().isEmpty() ) { return null; diff --git a/forester/java/src/org/forester/phylogeny/data/Taxonomy.java b/forester/java/src/org/forester/phylogeny/data/Taxonomy.java index b354921..26ed940 100644 --- a/forester/java/src/org/forester/phylogeny/data/Taxonomy.java +++ b/forester/java/src/org/forester/phylogeny/data/Taxonomy.java @@ -248,9 +248,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable lineage ) { diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index 47516e4..2583a90 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -11511,7 +11511,7 @@ public final class Test { System.out.println( entry4.getMap() ); return false; } - //TODO FIXME gi... + //TODO FIXME gi... // //TODO fails: // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" ); diff --git a/forester/java/src/org/forester/ws/seqdb/UniProtTaxonomy.java b/forester/java/src/org/forester/ws/seqdb/UniProtTaxonomy.java index b959899..c379607 100644 --- a/forester/java/src/org/forester/ws/seqdb/UniProtTaxonomy.java +++ b/forester/java/src/org/forester/ws/seqdb/UniProtTaxonomy.java @@ -32,18 +32,19 @@ import org.forester.util.ForesterUtil; public final class UniProtTaxonomy { - public static final String ARCHAEA = "Archaea"; - public static final String BACTERIA = "Bacteria"; - public static final String EUKARYOTA = "Eukaryota"; - private final List _lineage; - private final String _code; - private final String _scientific_name; - private final String _common_name; - private final String _synonym; - private final String _rank; - private final String _id; - public final static String CELLULAR_ORGANISMS = "cellular organisms"; - public final static String VIRUSES = "Viruses"; + public static final String ARCHAEA = "Archaea"; + public static final String BACTERIA = "Bacteria"; + public static final String EUKARYOTA = "Eukaryota"; + private final List _lineage; + private final String _code; + private final String _scientific_name; + private final String _common_name; + private final String _synonym; + private final String _rank; + private final String _id; + public final static String CELLULAR_ORGANISMS = "cellular organisms"; + public final static String VIRUSES = "Viruses"; + public static final String X = "x"; public UniProtTaxonomy( final String line ) { final String[] items = line.split( "\t" ); @@ -107,14 +108,13 @@ public final class UniProtTaxonomy { _synonym = synonym; _rank = rank; _id = id; - if ( ( _lineage != null && _lineage.isEmpty() ) || ( ( !ForesterUtil.isEmpty( _lineage ) ) && !_lineage.get( _lineage.size() - 1 ).equalsIgnoreCase( _scientific_name ) ) ) { + if ( ( ( _lineage != null ) && _lineage.isEmpty() ) + || ( ( !ForesterUtil.isEmpty( _lineage ) ) && !_lineage.get( _lineage.size() - 1 ) + .equalsIgnoreCase( _scientific_name ) ) ) { _lineage.add( _scientific_name ); } - } - - /** * Creates deep copy for all fields, except lineage. * @@ -157,17 +157,15 @@ public final class UniProtTaxonomy { public String getSynonym() { return _synonym; } - + public final static UniProtTaxonomy createSpecialFromScientificName( final String sn ) { - - List lineage = new ArrayList(); - String code = ""; - String common_name = ""; + final List lineage = new ArrayList(); + final String code = ""; + final String common_name = ""; String scientific_name = ""; - String synonym = ""; + final String synonym = ""; String rank = ""; String id = ""; - if ( sn.equalsIgnoreCase( BACTERIA ) ) { scientific_name = BACTERIA; lineage.add( "cellular organisms" ); @@ -177,7 +175,6 @@ public final class UniProtTaxonomy { else if ( sn.equalsIgnoreCase( ARCHAEA ) ) { scientific_name = ARCHAEA; lineage.add( "cellular organisms" ); - rank = "superkingdom"; id = "2157"; } @@ -192,11 +189,12 @@ public final class UniProtTaxonomy { rank = "superkingdom"; id = "10239"; } + else if ( sn.equalsIgnoreCase( X ) ) { + scientific_name = X; + } else { throw new IllegalArgumentException( "illegal attempt to make UniProt taxonomy for :" + sn ); } return new UniProtTaxonomy( lineage, code, common_name, scientific_name, synonym, rank, id ); - - } } -- 1.7.10.2