[BioSQL-l] Query Problem.

Marc Logghe Marc.Logghe at devgen.com
Mon Jan 5 08:46:17 EST 2004


Hi,
I'll try to tackle this one. But before starting off in debug mode, could you please verify whether the API built query is OK ?
This piece of code yields perfect SQL:
my $adp = $db->get_object_adaptor('Bio::SeqFeatureI');
$adp->verbose(1);
my $query = Bio::DB::Query::BioQuery->new(
                -datacollections => [
                    "Bio::Annotation::SimpleValue  term",
                    "Bio::SeqFeatureI<=>Bio::Annotation::SimpleValue  f"
                ],
                -where => ["term::tagname = 'other_name'"]
);
The resulting SQL looks like this:
SELECT seqfeature.oid, seqfeature.display_name, seqfeature.rank, seqfeature.ent_oid, seqfeature.type_trm_oid, seqfeature.source_trm_oid
FROM term, seqfeature, seqfeature_qualifier_value f
WHERE seqfeature.oid = f.fea_oid 
AND term.oid = f.trm_oid 
AND term.name = 'other_name'

Of course, here you get all the features containing a feature which has a 'other_name' tag.
When one is only interested in the 'other_name' tags with value 'mig-11' the only thing which should be added to the previous query is:
AND f.value LIKE 'mig-11'

I hoped to achieve this with the following API query:
my $adp = $db->get_object_adaptor('Bio::SeqFeatureI');
$adp->verbose(1);
my $query = Bio::DB::Query::BioQuery->new(
                -datacollections => [
                    "Bio::Annotation::SimpleValue  term",
                    "Bio::SeqFeatureI<=>Bio::Annotation::SimpleValue  f"
                ],
                -where => ["term::tagname = 'other_name'", "term::value like 'mig-11'"]
);

This does not work because the query does not make sense:
SELECT seqfeature.oid, seqfeature.display_name, seqfeature.rank, seqfeature.ent_oid, seqfeature.type_trm_oid, seqfeature.source_trm_oid 
FROM term, seqfeature, seqfeature_qualifier_value f 
WHERE seqfeature.oid = f.fea_oid 
AND term.oid = f.trm_oid 
AND term.name = 'other_name' 
AND term.=>{bioentry_qualifier_value,seqfeature_qualifier_value}.value LIKE 'mig-11'
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But like I said, not sure whether the API query is correct.
Regards,
Marc

> -----Original Message-----
> From: Hilmar Lapp [mailto:hlapp at gnf.org]
> Sent: Monday, December 22, 2003 5:27 PM
> To: Frederic Pecqueur
> Cc: biosql-l at open-bio.org
> Subject: Re: [BioSQL-l] Query Problem.
> 
> 
> This error is pretty weird. Smells like a bug, I'm just not 
> sure where.  
> Try collapsing the multiple spaces between entity and alias into a  
> single space for every datacollection and see whether it goes 
> away. I  
> can't tell where it would get the 'q' as an alias from.
> 
> A tip aside from that: I'd request the adaptor for Bio::SeqI or  
> otherwise you won't get features and annotation on the resulting  
> objects.
> 
> 	-hilmar
> 
> On Monday, December 22, 2003, at 07:05  AM, Frederic Pecqueur wrote:
> 
> > Hi,
> >
> > I try to create a query to search all the entries which have a tag  
> > "other_name" equal to 'mig-11'....and it dosen't work...
> >
> > I use this code :
> >
> > my $adp = $db->get_object_adaptor('Bio::PrimarySeqI');
> >
> > my $query = Bio::DB::Query::BioQuery->new(
> >                 -datacollections => [
> >                     "Bio::PrimarySeqI entr",
> >                     "Bio::SeqFeatureI  feat",
> >                     "Bio::Ontology::TermI  ter",
> >                     "BioNamespace=>Bio::PrimarySeqI db",
> >                     "Bio::PrimarySeqI=>Bio::SeqFeatureI",
> >                     "Bio::SeqFeatureI<=>Bio::Ontology::TermI  qual"
> >                 ],
> >                 -where => ["db.namespace = 'WormGene'",
> >                            "ter.name = 'other_name'",
> >                            "qual.value = 'mig-11'"]
> > );
> >
> > my $result = $adp->find_by_query($query);
> >
> > I have this error :
> >
> > attempting to load driver for adaptor class  
> > Bio::DB::BioSQL::PrimarySeqAdaptor
> > attempting to load driver for adaptor class  
> > Bio::DB::BioSQL::BasePersistenceAdaptor
> > Using Bio::DB::BioSQL::Oracle::BasePersistenceAdaptorDriver 
> as driver  
> > peer for Bio::DB::BioSQL::PrimarySeqAdaptor
> >
> > ------------- EXCEPTION  -------------
> > MSG: Alias "q" not mapped to entity. Are you sure there's no typo?
> > STACK Bio::DB::Query::BioQuery::_map_slot_to_col  
> > /usr/lib/perl5/site_perl/5.6.1/Bio/DB/Query/BioQuery.pm:466
> > STACK Bio::DB::Query::BioQuery::_map_constraint_slots_to_columns  
> > /usr/lib/perl5/site_perl/5.6.1/Bio/DB/Query/BioQuery.pm:369
> > STACK Bio::DB::Query::BioQuery::_map_constraint_slots_to_columns  
> > /usr/lib/perl5/site_perl/5.6.1/Bio/DB/Query/BioQuery.pm:355
> > STACK Bio::DB::Query::BioQuery::translate_query  
> > /usr/lib/perl5/site_perl/5.6.1/Bio/DB/Query/BioQuery.pm:305
> > STACK Bio::DB::BioSQL::BaseDriver::translate_query  
> > /usr/lib/perl5/site_perl/5.6.1/Bio/DB/BioSQL/BaseDriver.pm:1184
> > STACK Bio::DB::BioSQL::BasePersistenceAdaptor::find_by_query  
> > /usr/lib/perl5/site_perl/5.6.1/Bio/DB/BioSQL/ 
> > BasePersistenceAdaptor.pm:1198
> >
> > I don't use the API correctly??
> > Somebody has a response?
> >
> > Thanks a lot!
> > Frédéric.
> >
> > _______________________________________________
> > BioSQL-l mailing list
> > BioSQL-l at open-bio.org
> > http://open-bio.org/mailman/listinfo/biosql-l
> >
> -- 
> -------------------------------------------------------------
> Hilmar Lapp                            email: lapp at gnf.org
> GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
> -------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> BioSQL-l mailing list
> BioSQL-l at open-bio.org
> http://open-bio.org/mailman/listinfo/biosql-l
> 



More information about the BioSQL-l mailing list