Is there a list of available keywords for BioPerl?
2
1
Entering edit mode
9.7 years ago
Tawny ▴ 180

I would like to better utilize the functionality available through Bio Perl. I have not been able to find a list of available keywords to use to access different data when using something like Bio::SeqIO. Does anyone have a list like this or can anyone point me to where I would find it? For example: I have written a script to work with fasta files. I needed to check the GI numbers. It was easy to find the keyword accession but this didn't give me the number that I needed. After much online searching I was able to find that display_id will give me the number I need. I am sure there are other keywords like display_id. What are they?

Bio-SeqIO Perl Bioperl • 2.2k views
ADD COMMENT
0
Entering edit mode

Note: "methods" is the term for what you call "keywords"

ADD REPLY
8
Entering edit mode
9.7 years ago
SES 8.6k

With modern Perl object systems, introspection of classes is really easy. You don't have to depend on the documentation (which is usually out of date, and maybe nonexistent), you can use the meta-object methods (the MOP) to introspect the class. Anyway, I'll show you how to inspect classes like those with BioPerl.

The Bio::SeqIO class you mention is really just for IO, or reading and writing, so you probably aren't interested in those methods. You probably want to know what you can do with Bio::Seq objects. Ideally, there would be documentation that lists all of the methods, but BioPerl is a large and mature project, and sometimes you find inconsistencies. In this case, Bio::Seq is very well documented (just type: "perldoc Bio::Seq"), though I'll demonstrate how to do this anyway. Here is an example to get at what is available when you load the class:

use Bio::Seq;
no strict 'refs';

print join ', ', grep { defined &{"Bio::Seq::$_"} } keys %{Bio::Seq::};

The hash %{Bio::Seq::} is the symbol table of the Bio::Seq class and the grep filters out non-subroutine entries (e.g. package variables). This code will tell you the class methods, but I don't think it will give you inherited methods (the code above was modified from a SO answer).

Here is the result:

$ perl biostars108123.pl

validate_seq, primary_id, new, all_SeqFeatures, add_SeqFeature, get_num_of_annotations, DESTROY, feature_count, display_name, remove_Annotations, flush_SeqFeatures, remove_SeqFeatures, desc, description, alphabet, add_Annotation, num_Annotations, primary_seq, top_SeqFeatures, is_circular, namespace, seq, flush_SeqFeature, annotation, accession, id, display_id, object_id, accession_number, subseq, get_SeqFeatures, can_call_new, authority, length, get_Annotations, species, version

Not all of those will be of interest to the general public, but most are. If you are unsure about whether your object can do "method_a" you can always test it (with eval or try/catch):

eval { $object->can('method_a') };

if ($@) { print "Nope. Can not do 'method_a'"; }
ADD COMMENT
0
Entering edit mode

@SES Thank you for taking the time to write such a complete response! Exactly what I need!

ADD REPLY
0
Entering edit mode
9.7 years ago
Felix_Sim ▴ 260

Maybe try the CPAN website?

ADD COMMENT

Login before adding your answer.

Traffic: 1868 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6