How to access residues of a feature without doing direct SQL?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to access residues of a feature without doing direct SQL?

Michael Dondrup-3
Hi,
I have some features in my chado database which I want to retrieve their sequence automatically.
If the feature has a feature_loc and source feature annotated, I can simply retrieve the sequence
via Bio::DB::Das::Chado:

   my $feature = $db->get_feature_by_id($id);
   die ("feature $id not found") unless $feature;
   if (ref $feature->seq()) {
        $residue = $feature->seq()->seq
            || die "missing sequence for feature ".$feature->display_name;
   }

However, for features which only have residues and no feature_loc or source,
are not found by get_feature_by_id even though the feature exists in the database.
Do I have to use sql directly:

SELECT residues FROM chado.feature where feature_id=$id;

or is there a cleaner way?

Michael





Michael Dondrup
Postdoctoral fellow
Sea Lice Research Centre/Department of Informatics
University of Bergen
Thormøhlensgate 55, N-5008 Bergen,
Norway


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema

signature.asc (465 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to access residues of a feature without doing direct SQL?

Scott Cain
Hi Michael,

I haven't tried this in a while, but off the top of my head, if you create a Bio::DB::Das::Chado::Segment object for the feature that has its own residues, you should be able to call the seq method on it, which returns a Bio::Seq object, which you can then call the seq method on, which would return the residues.  Something like this will probably work:

my ($segment) = $db->segment(-name => 'featname');
my $residues = $segment->seq->seq;

Oh, looking at the code and docs for the Segment object, it looks like calling the dna method will get you the residues directly (regardless of whether they are dna or not), so this should work as well with out as much BioPerl overhead:

my $residues = $segment->dna;

If not, let me know, and I'll poke around a little harder.

Scott



On Thu, Jul 24, 2014 at 9:39 AM, Michael Dondrup <[hidden email]> wrote:
Hi,
I have some features in my chado database which I want to retrieve their sequence automatically.
If the feature has a feature_loc and source feature annotated, I can simply retrieve the sequence
via Bio::DB::Das::Chado:

   my $feature = $db->get_feature_by_id($id);
   die ("feature $id not found") unless $feature;
   if (ref $feature->seq()) {
        $residue = $feature->seq()->seq
            || die "missing sequence for feature ".$feature->display_name;
   }

However, for features which only have residues and no feature_loc or source,
are not found by get_feature_by_id even though the feature exists in the database.
Do I have to use sql directly:

SELECT residues FROM chado.feature where feature_id=$id;

or is there a cleaner way?

Michael





Michael Dondrup
Postdoctoral fellow
Sea Lice Research Centre/Department of Informatics
University of Bergen
Thormøhlensgate 55, N-5008 Bergen,
Norway


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema




--
------------------------------------------------------------------------
Scott Cain, Ph. D.                                   scott at scottcain dot net
GMOD Coordinator (http://gmod.org/)                     216-392-3087
Ontario Institute for Cancer Research

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Gmod-schema mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-schema