Archive Ensembl HomeArchive Ensembl Home
CreateRules.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::CreateRules
00011 
00012 =cut
00013 
00014 =head1 SYNOPSIS
00015 
00016 my $db      = Bio::EnsEMBL::Compara::DBAdaptor->new($locator);
00017 my $repmask = Bio::EnsEMBL::Pipeline::RunnableDB::CreateRules->new (
00018                                                     -db      => $db,
00019                                                     -input_id   => $input_id
00020                                                     -analysis   => $analysis );
00021 $repmask->fetch_input(); #reads from DB
00022 $repmask->run();
00023 $repmask->output();
00024 $repmask->write_output(); #writes to DB
00025 
00026 =cut
00027 
00028 =head1 DESCRIPTION
00029 
00030 =cut
00031 
00032 =head1 CONTACT
00033 
00034 Describe contact details here
00035 
00036 =cut
00037 
00038 =head1 APPENDIX
00039 
00040 The rest of the documentation details each of the object methods.
00041 Internal methods are usually preceded with a _
00042 
00043 =cut
00044 
00045 package Bio::EnsEMBL::Compara::Production::GenomicAlignBlock::CreateRules;
00046 
00047 use strict;
00048 
00049 use Bio::EnsEMBL::DBSQL::DBAdaptor;
00050 use Bio::EnsEMBL::Pipeline::RunnableDB;
00051 use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor;
00052 use Bio::EnsEMBL::Hive;
00053 
00054 use vars qw(@ISA);
00055 
00056 @ISA = qw(Bio::EnsEMBL::Pipeline::RunnableDB);
00057 
00058 sub fetch_input {
00059   my $self = shift;
00060 
00061   $self->throw("No input_id") unless defined($self->input_id);
00062   $self->throw("Improper formated input_id") unless ($self->input_id =~ /{/);
00063 
00064   return 1;
00065 }
00066 
00067 
00068 sub run
00069 {
00070   return 1;
00071 }
00072 
00073 
00074 sub write_output
00075 {
00076   my $self = shift;
00077 
00078   my $input_hash = eval($self->input_id);
00079   $self->{'from_prefix'} = $input_hash->{'from'};
00080   $self->{'to_prefix'} = $input_hash->{'to'};
00081 
00082   $self->createBlastRules();
00083   return 1;
00084 }
00085 
00086 
00087 
00088 
00089 ##################################
00090 #
00091 # subroutines
00092 #
00093 ##################################
00094 
00095 sub createBlastRules
00096 {
00097   my $self = shift;
00098 
00099   my $dataflowRuleDBA = $self->db->get_DataflowRuleAdaptor;
00100   my $analysisList = $self->db->get_AnalysisAdaptor->fetch_all();
00101 
00102   my @fromList = ();
00103 
00104   foreach my $analysis (@{$analysisList}) {
00105     next unless($analysis->logic_name =~ /^$self->{'from_prefix'}/);
00106     push @fromList, $analysis;
00107     print("FROM: ", $analysis->logic_name,"\n");
00108   }
00109 
00110   foreach my $to_analysis (@{$analysisList}) {
00111     next unless($to_analysis->logic_name =~ /^$self->{'to_prefix'}/);
00112     next if($to_analysis->logic_name eq $self->{'to_prefix'});
00113     foreach my $from_analysis (@fromList) {
00114       print("  ",$from_analysis->logic_name," -> ", $to_analysis->logic_name, "\n");
00115       $dataflowRuleDBA->create_rule($from_analysis, $to_analysis);
00116     }
00117   }
00118 
00119   foreach my $from_analysis (@fromList) {
00120     my $stats = $from_analysis->stats;
00121     $stats->status('LOADING');
00122     $stats->update;
00123   }
00124 }
00125 
00126 
00127 1;