def validate(data): try: if data['oligomerization_kekule'] is not None: Template.validate_oligomerization_mol( Chem.MolFromSmiles(data['oligomerization_kekule'])) if data['friedel_crafts_kekule'] is not None: Template.validate_friedel_crafts_mol( Chem.MolFromSmiles(data['friedel_crafts_kekule'])) if data['tsuji_trost_kekule'] is not None: Template.validate_tsuji_trost_mol( Chem.MolFromSmiles(data['tsuji_trost_kekule'])) if data['pictet_spangler_kekule'] is not None: Template.validate_pictet_spangler_mol( Chem.MolFromSmiles(data['pictet_spangler_kekule'])) if data['template_pictet_spangler_kekule'] is not None: Template.validate_template_pictet_spangler_mol( Chem.MolFromSmiles( data['template_pictet_spangler_kekule'])) if data['pyrroloindoline_kekule'] is not None: Template.validate_pyrroloindoline_mol( Chem.MolFromSmiles(data['pyrroloindoline_kekule'])) if data['aldehyde_cyclization_kekule'] is not None: Template.validate_aldehyde_cyclization_mol( Chem.MolFromSmiles(data['aldehyde_cyclization_kekule'])) except ValueError as err: raise exceptions.InvalidMolecule(str(err)) return True
def validate(mol): attachment_point = list( chain.from_iterable(mol.GetSubstructMatches(SC_ATTACHMENT_POINT))) if len(attachment_point) != 1: raise exceptions.InvalidMolecule( f'Sidechains must have exactly one attachment point') return attachment_point[0]
def validate(mol): if not [ ring for ring in mol.GetRingInfo().BondRings() if len(ring) >= config.MIN_MACRO_RING_SIZE ]: raise exceptions.InvalidMolecule( f'A macrocycle must have at least {config.MIN_MACRO_RING_SIZE} ring atoms!' ) return True
def validate(mol): try: _, map_nums = zip(*utils.get_atom_map_nums(mol)) if not all(map(lambda x: x == Backbone.MAP_NUM, map_nums)): raise ValueError except ValueError: raise exceptions.InvalidMolecule( f'Backbone molecule is missing an atom map number or the atom map number is not equal to 1' ) return True
def validate(mol, macrocycle): Macrocycle.validate(mol) if mol.GetNumConformers() <= 0: raise exceptions.InvalidMolecule( 'The conformer mol has no conformers')