Commit 863868eb authored by Graham McVicker's avatar Graham McVicker
Browse files

Added some sanity checks to ChromosomeAdaptor, Fixed some more bugs in...

Added some sanity checks to ChromosomeAdaptor, Fixed some more bugs in SliceAdaptor in which chromosome id was being used as chromosome name
parent 34cc4563
......@@ -69,6 +69,10 @@ sub fetch_by_dbID {
my $chr = ();
unless(defined $id) {
$self->throw("Chromosome dbID argument required\n");
}
unless(defined $self->{'_chr_cache'} ) {
$self->{'_chr_cache'} = {};
}
......@@ -129,6 +133,11 @@ sub fetch_by_chr_name{
#Convert the name to the dbID
my $dbID = $self->get_dbID_by_chr_name($chr_name);
unless(defined $dbID) {
$self->warn("chromosome with name $chr_name not in database");
return undef;
}
return $self->fetch_by_dbID($dbID);
}
......@@ -202,7 +211,6 @@ sub get_landmark_MarkerFeatures_old{
AND sgp.chr_name='$chr_name'";
$statement =~ s/\s+/ /g;
#print STDERR "Doing Query ... $statement\n";
my $sth = $self->prepare($statement);
$sth->execute;
......@@ -262,7 +270,6 @@ sub get_landmark_MarkerFeatures{
";
$statement =~ s/\s+/ /g;
#print STDERR "Doing Query ... $statement\n";
my $sth = $self->prepare($statement);
$sth->execute;
......
......@@ -76,11 +76,19 @@ use Bio::EnsEMBL::DBSQL::DBAdaptor;
sub fetch_by_chr_start_end {
my ($self,$chr,$start,$end) = @_;
if( !defined $end ) { # Why defined? Is '0' a valid end?
$self->throw("must provide chr, start and end");
unless($chr) {
$self->throw("chromosome name argument must be defined and not ''");
}
if( $start > $end ) {
unless(defined $end) { # Why defined? Is '0' a valid end?
$self->throw("end argument must be defined\n");
}
unless(defined $start) {
$self->throw("start argument must be defined\n");
}
if($start > $end) {
$self->throw("start must be less than end: parameters $chr:$start:$end");
}
......@@ -147,10 +155,11 @@ sub fetch_by_fpc_name {
my $type = $self->db->assembly_type();
my $sth = $self->db->prepare("
SELECT chromosome_id, superctg_ori, MIN(chr_start), MAX(chr_end)
FROM assembly
SELECT chr.name, a.superctg_ori, MIN(a.chr_start), MAX(a.chr_end)
FROM assembly a, chromosome chr
WHERE superctg_name = '$fpc_name'
AND type = '$type'
AND chr.chromosome_id = a.chromosome_id
GROUP by superctg_name
");
......@@ -193,14 +202,16 @@ sub fetch_by_clone_accession{
my $sth = $self->db->prepare("SELECT c.name,
a.chr_start,
a.chr_end,
a.chromosome_id
chr.name
FROM assembly a,
contig c,
clone cl
clone cl,
chromosome chr
WHERE c.clone_id = cl.clone_id
AND cl.name = '$clone'
AND c.contig_id = a.contig_id
AND a.type = '$type'
AND a.type = '$type'
AND chr.chromosome_id = a.chromosome_id
ORDER BY a.chr_start"
);
$sth->execute();
......@@ -399,11 +410,12 @@ sub _get_chr_start_end_of_contig {
my $sth = $self->db->prepare("SELECT c.name,
a.chr_start,
a.chr_end,
a.chromosome_id
FROM assembly a, contig c
chr.name
FROM assembly a, contig c, chromosome chr
WHERE c.name = '$contigid'
AND c.contig_id = a.contig_id
AND a.type = '$type'"
AND a.type = '$type'
AND chr.chromosome_id = a.chromosome_id"
);
$sth->execute();
my ($contig,$start,$end,$chr_name) = $sth->fetchrow_array;
......@@ -438,21 +450,21 @@ sub _get_chr_start_end_of_gene {
(a.chr_start+a.contig_end-e.contig_end)),
if(a.contig_ori=1,(e.contig_end-a.contig_start+a.chr_start),
(a.chr_start+a.contig_end-e.contig_start)),
c.name
chr.name
FROM exon e,
transcript tr,
exon_transcript et,
assembly a,
gene_stable_id gsi,
chromosome c
chromosome chr
WHERE e.exon_id=et.exon_id
AND et.transcript_id =tr.transcript_id
AND a.contig_id=e.contig_id
AND a.type = '$type'
AND tr.gene_id = gsi.gene_id
AND gsi.stable_id = '$geneid'
AND a.chromosome_id = c.chromosome_id"
AND a.chromosome_id = chr.chromosome_id"
);
$sth->execute();
......
Markdown is supported
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