G'day mashuk,
Welcome to the Monastery.
[I appreciate this is your first post here. For future reference, please read "How do I post a question effectively?". Also consider the comments others have made in this thread.]
For demonstration purposes, I've truncated your DNA sequences to 20 characters. I believe what you're after is code something like this (pm_11131708_fasta_rev_comp.pl):
#!/usr/bin/env perl use strict; use warnings; use autodie; my $in_file = 'pm_11131708_in'; my $out_file = 'pm_11131708_out'; { open my $in_fh, '<', $in_file; open my $out_fh, '>', $out_file; while (<$in_fh>) { if (0 == index $_, '>') { print $out_fh $_; } else { chomp; my $rev = scalar reverse; $rev =~ y/ATGC/TACG/; print $out_fh "$rev\n"; } } }
Sample run:
$ cat pm_11131708_in >adbca3e TGCTCCCCACGCTTGCCTCT >4c2a958 TCCCCACGCTTTCGCGCTTC >0639b5b TCGCGCCTCAGTGTCCAACG $ ./pm_11131708_fasta_rev_comp.pl $ cat pm_11131708_out >adbca3e AGAGGCAAGCGTGGGGAGCA >4c2a958 GAAGCGCGAAAGCGTGGGGA >0639b5b CGTTGGACACTGAGGCGCGA
See also: autodie, open, index and reverse.
— Ken
In reply to Re: Perl code for reverse complement of DNA sequence
by kcott
in thread Perl code for reverse complement of DNA sequence
by mashuk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |