ProcessGenome.pm
Go to the documentation of this file.
00001 
00002 =head1 LICENSE
00003 
00004 Copyright [2009-2016] EMBL-European Bioinformatics Institute
00005 
00006 Licensed under the Apache License, Version 2.0 (the "License");
00007 you may not use this file except in compliance with the License.
00008 You may obtain a copy of the License at
00009 
00010      http://www.apache.org/licenses/LICENSE-2.0
00011 
00012 Unless required by applicable law or agreed to in writing, software
00013 distributed under the License is distributed on an "AS IS" BASIS,
00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 See the License for the specific language governing permissions and
00016 limitations under the License.
00017 
00018 =head1 CONTACT
00019 
00020   Please email comments or questions to the public Ensembl
00021   developers list at <dev@ensembl.org>.
00022 
00023   Questions may also be sent to the Ensembl help desk at
00024   <helpdesk@ensembl.org>.
00025 
00026 =head1 NAME
00027 
00028 Bio::EnsEMBL::MetaData::Pipeline::ProcessGenome
00029 
00030 =head1 DESCRIPTION
00031 
00032 Runnable to process a species
00033 
00034 =head1 AUTHOR
00035 
00036 Dan Staines
00037 
00038 =cut
00039 
00040 use warnings;
00041 use strict;
00042 
00043 package Bio::EnsEMBL::MetaData::Pipeline::ProcessGenome;
00044 
00045 use base qw/Bio::EnsEMBL::Production::Pipeline::Base/;
00046 
00047 use Bio::EnsEMBL::MetaData::MetaDataProcessor;
00048 use Bio::EnsEMBL::MetaData::DBSQL::MetaDataDBAdaptor;
00049 use Bio::EnsEMBL::MetaData::AnnotationAnalyzer;
00050 
00051 use Carp;
00052 use Log::Log4perl qw(:easy);
00053 Log::Log4perl->easy_init($INFO);
00054 my $log = get_logger();
00055 
00056 sub param_defaults {
00057   my ($self) = @_;
00058   return {};
00059 }
00060 
00061 sub fetch_input {
00062   my ($self) = @_;
00063   return;
00064 }
00065 
00066 sub run {
00067   my ($self)  = @_;
00068   my $dbas    = {};
00069   my $species = $self->param_required('species');
00070 
00071   return if $species eq 'Ancestral sequences';
00072 
00073   $log->info("Finding DBAdaptors for $species");
00074   for my $type (qw/core variation otherfeatures funcgen/) {
00075     $dbas->{$type} = $self->get_DBAdaptor($type);
00076   }
00077   $log->info("Connecting to info database");
00078   my $dba =
00079     Bio::EnsEMBL::MetaData::DBSQL::MetaDataDBAdaptor->new(
00080                                              -USER =>,
00081                                              $self->param('info_user'),
00082                                              -PASS =>,
00083                                              $self->param('info_pass'),
00084                                              -HOST =>,
00085                                              $self->param('info_host'),
00086                                              -PORT =>,
00087                                              $self->param('info_port'),
00088                                              -DBNAME =>,
00089                                              $self->param('info_dbname')
00090     );
00091   my $gdba = $dba->get_GenomeInfoAdaptor();
00092 
00093   # set the release to use when storing genomes
00094   my $rdba = $dba->get_DataReleaseInfoAdaptor();
00095   my $release;
00096   if ( defined $self->param('eg_release') ) {
00097     $release =
00098       $rdba->fetch_by_ensembl_genomes_release(
00099                                            $self->param('eg_release') );
00100   }
00101   else {
00102     $release =
00103       $rdba->fetch_by_ensembl_release( $self->param('release') );
00104   }
00105   $gdba->data_release($release);
00106 
00107   my $upd = $self->param('force_update') || 0;
00108 
00109   my $opts = { -INFO_ADAPTOR => $gdba,
00110                -ANNOTATION_ANALYZER =>
00111                  Bio::EnsEMBL::MetaData::AnnotationAnalyzer->new(),
00112                -COMPARA      => 0,
00113                -CONTIGS      => $self->param('contigs') || 1,
00114                -FORCE_UPDATE => $upd,
00115                -VARIATION    => $self->param('variation') || 1 };
00116 
00117   my $processor =
00118     Bio::EnsEMBL::MetaData::MetaDataProcessor->new(%$opts);
00119 
00120   $log->info("Processing $species");
00121 
00122   my $md = $processor->process_genome($dbas);
00123 
00124   if ( defined $md->dbID() && $upd == 1 ) {
00125     $log->info( "Updating " . $md->name() );
00126     $gdba->update($md);
00127   }
00128   elsif ( !defined $md->dbID() ) {
00129     $log->info( "Storing " . $md->name() );
00130     $gdba->store($md);
00131   }
00132 
00133   $log->info("Completed processing $species");
00134   return;
00135 } ## end sub run
00136 
00137 sub write_output {
00138   my ($self) = @_;
00139   return;
00140 }
00141 
00142 1;
00143