Archive Ensembl HomeArchive Ensembl Home
DumpRepeats.pm
Go to the documentation of this file.
00001 package Bio::EnsEMBL::Compara::Production::EPOanchors::HMMer::DumpRepeats;
00002 
00003 use strict;
00004 use Data::Dumper;
00005 use Bio::EnsEMBL::Registry;
00006 
00007 use base ('Bio::EnsEMBL::Compara::RunnableDB::BaseRunnable');
00008 
00009 
00010 sub fetch_input {
00011     my ($self) = @_;
00012     Bio::EnsEMBL::Registry->load_registry_from_url( $self->param('core_db_url') );
00013 }
00014 
00015 sub write_output {
00016     my ($self) = @_;
00017     my $dump_file = $self->param('dump_file'); 
00018     my($species, $assembly) = ($self->param('species'), $self->param('assembly'));
00019     my $dump_dir = $self->param('repeat_dump_dir') . "/" . $species;
00020     mkdir( $dump_dir ) or warn $!;
00021     my $slice_adaptor = Bio::EnsEMBL::Registry->get_adaptor($species, "core", "Slice");
00022     my $dump_file = $dump_dir . '/' . $assembly . ".repeats";
00023     return if (-e $dump_file && ! -z $dump_file);
00024     open(IN, ">$dump_file") or die $!;
00025     my $rfa = Bio::EnsEMBL::Registry->get_adaptor($species, "core", "RepeatFeature");   
00026     my $compara_dba = $self->compara_dba();
00027     my $dnafrag_adaptor = $compara_dba->get_adaptor("DnaFrag");
00028     foreach my $slice( @{ $slice_adaptor->fetch_all("toplevel") } ){
00029         my $dnafrag = $dnafrag_adaptor->fetch_by_Slice($slice);
00030         foreach my $repeat( @{ $rfa->fetch_all_by_Slice($slice) } ){
00031             print IN join("\t", $dnafrag->dbID, $repeat->start, $repeat->end), "\n";
00032         }
00033     }
00034     close(IN);
00035 }
00036 
00037 1;