Seq.pm - new version

Georg Fuellen fuellen@chagall.Mathematik.Uni-Bielefeld.DE
Sun, 5 Jan 1997 22:35:43 +0000 (GMT)


Just a few more comments...

The fix to parse_unknown seems to be quite easy:
The regexp to recognize Fasta should look like /^>\S*\s*.*[^>]*/
I'll test it tomorrow for the Aln.pm module (where it's the same, but
multi-line, that is /^>\S*\s*.*[^>]*/m )

I think we can easily write a dup() that doesn't use Perl magic, but just
says ``my(%dup);'', copies from self->... in the same way it now copies 
from ``me'', and returns the blessed reference (``bless \%dup, ref($self);'' ,
I guess). Chris: Can you give it a try ?

I'd suggest 2 small additions to Bio::Seq:
- a function getLength() returning the length of a sequence
- a function to read in protein data in 3-letter code
- optionally: seq_by_index() taking lists of indices as parameters, 
  see seqs/slice in Aln.pm, now at 
  http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/Aln/Aln.pm 
[ I hope that Bio::Aln is in beta by the end of the week, incl. all POD.
I've appended a post about the main problem I'm struggling with right now.. ]

I'm currently trying to get the recommandations at
http://world.std.com/~swmcd/steven/Perl/module_mechanics.html
to work, but I got stuck where the author said I should issue
the command ``perl Makefile.PL'' (under the heading ``Building a Perl Module'').
On my machine, a complete search of all system-wide directories is started,
File::Find::finddir searches everything here :-/, and doesn't stop :-/

best wishes,
georg




=========
From: fuellen@techfak.uni-bielefeld.de (Georg Fuellen)
Subject: OO Qu.: Methods taking functions as arguments, how ? (repost,modified)
Date: Sun, 5 Jan 1997 22:01:20 GMT
Organization: Universitaet Bielefeld, Technische Fakultaet.

I'm co-developing free Perl OO modules for handling biological sequence data.
I'd like to write a method bar() which, among other things, applies a
function foo() to an array.

The module user should be able to specify foo() in the main code, 
such that s/he can give bar() a reference to foo(), and in method bar(), 
foo() is then invoked via &$ref_to_foo(@array).

However, other methods of the same module may also call bar(), which in my 
case then has to apply _another method_ baz() to the array, instead of foo().
Is there any elegant + fast way to do this, without rewriting bar() ?

Also, the user should be able to pass a reference to a built-in
function, like reverse. What's the best way to do this, does the user
need to write a wrapper function ?

Here's a diagram:

main code sub foo     PackageA::baz()      reverse
{ ... }
      \                  |                    /
       \                 |                   /
        \ |            \ | /              | /
       __\|             \|/               |/__

            ....some passing mechanism....
 
               PackageA::bar(....)
                  
            ....some calling mechanism :
          bar can call foo
                    or baz
                    or reverse
          depending on input; optimally, parameters for foo/baz 
                              can be handled, too.

In short, is there a way to write just one bar() for all these needs, in an 
elegant way with minimal performance overhead? 

Finally, can the callers of bar() pass appropriate arguments to
foo() in some generic way ? There may be zero arguments (e.g. if foo() 
is the (built-in) reverse function), but also one or two scalar parameters.
(This seems to be the most difficult subproblem, so I'm willing to tackle 
it later..)

Have you encountered this problem before, or heard about it, and/or
have possible solutions ? Alternatively, please anyone tell me that what
I want can't be done ?!   Thanks for your help !

--
best wishes,
  georg
fuellen@Techfak.Uni-Bielefeld.DE
  http://www.techfak.uni-bielefeld.de/techfak/persons/fuellen/georgF.html