cjfields / Bio-Tools-Primer3Redux

A reimplementation of BioPerl's Primer3-related code for primer3 v1 and v2
http://bioperl.org
10 stars 5 forks source link

alternatives for AUTOLOAD #15

Open fschwach opened 13 years ago

fschwach commented 13 years ago

Just wanted to raise this as a new issue because the pull request in which we discussed this originally is already closed but this issue is still open for discussion.

The problem: there is a large number of tags for input and output to/from primer3 for which we may want to create accessors. Writing all those accessors explicitly as methods will bloat the code quite a bit and may be a maintenance problem. AUTOLOAD is not an ideal solution and Bio::Root::Root::_set_from_args is only meant to create accessors from arguments given at object instantiation, which is not what we need.

I think these are the options:

  1. We could auto-generate accessors for the various output tags of primers and primer pairs by setting up methods from a list of allowed tag names (similar to what I have already done in Tools::Run::Primer3Redux::_create_run_methods) but I'm not sure if that is acceptable style for BioPerl?
  2. I can create all the subs for the different tag accessors and paste them into the code.
  3. Instead of creating direct accessor methods for each tag by name (such as $primer->hairpin_th), we could have methods "has_tag" and 'tag_value' where the tag name would have to be given as an argument. Maybe that's the cleanest solution.

What do you think?

Frank

JohnMCMa commented 13 years ago

The easiest way is to apply option (3) by reading the different tags that already existed in the infile, and make an array of legal tags for that result/pair/primer etc. This way we can solve a lot of headache in writing sanity check codes.

I'd say, though, I made this comment on the output tags--the input tags is a can of worms that I would open another issue to discuss.