Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Efficient walk/iterate along a string

by roboticus (Chancellor)
on Nov 23, 2010 at 01:08 UTC ( #873090=note: print w/replies, xml ) Need Help??

in reply to Efficient walk/iterate along a string


I think you may have simplified just a bit too much. Since you focused in on character-by-character iteration, you've pretty much constrained possible solutions into that mold. Depending on what you're doing, there may be methods that are significantly faster.

Are you looking for particular clusters to alter? If so, you may find index to be faster to locate the clusters of interest.

You mention that each protein is used 20 times. But that's for one run of your program, right? Are you going to use the program multiple times? If you take number of runs into account, and number of uses overall of the proteins, it may be possible that you can build a database of protein substrings and then just look them up in the database rather than having to dig for them sequentially.

If you can give us a little more information about the operations you're performing, perhaps we can be a little more helpful.


Replies are listed 'Best First'.
Re^2: Efficient walk/iterate along a string
by aquarium (Curate) on Nov 23, 2010 at 02:56 UTC
    i was also going to suggest that maybe refactoring may be possible if more context is known. index or straight regex can be used in a loop to traverse a string, don't know if more efficient or not. using index function with each letter (alphabetically) and incrementing the start index, could also be worth a try, but only if you're ok to traverse the string this way. there's also databases with bitmap indexes, which would allow very fast access to (pre-fetched cache) of particular sequences. but all depends on the semantics of your larger goal. a question that comes to mind, why is each protein sequence processed 20 times?
    the hardest line to type correctly is: stty erase ^H

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873090]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-06-19 05:07 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.