sub fetch_input
{ my( $self) = @_;
$self->SUPER::fetch_input;
$self->compara_dba->dbc->disconnect_when_inactive(0);
my $mlssa = $self->compara_dba->get_MethodLinkSpeciesSetAdaptor;
my $dafa = $self->compara_dba->get_DnaAlignFeatureAdaptor;
my $gaba = $self->compara_dba->get_GenomicAlignBlockAdaptor;
$gaba->lazy_loading(0);
$self->get_params($self->analysis->parameters);
$self->get_params($self->input_id);
my $qy_gdb = $self->query_dnafrag->genome_db;
my $tg_gdb = $self->target_dnafrag->genome_db;
print "mlss: ",$self->INPUT_METHOD_LINK_TYPE," ",$qy_gdb->dbID," ",$tg_gdb->dbID,"\n";
my $mlss;
if ($qy_gdb->dbID == $tg_gdb->dbID) {
$mlss = $mlssa->fetch_by_method_link_type_GenomeDBs($self->INPUT_METHOD_LINK_TYPE,
[$qy_gdb]);
} else {
$mlss = $mlssa->fetch_by_method_link_type_GenomeDBs($self->INPUT_METHOD_LINK_TYPE,
[$qy_gdb,
$tg_gdb]);
}
throw("No MethodLinkSpeciesSet for :\n" .
$self->INPUT_METHOD_LINK_TYPE . "\n" .
$qy_gdb->dbID . "\n" .
$tg_gdb->dbID)
if not $mlss;
my $out_mlss = new Bio::EnsEMBL::Compara::MethodLinkSpeciesSet;
$out_mlss->method_link_type($self->OUTPUT_METHOD_LINK_TYPE);
if ($qy_gdb->dbID == $tg_gdb->dbID) {
$out_mlss->species_set([$qy_gdb]);
} else {
$out_mlss->species_set([$qy_gdb, $tg_gdb]);
}
$mlssa->store($out_mlss);
$self->output_MethodLinkSpeciesSet($out_mlss);
my $query_slice = $self->query_dnafrag->slice;
my $target_slice = $self->target_dnafrag->slice;
print STDERR "Fetching all DnaDnaAlignFeatures by query and target...\n";
print STDERR "start fetching at time: ",scalar(localtime),"\n";
if ($self->input_job->retry_count > 0) {
print STDERR "Deleting alignments as it is a rerun\n";
$self->delete_alignments($out_mlss,$self->query_dnafrag,$self->target_dnafrag);
}
my $gabs = $gaba->fetch_all_by_MethodLinkSpeciesSet_DnaFrag_DnaFrag($mlss,$self->query_dnafrag,undef,undef,$self->target_dnafrag);
my $features;
while (my $gab = shift @{$gabs}) {
my ($qy_ga) = $gab->reference_genomic_align;
my ($tg_ga) = @{$gab->get_all_non_reference_genomic_aligns};
unless (defined $self->query_DnaFrag_hash->{$qy_ga->dnafrag->name}) {
$self->query_DnaFrag_hash->{$qy_ga->dnafrag->name} = $qy_ga->dnafrag;
}
unless (defined $self->target_DnaFrag_hash->{$tg_ga->dnafrag->name}) {
$self->target_DnaFrag_hash->{$tg_ga->dnafrag->name} = $tg_ga->dnafrag;
}
my $daf_cigar = $self->daf_cigar_from_compara_cigars($qy_ga->cigar_line,
$tg_ga->cigar_line);
if (defined $daf_cigar) {
my $daf = Bio::EnsEMBL::DnaDnaAlignFeature->new
(-seqname => $qy_ga->dnafrag->name,
-start => $qy_ga->dnafrag_start,
-end => $qy_ga->dnafrag_end,
-strand => $qy_ga->dnafrag_strand,
-hseqname => $tg_ga->dnafrag->name,
-hstart => $tg_ga->dnafrag_start,
-hend => $tg_ga->dnafrag_end,
-hstrand => $tg_ga->dnafrag_strand,
-cigar_string => $daf_cigar);
push @{$features}, $daf;
}
}
print STDERR scalar @{$features}," features at time: ",scalar(localtime),"\n";
$WORKDIR = "/tmp/worker.$$";
unless(defined($WORKDIR) and (-e $WORKDIR)) {
mkdir($WORKDIR, 0777);
}
my %parameters = (-analysis => $self->analysis,
-query_slice => $query_slice,
-target_slices => {$self->target_dnafrag->name => $target_slice},
-query_nib_dir => undef,
-target_nib_dir => undef,
-features => $features,
-workdir => $WORKDIR);
if ($self->QUERY_NIB_DIR and
-d $self->QUERY_NIB_DIR and
-e $self->QUERY_NIB_DIR . "/" . $query_slice->seq_region_name . ".nib") {
$parameters{-query_nib_dir} = $self->QUERY_NIB_DIR;
}
if ($self->TARGET_NIB_DIR and
-d $self->TARGET_NIB_DIR and
-e $self->TARGET_NIB_DIR . "/" . $target_slice->seq_region_name . ".nib") {
$parameters{-target_nib_dir} = $self->TARGET_NIB_DIR;
}
foreach my $program (qw(faToNib lavToAxt axtChain)) {
$parameters{'-' . $program} = $self->BIN_DIR . "/" . $program;
}
my $runnable = Bio::EnsEMBL::Analysis::Runnable::AlignmentChains->new(%parameters);
$self->runnable($runnable); } |