See http://www.iucr.org/__data/iucr/cif/standard/cifstd4.html, Acta Cryst. (1991). A47, 655-685.

def parse_cif(self, cif):
        '''See http://www.iucr.org/__data/iucr/cif/standard/cifstd4.html, Acta Cryst. (1991). A47, 655-685.'''
        found_cif_header = False
        found_cif_descriptors = False
        found_cif_identifiers = False

        blocks = []
        blocklines = []
        for l in cif.split('\n'):
            if l.strip() == '#':
                if blocklines:
                    blocks.append('\n'.join(blocklines))
                    blocklines = []
            else:
                blocklines.append(l)
        if blocklines:
            blocks.append('\n'.join(blocklines))

        for block in blocks:
            if block.find('_chem_comp.id') != -1:
                assert(not found_cif_header)
                self.parse_cif_header(block)
                found_cif_header = True
            elif block.find('_chem_comp_atom.model_Cartn_x') != -1:
                continue
            elif block.find('_chem_comp_atom.pdbx_stereo_config') != -1:
                continue
            elif block.find('_pdbx_chem_comp_descriptor.comp_id') != -1:
                assert(not found_cif_descriptors)
                self.parse_cif_descriptor(block)
                found_cif_descriptors = True
            elif block.find('_pdbx_chem_comp_identifier.comp_id') != -1:
                assert(not found_cif_identifiers)
                self.parse_cif_identifier(block)
                found_cif_identifiers = True
            elif block.find('_pdbx_chem_comp_audit.comp_id') != -1:
                continue
            else:
                continue