Archive Ensembl HomeArchive Ensembl Home
StoreSequence.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003   Copyright (c) 1999-2012 The European Bioinformatics Institute and
00004   Genome Research Limited.  All rights reserved.
00005 
00006   This software is distributed under a modified Apache license.
00007   For license details, please see
00008 
00009     http://www.ensembl.org/info/about/code_licence.html
00010 
00011 =head1 CONTACT
00012 
00013   Please email comments or questions to the public Ensembl
00014   developers list at <dev@ensembl.org>.
00015 
00016   Questions may also be sent to the Ensembl help desk at
00017   <helpdesk@ensembl.org>.
00018 
00019 =head1 NAME
00020 
00021 Bio::EnsEMBL::Compara::RunnableDB::PairAligner::StoreSequence
00022 
00023 =cut
00024 
00025 =head1 SYNOPSIS
00026 
00027 my $db       = Bio::EnsEMBL::Compara::DBAdaptor->new($locator);
00028 my $runnable = Bio::EnsEMBL::Compara::Production::GenomicAlignBlock::StoreSequence>new (
00029                                                     -db      => $db,
00030                                                     -input_id   => $input_id
00031                                                     -analysis   => $analysis );
00032 $runnable->fetch_input(); #reads from DB
00033 $runnable->run();
00034 $runnable->write_output(); #writes to DB
00035 
00036 =cut
00037 
00038 =head1 DESCRIPTION
00039 
00040 This object gets the DnaFrag objects from a DnaFragChunkSet and stores the sequence (if short enough) in the Compara sequence table
00041 
00042 =cut
00043 
00044 =head1 APPENDIX
00045 
00046 The rest of the documentation details each of the object methods.
00047 Internal methods are usually preceded with a _
00048 
00049 =cut
00050 
00051 package Bio::EnsEMBL::Compara::RunnableDB::PairAligner::StoreSequence;
00052 
00053 use strict;
00054 use Time::HiRes qw(time gettimeofday tv_interval);
00055 
00056 use Bio::EnsEMBL::DBSQL::DBAdaptor;
00057 use Bio::EnsEMBL::DBLoader;
00058 
00059 use Bio::EnsEMBL::Compara::Production::DBSQL::DBAdaptor;
00060 
00061 use Bio::EnsEMBL::Compara::Production::DnaFragChunk;
00062 use Bio::EnsEMBL::Compara::Production::DnaFragChunkSet;
00063 use Bio::EnsEMBL::Compara::Production::DnaCollection;
00064 
00065 use Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor;
00066 
00067 use Bio::EnsEMBL::Analysis::RunnableDB;
00068 use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable');
00069 
00070 =head2 fetch_input
00071 
00072     Title   :   fetch_input
00073     Usage   :   $self->fetch_input
00074     Function:   prepares global variables and DB connections
00075     Returns :   none
00076     Args    :   none
00077 
00078 =cut
00079 
00080 sub fetch_input {
00081     my( $self) = @_;
00082 
00083     #Convert chunkSetID into DnaFragChunkSet object
00084     if(defined($self->param('chunkSetID'))) {
00085     my $chunkset = $self->compara_dba->get_DnaFragChunkSetAdaptor->fetch_by_dbID($self->param('chunkSetID'));
00086     $self->param('dnaFragChunkSet', $chunkset);
00087     }
00088     
00089     #Convert chunkID into DnaFragChunk object
00090     if(defined($self->param('chunkID'))) {
00091     my $chunk = $self->compara_dba->get_DnaFragChunkAdaptor->fetch_by_dbID($self->param('chunkID'));
00092     $self->param('dnaFragChunk', $chunk);
00093     }
00094    
00095     return 1;
00096 }
00097 
00098 
00099 sub run {
00100   my ($self) = @_;
00101 
00102   return 1;
00103 }
00104 
00105 
00106 sub write_output {  
00107   my ($self) = @_;
00108 
00109   #
00110   #Get all the chunks in this dnaFragChunkSet
00111   #
00112   if (defined $self->param('dnaFragChunkSet')) {
00113       my $chunkSet = $self->param('dnaFragChunkSet');
00114       my $chunk_array = $chunkSet->get_all_DnaFragChunks;
00115       
00116       #Store sequence in Sequence table
00117       foreach my $chunk (@$chunk_array) {
00118       my $bioseq = $chunk->bioseq;
00119       if($chunk->sequence_id==0) {
00120           $self->compara_dba->get_DnaFragChunkAdaptor->update_sequence($chunk);
00121       }
00122       }
00123   }
00124 
00125   if (defined $self->param('dnaFragChunk')) {
00126       my $chunk = $self->param('dnaFragChunk');
00127 
00128       #Store sequence in Sequence table
00129       my $bioseq = $chunk->bioseq;
00130       if($chunk->sequence_id==0) {
00131       $self->compara_dba->get_DnaFragChunkAdaptor->update_sequence($chunk);
00132       }
00133   }
00134   return 1;
00135 }
00136 1;