Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Lower-casing Substrings and Iterating Two Files together

by BrowserUk (Patriarch)
on Apr 28, 2009 at 03:43 UTC ( [id://760493]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Lower-casing Substrings and Iterating Two Files together
in thread Lower-casing Substrings and Iterating Two Files together

But I also think that the solution is not to turn your back against it on the basis of poor performance or interface clunkiness alone.

The problems with BioPerl go so much deeper than just "poor performance" or "interface clunkiness".

  • Try abysmal performance:

    The last time I tried Bio::SeqIO::Fasta, it was three orders of magnitude slower than 4 lines of Perl that achieved the desired result. Read a Fasta format file and return the identifiers and sequences sequentially.

    I would have run a new benchmark to see if it had improved any in the interim couple of years, but that requires downloading and install 30MB of stuff spread across 2000 files. Never mind the quality--feel the width.

    So what you are probably saying. Disk space is cheap. True, but mind-space isn't! Here's just one of the ways installing that lot adversely affects me. The next time I re-build the index to my Perl documentation, that lot will get added--and triple it's size. And as it appears low in the alphabet, it means that I will have to labour my way past all that most every time I want to look up something useful. Small potatoes you might think, but the last time I made the mistake of installing it, I ended up blowing away my whole installation to get rid of it, because it was like carrying a heavy raincoat for a walk on the beach. Dead weight.

  • Try "clumsy", "hideous" or "tortuous" interface.

    Like trying to drive a car using a keyboard interface. Unintuitive, laborious and verbose. The triumph of OO-spaghetti (which is far, far worse than procedural spaghetti), over practicality. The clue to some of the problems is indicated by the repetition of things starting with "seq" in these synopsises:

    $sequence = $seqIO->next_seq() Fetch the next sequence from the stream. $seqIO->write_seq($sequence [,$another_sequence,...])

    Can a seqIO object read or write a (for example) disarray? If not, why not just $seq->next & seq->write?

    I see from the latest docs that it (now? I don't recall seeing it before), sports a tied interface, but the comments in the description sum up the attitude:

    # The SeqIO system does have a filehandle binding. Most people find t +his # a little confusing,

    The patronising attitude that you must somehow hide Perl from users. The idea that somehow this:

    while ( my $seq = $in->next_seq() ) { print "Sequence ",$seq->id, " first 10 bases ", $seq->subseq(1,10), "\n"; }

    Is better than this:

    while( my( $id, $seq ) = <$tiedFasta> ) { say "Sequence $id first 10 bases ", substr( $$seq, 0, 9 ); ]

    Perl works! That's why we use it in preference to other languages. Especially, Perl's file and string handling works far better than Java. So why wrap over Perl's strengths with Java-wanna-be OO wrappers. OO done well can be a productivity aid, but done badly (which is most of the time), it means that substr is called subseq in one context, and subString in another context; and sub_string in yet another context; and ...

    And all of those pseudonyms have to be looked up individually and are poor substitutes for the real thing. eg. No Lvalue context or 4 arg variants. That's a problem because if you want to operate on subsequences, using substr you can do things like:

    substr{ $$seq, $_, 12 ) =~ m[...] for 0 .. length( $seq ) - 12;

    to examine (or modify) all 108,000 12-char subsequences in the first sequence of Drosophila without any copying!. Do the same thing with the subseq method and you'll end up having to copy 1.2 MB of data--for the first sequence alone. And that's for read-only access only.

    Apply this same process to all 164MB of Drosophila and you'll end up copying 1,921,667,736 bytes of data in 12-byte chunks--when there is no need to copy any!

    And the after-though tied interface provided doesn't help much because it's just a wrap-over of the OO interface which means it does even more copying and is even slower.

And these are just a few of the problems with one tiny part of this behemoth. And they are endemic. O'Woe engineering built atop performance-doesn't-matter architecture.

There is simply no logic to wrapping 7 layers of OO over Perl's powerful built-ins in order to read and write simple file formats. But that horse long since flew the coupé :)

We are, however, open to anyone (biologists or not) willing to make contributions and improvements to the code; much of the tasks in this area don't require any bio-knowledge.

As Pat said, when asked for directions: "Ah now! If I were you trying to get to there, I wouldn't be starting from here."

The problem is that the problems run so deep, that you cannot patch-fix the implementation whilst leaving the architecture and interfaces intact. And any attempt by a non-biologist outsider to suggest changing the architecture, interfaces and implementation; would be like an Englishman suggesting the US change it's gun laws. It just ain't gonna happen. All the considerations of backward compatibility and installed base, compounded by vested interests, long standing contributions and NIH.

About the best thing that could be done is to go for a Bio::Lite. A few small modules with minimal interfaces optimised to work with rather than against Perl's native abilities.

  1. Half a dozen PerlIO layers for reading and writing the basic file formats.
  2. A few Genome-tailored regex generators to simplify searching and fuzzy-matching the basic ACGT & extended ACGTNXacgt sequence formats.
  3. A couple of wrap-overs of one of the Math* modules to provide the more commonly used statistical tools.
  4. And most importantly, some tailored, worked examples of using some of Perl's more esoteric built-in facilities--like pack/unpack and bit-wise string operations to perform the more common manipulations.

If anyone was to start that project, you could count me in, as I think that Genome research is one of the most worthwhile areas of open source development around. But it would require someone with a decent understanding of the field to head-up such a project, otherwise you'd just end up with another programmers view development, instead of a User's Needs driven one. And that would benefit no one.

In theory, Perl 6/Parrot would make a good basis for a new Bio-project, bringing the best of OO, functional, and perhaps even parallelism to the table to provide for a clean and efficient solution. But even then, it would be a surprise to me if anything more was done than just to re-implement the existing Bio-Perl interfaces as quickly and directly as possible, without spending any time exploring how the new language and facilities it provides could be best utilised.

It will probably take until BioPerl6-II, for people to have become sufficiently familiar with Perl 6 to begin to see the possibilities--and by then, 2 or 3 Christmases after the Christmas delivery of Perl 6--the existing interfaces will be too ingrained, and installed base will be too large, to consider radical changes. And it would take radical changes to address the problems.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^5: Lower-casing Substrings and Iterating Two Files together
by citromatik (Curate) on May 28, 2009 at 21:44 UTC
    In theory, Perl 6/Parrot would make a good basis for a new Bio-project, bringing the best of OO, functional, and perhaps even parallelism to the table to provide for a clean and efficient solution. But even then, it would be a surprise to me if anything more was done than just to re-implement the existing Bio-Perl interfaces as quickly and directly as possible, without spending any time exploring how the new language and facilities it provides could be best utilised.

    BioPerl has already started its way to Moose (BioMoose) as a first step towards BioPerl6. But after reading the seminal posts on the BioPerl mailing list, I'm afraid that you are right in your predictions. Sadly, I don't expect more than a porting re-implementation

    citromatik

      BioPerl has already started its way to Moose (BioMoose)

      Oh dear. So now, instead of being Biblically slow, it'll be glacially slow.

      Sadly, I don't expect more than a porting re-implementation

      Figures. Sometimes I think that people forget that Moose doesn't add much to the capabilities of Perl. It makes things cleaner, simpler, and ensures that they always get done. But that also means that they get done, regardless of whether they are needed or not.

      The real problem with overarching frameworks, is that the have to be written to meet the requirements of every project spec not yet written, which inevitably means that they are sub-optimal for all of them!


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://760493]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found