Hi guys ....
Thanxs alot for ur big help!
Kevin I have tried the following but when I want to write the data into a file I get problems with displaying the first line without repeating itself for every new data line (because of loop):
How do I display the first line only once and followed by the dataset
I have tried this:
open(IN, '<',"dna.fsa") or die "Can't read file\n $!";
my $first_line = <IN>;
my $dna = '';
while(my $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;
}
my $rdna = reverse $cdna;
substr($first_line, -1, 0)= "ComplementStrand";
open(OUT,'>' , "revdna.fsa") or die "Can't write file\n $!";
for($i=0; $i < length($rdna);$i+=60){
$base =substr($rdna, $i, 60);
print OUT "$base\n";
}
close OUT;
print "The DNA in FASTA format is now reversed complemented: \n", "$first_line $rdna\n";
as you can see here I only got the DNA sequence writing in the revdna.fsa, what should I do to display the first line followe by the given string ...!
Thanx