Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this exercise you have to work with the PDB files (can be found online) that

ID: 3685346 • Letter: I

Question

In this exercise you have to work with the PDB files (can be found online) that represeant proteins. A protein consists of a sequence of chains of amino acids, called residues. Sometimes a protein has a single chain, and sometime it has many chains. The ATOM records in the file indicate, for each atom, which chain it belongs to. Each chain is named by a one-letter code following the space after the residue name. For example, the following line

ATOM 62 CE3 TRP A 7 34.108 15.499 -6.564 1.00 11.05 C

indicates that the atom is part of a tryptophan residue on chain A and this line,

ATOM 930 N LYS B 22 38.096 60.058 67.587 1.0027.57 N

indicates that the atom is part of lysine residue on chain B.

Your job is to write a script named countatoms that expects three arguments. The first argument is the three letter code of an amino acid, in uppercase, such as LEU or ASN. The second is a one-letter chain name, such as A,B, or C. The third is the name of the PDB file in which to look. The script should count the number of atoms in the file that belong to the given amino acid and are in the given chain in the given file and display the number (and nothing but the number) on the screen (i.e.,on what we call standar output). If it finds no atoms of that amino acid type in that chain, it should output the number 0. When run it should look like this:

$ countatoms LEU A/data/bios/b/student_accounts/cs132/data/pdb_files/1AIO.pdb

380

$ countatoms LEU B/data/bios/b/student_accounts/cs132/data/pdb_files/1AIO.pdb

760

showing that there are 380 atoms in the leucine residues in chain A and 760 in the leucine residues in chain B. Your script must check that it is gien three arguments are exit with a usage message if it is not used properly. It does not have to check that the residue name or the chain name is valid, or even if the file can be opened.

Explanation / Answer

my $DELIMITER = ' ';

if [ $# -ne 3 ]; then
echo "We need three Arguments!"
exit 3
else
open( SOURCE, "$3" )
or die "Can not open $3 for reading: $!";
   while read line   
   do   
   if [ ${line[2]} ?? '$1' ]
       if [ ${line[3]} ?? '$2' ]
           echo-e "${line[1]}"   
   done <$3   
       fi
   fi
fi

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote