#!/usr/local/bin/perl

# This script has multiple components to demonestrate some simple features of Perl and their relevance to Bioinformatics
# written by Imtiaz Khan, wpciak@cf.ac.uk , Cardiff University, 2007


# TASK1: Get a command line input and print that on command line

#print "Please Enter the DNA sequence: ";
#$DNA=<STDIN>;
#chomp $DNA;
#print the scalar
#print $DNA,"\n";


# TASK2: reverse the DNA and get the length of the DNA
#$revDNA = reverse($DNA);
#$DNAlength = length($DNA);

# TASK3: convert into uppercase letters
#$upperCaseDNA = uc($DNA);
#$lowerCaseDNA = lc($DNA);


# TASK4:  Count the GC content of a DNA Sequence
#$GC = ($DNA =~ tr/GCgc//);
#$perGC = int(($GC/length($DNA))*100);
#print "The GC content is $perGC percent\n";


# TASK5: Convert DNA into RNA
#$RNA = ($DNA =~ tr/Tt/Uu/);
#print $RNA,"\n";

# TASK6: Through for loop count the nucleotide of the DNA sequence
#@arrayDNA= split(//,$DNA);
#my ($A, $C, $G, $T)=0;
#foreach $nucleotide(@arrayDNA)
#{
#	if($nucleotide =~ /A/i){$A++;}
#	if($nucleotide =~ /C/i){$C++;} 
#	if($nucleotide =~ /G/i){$G++;} 
#	if($nucleotide =~ /T/i){$T++;}  
#}
#print 	"There are:\n Adenine: $A\n Cytosis: $C\n Guanin:  $G\n Tyrosin: $T\n";

#for($n=0;$n<scalar@arrayDNA; $n++)
#{
#	$nucleotide = $arrayDNA[$n],"\n";
#}


# TASK7: Convert RNA to Protein sequence using codon table
#my $RNA = "auggcacaggcacuguugguacccccaggaccugaaagcuuccgccuuuuuacuaga";
#my $amino_acid;

# Iterate over RNA string translating codon to amino acid
#my $pos = 0;
#while ($pos < length $RNA) 
#{
#	my $codon = substr($RNA, $pos, 3);
#	$amino_acid .= ProteinConverter($codon);
#	$pos += 3;
#}
#
#print "Amino acid string $amino_acid \n";


sub ProteinConverter
{
	my $code = $_[0];
	
	if($code eq uuu){return F;}
	if($code eq uuc){return F;}
	if($code eq uua){ return L;} 
	if($code eq uug){ return L;}
	if($code eq ucu){ return S;} 
	if($code eq ucc){ return S;} 
	if($code eq uca){ return S;} 
	if($code eq ucg){ return S;}
	if($code eq uau){ return Y;} 
	if($code eq uac){ return Y;} 
	if($code eq uaa){ return "--STOP--";} 
	if($code eq uag){ return "--STOP--";}
	if($code eq ugu){ return C;} 
	if($code eq ugc){ return C;} 
	if($code eq uga){ return "--STOP--";} 
	if($code eq ugg){ return W;}
	if($code eq cuu){ return L;} 
	if($code eq cuc){ return L;} 
	if($code eq cua){ return L;} 
	if($code eq cug){ return L;}
	if($code eq ccu){ return P;} 
	if($code eq ccc){ return P;} 
	if($code eq cca){ return P;} 
	if($code eq ccg){ return P;}
	if($code eq cau){ return H;} 
	if($code eq cac){ return H;} 
	if($code eq caa){ return Q;} 
	if($code eq cag){ return Q;}
	if($code eq cgu){ return R;} 
	if($code eq cgc){ return R;} 
	if($code eq cga){ return R;} 
	if($code eq cgg){ return R;}
	if($code eq auu){ return I;} 
	if($code eq auc){ return I;} 
	if($code eq aua){ return I;} 
	if($code eq aug){ return M;}
	if($code eq acu){ return T;} 
	if($code eq acc){ return T;} 
	if($code eq aca){ return T;} 
	if($code eq acg){ return T;}
	if($code eq aau){ return N;} 
	if($code eq aac){ return N;} 
	if($code eq aaa){ return K;} 
	if($code eq aag){ return K;}
	if($code eq agu){ return S;} 
	if($code eq agc){ return S;} 
	if($code eq aga){ return R;} 
	if($code eq agg){ return R;}
	if($code eq guu){ return V;} 
	if($code eq guc){ return V;} 
	if($code eq gua){ return V;} 
	if($code eq gug){ return V;}
	if($code eq gcu){ return A;} 
	if($code eq gcc){ return A;} 
	if($code eq gca){ return A;} 
	if($code eq gcg){ return A;}
	if($code eq gau){ return D;} 
	if($code eq gac){ return D;} 
	if($code eq gaa){ return E;} 
	if($code eq gag){ return E;}
	if($code eq ggu){ return G;} 
	if($code eq ggc){ return G;} 
	if($code eq gga){ return G;} 
	if($code eq ggg){ return G;}
}