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

no longer relevant

parent 27cb9af0
No related branches found
No related tags found
No related merge requests found
#!/usr/local/bin/perl
use strict;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Clone;
use Bio::EnsEMBL::RawContig;
use Getopt::Long;
my $host = 'ecs1a';
my $dbname = 'mouse_sc011015_alistair';
my $newhost = 'ecs1f';
my $newdbname = 'mouse_denormalize_test2';
my $newpath = 'CHR';
my $dbuser = 'ensadmin';
my $pass = 'ensembl';
my $path = 'sanger_20011015_2';
my $genes = 0;
my $feature = 0;
my $genewise = 0;
my $repeat = 0;
my $chunk = 5000000;
my $threshold = 0;
my $chr_name;
$| = 1;
&GetOptions( 'host:s' => \$host,
'dbuser:s' => \$dbuser,
'dbname:s' => \$dbname,
'genes' => \$genes,
'feature' => \$feature,
'repeat' => \$repeat,
'path=s' => \$path,
'pass:s' => \$pass,
'chunk:n' => \$chunk,
'threshold:n' => \$threshold,
'chrname:s' => \$chr_name,
);
print STDERR "Time in dumpgff " . time . "\n";
my $db = new Bio::EnsEMBL::DBSQL::DBAdaptor(-host => $host,
-user => $dbuser,
-dbname => $dbname,
-pass => $pass);
my $newdb = new Bio::EnsEMBL::DBSQL::DBAdaptor(-host => $newhost,
-user => $dbuser,
-dbname => $newdbname,
-pass => $pass);
print STDERR "Time after db " . time . "\n";
print STDERR "Connected to database\n";
$db->assembly_type($path);
my $slice_adp = $db->get_SliceAdaptor();
my $chr_adp = $db->get_ChromosomeAdaptor();
my @chrs = @{$chr_adp->fetch_all};
my %analysis;
CHR: foreach my $chr (@chrs) {
next CHR unless $chr->name eq $chr_name;
my $length = $chr->length;
print STDERR "Chromosome $chr length $length\n";
my $current = 1;
while ($current <= $length) {
print STDERR "Time before chunk " . time . "\n";
my $end = $current + $chunk -1;
if ($end > $length) {
$end = $length;
}
my $slice = $slice_adp->fetch_by_chr_start_end($chr,
$current,
$end);
my $repeats = $slice->get_all_RepeatFeatures if ($repeat);
my $feat = $slice->get_all_SimilarityFeatures if ($feature);
my $seq = $slice->seq;
my $cloneid = $chr . ".$current-$end";
my $clone = new Bio::EnsEMBL::Clone;
$clone->htg_phase(3);
$clone->id($cloneid);
my $contigid = $cloneid;
my $contig = new Bio::EnsEMBL::RawContig;
$contig->name($contigid);
$contig->seq($seq);
print STDERR "Contig id " . $contigid . "\n";
print STDERR "Repeats are " . scalar(@$repeats) . "\n";
foreach my $f (@$repeats) {
$f->contig($contig);
}
foreach my $f (@$feat) {
if ($f->analysis->db ne "") {
if ($f->score > $threshold) {
$f->contig($contig);
$f->analysis->program_version(1);
}
} else {
$f->analysis->program_version(1);
$f->contig($contig);
}
}
$clone->add_Contig($contig);
eval {
$newdb->get_CloneAdaptor->store($clone);
print STDERR "Written ".$clone->id." scaffold into db\n";
};
if( $@ ) {
print STDERR "Could not write clone into database, error was $@\n";
} else {
my $contig =
$newdb->get_RawContigContigAdaptor->fetch_by_name($contigid);
# put into the golden path
my $len = ($end - $current + 1);
my $query = "insert into assembly values('$chr','$chr'," . $contig->dbID . ",$current,$end,1,$len,1,$len,1,'$newpath')";
my $sth = $newdb->prepare($query);
my $res = $sth->execute;
}
$current += $chunk;
}
}
sub print_analysis {
my ($analysis) = @_;
print STDERR "Analysis\n";
print STDERR "Id " . $analysis->id . "\n";
print STDERR "Db" . $analysis->db . "\n";
print STDERR "Db_file " . $analysis->db_file . "\n";
print STDERR "Db_version " . $analysis->db_version . "\n";
print STDERR "Program " . $analysis->program . "\n";
print STDERR "Program_version " . $analysis->program_version . "\n";
print STDERR "Program_file " . $analysis->program_file . "\n";
print STDERR "Gff_source " . $analysis->gff_source . "\n";
print STDERR "Gff_feature " . $analysis->gff_feature . "\n";
print STDERR "Module " . $analysis->module . "\n";
print STDERR "Module_version " . $analysis->module_version . "\n";
print STDERR "Parameters " . $analysis->parameters . "\n";
print STDERR "Created " . $analysis->created . "\n";
print STDERR "Logic_name " . $analysis->logic_name . "\n";
}
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