Archive Ensembl HomeArchive Ensembl Home
LoadConsEles.pm
Go to the documentation of this file.
00001 package Bio::EnsEMBL::Compara::Production::EPOanchors::HMMer::LoadConsEles;
00002 
00003 use strict;
00004 use Data::Dumper;
00005 use Bio::EnsEMBL::Registry;
00006 use Bio::EnsEMBL::Utils::Exception qw(throw);
00007 
00008 use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable');
00009 
00010 sub fetch_input {
00011     my ($self) = @_;
00012     my $self_dba = new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor( 
00013                 -host => $self->dbc->host, 
00014                 -pass => $self->dbc->password, 
00015                 -port => $self->dbc->port, 
00016                 -user => $self->dbc->username,
00017                 -dbname => $self->dbc->dbname);
00018     $self->param('self_dba', $self_dba);
00019 }
00020 
00021 sub run {
00022     my ($self) = @_;
00023     my $hcs = eval $self->param("high_coverage_species");
00024     my %HiCvSp;
00025     foreach my$hcs(@$hcs){
00026         $HiCvSp{$hcs}++;
00027     }
00028     my $compara_dba = $self->compara_dba();
00029     my $ce_adaptor = $compara_dba->get_adaptor("ConstrainedElement");
00030     my $mlss_adaptor = $compara_dba->get_adaptor("MethodLinkSpeciesSet");
00031     my $dnafrag_adaptor = $compara_dba->get_adaptor("DnaFrag");
00032     my $gab_adaptor = $compara_dba->get_adaptor("GenomicAlignBlock");
00033     my $genome_db_adaptor = $compara_dba->get_adaptor("GenomeDB");
00034     my $alignments_mlss = $mlss_adaptor->fetch_by_dbID( $self->param('mlssid_of_alignments') );
00035     my ($from_ce_id, $to_ce_id) = @{ $self->param('ce_ids') };
00036     my $self_gab_adaptor = $self->param('self_dba')->get_adaptor("GenomicAlignBlock");
00037     foreach my $ce_id($from_ce_id..$to_ce_id){
00038         my $ce = $ce_adaptor->fetch_by_dbID($ce_id);
00039         next unless($ce);
00040         my ($high_cover_species, $its_a_repeat);
00041         for(my$i=0;$i<@{ $ce->alignment_segments };$i++){
00042             if(exists($HiCvSp{ $ce->alignment_segments->[$i]->[4] })){
00043                 $high_cover_species = $i;
00044                 last;
00045             }
00046         }   
00047         my ($dnafrag_id,$dnafrag_start,$dnafrag_end)= @{ $ce->alignment_segments->[$high_cover_species] };
00048         my $dnafrag = $dnafrag_adaptor->fetch_by_dbID($dnafrag_id);
00049         my $gabs = $gab_adaptor->fetch_all_by_MethodLinkSpeciesSet_DnaFrag(
00050                 $alignments_mlss,$dnafrag,$dnafrag_start,$dnafrag_end, 0, 0, 1);
00051         foreach my $gab(@$gabs){
00052             $gab->dbID($ce_id);
00053             eval { $self_gab_adaptor->store($gab) };
00054             warn $@ if $@;
00055         }
00056     }
00057 }
00058 
00059 1;
00060