Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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]
What's the matter? Cat got your tongue?...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-01-23 05:26 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (190 votes). Check out past polls.