Example #1
0
 def _validate_reacting_mol(self):
     reacting_mol = Chem.MolFromSmiles(Chem.MolToSmiles(self.reacting_mol))
     if not reacting_mol.GetSubstructMatch(self.INDOLE) or not isinstance(
             self.model, models.Sidechain):
         raise InvalidMolecule(
             'The reacting molecule in a pyrroloindoline reaction must be a sidechain containing an indole!'
         )
Example #2
0
    def _validate_reacting_atom(self, atom):
        if atom.GetSymbol() != 'C' or atom.GetTotalNumHs(
        ) == 0 or not atom.GetIsAromatic():
            raise InvalidMolecule(
                'The nucleophilic reacting atom must be an aromatic carbon with at least one hydrogen for a pictet spangler reaction!'
            )

        self.reacting_atom = atom
Example #3
0
    def _process_nucleophile(self):

        if isinstance(self.model, models.Sidechain):
            self._tag_sidechain_connection_atom()
        elif isinstance(self.model, models.Monomer):
            self._tag_monomer_connection_atom()
        else:
            raise InvalidMolecule(
                f'The nucleophile needs to be an instance of a sidechain or a monomer!'
            )
Example #4
0
    def _initialize(self, reacting_mol):
        super()._initialize(reacting_mol)

        try:
            self.reacting_mol = reacting_mol.aldehyde_cyclization_mol
            if self.reacting_mol is None:
                raise AttributeError
        except AttributeError:
            raise InvalidMolecule(
                'The reactin mol must be a template with an aldehyde_cyclization_mol property that is not None!'
            )
Example #5
0
    def _initialize(self, reacting_mol):
        super()._initialize(reacting_mol)

        try:
            self.reacting_mol = reacting_mol.template_pictet_spangler_mol
            if self.reacting_mol is None:
                raise AttributeError
        except AttributeError:
            raise InvalidMolecule(
                'The reacting mol must be a template with a template_pictet_spangler_mol property that is not None!'
            )
Example #6
0
 def _validate_sidechain(self):
     connection_atom = utils.get_atom_with_map_num(
         self.reacting_mol, self.SIDECHAIN_OLIGOMERIZATION_MAP_NUM)
     paths = Chem.FindAllPathsOfLengthN(
         self.reacting_mol,
         3,
         useBonds=False,
         rootedAtAtom=self.reacting_atom.GetIdx())
     atoms = set().union([atom for path in paths for atom in path])
     if connection_atom.GetIdx() not in atoms - set(
             atom.GetIdx() for atom in connection_atom.GetNeighbors()):
         raise InvalidMolecule(
             'The attachment point of the reacting sidechain must be two atoms away from the reacting atom in a pictet spangler reaction!'
         )
Example #7
0
 def _validate_monomer(self):
     try:
         n_term_atom = utils.get_atom_with_map_num(
             self.reacting_mol, self.BACKBONE_NITROGEN_MAP_NUM)
         paths = Chem.FindAllPathsOfLengthN(
             self.reacting_mol,
             5,
             useBonds=False,
             rootedAtAtom=self.reacting_atom.GetIdx())
         atoms = set().union([atom for path in paths for atom in path])
         if n_term_atom.GetIdx() not in atoms - set(
                 atom.GetIdx() for atom in n_term_atom.GetNeighbors()):
             raise InvalidMolecule(
                 'The reacting atom in the monomer must be 4 atoms away from the N-terminus!'
             )
     except (AttributeError, RuntimeError):
         raise InvalidMolecule
Example #8
0
    def _validate_reacting_atom(self, atom):
        self._tag_sidechain_connection_atom(change_to_wildcard=False)

        num_neighbors_hydrogens = [
            neighbor.GetTotalNumHs() for neighbor in atom.GetNeighbors()
        ]
        connection_atom = self._get_connection_atom()
        connection_atom_neighbors = [
            neighbor.GetIdx() for neighbor in connection_atom.GetNeighbors()
        ]

        # reaction initiated at carbon that is the attachment point to amino acid backbone, which contains no hydrogens
        if atom.GetTotalNumHs() != 0 \
                or atom.GetSymbol() != 'C' \
                or 1 not in num_neighbors_hydrogens \
                or atom.GetIdx() not in connection_atom_neighbors:
            raise InvalidMolecule(
                'The reacting atom of a pyrroloindoline reaction must be an aromatic carbon with no'
                ' hydrogens, adjacent to the connecting atom between the sidechain and backbone, and'
                ' with a neighbor that has exactly one hydrogen.')
Example #9
0
 def _validate_template(self):
     if self.template is None or not self.template.GetSubstructMatch(
             self.REQUIRED_SUBSTRUCT):
         raise InvalidMolecule(
             'The template molecule must contain a "C=CC" substructure for a pyrroloindoline reaction!'
         )
Example #10
0
 def _validate_reacting_atom(self, atom):
     if atom.GetSymbol() not in ('N', 'O',
                                 'S') or atom.GetTotalNumHs() == 0:
         raise InvalidMolecule(
             'The nucleophilic reacting atom must be a heteroatom with at least one hydrogen for a tsuji trost reaction!'
         )