[BioSQL-l] Bio::Seq and sequence version numbers

Hilmar Lapp hlapp at gnf.org
Mon Nov 10 12:51:39 EST 2003


Cool - thanks for your help Marc. See below for a few additions.

On Monday, November 10, 2003, at 06:39  AM, Marc Logghe wrote:

> Hi,
>
>> -----Original Message-----
>> From: William Kenworthy [mailto:billk at iinet.net.au]
>> Sent: Monday, November 10, 2003 2:34 PM
>> To: BioSQL List
>> Subject: [BioSQL-l] Bio::Seq and sequence version numbers
>>
>>
>> Hi I am using the following to retrieve a seq object
>>
>> $seq = Bio::Seq->new(-accession_number => "AL022723",
>>                      -namespace        => "bioperl");
>>
>> This fails to retrieve the sequence because it defaults to a
>> version of
>> "0", and this sequence is at version 4.  It works if I set it to
>> "-version=>"4", but usually you dont know what version you
>> are trying to
>> retrieve.  Is there a way of forcing a wildcard for version, or an
>> alternate method that ignores it?
> I think when you use the find_by_unique_key, you have to know the 
> accession number AND version (after all you want to fetch a *unique* 
> record; in case more versions are available, the system does not know 
> which one you want).
> find_by_query might be a valid alternative.

Right, that's the answer.

> # set up the query template
> my $query  = Bio::DB::Query::BioQuery->new(
>         -datacollections => [ "Bio::PrimarySeqI e",  
> "BioNamespace=>Bio::PrimarySeqI db"  ],

BioNamespace may look like a type but it's not. It's a virtual object 
because bioperl does not have an equivalent class.

>         -where => [ "e.accession_number = ?", "db.namespace = 
> 'bioperl'" ] ,
>         -order  => ["e.version"]
> );
>
> # perform the query with the desired value
> my $result = $adp->find_by_query($query, -name => 'test', -values => 
> ['AL022723']);

Note that you don't have to name the query. If you do name it, it will 
become a prepared statement that the adaptor caches.

> my $seq = $result->next_object; # gives you the first sequence object 
> from the ordered list
>

The class of the $seq object you can control in two ways. Either, 
specify the class when you obtain the adaptor:

	$adp = $db->get_persistence_adaptor("Bio::PrimarySeqI"); # or Bio::SeqI

This will make you rely on the default object factory used by the 
adaptor you get returned. You can take full control by supplying the 
factory to find_by_query():

	my $result = $adp->find_by_query($query, -name => 'test', -values => 
['AL022723'],
           -obj_factory => Bio::Seq::SeqFactory->new(-type => 
"Bio::Seq::RichSeq"));

Hth too,

	-hilmar

> HTH,
> Marc
>
> _______________________________________________
> 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
-------------------------------------------------------------




More information about the BioSQL-l mailing list