$k=0; open (IN, '6U9D.pdb.txt'); %amino_acid_conversion = (ALA=>'A',TYR=>'Y',MET=>'M',LEU=>'L',CYS=>'C',GLY=>'G', ARG=>'R',ASN=>'N',ASP=>'D',GLN=>'Q',GLU=>'E',HIS=>'H',TRP=>'W',LYS=>'K',PHE=>'F',PRO=>'P',SER=>'S',THR=>'T',ILE=>'I',VAL=>'V'); while () { if ($_=~m/HEADER\s+(.*)/){ print ">$1\n"; } if ($_=~m/^SEQRES\s+\d+\s+\w+\s+\d+\s+(.*)/){ $seq.=$1; $seq=~s/ //g;} } #THIS IS THE PART I CANT SEEM TO FIGURE OUT for ($i=0;$i<=length $seq; $i+=3) { print "$amino_acid_conversion{substr($seq,$i,3)}"; #All seems well with the sequence I get the desired output $k++;} print "\n"; if ($_=~m/^ATOM\s+\d+\s+\w+\s+\w+\s+\w+\d+\s+(\S+)\s+(\S+)\s+(\S+)/){ #the parentheses are the xyz coordinates respectively $x+=$1; $y+=$2; $z+=$3; } $xgk=($x/$k); $ygk=($y/$k); $zgk=($z/$k); print "$xgk $ygk $zgk \n";