Skip to content
Snippets Groups Projects
Commit 19c2f5dc authored by Emmanuel Mongin's avatar Emmanuel Mongin
Browse files

New schema update

parent e26b2055
No related branches found
No related tags found
No related merge requests found
use strict;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::SeqIO;
use Bio::EnsEMBL::DBSQL::ProteinAdaptor;
use Bio::EnsEMBL::Utils::Eprof('eprof_start','eprof_end','eprof_dump');
my $host = 'ecs1b';
my $dbuser = 'ensro';
my $dbname = 'anopheles_arne_core_9_2';
my $dbpass = undef;
my $path = 'NOTRE_DAME';
my $port;# = 19322;
my $port;
print STDERR "Connecting to $host, $dbname\n";
......@@ -45,9 +41,6 @@ while(<BAC>) {
my $sc = $array[2];
my $start = $array[8];
my $end = $array[9];
my $status = $array[11];
# print STDERR "BO:$sc\t$array[4]\t$start\t$end\n";
my $query = "SELECT
if(a.superctg_ori=1,($start-a.superctg_start+a.chr_start),
......@@ -55,7 +48,7 @@ while(<BAC>) {
if(a.superctg_ori=1,($end-a.superctg_start+a.chr_start),
(a.chr_start+a.superctg_end-$start)),
c.name FROM assembly a, chromosome c WHERE a.superctg_name = '$sc' and c.chromosome_id = a.chromosome_id";
# print STDERR "$query\n";
my $sth = $db->prepare($query);
$sth->execute();
my @res = $sth->fetchrow_array();
......
use strict;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::DBLoader;
use Getopt::Long;
my $dbname;
my $dbhost;
my $dbuser;
my $dbpass;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::DBSQL::ProteinAdaptor;
my $host = 'ecs1b';
my $dbuser = 'ensro';
my $dbname = 'anopheles_arne_core_9_2';
my $dbpass = undef;
my $path = 'NOTRE_DAME';
my $port;
my $mapping;
my $matepairs;
my %map;
my %seen;
#perl format_matepairs.pl -mapping /acari/work4/mongin/anopheles_gambiae/mapacs/celera2uid2embl.txt -matepairs /acari/work4/mongin/anopheles_gambiae/matepairs/mosquito_scaffold_matepair.txt
&GetOptions(
'db:s' => \$dbname,
'dbhost:s'=> \$dbhost,
'dbhost:s'=> \$host,
'dbuser:s'=> \$dbuser,
'mapping:s'=>\$mapping,
'matepairs:s'=>\$matepairs
);
print STDERR "Connecting to $host, $dbname\n";
#perl format_matepairs.pl -db anopheles_gambiae_core_6_1 -dbhost ecs1d -dbuser ensro -mapping /acari/work4/mongin/anopheles_gambiae/matepairs/ga_name_scf_uid_lookup.txt -matepairs /acari/work4/mongin/anopheles_gambiae/matepairs/mosquito_scaffold_matepair.txt
my %map;
my %seen;
my $db = new Bio::EnsEMBL::DBSQL::DBAdaptor(
'-host' => $host,
'-user' => $dbuser,
'-dbname' => $dbname,
'-pass' => $dbpass,
'-port' => $port
);
my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-user => $dbuser,
-dbname => $dbname,
-host => $dbhost
);
open (MAP,"$mapping") || die "Can't open mapping (celera uid to celera stable ids): $mapping\n";
......@@ -37,7 +43,7 @@ while (<MAP>) {
chomp;
my @array = split;
$map{$array[1]} = $array[0];
$map{$array[1]} = $array[2];
}
......@@ -57,7 +63,7 @@ while (<MATE>) {
#print STDERR "Celera internal id $array[0] not defined in mapping\n";
}
if ($array[12] ne "happy") {
#if ($array[12] ne "happy") {
my $tag = $array[12];
......@@ -83,42 +89,45 @@ while (<MATE>) {
}
my ($chr_start,$chr_end,$ori) = &fpc2chr($cra_id,$start,$end);
my ($chr_start,$chr_end,$ori,$chr_id) = &fpc2chr($cra_id,$start,$end);
my $chr_id;
# my $chr_id;
if (! defined $seen{$cra_id}) {
($chr_id) = &contig2chr($cra_id);
$seen{$cra_id} = $chr_id;
}
#if (! defined $seen{$cra_id}) {
# ($chr_id) = &contig2chr($cra_id);
# $seen{$cra_id} = $chr_id;
#}
print "$seen{$cra_id}\t$chr_start\t$chr_end\t1\t$tag\n";
print "$chr_id\t$chr_start\t$chr_end\t1\t$tag\n";
}
#}
}
sub fpc2chr {
my ($cra_id,$start,$end) = @_;
my ($sc,$start,$end) = @_;
$start = $start + 1;
$end = $end;
my $command = "select fpcctg_ori,IF(fpcctg_ori=1,($start+chr_start-fpcctg_start), (chr_start+fpcctg_end-$end)) as chrom_start, IF(fpcctg_ori=1,($end+chr_start-fpcctg_start), (chr_start+fpcctg_end-$start)) as chrom_end from static_golden_path where fpcctg_name = '$cra_id' and fpcctg_start <= $start and fpcctg_end >= $start";
my $query = "SELECT
if(a.superctg_ori=1,($start-a.superctg_start+a.chr_start),
(a.chr_start+a.superctg_end-$end)),
if(a.superctg_ori=1,($end-a.superctg_start+a.chr_start),
(a.chr_start+a.superctg_end-$start)),
c.name, a.superctg_ori FROM assembly a, chromosome c WHERE a.superctg_name = '$sc' and c.chromosome_id = a.chromosome_id";
my $sth = $db->prepare($command);
my $sth = $db->prepare($query);
$sth->execute;
my ($ori,$chr_start,$chr_end) = $sth->fetchrow;
my ($chr_start,$chr_end,$name,$ori) = $sth->fetchrow;
if ($chr_start == 0) {
print "ID: $cra_id\tSTART: $start\tEND: $end\tCHR_START: $chr_start\tCHR_END: $chr_end\n";
print "$command\n";
print "ID: $sc\tSTART: $start\tEND: $end\tCHR_START: $chr_start\tCHR_END: $chr_end\n";
print "$query\n";
}
return($chr_start,$chr_end,$ori);
return($chr_start,$chr_end,$ori,$name);
}
......@@ -126,7 +135,11 @@ sub fpc2chr {
sub contig2chr {
my ($cra_id) = @_;
my $command = "select ch.name from contig c, chromosome ch where c.id like '$cra_id%' and c.chromosomeId = ch.chromosome_id";
# my $command = "select ch.name from contig c, chromosome ch where c.contig_id like '$cra_id%' and c.chromosome_id = ch.chromosome_id";
my $command = "select c.name from chromosome c, assembly a where a.superctg_name = '$cra_id' and a.chromosome_id = c.chromosome_id";
print STDERR "$command\n";
my $sth = $db->prepare($command);
$sth->execute;
......
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