1

How do I view the arguments/parameters that can be passed to a new object on a Perl module? I usually go to CPAN and look at the SYNPOSIS section for examples of what I'm trying to do. But the examples and the descriptions they provide aren't always comprehensive, and I end up having to look for examples of other people using the module and hope someone has tried to use the module in the same way I am.

Here the latest module I'm trying to use

 use Bio::DB::GenBank;
 my $gb = Bio::DB::GenBank->new(-format     => 'Fasta',
                                -seq_start  => 2,
                                -seq_stop   => 51,
                                -strand     => 1,
                                -complexity => 1);

How do I view the complete list of parameters that I can pass to Bio::DB::GenBank->new(). Is there a way to view the object/object/module definition? Or the object's constructor?

EDIT: I just realized I can download the module from CPAN and look at the code in the module myself for the object parameters but I was wondering if anyone has a better way of doing it?

cooldood3490
  • 2,418
  • 7
  • 51
  • 66
  • 1
    Code inspection is the reliable way. Referring to documentation is the official way, but as you've noted - sometimes lacking :) – Sobrique Oct 29 '15 at 16:23

2 Answers2

2

Modules on CPAN - the way to know for sure is to look at the code, and see what they do. This isn't always particularly straightforward, but it's the one definitive source of truth.

Otherwise there's the documentation, which is where the developer should have described the (public) module functionality. This doesn't always happen, and sometimes what's clear to the developer, isn't as clear to every potential module user.

But this is in part, the tradeoff of using a public contribution module library - some modules are so well polished that they gleam, and others are ... well, rather more of a work-in-progress.

The good news is - most maintainers are receptive to updates and fixes. Often something is 'lacking' simply because of available time, or it meeting the current demands in terms in terms of functionality.

Sobrique
  • 52,974
  • 7
  • 60
  • 101
  • Honestly, I don't find this very helpful. The question was about a specific module and the answer isn't even related to the programming language in question. This is extremely vague and doesn't provide a way to get an answer. We can always say 'just look at the code' but there has got to be a better solution, and in this case, there definitely is. – SES Nov 01 '15 at 02:42
  • I'll wait a couple more days for other responses then I'll accept one. – cooldood3490 Nov 02 '15 at 03:32
1

The first thing to do is look at the documentation, and this is where Perl rules because it is available at the command line:

perldoc Bio::DB::GenBank

That check takes no time. If that does not tell you everything you need to know, as in this case, I always look at the tests next. That is the simplest way, in my opinion, to see how a class/method should work. Reading good tests is better/faster than reading documentation if you have a little experience. Reading the code is usually the last resort for me because it is often hard to make sense of even simple code and I think that could be blamed on stylistic differences (and Perl itself).

At this point, if you can't find any tests or documentation you need to ask yourself if this module is worth your time. I would say almost always the answer is no. Useful and popular modules should have some basic tests and docs. One thing to be aware of (especially with BioPerl) is that if there is documentation it may be from another module. People often copy modules over, change the code, then upload it to CPAN or github :-/.

You didn't ask a specific question but I am guessing you're trying to get/manipulate data from GenBank. In this case, I would recommend using NCBI's E-Utilities interface directly or use Bio::DB::EUtilities from BioPerl (not core though, separate install). There are some nice guides such as the EUtilites Cookbook and the EUtilities webservices guide, though the latter is based on SOAP services and may be beyond what you need for most uses.

If you have a more specific question I'd be happy to help with that too.

SES
  • 850
  • 1
  • 9
  • 21