Archive Ensembl HomeArchive Ensembl Home
HomologyGroupingFactory.pm
Go to the documentation of this file.
00001 #
00002 # You may distribute this module under the same terms as perl itself
00003 #
00004 # POD documentation - main docs before the code
00005 
00006 =pod 
00007 
00008 =head1 NAME
00009 
00010 Bio::EnsEMBL::Compara::RunnableDB::ProteinTrees::HomologyGroupingFactory
00011 
00012 =cut
00013 
00014 =head1 SYNOPSIS
00015 
00016 my $aa = $sdba->get_AnalysisAdaptor;
00017 my $analysis = $aa->fetch_by_logic_name('HomologyGroupingFactory');
00018 my $rdb = new Bio::EnsEMBL::Compara::RunnableDB::ProteinTrees::HomologyGroupingFactory(
00019                          -input_id   => [[1,2,3,14],[4,13],[11,16]]
00020                          -analysis   => $analysis);
00021 
00022 $rdb->fetch_input
00023 $rdb->run;
00024 
00025 =cut
00026 
00027 =head1 DESCRIPTION
00028 
00029 This is a homology compara specific runnableDB, that based on an input
00030 of arrayrefs of genome_db_ids, creates Homology_dNdS jobs in the hive 
00031 analysis_job table.
00032 
00033 =cut
00034 
00035 =head1 CONTACT
00036 
00037 abel@ebi.ac.uk, jessica@ebi.ac.uk
00038 
00039 =cut
00040 
00041 =head1 APPENDIX
00042 
00043 The rest of the documentation details each of the object methods. 
00044 Internal methods are usually preceded with a _
00045 
00046 =cut
00047 
00048 package Bio::EnsEMBL::Compara::RunnableDB::ProteinTrees::HomologyGroupingFactory;
00049 
00050 use strict;
00051 
00052 use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable');
00053 
00054 
00055 sub param_defaults {
00056     return {
00057             'group_size'         => 20,
00058     };
00059 }
00060 
00061 
00062 sub fetch_input {
00063     my $self = shift @_;
00064 
00065     my $mlss_id = $self->param('mlss_id') or die "'mlss_id' is an obligatory parameter";
00066 
00067     my $sql = "SELECT homology_id FROM homology WHERE method_link_species_set_id = ?";
00068     my $sth = $self->compara_dba->dbc->prepare($sql);
00069 
00070     my @homology_ids = ();
00071     $sth->execute($mlss_id);
00072     while( my ($homology_id) = $sth->fetchrow() ) {
00073         push @homology_ids, $homology_id;
00074     }
00075 
00076     $self->param('inputlist', \@homology_ids);
00077 }
00078 
00079 
00080 sub write_output {
00081     my $self = shift @_;
00082 
00083     my $inputlist  = $self->param('inputlist');
00084     my $group_size = $self->param('group_size');
00085 
00086     while (@$inputlist) {
00087         my @job_array = splice(@$inputlist, 0, $group_size);
00088         $self->dataflow_output_id( { 'ids' => [@job_array] }, 2);
00089     }
00090 }
00091 
00092 1;