Skip to content
Snippets Groups Projects
Commit 878bbdce authored by Graham McVicker's avatar Graham McVicker
Browse files

store each density feature as it is created rather than building a list per...

store each density feature as it is created rather than building a list per seq_region - smaller memory footprint (but repeats still leaking mem)
parent bfc26227
No related branches found
No related tags found
No related merge requests found
......@@ -115,32 +115,26 @@ foreach my $slice ( @$slices ) {
my $blocksize = $density_type->block_size();
$current_start = 1;
my @density_features=();
while($current_start <= $slice->end()) {
$current_end = $current_start+$blocksize-1;
if( $current_end > $slice->end() ) {
$current_end = $slice->end();
$current_end = $slice->end();
}
my $sub_slice = $slice->sub_Slice( $current_start, $current_end );
my $gc = $sub_slice->get_base_count()->{'%gc'};
push @density_features, Bio::EnsEMBL::DensityFeature->new
(-seq_region => $slice,
-start => $current_start,
-end => $current_end,
-density_type => $density_type,
-density_value => $gc);
my $df = Bio::EnsEMBL::DensityFeature->new
(-seq_region => $slice,
-start => $current_start,
-end => $current_end,
-density_type => $density_type,
-density_value => $gc);
$dfa->store($df);
$current_start = $current_end+1;
}
$dfa->store(@density_features);
print "Created ",scalar @density_features, " %GC density features ";
print "for seq_region ", $slice->seq_region_name(),"\n";
# print_features(\@density_features);
}
}
......
......@@ -107,12 +107,10 @@ foreach my $slice ( @$slices ) {
my $blocksize = $density_type->block_size();
$current_start = 1;
my @density_features=();
while($current_start <= $slice->end()) {
$current_end = $current_start+$blocksize-1;
if( $current_end > $slice->end() ) {
$current_end = $slice->end();
$current_end = $slice->end();
}
my $this_block_size = $current_end - $current_start + 1;
......@@ -122,35 +120,29 @@ foreach my $slice ( @$slices ) {
my $rr = Bio::EnsEMBL::Mapper::RangeRegistry->new();
foreach my $repeat (@{$sub_slice->get_all_RepeatFeatures()}){
$rr->check_and_register("1",$repeat->start,$repeat->end);
$rr->check_and_register("1",$repeat->start,$repeat->end);
}
my $count = 0;
my $non_repeats = $rr->check_and_register("1",1,$this_block_size);
if( defined $non_repeats ) {
foreach my $non_repeat ( @$non_repeats ) {
$count += ($non_repeat->[1]-$non_repeat->[0])+1;
}
}
foreach my $non_repeat ( @$non_repeats ) {
$count += ($non_repeat->[1]-$non_repeat->[0])+1;
}
}
print "repeat-> ".$count." are none repeat regions out of $this_block_size\n";
my $percentage_repeat = (($this_block_size-$count)/$this_block_size)*100;
push @density_features, Bio::EnsEMBL::DensityFeature->new
(-seq_region => $slice,
-start => $current_start,
-end => $current_end,
-density_type => $density_type,
-density_value => $percentage_repeat);
my $df = Bio::EnsEMBL::DensityFeature->new
(-seq_region => $slice,
-start => $current_start,
-end => $current_end,
-density_type => $density_type,
-density_value => $percentage_repeat);
$dfa->store($df);
$current_start = $current_end + 1;
}
$dfa->store(@density_features);
print STDERR "Created ",scalar @density_features," repeat density features ";
print STDERR "for ",$slice->seq_region_name(),"\n";
# print_features(\@density_features);
}
}
......
......@@ -85,8 +85,6 @@ foreach my $slice (@$top_slices){
$current_start = 1;
my @density_features=();
print "SNP densities for ".$slice->seq_region_name().
" with block size $block_size\n";
......@@ -104,14 +102,13 @@ foreach my $slice (@$top_slices){
#
# How many snps fall into this subslice
#
foreach my $snp (@{$sub_slice->get_all_SNPs()}){
if( $snp->start >= 1 ) {
$count++
$count++
}
}
push @density_features, Bio::EnsEMBL::DensityFeature->new
my $df = Bio::EnsEMBL::DensityFeature->new
(-seq_region => $slice,
-start => $current_start,
-end => $current_end,
......@@ -120,10 +117,8 @@ foreach my $slice (@$top_slices){
$current_start = $current_end + 1;
$dfa->store($df);
}
$dfa->store(@density_features);
print "Created ", scalar @density_features, " snp density features.\n";
# print_features(\@density_features);
}
......
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