Returns a pandas dataframe of X, Y, Z coordinates for the PDB chain.
           Note: This function is not intended to handle structures with MODELs e.g. from NMR although the fail_on_model_records
           check is optional for convenience in case the chain of the first model is to be parsed.

def extract_xyz_matrix_from_pdb_chain(pdb_lines, chain_id, atoms_of_interest = backbone_atoms, expected_num_residues = None, expected_num_residue_atoms = None, fail_on_model_records = True, include_all_columns = False):
        '''Returns a pandas dataframe of X, Y, Z coordinates for the PDB chain.
           Note: This function is not intended to handle structures with MODELs e.g. from NMR although the fail_on_model_records
           check is optional for convenience in case the chain of the first model is to be parsed.'''

        if fail_on_model_records and [l for l in pdb_lines if l.startswith('MODEL')]:
            raise Exception('This function does not handle files with MODEL records. Please split those file by model first.')

        new_pdb_lines = []
        found_chain = False
        for l in pdb_lines:
            if l.startswith('ATOM  '):
                if l[21] == chain_id:
                    found_chain = True
                    if found_chain:
                        new_pdb_lines.append(l)
            if found_chain and (l.strip() == 'TER' or l.startswith('MODEL') or (len(l) > 21 and l[21] != chain_id)):
                # Do not cross over into other chains or models
                break
        return PDB.extract_xyz_matrix_from_pdb_residue_range(new_pdb_lines, atoms_of_interest = atoms_of_interest, expected_num_residues = expected_num_residues, expected_num_residue_atoms = expected_num_residue_atoms, include_all_columns = include_all_columns)