Bio::EnsEMBL::Analysis::RunnableDB
IncrementalBuild
Toolbar
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Analysis::Config::GeneBuild::IncrementalBuild
Inherit
Synopsis
No synopsis!
Description
No description!
Methods
CALCULATE_TRANSLATION | No description | Code |
DISCARD_IF_NO_ORF | No description | Code |
NEW_BIOTYPE | No description | Code |
OUTPUT_DB | No description | Code |
POST_FILTER | No description | Code |
PRE_FILTER | No description | Code |
PRIMARY_BIOTYPES | No description | Code |
PRIMARY_DB | No description | Code |
SECONDARY_BIOTYPES | No description | Code |
SECONDARY_DB | No description | Code |
SECONDARY_FILTER | No description | Code |
SECONDARY_PADDING | No description | Code |
STORE_PRIMARY | No description | Code |
calculate_translation | No description | Code |
fetch_input | No description | Code |
filter_object | No description | Code |
get_Genes | No description | Code |
mask_gene_regions | No description | Code |
new | No description | Code |
output_database | No description | Code |
overlapping_genes | No description | Code |
primary_database | No description | Code |
primary_genes | No description | Code |
primary_slice | No description | Code |
read_and_check_config | No description | Code |
run | No description | Code |
secondary_database | No description | Code |
secondary_genes | No description | Code |
write_output | No description | Code |
Methods description
None available.
Methods code
CALCULATE_TRANSLATION | description | prev | next | Top |
sub CALCULATE_TRANSLATION
{ my ($self,$value) = @_;
if (defined $value) {
$self->{'CALCULATE_TRANSLATION'} = $value;
}
if (exists($self->{'CALCULATE_TRANSLATION'})) {
return $self->{'CALCULATE_TRANSLATION'};
} else {
return undef;
} } |
sub DISCARD_IF_NO_ORF
{ my ($self,$value) = @_;
if (defined $value) {
$self->{'DISCARD_IF_NO_ORF'} = $value;
}
if (exists($self->{'DISCARD_IF_NO_ORF'})) {
return $self->{'DISCARD_IF_NO_ORF'};
} else {
return undef;
} } |
sub NEW_BIOTYPE
{ my ($self,$value) = @_;
if ($value) {
$self->{'NEW_BIOTYPE'} = $value;
}
if (exists($self->{'NEW_BIOTYPE'})) {
return $self->{'NEW_BIOTYPE'};
} else {
return undef;
} } |
sub OUTPUT_DB
{ my ($self,$value) = @_;
if ($value) {
$self->{'OUTPUT_DB'} = $value;
}
if (exists($self->{'OUTPUT_DB'})) {
return $self->{'OUTPUT_DB'};
} else {
return undef;
} } |
sub POST_FILTER
{ my ($self,$value) = @_;
if (defined $value) {
$self->{'POST_FILTER'} = $value;
}
if (exists($self->{'POST_FILTER'})) {
return $self->{'POST_FILTER'};
} else {
return undef;
} } |
sub PRE_FILTER
{ my ($self,$value) = @_;
if (defined $value) {
$self->{'PRE_FILTER'} = $value;
}
if (exists($self->{'PRE_FILTER'})) {
return $self->{'PRE_FILTER'};
} else {
return undef;
} } |
sub PRIMARY_BIOTYPES
{ my ($self,$value) = @_;
if ($value) {
$self->{'PRIMARY_BIOTYPES'} = $value;
}
if (exists($self->{'PRIMARY_BIOTYPES'})) {
return $self->{'PRIMARY_BIOTYPES'};
} else {
return undef;
} } |
sub PRIMARY_DB
{ my ($self,$value) = @_;
if ($value) {
$self->{'PRIMARY_DB'} = $value;
}
if (exists($self->{'PRIMARY_DB'})) {
return $self->{'PRIMARY_DB'};
} else {
return undef;
} } |
sub SECONDARY_BIOTYPES
{ my ($self,$value) = @_;
if ($value) {
$self->{'SECONDARY_BIOTYPES'} = $value;
}
if (exists($self->{'SECONDARY_BIOTYPES'})) {
return $self->{'SECONDARY_BIOTYPES'};
} else {
return undef;
} } |
sub SECONDARY_DB
{ my ($self,$value) = @_;
if ($value) {
$self->{'SECONDARY_DB'} = $value;
}
if (exists($self->{'SECONDARY_DB'})) {
return $self->{'SECONDARY_DB'};
} else {
return undef;
} } |
sub SECONDARY_FILTER
{ my ($self,$value) = @_;
if ($value) {
$self->{'SECONDARY_FILTER'} = $value;
}
if (exists($self->{'SECONDARY_FILTER'})) {
return $self->{'SECONDARY_FILTER'};
} else {
return undef;
} } |
sub SECONDARY_PADDING
{ my ($self,$value) = @_;
if ($value) {
$self->{'SECONDARY_PADDING'} = $value;
}
if (exists($self->{'SECONDARY_PADDING'})) {
return $self->{'SECONDARY_PADDING'};
} else {
return undef;
} } |
sub STORE_PRIMARY
{ my ($self,$value) = @_;
if (defined $value) {
$self->{'STORE_PRIMARY'} = $value;
}
if (exists($self->{'STORE_PRIMARY'})) {
return $self->{'STORE_PRIMARY'};
} else {
return undef;
} } |
sub calculate_translation
{ my ($self, $gene) = @_;
my $gene_to_keep = Bio::EnsEMBL::Gene->new();
$gene_to_keep->biotype($gene->biotype);
$gene_to_keep->confidence($gene->confidence);
$gene_to_keep->analysis($self->analysis);
$gene_to_keep->source($gene->source);
$gene_to_keep->stable_id($gene->stable_id);
my @new_transcripts;
TRANS:foreach my $transcript (@{$gene->get_all_Transcripts}){
my $seq = $transcript->slice->seq;
my $new_translation = Bio::EnsEMBL::Pipeline::Tools::TranslationUtils->return_translation($transcript);
if(!$new_translation && $self->DISCARD_IF_NO_ORF){
next TRANS;
}else{
$transcript->translation($new_translation);
push(@new_transcripts, $transcript);
}
}
if(@new_transcripts >= 1){
foreach my $new_transcript(@new_transcripts){
$gene_to_keep->add_Transcript($new_transcript);
}
return $gene_to_keep;
}else{
return undef;
} } |
sub fetch_input
{ my ($self) = @_;
my $secondary_slice = $self->fetch_sequence($self->input_id,
$self->secondary_database);
my $secondary_genes = $self->get_Genes($secondary_slice,
$self->SECONDARY_BIOTYPES);
my $primary_slice = $self->fetch_sequence($self->input_id,
$self->primary_database);
my $primary_genes = $self->get_Genes($primary_slice,
$self->PRIMARY_BIOTYPES);
$self->query($secondary_slice);
$self->secondary_genes($secondary_genes);
$self->primary_genes($primary_genes);
$self->primary_slice($primary_slice); } |
sub filter_object
{ my ($self,$value) = @_;
if ( $value) {
$self->{'filter_object'} = $value;
}
if (exists($self->{'filter_object'})) {
return $self->{'filter_object'};
} else {
return undef;
} } |
sub get_Genes
{ my ($self, $slice, $biotypes) = @_;
my @genes;
if(@$biotypes){
foreach my $biotype(@$biotypes){
push(@genes, @{$slice->get_all_Genes_by_type($biotype)});
}
}else{
push(@genes, @{$slice->get_all_Genes});
}
return\@ genes;
}
1; } |
sub mask_gene_regions
{ my ($self, $genes) = @_;
my @mask_gene_regions;
foreach my $gene(@$genes){
push @mask_gene_regions, { start => $gene->start,
end => $gene->end };
}
@mask_gene_regions = sort {$a->{'start'} <=> $b->{'start'} }
@mask_gene_regions;
return\@ mask_gene_regions; } |
sub new
{ my ($class,@args) = @_;
my $self = $class->SUPER::new(@args);
$self->read_and_check_config($INCREMENTAL_HASH);
return $self; } |
sub output_database
{ my ($self, $value) = @_;
if($value){
$self->{'output_database'} = $value;
}
if(!$self->{'output_database'}){
my $db = $self->get_dbadaptor($self->OUTPUT_DB);
$db->dnadb($self->db);
$self->{'output_database'} = $db;
}
return $self->{'output_database'}; } |
sub overlapping_genes
{ my ($self, $value) = @_;
if($value){
$self->{'overlapping_genes'} = $value;
}
return $self->{'overlapping_genes'}; } |
sub primary_database
{ my ($self, $value) = @_;
if($value){
$self->{'primary_database'} = $value;
}
if(!$self->{'primary_database'}){
my $db = $self->get_dbadaptor($self->PRIMARY_DB);
$db->dnadb($self->db);
$self->{'primary_database'} = $db;
}
return $self->{'primary_database'}; } |
sub primary_genes
{ my ($self, $value) = @_;
if($value){
$self->{'primary_genes'} = $value;
}
return $self->{'primary_genes'}; } |
sub primary_slice
{ my ($self, $value) = @_;
if($value){
$self->{'primary_slice'} = $value;
}
return $self->{'primary_slice'}; } |
sub read_and_check_config
{ my $self = shift;
$self->SUPER::read_and_check_config($INCREMENTAL_HASH);
foreach my $config_var (qw(PRIMARY_DB
SECONDARY_DB
OUTPUT_DB)) {
throw("You must define $config_var in config for logic '".
$self->analysis->logicname."'")
if not defined $self->$config_var;
}
if($self->SECONDARY_FILTER){
if($self->SECONDARY_FILTER->{OBJECT}){
my $module = $self->SECONDARY_FILTER->{OBJECT};
my $pars = $self->SECONDARY_FILTER->{PARAMETERS};
(my $class = $module) =~ s/::/\//g;
eval{
require "$class.pm";
};
throw("Couldn't require ".$class.
" IncrementalBuild:read_and_check_config $@") if($@);
$self->filter_object($module->new(%{$pars}));
}
} } |
sub run
{ my ($self) = @_;
my $mask_regions = $self->mask_gene_regions($self->primary_genes);
my @non_overlaps;
my @overlaps;
my @genes;
if($self->PRE_FILTER){
my $filtered_genes = $self->filter_object->filter_genes($self->secondary_genes);
push(@genes, @$filtered_genes);
}else{
push(@genes, @{$self->secondary_genes});
}
foreach my $gene(@genes){
my $keep_gene = 1;
my $mask_reg_idx = 0;
my @test_regions = ({start => $gene->start, end => $gene->end});
FEAT: foreach my $f (@test_regions) {
for( ; $mask_reg_idx < @$mask_regions; ) {
my $mask_reg = $mask_regions->[$mask_reg_idx];
if ($mask_reg->{'start'} > $f->{'end'}) {
next FEAT;
}
elsif ( $mask_reg->{'end'} >= $f->{'start'}) {
$keep_gene = 0;
last FEAT;
}
else {
$mask_reg_idx++;
}
}
}
if ($keep_gene) {
my $gene_to_keep;
if($self->CALCULATE_TRANSLATION){
$gene_to_keep = $self->calculate_translation($gene);
}else{
$gene_to_keep = $gene;
}
push @non_overlaps, $gene_to_keep if($gene_to_keep);
}else{
push(@overlaps, $gene);
}
}
my @non_overlapping_genes;
if($self->POST_FILTER){
my $filtered_genes = $self->filter_object->filter_genes(\@non_overlaps);
push(@non_overlapping_genes, @$filtered_genes);
}else{
push(@non_overlapping_genes, @non_overlaps);
}
my @output;
push(@output, @non_overlapping_genes);
if($self->NEW_BIOTYPE){
foreach my $output(@output){
$output->biotype($self->NEW_BIOTYPE);
}
}
my $primary_genes = $self->primary_genes;
print "Adding primary genes to set\n" if($self->STORE_PRIMARY);
push(@output, @$primary_genes) if($self->STORE_PRIMARY);
$self->output(\@output);
$self->overlapping_genes(\@overlaps); } |
sub secondary_database
{ my ($self, $value) = @_;
if($value){
$self->{'secondary_database'} = $value;
}
if(!$self->{'secondary_database'}){
my $db = $self->get_dbadaptor($self->SECONDARY_DB);
$db->dnadb($self->db);
$self->{'secondary_database'} = $db;
}
return $self->{'secondary_database'}; } |
sub secondary_genes
{ my ($self, $value) = @_;
if($value){
$self->{'secondary_genes'} = $value;
}
return $self->{'secondary_genes'}; } |
sub write_output
{ my ($self) = @_;
my $db = $self->output_database;
my $gene_adaptor = $db->get_GeneAdaptor;
foreach my $gene (@{$self->output}){
empty_Gene($gene);
eval{
$gene_adaptor->store($gene);
};
if($@){
throw("Failed to store gene $@");
}
} } |
General documentation
No general documentation available.