# test des paramètres if ($ARGV[0] eq "") { print " syntaxe : perl codons2aa.pl nom_de_fichier \n" ; exit(-1) ; } ; # fin de test sur les arguments $fichier = $ARGV[0] ; # récupération du nom du fichier # essai d'ouverture du fichier d'entrée open( FIC ,"<$fichier") || die "\n impossible d'ouvrir le fichier nommé $fichier \n\n" ; # préparation du fichier de sortie # on utilise le texte avant le dernier point, soit : $sortie = substr($fichier,0,rindex($fichier,".")).".aa" ; open( FS ,">$sortie") || die "\n impossible d'écrire dans le fichier nommé $sortie \n\n" ; # table de correspondance entre codon et acide aminé # on rajoute ___ vers _ pour gap %dcod=( "aaa"=>"K", "aac"=>"N", "aag"=>"K", "aat"=>"N", "aca"=>"T", "acc"=>"T", "acg"=>"T", "act"=>"T", "aga"=>"R", "agc"=>"S", "agg"=>"R", "agt"=>"S", "ata"=>"I", "atc"=>"I", "atg"=>"M", "att"=>"I", "caa"=>"Q", "cac"=>"H", "cag"=>"Q", "cat"=>"H", "cca"=>"P", "ccc"=>"P", "ccg"=>"P", "cct"=>"P", "cga"=>"R", "cgc"=>"R", "cgg"=>"R", "cgt"=>"R", "cta"=>"L", "ctc"=>"L", "ctg"=>"L", "ctt"=>"L", "gaa"=>"E", "gac"=>"D", "gag"=>"E", "gat"=>"D", "gca"=>"A", "gcc"=>"A", "gcg"=>"A", "gct"=>"A", "gga"=>"G", "ggc"=>"G", "ggg"=>"G", "ggt"=>"G", "gta"=>"V", "gtc"=>"V", "gtg"=>"V", "gtt"=>"V", "taa"=>"*", "tac"=>"Y", "tag"=>"*", "tat"=>"Y", "tca"=>"S", "tcc"=>"S", "tcg"=>"S", "tct"=>"S", "tga"=>"*", "tgc"=>"C", "tgg"=>"W", "tgt"=>"C", "tta"=>"L", "ttc"=>"F", "ttg"=>"L", "ttt"=>"F", "___"=>"_" ) ; # fin de tableau de décodage # parcours du fichier avec conversion par paquets de 3 $nbl = 0 ; while (chomp($lig=)) { $nbl++; if (length($lig)>0) { $lng = length($lig)/3 ; $nlig = "" ; for ($idc=0;$idc<$lng;$idc++) { $nlig .= $dcod{substr($lig,3*$idc,3)} ; } ; # fin de pour idc if ($nbl<=3) { if ($nbl==1) { print "\n pour vérification, affichage des 3 premières lignes (ou moins) :\n\n" ; } ; print " Ligne $nbl \n" ; print " codons : $lig\n" ; print " acides aminés : $nlig\n" ; } ; # fin de si on est dans les trois premières lignes } ; # fin de si ligne non vide print FS "$nlig\n" ; } ; # fin de tant que # fermeture des fichiers et message de fin close(FIC) ; close(FS) ; print "\n vous pouvez utiliser $sortie \n\n"