Commit d095755d authored by Web Admin's avatar Web Admin
Browse files

merge from vega-44-dev

parent 53135a1d
......@@ -149,22 +149,21 @@ if($support->param('prune')){
# delete the results in the database from a previous run
$support->log("running in prune mode\n");
$support->log("pruning 1 (tables analysis, density_type, density_feature)\n");
$support->log("pruning analysis, density_type, density_feature tables\n");
# Note: Need to use a left-join in the multitable delete otherwise rows in e.g. analysis which have program= vega_gene_density.pl, but no corresponding rows in the density_type or density_feature table will NOT be deleted.
my $query= "delete analysis, density_type, density_feature
from analysis
left join density_type on analysis.analysis_id= density_type.analysis_id
left join density_feature on density_type.density_type_id= density_feature.density_type_id
where analysis.program= 'vega_gene_density.pl'";
my $query= "delete a, dt, df
from analysis a
left join density_type dt on a.analysis_id= dt.analysis_id
left join density_feature df on dt.density_type_id= df.density_type_id
where a.program= 'vega_gene_density.pl'";
if(my $c = $dbh->do($query)){
$support->log("prune 1 was successfull: $c previous entries in the database generated by this script have been deleted\n");
$support->log("prune was successfull: $c previous entries in the database generated by this script have been deleted\n");
}
else {
$support->log_error("prune 1 failed: any previous entries in the database generated by this script have NOT been deleted\n");
$support->log_error("prune failed: any previous entries in the database generated by this script have NOT been deleted\n");
exit;
}
......@@ -174,10 +173,10 @@ if($support->param('prune')){
if($code){
$query= "delete attrib_type, seq_region_attrib from attrib_type left join seq_region_attrib on attrib_type.attrib_type_id= seq_region_attrib.attrib_type_id where attrib_type.code= '$code'";
if(my $c = $dbh->do($query)){
$support->log("$c entries removed successfull for code $code\n");
$support->log("$c entries removed successfully for code $code\n");
}
else{
$support->log_error("prune 2 failed for code $code\n");
$support->log_error("prune failed for code $code\n");
}
}
}
......
......@@ -114,68 +114,68 @@ if($support->param('prune')){
$support->log_error("prune failed: any previous entries in the database generated by this script have NOT been deleted\n");
exit;
}
}
# Create new Analysis object
my $analysis = Bio::EnsEMBL::Analysis->new(
-program => "percent_gc_calc.pl",
-database => "ensembl",
-gff_source => "percent_gc_calc.pl",
-gff_feature => "density",
-logic_name => "PercentGC",
);
$aa->store($analysis) unless ($support->param('dry_run'));
# split chromosomes by size and determine block size
my $chr_slices = $support->split_chromosomes_by_size(5000000);
# loop over block sizes
foreach my $block_size (keys %{ $chr_slices }) {
$support->log("Available chromosomes using block size of $block_size:\n ");
$support->log(join("\n ", map { $_->seq_region_name } @{ $chr_slices->{$block_size} })."\n");
# create DensityType objects
my $density_type = Bio::EnsEMBL::DensityType->new(
-analysis => $analysis,
-block_size => $block_size,
-value_type => 'ratio',
);
$dta->store($density_type) unless ($support->param('dry_run'));
# loop over chromosomes
$support->log_stamped("Looping over chromosomes...\n");
my ($current_start, $current_end);
foreach my $slice (@{ $chr_slices->{$block_size} }) {
$current_start = 1;
my $chr = $slice->seq_region_name;
my $i;
my $bins = POSIX::ceil($slice->end/$block_size);
$support->log_stamped("Chromosome $chr with block size $block_size...\n", 1);
# loop over blocks
while($current_start <= $slice->end) {
$i++;
$current_end = $current_start + $block_size - 1;
if ($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'};
$support->log_verbose("Chr: $chr | Bin: $i/$bins | \%GC: $gc\n", 2);
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) unless ($support->param('dry_run'));
$current_start = $current_end + 1;
}
$support->log_stamped("Done.\n", 1);
}
$support->log_stamped("Done.\n");
}
# Create new Analysis object
my $analysis = Bio::EnsEMBL::Analysis->new(
-program => "percent_gc_calc.pl",
-database => "ensembl",
-gff_source => "percent_gc_calc.pl",
-gff_feature => "density",
-logic_name => "PercentGC",
);
$aa->store($analysis) unless ($support->param('dry_run'));
# split chromosomes by size and determine block size
my $chr_slices = $support->split_chromosomes_by_size(5000000);
# loop over block sizes
foreach my $block_size (keys %{ $chr_slices }) {
$support->log("Available chromosomes using block size of $block_size:\n ");
$support->log(join("\n ", map { $_->seq_region_name } @{ $chr_slices->{$block_size} })."\n");
# create DensityType objects
my $density_type = Bio::EnsEMBL::DensityType->new(
-analysis => $analysis,
-block_size => $block_size,
-value_type => 'ratio',
);
$dta->store($density_type) unless ($support->param('dry_run'));
# loop over chromosomes
$support->log_stamped("Looping over chromosomes...\n");
my ($current_start, $current_end);
foreach my $slice (@{ $chr_slices->{$block_size} }) {
$current_start = 1;
my $chr = $slice->seq_region_name;
my $i;
my $bins = POSIX::ceil($slice->end/$block_size);
$support->log_stamped("Chromosome $chr with block size $block_size...\n", 1);
# loop over blocks
while($current_start <= $slice->end) {
$i++;
$current_end = $current_start + $block_size - 1;
if ($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'};
$support->log_verbose("Chr: $chr | Bin: $i/$bins | \%GC: $gc\n", 2);
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) unless ($support->param('dry_run'));
$current_start = $current_end + 1;
}
$support->log_stamped("Done.\n", 1);
}
$support->log_stamped("Done.\n");
}
# finish logfile
......
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