like this above file. file 1 has 1000's of lines. I would like to edit this file1 using the information from file2 (see below), by replacing the 4th alphabet or alphabet at the position 4 C with T; 10th position alphabet A to C ......61th position alphabet G to A and 66th position alphabet A to C.
file 2
4 C T
10 A C
19 G A
38 G T
61 G A
66 A C
I am expecting the output file, file 3 with the edits.
No it doesn't have a length of 66. In the second file, file2 shows the position on file1 where the edits has to be done. The actual file have 1000's of letters. Hope this helps
Your sample output file does by no means fit the edits defined in file 2 applied to file1, e.g. line 2 pos 10 should have become a C ; and where does line 2 pos 29 A come from?
Please post representative samples, and your solution attempts so far.
Counts don't go for each line. It starts from position 1 and goes continuously to the end of the file. It is not counted separately for each line. Hope this makes it clearer. I tried to put in it all in a hash using perl but was not successful in getting the output
So you have ">SAM" in the file? I read it as being a prompt and a command... In your spec, you didn't count it nor took it into account! Should have mentioned that.
Add FNR > 1 to the second line...
Not sure. As F[ ] elements are created when referenced, memory may become exhausted, but then the error msg should complain about memory allocation problems. Try this: