[Bioperl-l] how to use BioQuery

Hilmar Lapp hlapp at gnf.org
Sun Jun 8 02:44:39 EDT 2003

On Saturday, June 7, 2003, at 07:54  AM, Michael Thon wrote:

> I've set up a bioperldb database and loaded a few sequences with
> annotations.  Now I'm trying to figure out how to perform some basic
> queries using Bio::DB::Query::BioQuery.

First off, congratulations. You're moving forward pretty aggressively  

> I'm trying to write a simple script to return all sequences that have a
> Bio::Annotation::SimpleValue with a tagname of 'interpro'.  I've been
> looking at code in t/query.t included with bioperl-db and at
> documentation in various bioperl modules but I still haven't figured  
> out
> how to use BioQuery objects.

How to use BioQuery is the most undocumented piece of the story.  
t/query.t is probably the single most useful place to get a grasp of  
what the ideas are. It may also be useful to check in the Bio/DB/BioSQL  
directory for adaptors that implement (i.e., override)  
attach_children() and attach_foreign_key_objects() to how to find  
objects by foreign key or by association.

Also, the mapping and translation code in BioQuery.pm is not very  
robust. I had to write it in a crunch and have since never found the  
time to rewrite it such that it becomes at least remotely  
comprehensible. There may be lots of bugs lurking, as it is not really  
tested beyond what t/query.t and the adaptors test.

So far for the disclaimers ... I'd be glad if you take this for a test  
drive, but the road may be bumpy...

> The following lines:
> my $seqadaptor = $db->get_object_adaptor('Bio::SeqI');
> my $query = Bio::DB::Query::BioQuery->new(
>   '-where' => ["Bio::Annotation::SimpleValue::tagname = interpro"],

You need to quote all values in single quotes. The mapper will not  
quote any values for you. I.e., you need to have

	'-where' => ["Bio::Annotation::SimpleValue::tagname = 'interpro'"],

Note that you can also parameterize it:

	'-where' => ["Bio::Annotation::SimpleValue::tagname = ?"],

and then you would add -values => ["interpro"] to the args you pass to  

Hope this helps,


>   '-datacollections'
>           => ["Bio::PrimarySeqI<=>Bio::Annotation::SimpleValue"]);
> my $result = $seqadaptor->find_by_query($query);
> returns this error:
> ------------- EXCEPTION  -------------
> MSG: error while executing query in
> Bio::DB::BioSQL::SeqAdaptor::find_by_query: Unknown column 'interpro'  
> in
> 'where clause'
> STACK Bio::DB::BioSQL::BasePersistenceAdaptor::find_by_query
> /usr/lib/perl5/site_perl/5.8.0/Bio/DB/BioSQL/ 
> BasePersistenceAdaptor.pm:1200
> STACK toplevel bioquery2.pl:26
> --------------------------------------
> Can anyone provide some pointers about how to perform this type of
> query?
> Thanks
> Mike
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757

More information about the Bioperl-l mailing list