From: cmzmasek Date: Thu, 11 May 2017 00:30:14 +0000 (-0700) Subject: in progress... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4ec226ac591d8c9e3837e4c096b2d3cdafd3a3a7;p=jalview.git in progress... --- diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java index 9f73532..42fde76 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java @@ -261,8 +261,6 @@ public class PhylogenyMethods { return node1; } - - public static int calculateMaxDepth( final Phylogeny phy ) { int max = 0; for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) { @@ -548,6 +546,30 @@ public class PhylogenyMethods { return descs; } + public static List getAllDescendantsOfGivenLevel( final PhylogenyNode node, final int level ) { + final List descs = new ArrayList(); + final Set encountered = new HashSet(); + if ( !node.isExternal() ) { + final List exts = node.getAllExternalDescendants(); + for( PhylogenyNode current : exts ) { + if ( calculateLevel( current ) == level ) { + descs.add( current ); + } + while ( current != node ) { + current = current.getParent(); + if ( encountered.contains( current.getId() ) ) { + continue; + } + if ( calculateLevel( current ) == level ) { + descs.add( current ); + } + encountered.add( current.getId() ); + } + } + } + return descs; + } + /** * * Convenience method diff --git a/forester/java/src/org/forester/surfacing/MinimalDomainomeCalculator.java b/forester/java/src/org/forester/surfacing/MinimalDomainomeCalculator.java index 8c25cd3..1fa7929 100644 --- a/forester/java/src/org/forester/surfacing/MinimalDomainomeCalculator.java +++ b/forester/java/src/org/forester/surfacing/MinimalDomainomeCalculator.java @@ -313,42 +313,57 @@ public final class MinimalDomainomeCalculator { } final List> features_per_genome_list = new ArrayList>(); boolean first = true; - for( final PhylogenyNode external_desc : external_descs ) { - final String code = external_desc.getNodeData().getTaxonomy().getTaxonomyCode(); - if ( node.isInternal() ) { - if ( first ) { - first = false; - } - else { - out.write( ", " ); + if ( level >= 1 ) { + //////////// + //////////// + final int node_level = PhylogenyMethods.calculateLevel( node ); + if ( node_level >= level ) { + final List given_level_descs = PhylogenyMethods + .getAllDescendantsOfGivenLevel( node, level ); + for( final PhylogenyNode given_level_desc : given_level_descs ) { + final String spec_name = given_level_desc.getNodeData().isHasTaxonomy() + ? given_level_desc.getNodeData().getTaxonomy().getScientificName() : given_level_desc.getName(); } - out.write( code ); } - final List proteins_per_species = protein_lists_per_species.get( new BasicSpecies( code ) ); - final int node_level = PhylogenyMethods.calculateLevel( node ); - final List proteins_per_quasi_species = protein_lists_per_species - .get( new BasicSpecies( code ) ); - if ( proteins_per_species != null ) { - final SortedSet features_per_genome = new TreeSet(); - for( final Protein protein : proteins_per_species ) { - if ( use_domain_architectures ) { - final String da = protein.toDomainArchitectureString( separator, ie_cutoff ); - features_per_genome.add( da ); + /////////// + /////////// + } + else { + for( final PhylogenyNode external_desc : external_descs ) { + final String code = external_desc.getNodeData().getTaxonomy().getTaxonomyCode(); + if ( node.isInternal() ) { + if ( first ) { + first = false; } else { - List domains = protein.getProteinDomains(); - for( final Domain domain : domains ) { - if ( ( ie_cutoff <= -1 ) || ( domain.getPerDomainEvalue() <= ie_cutoff ) ) { - features_per_genome.add( domain.getDomainId() ); + out.write( ", " ); + } + out.write( code ); + } + final List proteins_per_species = protein_lists_per_species + .get( new BasicSpecies( code ) ); + if ( proteins_per_species != null ) { + final SortedSet features_per_genome = new TreeSet(); + for( final Protein protein : proteins_per_species ) { + if ( use_domain_architectures ) { + final String da = protein.toDomainArchitectureString( separator, ie_cutoff ); + features_per_genome.add( da ); + } + else { + List domains = protein.getProteinDomains(); + for( final Domain domain : domains ) { + if ( ( ie_cutoff <= -1 ) || ( domain.getPerDomainEvalue() <= ie_cutoff ) ) { + features_per_genome.add( domain.getDomainId() ); + } } } } + if ( features_per_genome.size() > 0 ) { + features_per_genome_list.add( features_per_genome ); + } } - if ( features_per_genome.size() > 0 ) { - features_per_genome_list.add( features_per_genome ); - } - } - } // for( final PhylogenyNode external_desc : external_descs ) + } // for( final PhylogenyNode external_desc : external_descs ) + } // else if ( features_per_genome_list.size() > 0 ) { SortedSet intersection = calcIntersection( features_per_genome_list ); out.write( "\t" + intersection.size() + "\t" );