diff --git a/modules/Bio/EnsEMBL/DBSQL/AssemblyMapperAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/AssemblyMapperAdaptor.pm index 8cec47afb5ab279fc0ee6904f67653d060c7b922..dc11a4b34851b5c34be33561539f9dd9d4147157 100644 --- a/modules/Bio/EnsEMBL/DBSQL/AssemblyMapperAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/AssemblyMapperAdaptor.pm @@ -494,12 +494,16 @@ sub _seq_region_name_to_id { $sth->bind_param(2,$cs_id,SQL_INTEGER); $sth->execute(); - if(!$sth->rows() == 1) { - throw("Ambiguous or non-existant seq_region [$sr_name] " . - "in coord system $cs_id"); + my @row = $sth->fetchrow_array(); + unless ( @row ) { + throw("No-existent seq_region [$sr_name] in coord system $cs_id"); + } + my @more = $sth->fetchrow_array(); + if ( @more ) { + throw("Ambiguous seq_region [$sr_name] in coord system $cs_id"); } - my ($sr_id, $sr_length) = $sth->fetchrow_array(); + my ($sr_id, $sr_length) = @row; $sth->finish(); $arr = [ $sr_id, $sr_name, $cs_id, $sr_length ]; @@ -532,11 +536,12 @@ sub _seq_region_id_to_name { $sth->bind_param(1,$sr_id,SQL_INTEGER); $sth->execute(); + my @row = $sth->fetchrow_array(); if(!$sth->rows() == 1) { throw("non-existant seq_region [$sr_id]"); } - my ($sr_name, $sr_length, $cs_id) = $sth->fetchrow_array(); + my ($sr_name, $sr_length, $cs_id) = @row; $sth->finish(); $arr = [ $sr_id, $sr_name, $cs_id, $sr_length ]; @@ -615,6 +620,8 @@ sub register_component { $sth->bind_param(2,$asm_cs_id,SQL_INTEGER); $sth->execute(); + my @rows = $sth->fetchrow_array(); + if($sth->rows() == 0) { #this component is not used in the assembled part i.e. gap $asm_mapper->register_component($cmp_seq_region); @@ -627,6 +634,7 @@ sub register_component { # chromosome:EquCab2#contig ( use'#' for multiple mappings ) # chromosome:EquCab2|contig ( use '|' delimiter for 1-1 mappings ) # + my @more = $sth->fetchrow_array(); if($sth->rows() != 1) { $sth->finish(); throw("Multiple assembled regions for single " . @@ -636,7 +644,7 @@ sub register_component { } my ($asm_start, $asm_end, $asm_seq_region_id, - $asm_seq_region, $asm_seq_region_length) = $sth->fetchrow_array(); + $asm_seq_region, $asm_seq_region_length) = @rows; my $arr = [ $asm_seq_region_id, $asm_seq_region, $asm_cs_id, $asm_seq_region_length ]; diff --git a/modules/Bio/EnsEMBL/DBSQL/MiscSetAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/MiscSetAdaptor.pm index d615f2d7de073c54f07d108a06b72df818de1400..dfc0b0e041d70e95ca6d165d9f5bec196bc3ae87 100644 --- a/modules/Bio/EnsEMBL/DBSQL/MiscSetAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/MiscSetAdaptor.pm @@ -260,12 +260,12 @@ sub store { $sth2->bind_param(1,$ms->code,SQL_VARCHAR); $sth2->execute(); + ($dbID) = $sth2->fetchrow_array(); + if($sth2->rows() != 1) { throw("Could not retrieve or store MiscSet, code=[".$ms->code."]\n". "Wrong database user/permissions?"); } - - ($dbID) = $sth2->fetchrow_array(); } else { $dbID = $sth->{'mysql_insertid'}; } diff --git a/modules/Bio/EnsEMBL/DBSQL/ProteinFeatureAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/ProteinFeatureAdaptor.pm index 158c1b25a15fbffc27011e240540a7765fd2d25d..5e9269b1a3f699c2c3aff413b10368592131c7c9 100755 --- a/modules/Bio/EnsEMBL/DBSQL/ProteinFeatureAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/ProteinFeatureAdaptor.pm @@ -150,14 +150,15 @@ sub fetch_by_dbID { $sth->bind_param(1, $protfeat_id, SQL_INTEGER); my $res = $sth->execute(); + + my ($start, $end, $analysis_id, $score, $perc_ident, $pvalue, $hstart, + $hend, $hseqname, $idesc, $interpro_ac) = $sth->fetchrow_array(); - if ($sth->rows == 0) { - $sth->finish(); - return undef; + if($sth->rows == 0) { + $sth->finish(); + return undef; } - my ($start, $end, $analysis_id, $score, $perc_ident, $pvalue, $hstart, $hend, $hseqname, $idesc, $interpro_ac) = $sth->fetchrow_array(); - $sth->finish(); my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_dbID($analysis_id); diff --git a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm index 327b0eb922f3b54c5b9adff7b0fcd98fe8d8ca23..ca4c883c1a24dabea20a975540d2c448250fe68e 100644 --- a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm @@ -299,10 +299,10 @@ sub fetch_by_region { } $sth->execute(); + my @row = $sth->fetchrow_array(); + $sth->finish(); - if ( $sth->rows() == 0 ) { - $sth->finish(); - + unless ( @row ) { # try synonyms my $syn_sql_sth = $self->prepare("select s.name, cs.name, cs.version from seq_region s join seq_region_synonym ss using (seq_region_id) join coord_system cs using (coord_system_id) where ss.synonym = ? and cs.species_id =?"); @@ -407,9 +407,7 @@ sub fetch_by_region { } else { my ( $id, $cs_id ); - ( $seq_region_name, $id, $length, $cs_id ) = - $sth->fetchrow_array(); - $sth->finish(); + ( $seq_region_name, $id, $length, $cs_id ) = @row; # cache to speed up for future queries my $arr = [ $id, $seq_region_name, $cs_id, $length ]; @@ -832,7 +830,8 @@ sub fetch_by_seq_region_id { $sth->bind_param( 1, $seq_region_id, SQL_INTEGER ); $sth->execute(); - if ( $sth->rows() == 0 ) { + my @row = $sth->fetchrow_array(); + unless ( @row ) { # This could have been an old seq region id so see if we can # translate it into a more recent version. if($check_prior_ids) { @@ -845,7 +844,7 @@ sub fetch_by_seq_region_id { return undef; } - ( $name, $cs_id, $length ) = $sth->fetchrow_array(); + ( $name, $cs_id, $length ) = @row; $sth->finish(); $cs = $self->db->get_CoordSystemAdaptor->fetch_by_dbID($cs_id); @@ -914,14 +913,16 @@ sub get_seq_region_id { $sth->bind_param(2,$cs_id,SQL_INTEGER); $sth->execute(); - if($sth->rows() != 1) { - throw("Non existant or ambigous seq_region:\n" . - " coord_system=[$cs_id],\n" . - " name=[$seq_region_name],\n"); - + my @row = $sth->fetchrow_array(); + unless ( @row ) { + throw("No-existent seq_region [$seq_region_name] in coord system [$cs_id]"); + } + my @more = $sth->fetchrow_array(); + if ( @more ) { + throw("Ambiguous seq_region [$seq_region_name] in coord system [$cs_id]"); } - my($seq_region_id, $length) = $sth->fetchrow_array(); + my($seq_region_id, $length) = @row; $sth->finish(); #cache information for future requests @@ -2618,13 +2619,13 @@ sub fetch_by_clone_accession{ $sth->bind_param( 1, $self->species_id(), SQL_INTEGER ); $sth->execute(); + ($name) = $sth->fetchrow_array(); + if(!$sth->rows()) { $sth->finish(); throw("Clone $name not found in database"); } - ($name) = $sth->fetchrow_array(); - $sth->finish(); }