Bio::EnsEMBL::Compara::RunnableDB
BlastComparaPep
Toolbar
Summary
Bio::EnsEMBL::Compara::RunnableDB::BlastComparaPep
Package variables
Privates (from "my" definitions)
$g_BlastComparaPep_workdir;
Included modules
Inherit
Synopsis
my $db = Bio::EnsEMBL::Compara::DBAdaptor->new($locator);
my $blast = Bio::EnsEMBL::Compara::RunnableDB::BlastComparaPep->new
(
-db => $db,
-input_id => $input_id
-analysis => $analysis );
$blast->fetch_input(); #reads from DB
$blast->run();
$blast->output();
$blast->write_output(); #writes to DB
Description
This object wraps Bio::EnsEMBL::Analysis::Runnable::Blast to add
functionality to read and write to databases.
The appropriate Bio::EnsEMBL::Analysis object must be passed for
extraction of appropriate parameters. A Bio::EnsEMBL::Analysis::DBSQL::Obj is
required for databse access.
Methods
Methods description
Title : fetch_input Usage : $self->fetch_input Function: Fetches input data for repeatmasker from the database Returns : none Args : none |
Arg[1] : -none- Example : $self->run; Function : Runs the runnable set in fetch_input Returns : 1 on succesfull completion Exceptions : dies if runnable throws an unexpected error |
Arg[1] : (optional) Bio::EnsEMBL::Analysis::Runnable $runnable Example : $self->runnable($runnable); Function : Getter/setter for the runnable Returns : Bio::EnsEMBL::Analysis::Runnable $runnable Exceptions : none |
Methods code
dumpPeptidesToFasta | description | prev | next | Top |
sub dumpPeptidesToFasta
{
my $self = shift;
my $startTime = time();
my $params = eval($self->analysis->data);
my $genomeDB = $self->{'comparaDBA'}->get_GenomeDBAdaptor->fetch_by_dbID($params->{'genome_db_id'});
my $species = $genomeDB->name();
$species =~ s/\s+/_/g;
$g_BlastComparaPep_workdir = "/tmp/worker.$$/";
mkdir($g_BlastComparaPep_workdir, 0777);
my $fastafile = $g_BlastComparaPep_workdir.
$species . "_" .
$genomeDB->assembly() . ".fasta";
$fastafile =~ s/\/\//\//g; return $fastafile if(-e $fastafile);
print("fastafile = '$fastafile'\n");
my $subset = $self->{'comparaDBA'}->get_SubsetAdaptor()->fetch_by_dbID($params->{'subset_id'});
$self->{'comparaDBA'}->get_SubsetAdaptor->dumpFastaForSubset($subset, $fastafile);
my $blastdb = new Bio::EnsEMBL::Analysis::Runnable::BlastDB (
-dbfile => $fastafile,
-type => 'PROTEIN');
$blastdb->run;
print("registered ". $blastdb->dbname . " for ".$blastdb->dbfile . "\n");
printf("took %d secs to dump database to local disk\n", (time() - $startTime));
return $fastafile;
}
1; } |
sub fetch_input
{ my( $self) = @_;
throw("No input_id") unless defined($self->input_id);
$self->{'comparaDBA'} = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new(-DBCONN=>$self->db->dbc);
$self->{'comparaDBA'}->dbc->disconnect_when_inactive(0);
my $member_id = $self->input_id;
my $member = $self->{'comparaDBA'}->get_MemberAdaptor->fetch_by_dbID($member_id);
throw("No member in compara for member_id = $member_id") unless defined($member);
if (10 > $member->bioseq->length) {
$self->input_job->update_status('DONE');
throw("BLAST : Peptide is too short for BLAST");
}
my $query = $member->bioseq();
throw("Unable to make bioseq for member_id = $member_id") unless defined($query);
my $dbfile = $self->analysis->db_file;
my ($thr, $thr_type, $options);
my $p = eval($self->analysis->data);
if (defined $p->{'-threshold'} && defined $p->{'-threshold_type'}) {
$thr = $p->{-threshold};
$thr_type = $p->{-threshold_type};
} else {
$thr_type = 'PVALUE';
$thr = 1e-10;
}
if (defined $p->{'options'}) {
$options = $p->{'options'};
} else {
$options = '';
}
my $regex = '^(\S+)\s*';
if ($p->{'regex'}) {
$regex = $p->{'regex'};
}
my $parser = Bio::EnsEMBL::Analysis::Tools::FilterBPlite->new(
-regex => $regex,
-query_type => "pep",
-input_type => "pep",
-threshold_type => $thr_type,
-threshold => $thr,
);
my $runnable = Bio::EnsEMBL::Analysis::Runnable::Blast->new(
-query => $query,
-database => $dbfile,
-program => $self->analysis->program_file,
-analysis => $self->analysis,
-options => $options,
-parser => $parser,
-filter => undef,
);
$self->runnable($runnable);
return 1; } |
sub global_cleanup
{ my $self = shift;
if($g_BlastComparaPep_workdir) {
unlink(<$g_BlastComparaPep_workdir/*>); rmdir($g_BlastComparaPep_workdir);
}
return 1;
}
} |
sub output
{ my ($self, @args) = @_;
throw ("Cannot call output without a runnable") if (!defined($self->runnable));
return $self->runnable->output(@args); } |
sub run
{ my $self = shift;
$self->{'comparaDBA'}->dbc->disconnect_when_inactive(1);
eval { $self->runnable->run(); };
if ($@) {
printf(STDERR ref($self->runnable)." threw exception:\n$@$_");
if($@ =~ /"VOID"/) {
printf(STDERR "this is OK: member_id=%d doesn't have sufficient structure for a search\n", $self->input_id);
} else {
die("$@$_");
}
}
$self->{'comparaDBA'}->dbc->disconnect_when_inactive(0);
return 1; } |
sub runnable
{ my $self = shift(@_);
if (@_) {
$self->{_runnable} = shift;
}
return $self->{_runnable}; } |
sub write_output
{ my( $self) = @_;
foreach my $feature (@{$self->output}) {
if($feature->isa('Bio::EnsEMBL::FeaturePair')) {
$feature->analysis($self->analysis);
}
}
$self->{'comparaDBA'}->get_PeptideAlignFeatureAdaptor->store(@{$self->output}); } |
General documentation
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _