I was trying to make a perl code to get the reverse complement of fasta sequences of DNA in a .fna file format. the sequence02C.fna file contains 100s of DNA sequences :
>adbca3e
TGCTCCCCACGCTTGCCTCTCCAGTACTCAACCAAAGCAGTCTCTAGAAAAACAGTTTCCAACGCAATACGATGGAATTCCACTTCCCAAATATCTC
>4c2a958
TCCCCACGCTTTCGCGCTTCAGCGTCAGTATCTGTCCAGTGAGCTGACTTCTCCATCGGCATTCCTACACAGTACTCTAGAAAAACAGTTTCTGCTC
>0639b5b
TCGCGCCTCAGTGTCCAACGCAATACGAGTTGCAGACCAGGACACATGGAATTCCACTTCCCTCTCCAGTACTCAACCAAAGCAGTCTCTAGAAAAG
I have used the following command which can open the file and make reverse but does not show the sequence ID (eg: >adbca3e
) in the output.
The code is:
#!/usr/local/perl
open (NS, "sequence02C.fna");
while (<NS>) {
if ($_ =~ tr/ATGC/TACG/) {print $_;}
}
output file is only the complementary of the sequence but not reverse. Additionally, it does not contain the sequence IDs ">adbca3e"
Could anyone please suggest the appropriate code to do this reverse complementary of this sequence at once and getting the result into an output file?