Skip to content

Commit

Permalink
INCUBATORS-17: use reconciliation attributes to get the speciation an…
Browse files Browse the repository at this point in the history
…d duplication counts.
  • Loading branch information
slr71 committed Feb 18, 2011
1 parent c278696 commit 34b78b6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
3 changes: 3 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ lib/IPlant/DB/TreeRec/Result/DuplicationCount.pm
lib/IPlant/DB/TreeRec/Result/Duplications.pm
lib/IPlant/DB/TreeRec/Result/DuplicationSearch.pm
lib/IPlant/DB/TreeRec/Result/Family.pm
lib/IPlant/DB/TreeRec/Result/FamilyAttribute.pm
lib/IPlant/DB/TreeRec/Result/FamilyMember.pm
lib/IPlant/DB/TreeRec/Result/GeneIdSearch.pm
lib/IPlant/DB/TreeRec/Result/GoAccessionSearch.pm
Expand All @@ -27,6 +28,7 @@ lib/IPlant/DB/TreeRec/Result/ProteinTreeAttribute.pm
lib/IPlant/DB/TreeRec/Result/ProteinTreeMember.pm
lib/IPlant/DB/TreeRec/Result/ProteinTreeNode.pm
lib/IPlant/DB/TreeRec/Result/ProteinTreeNodeAttribute.pm
lib/IPlant/DB/TreeRec/Result/ProteinTreeNodePath.pm
lib/IPlant/DB/TreeRec/Result/Reconciliation.pm
lib/IPlant/DB/TreeRec/Result/ReconciliationAttribute.pm
lib/IPlant/DB/TreeRec/Result/ReconciliationNode.pm
Expand All @@ -44,6 +46,7 @@ lib/IPlant/DB/TreeRec/Result/SpeciesTreeNodePath.pm
lib/IPlant/DB/TreeRec/ResultSet/Family.pm
lib/IPlant/DB/TreeRec/ResultSet/ProteinTree.pm
lib/IPlant/DB/TreeRec/ResultSet/Reconciliation.pm
lib/IPlant/DB/TreeRec/ResultSet/ReconciliationAttribute.pm
lib/IPlant/DB/TreeRec/ResultSet/SpeciesTree.pm
lib/IPlant/DB/TreeRec/ResultSet/SpeciesTreeNode.pm
lib/IPlant/TreeRec.pm
Expand Down
38 changes: 38 additions & 0 deletions lib/IPlant/DB/TreeRec/ResultSet/ReconciliationAttribute.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package IPlant::DB::TreeRec::ResultSet::ReconciliationAttribute;

use warnings;
use strict;

use IPlant::TreeRec::X;

use base 'DBIx::Class::ResultSet';

##########################################################################
# Usage : @values = $dbh->resultset('ReconciliationAttribute')
# ->get_values( $reconciliation_id, $attribute_name );
#
# Purpose : Retrieves the attribute values for all attributes of the
# reconciliation with the given ID that have the given name.
#
# Returns : The list of values.
#
# Parameters : $reconciliation_id - the reconciliation identifier.
# $attribute_name - the name of the attribute.
#
# Throws : No exceptions.
sub get_values {
my ( $self, $reconciliation_id, $attribute_name ) = @_;

# Find the tree.
my @results = $self->search(
{ 'reconciliation_id' => $reconciliation_id,
'cvterm.name' => $attribute_name,
},
{ 'join' => 'cvterm' }
);

return map { $_->value() } @results;
}

1;
__END__
16 changes: 9 additions & 7 deletions lib/IPlant/TreeRec/GeneFamilyInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,11 @@ Readonly my %EMPTY_SUMMARY => (
my $dbh = $dbh_of{ ident $self };

# Get the number of duplications.
my @results = eval { $dbh->resultset('DuplicationCount')
->search( {}, { 'bind' => [ $reconciliation_id ] } ) };
warn $EVAL_ERROR if $EVAL_ERROR;
return scalar @results > 0 ? $results[0]->duplication_count() : 0;
my @results = eval {
$dbh->resultset('ReconciliationAttribute')
->get_values( $reconciliation_id, 'duplication' );
};
return scalar @results > 0 ? $results[0] : 0;
}

##########################################################################
Expand All @@ -466,9 +467,10 @@ Readonly my %EMPTY_SUMMARY => (
my $dbh = $dbh_of{ ident $self };

# Get the number of speciations.
my @results = eval { $dbh->resultset('SpeciationCount')
->search( {}, { 'bind' => [ $reconciliation_id ] } ) };
warn $EVAL_ERROR if $EVAL_ERROR;
my @results = eval {
$dbh->resultset('ReconciliationAttribute')
->get_values( $reconciliation_id, 'speciation' );
};
return scalar @results > 0 ? $results[0]->speciation_count() : 0;
}

Expand Down
3 changes: 2 additions & 1 deletion t/IPlant-TreeRec.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;

#########################

use Test::More tests => 71;
use Test::More tests => 72;
BEGIN { use_ok('IPlant::DB::TreeRec') };
BEGIN { use_ok('IPlant::DB::TreeRec::Result::Cv') };
BEGIN { use_ok('IPlant::DB::TreeRec::Result::Cvterm') };
Expand Down Expand Up @@ -49,6 +49,7 @@ BEGIN { use_ok('IPlant::DB::TreeRec::Result::SpeciesTreeNodePath') };
BEGIN { use_ok('IPlant::DB::TreeRec::ResultSet::Family') };
BEGIN { use_ok('IPlant::DB::TreeRec::ResultSet::ProteinTree') };
BEGIN { use_ok('IPlant::DB::TreeRec::ResultSet::Reconciliation') };
BEGIN { use_ok('IPlant::DB::TreeRec::ResultSet::ReconciliationAttribute') };
BEGIN { use_ok('IPlant::DB::TreeRec::ResultSet::SpeciesTree') };
BEGIN { use_ok('IPlant::DB::TreeRec::ResultSet::SpeciesTreeNode') };
BEGIN { use_ok('IPlant::TreeRec') };
Expand Down

0 comments on commit 34b78b6

Please sign in to comment.