title: How to extract chains from a PDB file?
body: <p>I would like to extract chains from pdb files. I have a file named pdb.txt which contains pdb IDs as shown below. The first four characters represent PDB IDs and  last character is the chain IDs.</p>
  
  <pre><code>1B68A 
  1BZ4B
  4FUTA
  </code></pre>
  
  <p>I would like to  1) read the file line by line 
                   2) download the atomic coordinates of each chain from the corresponding PDB files.<br>
                   3) save the output to a folder.</p>
  
  <p>I used the following script to extract chains. But this code prints only A chains from pdb files.</p>
  
  <pre><code>for i in 1B68 1BZ4 4FUT
  do 
  wget -c "http://www.pdb.org/pdb/download/downloadFile.do?fileFormat=pdb&amp;compression=NO&amp;structureId="$i -O $i.pdb
  grep  ATOM $i.pdb | grep 'A' &gt; $i\_A.pdb
  done
  </code></pre>