my $dust = Bio::EnsEMBL::Analysis::RunnableDB::Dust->
new(
-input_id => 'contig::AL805961.22.1.166258:1:166258:1',
-db => $db,
-analysis => $analysis,
);
$dust->fetch_input;
$dust->run;
$dust->write_output;
sub convert_feature
{ my ($self, $rf) = @_;
print "Converting ".$rf->start." ".$rf->end." ".
$rf->slice->seq_region_name."\n";
my $ff = $self->feature_factory;
my $projections = $rf->project('seqlevel');
my @converted;
my $feature_length = $rf->length;
my $projected_length = 0;
PROJECT:foreach my $projection(@$projections){
$projected_length += ($projection->from_end -
$projection->from_start) +1;
}
my $percentage = 100;
if($projected_length != 0){
$percentage = ($projected_length / $feature_length)*100; }
if($percentage <= 75){
return;
}
REPEAT:foreach my $projection(@$projections){
my $start = 1;
my $end = $projection->to_Slice->length;
my $slice = $projection->to_Slice;
my $rc = $ff->create_repeat_consensus('dust', 'dust', 'simple', 'N');
my $rf = $ff->create_repeat_feature($start, $end, 0, 0, $start,
$end, $rc, $slice->name,
$slice);
my $transformed = $rf->transform($self->query->coord_system->name,
$self->query->coord_system->version);
if(!$transformed){
throw("Failed to transform ".$rf." ".$rf->start." ".
$rf->end." ".$rf->seq_region_name." skipping\n ");
}
push(@converted, $transformed);
}
return\@ converted;
}
1; } |
sub fetch_input
{ my ($self) = @_;
my $slice = $self->fetch_sequence;
$self->query($slice);
my %parameters;
if($self->parameters_hash){
%parameters = %{$self->parameters_hash};
}
my $runnable = Bio::EnsEMBL::Analysis::Runnable::Dust->new
(
-query => $self->query,
-program => $self->analysis->program_file,
-analysis => $self->analysis,
%parameters,
);
$self->runnable($runnable);
return 1; } |
sub write_output
{ my ($self) = @_;
my $adaptor = $self->get_adaptor;
my @transformed;
foreach my $feature (@{$self->output}) {
if ( $feature->length > 50000 ) {
my $transformed_features = $self->convert_feature($feature);
push(@transformed, @$transformed_features) if($transformed_features);
}else{
push(@transformed, $feature);
}
}
foreach my $feature (@transformed) {
$feature->analysis($self->analysis);
$feature->slice($self->query) if(!$feature->slice);
$self->feature_factory->validate($feature);
eval{
$adaptor->store($feature);
};
if ($@){
throw("RunnableDB:store failed, failed to write ".$feature." to ".
"the database $@");
}
} } |