print "\nWelcome to the FASTA to QUASI converter.\n"; print "\nRemember that the sequences must be aligned and that the\n"; print '"no data" symbol: "." is distinct from the true alignment gap symbol: "-"'; print "\n"; #gets the names of the files and opens them print "Enter the name of the FASTA file to convert:\n"; chomp($infile_name = ); open(INFILE,"$infile_name"); print "\nEnter the name you want for the converted QUASI-ready output file:\n"; chomp($outfile_name = ); open(OUTFILE,">$outfile_name"); $status="start"; while (eof(INFILE) == 0) { $fromin=getc(INFILE); $seqletter = ""; if ($status eq "start" && $fromin eq ">") { #once the first name starts, I stop ignoring garbage $status = "name"; } #next I check for the FASTA name and ignore it until it's finished. if ($status eq "name" && $fromin eq "\n") { #now we know we are in the sequence section $status = "sequence"; } #Now, Ihave to check once again for the beginning of a new name (and #I will output a newline if there is a name (i.e., the sequence is finished) if ($status eq "sequence" && $fromin eq ">") { $status = "name"; print OUTFILE ("\n"); } #Next I read only the valid symbols into the seq var if ($status eq "sequence") { #standard nucleotides are allowed if ($fromin eq "a" || $fromin eq "A") { $seqletter = "A"; } if ($fromin eq "c" || $fromin eq "C") { $seqletter = "C"; } if ($fromin eq "d" || $fromin eq "D") { $seqletter = "D"; } if ($fromin eq "e" || $fromin eq "E") { $seqletter = "E"; } if ($fromin eq "f" || $fromin eq "F") { $seqletter = "F"; } if ($fromin eq "g" || $fromin eq "G") { $seqletter = "G"; } if ($fromin eq "h" || $fromin eq "H") { $seqletter = "H"; } if ($fromin eq "I" || $fromin eq "i") { $seqletter = "I"; } if ($fromin eq "K" || $fromin eq "k") { $seqletter = "K"; } if ($fromin eq "L" || $fromin eq "l") { $seqletter = "L"; } if ($fromin eq "m" || $fromin eq "M") { $seqletter = "M"; } if ($fromin eq "n" || $fromin eq "N") { $seqletter = "N"; } if ($fromin eq "p" || $fromin eq "P") { $seqletter = "P"; } if ($fromin eq "q" || $fromin eq "Q") { $seqletter = "Q"; } if ($fromin eq "r" || $fromin eq "R") { $seqletter = "R"; } if ($fromin eq "S" || $fromin eq "s") { $seqletter = "S"; } if ($fromin eq "t" || $fromin eq "T") { $seqletter = "T"; } if ($fromin eq "V" || $fromin eq "v") { $seqletter = "V"; } if ($fromin eq "W" || $fromin eq "W") { $seqletter = "W"; } if ($fromin eq "x" || $fromin eq "X") { $seqletter = "X"; } if ($fromin eq "y" || $fromin eq "Y") { $seqletter = "Y"; } #now the gap and no data symbols are allowed if ($fromin eq "-") { $seqletter = "-"; } if ($fromin eq ".") { $seqletter = "."; } } #Finally, we will print the letter unless ($seqletter eq "") { print OUTFILE ("$seqletter"); } } close(INFILE); close(OUTFILE);