Skip to content
Snippets Groups Projects
Commit f88c96ae authored by Graham McVicker's avatar Graham McVicker
Browse files

out of date

parent 92b62a28
No related branches found
No related tags found
No related merge requests found
#!/usr/local/bin/perl
BEGIN {
unshift(@INC,"../ensembl/modules");
unshift(@INC,"../bioperl-live");
}
use Bio::EnsEMBL::DBLoader;
use Bio::EnsEMBL::DBSQL::Obj;
use Bio::EnsEMBL::EMBL_Dump;
use strict;
use Bio::EnsEMBL::Utils::Eprof qw( eprof_start eprof_end eprof_dump);
my $dbuser = 'ensro';
my $dbname = 'ensembl080';
#my $host = 'obi-wan';
#my $host = 'cgisrv4';
my $host = 'ensrv1';
my $dbpass = undef;
sub get_locator {
return "Bio::EnsEMBL::DBSQL::Obj/host=$host;dbname=$dbname;user=$dbuser;pass=$dbpass";
}
$|=1;
my $outpath = '/mysql/dumps/';
my @clones = ();
my @contigs;
my $db;
my $count = 0;
eval {
my $locator = get_locator();
$db = Bio::EnsEMBL::DBLoader->new($locator);
};
if( $@ ) {
print STDERR "Apologies. An exception occured: $@\n";
exit;
}
@clones = &find_clones($db);
if ($ARGV[1] =~ /start=(.*)/){
while ($clones[0] ne $1){
shift(@clones);
}
}
for (0..7){ shift @clones;}
my $num = scalar @clones;
print STDERR "Writing flat files for $num clones...\n";
die "No clones!\n" unless (@clones);
my $emblout;
my ($clone,$as);
HOP: foreach my $c (@clones){
$count++;
#&eprof_dump(\*STDERR);
eval{
$clone = $db->get_Clone($c);
$as = $clone->virtualcontig;
};
if ($@){
print STDERR "Exception in embldump for $c!: $@\n";
next;
}
eval{
&eprof_start('make_db_flatfiles - genbank');
my $filename = "$outpath/genbank/$c.genbank";
print STDERR "Creating genbank dump file $count: $filename...\n";
open (FLAT, ">$filename") or die "Cannot create flat file ($filename): $!\n";
&eprof_start('make_db_flatfiles - add_comments');
&Bio::EnsEMBL::EMBL_Dump::add_ensembl_comments($as);
&eprof_end('make_db_flatfiles - add_comments');
&eprof_start('make_db_flatfiles - bio_seq');
my $gbout = Bio::SeqIO->new( '-format' => 'GenBank', -fh => \*FLAT);
&eprof_end('make_db_flatfiles - bio_seq');
&eprof_start('make_db_flatfiles - ensembl_dump');
&Bio::EnsEMBL::EMBL_Dump::ensembl_annseq_output($gbout);
&eprof_end('make_db_flatfiles - ensembl_dump');
# genbank format - the ID line is wrong. Fall back to locus
#$gbout->_id_generation_func(undef);
#$gbout->_ac_generation_func(undef);
#$as->accession($clone->id());
#$as->division("PRI");
&eprof_start('make_db_flatfiles - write_seq');
$gbout->write_seq($as);
&eprof_end('make_db_flatfiles - write_seq');
close(FLAT);
&eprof_end('make_db_flatfiles - genbank');
my $filename = "$outpath/embl/$c.embl";
print STDERR "Creating embldump file $count: $filename...\n";
open (FLAT, ">$filename") or die "Cannot create flat file ($filename): $!\n";
my $emblout = Bio::SeqIO->new( '-format' => 'EMBL', -fh => \*FLAT);
&Bio::EnsEMBL::EMBL_Dump::ensembl_annseq_output($emblout);
$emblout->write_seq($as);
close(FLAT);
};
if ($@){
print STDERR "Exception in embldump for $c!: $@\n";
next;
}
}
1;
############################################################################
sub find_clones {
my ($db) = @_;
my @clones;
my $sql = "";
if ($ARGV[0] eq 'all'){
$sql = "select id from clone";
}
elsif ($ARGV[0] =~ /clone=(.*)/){
$sql = "select id from clone where id= '$1'";
}
else{
$sql = "select id from clone where stored>'2000-05-04 17:22:05'";
}
my $sth = $db->prepare("$sql");
my $rv = $sth->execute();
while (my $row = $sth->fetchrow) {
push (@clones,$row);
}
return @clones;
}
############################################################################
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment