Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Efficient walk/iterate along a string

by roboticus (Canon)
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

gje21c:

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.

...roboticus


Comment on Re: Efficient walk/iterate along a string
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (15)
As of 2014-09-18 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (114 votes), past polls