docs: def prune_structure_according_to_loops_file(self, loops_file_content, search_radius, expected_loop_length = None, generate_pymol_session = True):
          '''todo: this needs to be rewritten to include the logic in prune_structure_according_to_loop_definitions.'''
          lf = LoopsFile(loops_file_content)
          assert(len(lf.data) == 1) # todo: remove
  
          # Extract the list of Residues defined in the loops file
          loop_residues = []
          for loop in lf.data:
              # Identify the Residues corresponding to the loops file definition
              start_id = str(loop['start'])
              end_id = str(loop['end'])
              start = []
              end = []
              for chain, chain_residues in self.residues.iteritems():
                  for res, residue_object in chain_residues.iteritems():
                      if res.strip() == start_id:
                          start.append((chain, res, residue_object))
                      if res.strip() == end_id:
                          end.append((chain, res, residue_object))
              if len(start) != len(end) != 1:
                  raise Exception('The PDB is ambiguous with respect to the loops file i.e. more than one PDB residue corresponds to the start or end residue defined in the loops file.')
              start, end = start[0], end[0]
  
              # We assume that the loops file identifies a range in document order
              loop_start = False
              for l in self.indexed_lines:
                  if l[0] == 'ATOM' or l[0] == 'HETATM':
                      atom_residue = l[3].residue
                      if not loop_start:
                          if atom_residue == start[2]:
                              loop_start = True
                              if atom_residue not in loop_residues:
                                  loop_residues.append(atom_residue)
                      else:
                          if atom_residue not in loop_residues:
                              loop_residues.append(atom_residue)
                          if atom_residue == end[2]:
                              break
          if expected_loop_length != None and expected_loop_length != len(loop_residues):
              raise Exception('Expected to identify {0} residues but {1} were identified.'.format(expected_loop_length, len(loop_residues)))
  
          # Determine the sidechain atoms to be removed
          sidechain_atom_serial_numbers = self.find_sidechain_atoms_within_radius_of_residue_objects(loop_residues, search_radius)
  
          # Determine the loop residue atoms to be removed
          loop_residues_ids = set()
          loop_atom_serial_numbers = set()
          for loop_residue in loop_residues:
              for aatom in loop_residue.get('ATOM'):
                  loop_atom_serial_numbers.add(aatom.serial_number)
          assert(len(sidechain_atom_serial_numbers.intersection(loop_atom_serial_numbers)) == 0)
  
          return self.prune(loop_atom_serial_numbers, sidechain_atom_serial_numbers, generate_pymol_session = generate_pymol_session)