[Bioperl-l] [BioSQL-l] Load seqfeature from biosql database with perl

Hilmar Lapp hlapp at gnf.org
Fri Feb 24 02:10:13 UTC 2006


Yes, kudos to you for figuring this out yourself, and you actually figured
out the more difficult way. I apologize for my delay in responding, I was
tied up this morning and last night.

You got the first key step right, namely obtaining the right persistence
adaptor. This step determines which object you get back.

Your query will work, and in fact will be equally fast as the simple
solution (which is simple only because it is simpler to code, not because
the internally executed query is simpler). The simple solution is that every
Bio::DB::PersistenceAdaptorI implementing object (i.e., any object you get
back from $db->get_object_adaptor(..)) has a method
$adp->find_by_primary_key(). So, using that method:

    $feature = $adaptor->find_by_primary_key($seqfeature_id);

You can also control the type of object to be created (so long as it is a
Bio::SeqFeatureI) by passing in an object factory in addition.

BTW as an aside, using the finder method will also make the object cache
used for lookup first if the cache is enabled. It doesn't matter for seq
features because due to the potentially large number of objects the cache is
not enabled by default for this adaptor.

    -hilmar  

On 2/23/06 5:29 PM, "Michael Cipriano" <mjcipriano at lbl.gov> wrote:

> Ah, I think I figured it out.
> 
> my $seqfeature_id = '401138';
> my $adaptor = $seqdb_obj->get_object_adaptor("Bio::SeqFeatureI");
> 
> my $query = Bio::DB::Query::BioQuery->new(
> 
> -datacollections=>["Bio::SeqFeatureI t1"],
>                                         -where => ["t1.Bio::SeqFeatureI
> = ?"]);
> 
> my $qres = $adaptor->find_by_query($query,      -name=>'FIND FEATURE BY
> SEQ',
> 
> -values=>[$seqfeature_id]);
> 
> while(my $loc = $qres->next_object())
> {
>         my $obj = $loc;
> 
>         print $obj->primary_key() . "\n";
>         print 'location:' . $obj->location->to_FTstring() . "\n";
>         $obj->add_tag_value("test", "moretest");
>         foreach my $tag ($obj->get_all_tags())
>         {
>                 print " Values for tag $tag: ";
>                 print join(' ',$obj->get_tag_values($tag));
>                 print "\n";
>         }
>         print "------------------\n";
> 
> }
> 
> 
> 
> This seems to work
> On Wed, 2006-02-22 at 16:58 -0800, Michael Cipriano wrote:
>> Hello BioSQLers,
>> 
>> I have a simple question (I hope), Can I easily load a seqfeature from a
>> biosql database into a perl Bio::SeqFeatureI object?  I have the
>> database value for the  seqfeature.seqfeature_id and would like to load
>> it using this alone.
>> 
>> I do not want to have to load the whole bioentry object then search for
>> the feature, I just want the feature object since the bioentry is a
>> whole genome and loading that will take more time then necessary.
>> 
>> I have searched the documentation and have even tried looking through
>> the code for the modules, but could not find an easy fast method.
>> 
>> Please reply directly to me as well as the list as I am not a list
>> member.
>> 
>> Thanks for your help,
>> 
>> 
>> Michael Cipriano
>> 
>> _______________________________________________
>> BioSQL-l mailing list
>> BioSQL-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/biosql-l
> 
> _______________________________________________
> BioSQL-l mailing list
> BioSQL-l at lists.open-bio.org
> http://lists.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 Bioperl-l mailing list