Commit 2dc28bec authored by Monika Komorowska's avatar Monika Komorowska
Browse files

added percentgc density type to fetch_stats

parent 44e5145f
......@@ -141,7 +141,7 @@ sub fetch_info {
=head2 fetch_stats
Arg [1] : string $seq_region_name (optional)
The name of a toplevel seq_region for which statistics should be fetched
The name of the toplevel seq_region for which statistics should be fetched
Description: Returns a hash
Returntype : hash with assembly statistics name and value pairs
......@@ -174,7 +174,7 @@ sub fetch_stats {
@slices = @{$sa->fetch_all('toplevel')};
}
my @density_types = qw(genedensity knowngenedensity snpdensity);
my @density_types = qw(genedensity knowngenedensity snpdensity percentgc);
my @attrib_types = qw(GeneNo% SNPCount);
......@@ -182,6 +182,10 @@ sub fetch_stats {
my $dfa = $self->db()->get_adaptor('DensityFeature');
#used to calculate the average density value for density types represented as ratios
my %density_ft_count = ();
foreach my $slice (@slices) {
$assembly_stats{'Length (bps)'} += $slice->length();
......@@ -189,9 +193,13 @@ sub fetch_stats {
foreach my $density_type (@density_types) {
my $density_features = $dfa->fetch_all_by_Slice($slice,$density_type);
foreach my $density_feature (@$density_features) {
if ($density_feature->density_type()->value_type() eq 'ratio') {
$density_ft_count{$density_feature->density_type()->analysis()->display_label()} += 1;
}
$assembly_stats{$density_feature->density_type()->analysis()->display_label()} += $density_feature->density_value();
}
}
......@@ -206,6 +214,15 @@ sub fetch_stats {
}
}
foreach my $density_analysis (keys %density_ft_count) {
if ($density_ft_count{$density_analysis} > 1) {
$assembly_stats{$density_analysis} /= $density_ft_count{$density_analysis};
$assembly_stats{$density_analysis} = sprintf "%.2f", $assembly_stats{$density_analysis};
$assembly_stats{$density_analysis} .= '%';
}
}
return \%assembly_stats;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment