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

Re: Lower-casing Substrings and Iterating Two Files together

by kirillm (Friar)
on Dec 27, 2008 at 14:27 UTC ( #732794=note: print w/replies, xml ) Need Help??


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

How about reading one character from each of the files and depending on the current value of character from data2.txt print out either lowercased or uppercased value of the character from data1.txt. Something like this (no error checking etc, but you see the idea):

open D1, 'data1.txt'; open D2, 'data2.txt'; my ($c1, $c2); while (read D2, $c2, 1) { read D1, $c1, 1; print $c2 eq 'N' ? lc($c1) : $c1; } close D2; close D1;

This produces the desired output:

>seq1 GGTacacagaagccaaagcaggctccaggctctgagctgtcagcacagagaccgaT >seq2 GTCTCTGTCTCtaaaataaataaacattaaaaaaattttaaaagaaaaGATTCTCTCC

-- Kirill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2022-08-10 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?