Hi :-|
I am workning on a projekt based on DNA sequences in Perl. I wanna make a program that reverse complements the DNA sequence and writes it into a file fx. revdna.fsa (Which I have done ) but the problem is that I want to keep the first unaltered because it's just a description line and therefore has to stay that way even though I change the lines after it.
Also If I wanna keep the first line AND add some more text to the first line-how do I do that???
This is a DNA seqeunce taken from the GenBank database. (the first line is not part of the sequence and is the line I wanna keep as it is)
>AB000410 1559 bp mRNA Homo sapiens
GAGAAGATAAGTCGCAAGGAGGGGGCGGGACCCACACCTCAGGAAAGCCGGAGAATTGGG
GCACGCAAGCGGGGGGGCTTTGATGACCCCCCAAAGGGCGAGGCATGCAGGAGGTGGAGG
AATTAAGTGAAACAGGGAAGGTTGTTAAACAGCACCGTGTGGGCGAGGCCTTAAGGGTCG
TGGTCCTCGTCTGGGCGGGGTCTTTGGGCGTCGACGAGGCCTGGTTCTGGGTAGGCGGGG
CTACTACGGGGCGGTGCCTGCTGTGGAAATGCCTGCCCGCGCGCTTCTGCCCAGGCGCAT
GGGGCATCGTACTCTAGCCTCCACTCCTGCCCTGTGGGCCTCCATCCCGTGCCCTCGCTC
TGAGCTGCGCCTGGACCTGGTTCTGCCTTCTGGACAATCTTTCCGGTGGAGGGAGCAAAG
TCCTGCACACTGGAGTGGTGTACTAGCGGATCAAGTATGGACACTGACTCAGACTGAGGA
GCAGCTCCACTGCACTGTGTACCGAGGAGACAAGAGCCAGGCTAGCAGGCCCACACCAGA
CGAGCTGGAGGCCGTGCGCAAGTACTTCCAGCTAGATGTTACCCTGGCTCAACTGTATCA
CCACTGGGGTTCCGTGGACTCCCACTTCCAAGAGGTGGCTCAGAAATTCCAAGGTGTGCG
I have done this so far:
open(IN, '<',"dna.dat") or die "Can't read file\n $!";
$dna = "";
while(defined($line=<IN>)){
chomp $line;
$dna .= $line;
}
close IN;
$cdna = "";
for($i=0; $i < length($dna); $i++){
$base =substr($dna, $i, 1);
if($base eq "A"){
$base= "T";
}
elsif($base eq "T"){
$base="A";
}
elsif($base eq "C"){
$base= "G";
}
elsif($base eq "G"){
$base= "C";
}
else {
die "Unknown base; $base\n";
}
$cdna .= $base;
}
$rdna = "";
for($i=-1; $i >= -length($cdna); $i--){
$base =substr($cdna, $i, 1);
$rdna .= $base;
}
)
print "The DNA string is now reversed complemented: $rdna\n";
__END__
here the file "dna.dat" containe the DNA sequence without the first line.
hope u can help me to skipt the first line;)