Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by neversaint (Deacon)
on Dec 29, 2008 at 05:32 UTC ( #732959=note: print w/replies, xml ) Need Help??

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

Dear BrowserUK,
Your magical approach is at least 6980x faster than mine!

My approach:
191.52user 153.47system 5:49.44elapsed 98%CPU
BrowserUk Perl's approach (modified to handle FASTA):
open SEQ, '<', $ARGV[0] or die $!; #plain open MASK, '<', $ARGV[1] or die $!; #hardmask while ( my $seq = <SEQ> ) { ## Read a sequence my $mask = <MASK>; ## And the corresponding mask if ( $mask =~ /^>/ ) { print "$seq"; } else { $mask =~ tr[N][ ]; ## Ns => spaces print $seq | $mask; ## bitwise-OR them and print the re +sult; } } close SEQ; close MASK;
Takes only this much time:
0.45user 0.07system 0:05.59elapsed 9%CPU
This is tested on 12MB dataset, and the breakdown of sequence length is this:
#Seq_name #Seq_len 2-micron 6318 MT 85779 I 230208 VI 270148 III 316617 IX 439885 VIII 562643 V 576869 XI 666454 X 745745 XIV 784333 II 813178 XIII 924429 XVI 948062 XII 1078175 VII 1090946 XV 1091289 IV 1531918
Update: These test datasets (full and hardmasked) can be downloaded here.

neversaint and everlastingly indebted.......

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2020-02-28 22:01 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (127 votes). Check out past polls.