#!/usr/bin/perl -w
#
unless(@ARGV==1) {die "please provide name of the file in the command line!!\n";}
my$filename=$ARGV[0]; #takes filenname from input line
open(IN, "< $filename") or die "cannot open $filename:$!"; #assigns filehandle IN to filename or dies
$outfile=$filename.'.mod';
open(OUT, ">$outfile") or die "cannot open $filename\.mod:$!"; #assigns filehandle IN to filename or dies\\\\

my$seq=''; #assigns empty string
my$line='';
my$name='';

while(defined($line=<IN>))
	{
		chomp($line);
			if ($line=~/^>/) 
				{  #look for beginning of line starting with > (^ is an anchor for the beginning of the line)
				print OUT "$line\n";
				$header=$line ;
				}
			else 
				{  $line =~ tr/galmfwkqespvicyhrndt/GALMFWKQESPVICYHRNDT/; #translates all ATGC to upper case
				$line =~ s/\s//g;# substitutes all white spaces \s with nothing globally in $seq
				@aa=split(//,$line);  #splits string into separate elements (bases)
				foreach (@aa) 
					{
					if($_=~/[GALMFWKQESPVICYHRNDT]/) 
							{print OUT "$_"}
					else {print "Warning there is a strange aa  $_ in sequnece \n \t $header \n";}
						}
							print OUT "\n";
				}	
			}

close (OUT);
close (IN); 
													
