Skip to content
Snippets Groups Projects
Commit 00262241 authored by Magali Ruffier's avatar Magali Ruffier
Browse files

added methods to get count on alternate sequences

parent b084c3b9
No related branches found
No related tags found
No related merge requests found
......@@ -15,24 +15,57 @@ sub run {
my %attrib_codes = $self->get_attrib_codes();
$self->delete_old_attrib($dba, %attrib_codes);
my %alt_attrib_codes = $self->get_alt_attrib_codes();
$self->delete_old_attrib($dba, %alt_attrib_codes);
my $total = $self->get_total();
my $sum = 0;
my $count;
my %slices_hash;
my $slices = $self->get_slices($species);
my @sorted_slices =
my $all_slices = $self->get_all_slices($species);
foreach my $region (@$slices) {
$slices_hash{$region->name} = 1;
}
print scalar(@$slices) . " ref slices and " . scalar(@$all_slices) . " all slices\n" ;
if (scalar(@$slices) == scalar(@$all_slices)) {
my @sorted_slices =
sort( { $a->coord_system()->rank() <=> $b->coord_system()->rank()
|| $b->seq_region_length() <=> $a->seq_region_length() } @$slices) ;
while (my $slice = shift @sorted_slices) {
foreach my $code (keys %attrib_codes) {
my $count = $self->get_feature_count($slice, $code, $attrib_codes{$code});
if ($count > 0) {
$self->store_attrib($slice, $count, $code);
while (my $ref_slice = shift @sorted_slices) {
foreach my $code (keys %attrib_codes) {
$count = $self->get_feature_count($ref_slice, $code, $attrib_codes{$code});
if ($count > 0) {
$self->store_attrib($ref_slice, $count, $code);
}
$sum += $count;
}
if ($sum >= $total) {
last;
}
$sum += $count;
}
if ($sum >= $total) {
last;
} else {
my @all_sorted_slices =
sort( { $a->coord_system()->rank() <=> $b->coord_system()->rank()
|| $b->seq_region_length() <=> $a->seq_region_length() } @$all_slices) ;
while (my $slice = shift @all_sorted_slices) {
if (exists $slices_hash{$slice->name}) {
foreach my $ref_code (keys %attrib_codes) {
$count = $self->get_feature_count($slice, $ref_code, $attrib_codes{$ref_code});
if ($count > 0) {
$self->store_attrib($slice, $count, $ref_code);
}
}
} else {
foreach my $alt_code (keys %alt_attrib_codes) {
my $alt_count = $self->get_feature_count($slice, $alt_code, $alt_attrib_codes{$alt_code});
if ($alt_count > 0) {
$self->store_attrib($slice, $alt_count, $alt_code);
}
}
}
}
}
}
......@@ -43,6 +76,11 @@ sub get_slices {
return $slices;
}
sub get_all_slices {
my ($self, $species) = @_;
my $slices = Bio::EnsEMBL::Registry->get_adaptor($species, 'core', 'slice')->fetch_all('toplevel', undef, 1);
return $slices;
}
sub delete_old_attrib {
my ($self, $dba, %attrib_codes) = @_;
......
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