text: user14439: Can anybody please explain the below line to me.
  "We took the structure and coordinates of nogalamycin
  from the X-ray structure determined in PDB code = 1D17"
  What do I need to download from there....a pdb file or what?
  Thank you
  
  user10049: well wasnt able to figure out how to make openapigenerator work with rcsb pdb ModelServer https://models.rcsb.org/, I ended up with this code
  copying the webserver manual input results for ligands:
  import requests
  
  
  def main():
     
    risposta = requests.get('https://models.rcsb.org/v1/1d17/ligand?encoding=cif&copy_all_categories=false&download=true&filename=out',
                            
                            allow_redirects=True)
    
    open('out.cif', 'wb').write(risposta.content)
  
    print(risposta.status_code)
  
  if __name__ == '__main__':      
     
     main()
  
  unfortunately the server gives you the wrong ligand (try it out)
  it says :' ​/v1​/{id}​/ligand
  Coordinates of the first group satisfying the given criteria.'
  tried with:
  risposta = requests.get('https://models.rcsb.org/v1/1d17/ligand?label_atom_id=NGM&encoding=cif&copy_all_categories=false&download=true&filename=out',
                         
                         allow_redirects=True)
  
  but no luck again, think problem is in downloaded file :
  _model_server_params.name     atom_site 
  _model_server_params.value    '{"label_atom_id":"NGM"}'  ###### here
  
  but not an expert of APis and openAPI at all
  EDITED:
  eventually I got it right using in the code above:
  risposta = requests.get('https://models.rcsb.org/v1/1d17/ligand?label_comp_id=NGM&encoding=cif&copy_all_categories=false&download=true&filename=out',
                        
                        allow_redirects=True) 
  
  so I get a out.cif file containing NGM
  using another database and FTP :
  #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  """
  Created on Fri Nov 19 19:29:30 2021
  
  @author: Pietro
  
  
  https://bioinformatics.stackexchange.com/questions/18076/help-me-in-understanding-the-pdb-file#comment25289_18076
  
  Ligand extract:
      
  https://stackoverflow.com/questions/61390035/how-to-save-each-ligand-from-a-pdb-file-separately-with-bio-pdb
  
  """
  
  from ftplib import FTP
  
  import gzip
  
  import os
  
  from Bio.PDB import PDBParser, PDBIO, Select
  
  
  def is_het(residue):
      res = residue.id[0]
      return res != " " and res != "W"
  
  
  class ResidueSelect(Select):
      def __init__(self, chain, residue):
          self.chain = chain
          self.residue = residue
  
      def accept_chain(self, chain):
          return chain.id == self.chain.id
  
      def accept_residue(self, residue):
          """ Recognition of heteroatoms - Remove water molecules """
          return residue == self.residue and is_het(residue)
  
  
  def extract_ligands(path):
      """ Extraction of the heteroatoms of .pdb files """
  
      for pfb_file in os.listdir(path):
          i = 1
          if pfb_file.endswith('.pdb') and not pfb_file.startswith("lig_"):
              pdb_code = pfb_file[:-4]
              pdb = PDBParser().get_structure(pdb_code, path + pfb_file)
              io = PDBIO()
              io.set_structure(pdb)
              for model in pdb:
                  for chain in model:
                      for residue in chain:
                          if not is_het(residue):
                              continue
                          print(f"saving {chain} {residue}")
                          io.save(f"lig_{pdb_code}_{i}.pdb", ResidueSelect(chain, residue))
                          i += 1
  
  
  
  
  def getFile(ftp, filename):
      try:
          # ftp.retrbinary("RETR", filename ,open(code+'.gz', 'wb').write)
          ftp.retrbinary("RETR " + filename ,open(code+'.gz', 'wb').write)
      except:
          print("Error somewhere !!!!")
  
  
  code = '1D17'
  filename = 'pdb'+code.lower()+'.ent.gz'                 ## pdb1D17.ent.gz    
  
  print(filename)
  
  
  
  
  ftp = FTP('ftp.wwpdb.org')   # connect to host, default port
  
  # ftp.login()               # user anonymous, passwd anonymous@
  print(ftp.login())
  
  ftp.cwd('/pub/pdb/data/structures/all/pdb/')  
  
  print(ftp.pwd()  )
  
  getFile(ftp, filename)
  
  zipped = gzip.open(code+'.gz', 'rb')
  
  unzipped = zipped.read()
  
  # print(unzipped)
  
  
  saved = open(code+'.pdb', 'wb')
  
  saved.write(unzipped)
  saved.close()
  
  
  path = './'
  
  extract_ligands(path)
  
  
  copying from : https://stackoverflow.com/questions/61390035/how-to-save-each-ligand-from-a-pdb-file-separately-with-bio-pdb
  and using FTP from ftplib on http://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/   : PDB - FTP Archive over HTTP
  NOGALAMYCIN is NGM third ligand downloaded (shuold be the only one according to https://www.rcsb.org/structure/1d17)
  In any case I am failing at ubderstandung *,-)  how https://models.rcsb.org/
  Parameters are related to https://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/beginner%E2%80%99s-guide-to-pdb-structures-and-the-pdbx-mmcif-format , the mmcif format
  but as I told before I can't read inside openapi.json OpenAPI Specification
  
original_text: 14439: <p>Can anybody please explain the below line to me.</p>
  <p>&quot;We took the structure and coordinates of nogalamycin
  from the X-ray structure determined in PDB code = 1D17&quot;</p>
  <p>What do I need to download from there....a pdb file or what?</p>
  <p>Thank you</p>
   10049: <p>well wasnt able to figure out how to make openapigenerator work with rcsb pdb ModelServer <a href="https://models.rcsb.org/" rel="nofollow noreferrer">https://models.rcsb.org/</a>, I ended up with this code
  copying the webserver manual input results for ligands:</p>
  <pre><code>import requests
  
  
  def main():
     
    risposta = requests.get('https://models.rcsb.org/v1/1d17/ligand?encoding=cif&amp;copy_all_categories=false&amp;download=true&amp;filename=out',
                            
                            allow_redirects=True)
    
    open('out.cif', 'wb').write(risposta.content)
  
    print(risposta.status_code)
  
  if __name__ == '__main__':      
     
     main()
  </code></pre>
  <p>unfortunately the server gives you the wrong ligand (try it out)</p>
  <p>it says :' ​/v1​/{id}​/ligand
  Coordinates of the first group satisfying the given criteria.'</p>
  <p>tried with:</p>
  <pre><code>risposta = requests.get('https://models.rcsb.org/v1/1d17/ligand?label_atom_id=NGM&amp;encoding=cif&amp;copy_all_categories=false&amp;download=true&amp;filename=out',
                         
                         allow_redirects=True)
  </code></pre>
  <p>but no luck again, think problem is in downloaded file :</p>
  <pre><code>_model_server_params.name     atom_site 
  _model_server_params.value    '{&quot;label_atom_id&quot;:&quot;NGM&quot;}'  ###### here
  </code></pre>
  <p>but not an expert of APis and openAPI at all</p>
  <p>EDITED:</p>
  <p>eventually I got it right using in the code above:</p>
  <pre><code>risposta = requests.get('https://models.rcsb.org/v1/1d17/ligand?label_comp_id=NGM&amp;encoding=cif&amp;copy_all_categories=false&amp;download=true&amp;filename=out',
                        
                        allow_redirects=True) 
  </code></pre>
  <p>so I get a out.cif file containing NGM</p>
  <p>using another database and FTP :</p>
  <pre><code>#!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  &quot;&quot;&quot;
  Created on Fri Nov 19 19:29:30 2021
  
  @author: Pietro
  
  
  https://bioinformatics.stackexchange.com/questions/18076/help-me-in-understanding-the-pdb-file#comment25289_18076
  
  Ligand extract:
      
  https://stackoverflow.com/questions/61390035/how-to-save-each-ligand-from-a-pdb-file-separately-with-bio-pdb
  
  &quot;&quot;&quot;
  
  from ftplib import FTP
  
  import gzip
  
  import os
  
  from Bio.PDB import PDBParser, PDBIO, Select
  
  
  def is_het(residue):
      res = residue.id[0]
      return res != &quot; &quot; and res != &quot;W&quot;
  
  
  class ResidueSelect(Select):
      def __init__(self, chain, residue):
          self.chain = chain
          self.residue = residue
  
      def accept_chain(self, chain):
          return chain.id == self.chain.id
  
      def accept_residue(self, residue):
          &quot;&quot;&quot; Recognition of heteroatoms - Remove water molecules &quot;&quot;&quot;
          return residue == self.residue and is_het(residue)
  
  
  def extract_ligands(path):
      &quot;&quot;&quot; Extraction of the heteroatoms of .pdb files &quot;&quot;&quot;
  
      for pfb_file in os.listdir(path):
          i = 1
          if pfb_file.endswith('.pdb') and not pfb_file.startswith(&quot;lig_&quot;):
              pdb_code = pfb_file[:-4]
              pdb = PDBParser().get_structure(pdb_code, path + pfb_file)
              io = PDBIO()
              io.set_structure(pdb)
              for model in pdb:
                  for chain in model:
                      for residue in chain:
                          if not is_het(residue):
                              continue
                          print(f&quot;saving {chain} {residue}&quot;)
                          io.save(f&quot;lig_{pdb_code}_{i}.pdb&quot;, ResidueSelect(chain, residue))
                          i += 1
  
  
  
  
  def getFile(ftp, filename):
      try:
          # ftp.retrbinary(&quot;RETR&quot;, filename ,open(code+'.gz', 'wb').write)
          ftp.retrbinary(&quot;RETR &quot; + filename ,open(code+'.gz', 'wb').write)
      except:
          print(&quot;Error somewhere !!!!&quot;)
  
  
  code = '1D17'
  filename = 'pdb'+code.lower()+'.ent.gz'                 ## pdb1D17.ent.gz    
  
  print(filename)
  
  
  
  
  ftp = FTP('ftp.wwpdb.org')   # connect to host, default port
  
  # ftp.login()               # user anonymous, passwd anonymous@
  print(ftp.login())
  
  ftp.cwd('/pub/pdb/data/structures/all/pdb/')  
  
  print(ftp.pwd()  )
  
  getFile(ftp, filename)
  
  zipped = gzip.open(code+'.gz', 'rb')
  
  unzipped = zipped.read()
  
  # print(unzipped)
  
  
  saved = open(code+'.pdb', 'wb')
  
  saved.write(unzipped)
  saved.close()
  
  
  path = './'
  
  extract_ligands(path)
  
  </code></pre>
  <p>copying from : <a href="https://stackoverflow.com/questions/61390035/how-to-save-each-ligand-from-a-pdb-file-separately-with-bio-pdb">https://stackoverflow.com/questions/61390035/how-to-save-each-ligand-from-a-pdb-file-separately-with-bio-pdb</a></p>
  <p>and using FTP from ftplib on <a href="http://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/" rel="nofollow noreferrer">http://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/</a>   : PDB - FTP Archive over HTTP</p>
  <p>NOGALAMYCIN is NGM third ligand downloaded (shuold be the only one according to <a href="https://www.rcsb.org/structure/1d17" rel="nofollow noreferrer">https://www.rcsb.org/structure/1d17</a>)</p>
  <p>In any case I am failing at ubderstandung *,-)  how <a href="https://models.rcsb.org/" rel="nofollow noreferrer">https://models.rcsb.org/</a></p>
  <p>Parameters are related to <a href="https://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/beginner%E2%80%99s-guide-to-pdb-structures-and-the-pdbx-mmcif-format" rel="nofollow noreferrer">https://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/beginner%E2%80%99s-guide-to-pdb-structures-and-the-pdbx-mmcif-format</a> , the mmcif format</p>
  <p>but as I told before I can't read inside openapi.json OpenAPI Specification</p>
  