import logging

from gavel.logic import logic
from rdkit import Chem

from chemlog.base_classifier import Classifier
from chemlog.fol_classification.peptide_size_verifier import FOLPeptideSizeClassifierTranslated
from chemlog.fol_to_py.folToPyTranslator import PythonCompiler, SO_KEY
from chemlog.preprocessing.mol_to_fol import mol_to_fol_atoms_plus_building_blocks


class AlgPeptideSizeClassifierTranslated(Classifier):
    """This class classifies peptides based on the number of amino acid residues connected via peptide bonds.
        It uses a translation of MSOL definitions via FOL to Python code (for the first-order fragment of our definitions).
    """

    def classify(self, mol: Chem.Mol, *args, **kwargs) -> (int, dict):
        # calculate so_elements (here, building blocks) separately, not from a FOL translation
        so_elements = mol_to_fol_atoms_plus_building_blocks(mol)[-1]
        logging.debug(f"Building blocks (so_elements): {so_elements}")
        for n in range(2, 11):
            res = eval(f"peptide_{n}plus(mol, so_elements)")
            logging.debug(f"peptide_{n}plus(mol, so_elements): {res}")
            if not res:
                return n - 1, dict()
        return 10, dict()


def translate_definitions():
    # generate a python function that returns true iff the corresponding predicate expression holds
    compiler = PythonCompiler(mol=None)
    fol_classifier = FOLPeptideSizeClassifierTranslated()
    #print('\n'.join([f'{k}: {v}' for k, v in fol_classifier.structure_formulas.items()]))
    peptide_definitions = {
        f"peptide_{n}plus": logic.BinaryFormula(logic.PredicateExpression(f"peptide_{n}plus", []),
                                                logic.BinaryConnective.BIIMPLICATION,
                                                fol_classifier.build_peptide_structure_formula(n)
                                                ) for n in range(2, 11)
    }
    for name, fol_definition in {**fol_classifier.structure_formulas, **peptide_definitions}.items():
        definition = f"def {name}({', '.join(['mol: Chem.Mol', SO_KEY] + [str(a) for a in fol_definition.left.arguments])}):\n" \
                    f"    # {fol_definition}\n" \
                    f"    return {compiler.visit(fol_definition.right)}\n"
        print(definition)

# these functions have been generated automatically by translate_definitions()
def HasOverlap(mol: Chem.Mol, so_elements, x1, x2):
    # (HasOverlap(x1, x2)) <=> (∃[x0]: ((is_in(x0, x1)) & (is_in(x0, x2))))
    return any((x0.GetIdx() in x1 and x0.GetIdx() in x2) for x0 in mol.GetAtoms())

def AmideBondFO(mol: Chem.Mol, so_elements, a_c, a_o, a_n):
    # (AmideBondFO(a_c, a_o, a_n)) <=> (((c(a_c)) & (o(a_o)) & (n(a_n)) & (bSINGLE(a_c, a_o) | bDOUBLE(a_c, a_o)) & (bSINGLE(a_c, a_o) | bSINGLE(a_c, a_n)) & (bDOUBLE(a_c, a_n) | bDOUBLE(a_c, a_o)) & (bDOUBLE(a_c, a_n) | bSINGLE(a_c, a_n)) & (has1hs(a_o) | chargen(a_o) | bDOUBLE(a_c, a_o)) & (has1hs(a_o) | chargen(a_o) | bSINGLE(a_c, a_n))))
    return (a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and a_n.GetSymbol() == 'N' and ((mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.SINGLE) or (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE)) and ((mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.SINGLE) or (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and ((mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) or (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE)) and ((mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) or (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and (a_o.GetTotalNumHs() == 1 or a_o.GetFormalCharge() < 0 or (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE)) and (a_o.GetTotalNumHs() == 1 or a_o.GetFormalCharge() < 0 or (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_n.GetIdx()).GetBondType() == Chem.BondType.SINGLE)))

def AminoGroupFO(mol: Chem.Mol, so_elements, a_n):
    # (AminoGroupFO(a_n)) <=> (((n(a_n)) & (∀[x0]: ∃[x1]: ((~(has_bond_to(a_n, x0)) | c(x0)) & (~(has_bond_to(a_n, x0)) | bSINGLE(a_n, x0) | AmideBondFO(x0, x1, a_n))))))
    return (a_n.GetSymbol() == 'N' and all(any(((not(mol.GetBondBetweenAtoms(a_n.GetIdx(), x0.GetIdx()) is not None) or x0.GetSymbol() == 'C') and (not(mol.GetBondBetweenAtoms(a_n.GetIdx(), x0.GetIdx()) is not None) or (mol.GetBondBetweenAtoms(a_n.GetIdx(), x0.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_n.GetIdx(), x0.GetIdx()).GetBondType() == Chem.BondType.SINGLE) or AmideBondFO(mol, so_elements, x0, x1, a_n))) for x1 in mol.GetAtoms()) for x0 in mol.GetAtoms()))

def CarboxyResidueFO(mol: Chem.Mol, so_elements, a_c, a_o, a_s):
    # (CarboxyResidueFO(a_c, a_o, a_s)) <=> (((c(a_c)) & (o(a_o)) & (bDOUBLE(a_c, a_o)) & (bSINGLE(a_c, a_s))))
    return (a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE))

def AAR(mol: Chem.Mol, so_elements, x):
    # (AAR(x)) <=> (∃[x0, x1, x2, x3]: ((BuildingBlock(x)) & (AminoGroupFO(x0)) & (is_in(x0, x)) & (CarboxyResidueFO(x1, x2, x3)) & (is_in(x1, x))))
    return any((x in so_elements and AminoGroupFO(mol, so_elements, x0) and x0.GetIdx() in x and CarboxyResidueFO(mol, so_elements, x1, x2, x3) and x1.GetIdx() in x) for x0 in mol.GetAtoms() for x1 in mol.GetAtoms() for x2 in mol.GetAtoms() for x3 in mol.GetAtoms())

def peptide_2plus(mol: Chem.Mol, so_elements):
    # (peptide_2plus()) <=> (∃[A0, A1]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a))))))
    return any((
                       (
                               A0 in so_elements
                               and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms())
                               and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())
                       )
                       and (
                               A1 in so_elements
                               and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms())
                               and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())
                       )
                       and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms()))
                       and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms())
               ) for A0 in so_elements for A1 in so_elements)

def peptide_3plus(mol: Chem.Mol, so_elements):
    # (peptide_3plus()) <=> (∃[A0, A1, A2]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements)

def peptide_4plus(mol: Chem.Mol, so_elements):
    # (peptide_4plus()) <=> (∃[A0, A1, A2, A3]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements)

def peptide_5plus(mol: Chem.Mol, so_elements):
    # (peptide_5plus()) <=> (∃[A0, A1, A2, A3, A4]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & (BuildingBlock(A4) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A4)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A4))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A4))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a)))) & ∃[b3b]: ((is_in(b3b, A0) | is_in(b3b, A1) | is_in(b3b, A2) | is_in(b3b, A3) | is_in(b3b, A4)) & ∃[b3a]: (is_in(b3a, A4) & ∃[b3o]: (AmideBondFO(b3a, b3o, b3b)) | (AmideBondFO(b3b, b3o, b3a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A4 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A4) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A4) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A4) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms()) and any(((b3b.GetIdx() in A0 or b3b.GetIdx() in A1 or b3b.GetIdx() in A2 or b3b.GetIdx() in A3 or b3b.GetIdx() in A4) and any((b3a.GetIdx() in A4 and any((AmideBondFO(mol, so_elements, b3a, b3o, b3b) or AmideBondFO(mol, so_elements, b3b, b3o, b3a)) for b3o in mol.GetAtoms())) for b3a in mol.GetAtoms())) for b3b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements for A4 in so_elements)

def peptide_6plus(mol: Chem.Mol, so_elements):
    # (peptide_6plus()) <=> (∃[A0, A1, A2, A3, A4, A5]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & (BuildingBlock(A4) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A4)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A4))) & (BuildingBlock(A5) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A5)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A5))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A5))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a)))) & ∃[b3b]: ((is_in(b3b, A0) | is_in(b3b, A1) | is_in(b3b, A2) | is_in(b3b, A3) | is_in(b3b, A4)) & ∃[b3a]: (is_in(b3a, A4) & ∃[b3o]: (AmideBondFO(b3a, b3o, b3b)) | (AmideBondFO(b3b, b3o, b3a)))) & ∃[b4b]: ((is_in(b4b, A0) | is_in(b4b, A1) | is_in(b4b, A2) | is_in(b4b, A3) | is_in(b4b, A4) | is_in(b4b, A5)) & ∃[b4a]: (is_in(b4a, A5) & ∃[b4o]: (AmideBondFO(b4a, b4o, b4b)) | (AmideBondFO(b4b, b4o, b4a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A4 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A4) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A4) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A5 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A5) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A5) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A5) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms()) and any(((b3b.GetIdx() in A0 or b3b.GetIdx() in A1 or b3b.GetIdx() in A2 or b3b.GetIdx() in A3 or b3b.GetIdx() in A4) and any((b3a.GetIdx() in A4 and any((AmideBondFO(mol, so_elements, b3a, b3o, b3b) or AmideBondFO(mol, so_elements, b3b, b3o, b3a)) for b3o in mol.GetAtoms())) for b3a in mol.GetAtoms())) for b3b in mol.GetAtoms()) and any(((b4b.GetIdx() in A0 or b4b.GetIdx() in A1 or b4b.GetIdx() in A2 or b4b.GetIdx() in A3 or b4b.GetIdx() in A4 or b4b.GetIdx() in A5) and any((b4a.GetIdx() in A5 and any((AmideBondFO(mol, so_elements, b4a, b4o, b4b) or AmideBondFO(mol, so_elements, b4b, b4o, b4a)) for b4o in mol.GetAtoms())) for b4a in mol.GetAtoms())) for b4b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements for A4 in so_elements for A5 in so_elements)

def peptide_7plus(mol: Chem.Mol, so_elements):
    # (peptide_7plus()) <=> (∃[A0, A1, A2, A3, A4, A5, A6]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & (BuildingBlock(A4) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A4)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A4))) & (BuildingBlock(A5) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A5)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A5))) & (BuildingBlock(A6) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A6)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A6))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A6))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a)))) & ∃[b3b]: ((is_in(b3b, A0) | is_in(b3b, A1) | is_in(b3b, A2) | is_in(b3b, A3) | is_in(b3b, A4)) & ∃[b3a]: (is_in(b3a, A4) & ∃[b3o]: (AmideBondFO(b3a, b3o, b3b)) | (AmideBondFO(b3b, b3o, b3a)))) & ∃[b4b]: ((is_in(b4b, A0) | is_in(b4b, A1) | is_in(b4b, A2) | is_in(b4b, A3) | is_in(b4b, A4) | is_in(b4b, A5)) & ∃[b4a]: (is_in(b4a, A5) & ∃[b4o]: (AmideBondFO(b4a, b4o, b4b)) | (AmideBondFO(b4b, b4o, b4a)))) & ∃[b5b]: ((is_in(b5b, A0) | is_in(b5b, A1) | is_in(b5b, A2) | is_in(b5b, A3) | is_in(b5b, A4) | is_in(b5b, A5) | is_in(b5b, A6)) & ∃[b5a]: (is_in(b5a, A6) & ∃[b5o]: (AmideBondFO(b5a, b5o, b5b)) | (AmideBondFO(b5b, b5o, b5a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A4 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A4) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A4) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A5 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A5) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A5) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A6 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A6) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A6) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A6) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms()) and any(((b3b.GetIdx() in A0 or b3b.GetIdx() in A1 or b3b.GetIdx() in A2 or b3b.GetIdx() in A3 or b3b.GetIdx() in A4) and any((b3a.GetIdx() in A4 and any((AmideBondFO(mol, so_elements, b3a, b3o, b3b) or AmideBondFO(mol, so_elements, b3b, b3o, b3a)) for b3o in mol.GetAtoms())) for b3a in mol.GetAtoms())) for b3b in mol.GetAtoms()) and any(((b4b.GetIdx() in A0 or b4b.GetIdx() in A1 or b4b.GetIdx() in A2 or b4b.GetIdx() in A3 or b4b.GetIdx() in A4 or b4b.GetIdx() in A5) and any((b4a.GetIdx() in A5 and any((AmideBondFO(mol, so_elements, b4a, b4o, b4b) or AmideBondFO(mol, so_elements, b4b, b4o, b4a)) for b4o in mol.GetAtoms())) for b4a in mol.GetAtoms())) for b4b in mol.GetAtoms()) and any(((b5b.GetIdx() in A0 or b5b.GetIdx() in A1 or b5b.GetIdx() in A2 or b5b.GetIdx() in A3 or b5b.GetIdx() in A4 or b5b.GetIdx() in A5 or b5b.GetIdx() in A6) and any((b5a.GetIdx() in A6 and any((AmideBondFO(mol, so_elements, b5a, b5o, b5b) or AmideBondFO(mol, so_elements, b5b, b5o, b5a)) for b5o in mol.GetAtoms())) for b5a in mol.GetAtoms())) for b5b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements for A4 in so_elements for A5 in so_elements for A6 in so_elements)

def peptide_8plus(mol: Chem.Mol, so_elements):
    # (peptide_8plus()) <=> (∃[A0, A1, A2, A3, A4, A5, A6, A7]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & (BuildingBlock(A4) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A4)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A4))) & (BuildingBlock(A5) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A5)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A5))) & (BuildingBlock(A6) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A6)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A6))) & (BuildingBlock(A7) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A7)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A7))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A6)) & (is_in(a, A7))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a)))) & ∃[b3b]: ((is_in(b3b, A0) | is_in(b3b, A1) | is_in(b3b, A2) | is_in(b3b, A3) | is_in(b3b, A4)) & ∃[b3a]: (is_in(b3a, A4) & ∃[b3o]: (AmideBondFO(b3a, b3o, b3b)) | (AmideBondFO(b3b, b3o, b3a)))) & ∃[b4b]: ((is_in(b4b, A0) | is_in(b4b, A1) | is_in(b4b, A2) | is_in(b4b, A3) | is_in(b4b, A4) | is_in(b4b, A5)) & ∃[b4a]: (is_in(b4a, A5) & ∃[b4o]: (AmideBondFO(b4a, b4o, b4b)) | (AmideBondFO(b4b, b4o, b4a)))) & ∃[b5b]: ((is_in(b5b, A0) | is_in(b5b, A1) | is_in(b5b, A2) | is_in(b5b, A3) | is_in(b5b, A4) | is_in(b5b, A5) | is_in(b5b, A6)) & ∃[b5a]: (is_in(b5a, A6) & ∃[b5o]: (AmideBondFO(b5a, b5o, b5b)) | (AmideBondFO(b5b, b5o, b5a)))) & ∃[b6b]: ((is_in(b6b, A0) | is_in(b6b, A1) | is_in(b6b, A2) | is_in(b6b, A3) | is_in(b6b, A4) | is_in(b6b, A5) | is_in(b6b, A6) | is_in(b6b, A7)) & ∃[b6a]: (is_in(b6a, A7) & ∃[b6o]: (AmideBondFO(b6a, b6o, b6b)) | (AmideBondFO(b6b, b6o, b6a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A4 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A4) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A4) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A5 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A5) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A5) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A6 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A6) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A6) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A7 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A7) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A7) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A6 and a.GetIdx() in A7) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms()) and any(((b3b.GetIdx() in A0 or b3b.GetIdx() in A1 or b3b.GetIdx() in A2 or b3b.GetIdx() in A3 or b3b.GetIdx() in A4) and any((b3a.GetIdx() in A4 and any((AmideBondFO(mol, so_elements, b3a, b3o, b3b) or AmideBondFO(mol, so_elements, b3b, b3o, b3a)) for b3o in mol.GetAtoms())) for b3a in mol.GetAtoms())) for b3b in mol.GetAtoms()) and any(((b4b.GetIdx() in A0 or b4b.GetIdx() in A1 or b4b.GetIdx() in A2 or b4b.GetIdx() in A3 or b4b.GetIdx() in A4 or b4b.GetIdx() in A5) and any((b4a.GetIdx() in A5 and any((AmideBondFO(mol, so_elements, b4a, b4o, b4b) or AmideBondFO(mol, so_elements, b4b, b4o, b4a)) for b4o in mol.GetAtoms())) for b4a in mol.GetAtoms())) for b4b in mol.GetAtoms()) and any(((b5b.GetIdx() in A0 or b5b.GetIdx() in A1 or b5b.GetIdx() in A2 or b5b.GetIdx() in A3 or b5b.GetIdx() in A4 or b5b.GetIdx() in A5 or b5b.GetIdx() in A6) and any((b5a.GetIdx() in A6 and any((AmideBondFO(mol, so_elements, b5a, b5o, b5b) or AmideBondFO(mol, so_elements, b5b, b5o, b5a)) for b5o in mol.GetAtoms())) for b5a in mol.GetAtoms())) for b5b in mol.GetAtoms()) and any(((b6b.GetIdx() in A0 or b6b.GetIdx() in A1 or b6b.GetIdx() in A2 or b6b.GetIdx() in A3 or b6b.GetIdx() in A4 or b6b.GetIdx() in A5 or b6b.GetIdx() in A6 or b6b.GetIdx() in A7) and any((b6a.GetIdx() in A7 and any((AmideBondFO(mol, so_elements, b6a, b6o, b6b) or AmideBondFO(mol, so_elements, b6b, b6o, b6a)) for b6o in mol.GetAtoms())) for b6a in mol.GetAtoms())) for b6b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements for A4 in so_elements for A5 in so_elements for A6 in so_elements for A7 in so_elements)

def peptide_9plus(mol: Chem.Mol, so_elements):
    # (peptide_9plus()) <=> (∃[A0, A1, A2, A3, A4, A5, A6, A7, A8]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & (BuildingBlock(A4) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A4)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A4))) & (BuildingBlock(A5) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A5)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A5))) & (BuildingBlock(A6) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A6)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A6))) & (BuildingBlock(A7) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A7)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A7))) & (BuildingBlock(A8) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A8)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A8))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A6)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A6)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A7)) & (is_in(a, A8))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a)))) & ∃[b3b]: ((is_in(b3b, A0) | is_in(b3b, A1) | is_in(b3b, A2) | is_in(b3b, A3) | is_in(b3b, A4)) & ∃[b3a]: (is_in(b3a, A4) & ∃[b3o]: (AmideBondFO(b3a, b3o, b3b)) | (AmideBondFO(b3b, b3o, b3a)))) & ∃[b4b]: ((is_in(b4b, A0) | is_in(b4b, A1) | is_in(b4b, A2) | is_in(b4b, A3) | is_in(b4b, A4) | is_in(b4b, A5)) & ∃[b4a]: (is_in(b4a, A5) & ∃[b4o]: (AmideBondFO(b4a, b4o, b4b)) | (AmideBondFO(b4b, b4o, b4a)))) & ∃[b5b]: ((is_in(b5b, A0) | is_in(b5b, A1) | is_in(b5b, A2) | is_in(b5b, A3) | is_in(b5b, A4) | is_in(b5b, A5) | is_in(b5b, A6)) & ∃[b5a]: (is_in(b5a, A6) & ∃[b5o]: (AmideBondFO(b5a, b5o, b5b)) | (AmideBondFO(b5b, b5o, b5a)))) & ∃[b6b]: ((is_in(b6b, A0) | is_in(b6b, A1) | is_in(b6b, A2) | is_in(b6b, A3) | is_in(b6b, A4) | is_in(b6b, A5) | is_in(b6b, A6) | is_in(b6b, A7)) & ∃[b6a]: (is_in(b6a, A7) & ∃[b6o]: (AmideBondFO(b6a, b6o, b6b)) | (AmideBondFO(b6b, b6o, b6a)))) & ∃[b7b]: ((is_in(b7b, A0) | is_in(b7b, A1) | is_in(b7b, A2) | is_in(b7b, A3) | is_in(b7b, A4) | is_in(b7b, A5) | is_in(b7b, A6) | is_in(b7b, A7) | is_in(b7b, A8)) & ∃[b7a]: (is_in(b7a, A8) & ∃[b7o]: (AmideBondFO(b7a, b7o, b7b)) | (AmideBondFO(b7b, b7o, b7a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A4 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A4) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A4) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A5 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A5) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A5) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A6 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A6) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A6) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A7 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A7) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A7) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A8 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A8) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A8) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A6 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A6 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A7 and a.GetIdx() in A8) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms()) and any(((b3b.GetIdx() in A0 or b3b.GetIdx() in A1 or b3b.GetIdx() in A2 or b3b.GetIdx() in A3 or b3b.GetIdx() in A4) and any((b3a.GetIdx() in A4 and any((AmideBondFO(mol, so_elements, b3a, b3o, b3b) or AmideBondFO(mol, so_elements, b3b, b3o, b3a)) for b3o in mol.GetAtoms())) for b3a in mol.GetAtoms())) for b3b in mol.GetAtoms()) and any(((b4b.GetIdx() in A0 or b4b.GetIdx() in A1 or b4b.GetIdx() in A2 or b4b.GetIdx() in A3 or b4b.GetIdx() in A4 or b4b.GetIdx() in A5) and any((b4a.GetIdx() in A5 and any((AmideBondFO(mol, so_elements, b4a, b4o, b4b) or AmideBondFO(mol, so_elements, b4b, b4o, b4a)) for b4o in mol.GetAtoms())) for b4a in mol.GetAtoms())) for b4b in mol.GetAtoms()) and any(((b5b.GetIdx() in A0 or b5b.GetIdx() in A1 or b5b.GetIdx() in A2 or b5b.GetIdx() in A3 or b5b.GetIdx() in A4 or b5b.GetIdx() in A5 or b5b.GetIdx() in A6) and any((b5a.GetIdx() in A6 and any((AmideBondFO(mol, so_elements, b5a, b5o, b5b) or AmideBondFO(mol, so_elements, b5b, b5o, b5a)) for b5o in mol.GetAtoms())) for b5a in mol.GetAtoms())) for b5b in mol.GetAtoms()) and any(((b6b.GetIdx() in A0 or b6b.GetIdx() in A1 or b6b.GetIdx() in A2 or b6b.GetIdx() in A3 or b6b.GetIdx() in A4 or b6b.GetIdx() in A5 or b6b.GetIdx() in A6 or b6b.GetIdx() in A7) and any((b6a.GetIdx() in A7 and any((AmideBondFO(mol, so_elements, b6a, b6o, b6b) or AmideBondFO(mol, so_elements, b6b, b6o, b6a)) for b6o in mol.GetAtoms())) for b6a in mol.GetAtoms())) for b6b in mol.GetAtoms()) and any(((b7b.GetIdx() in A0 or b7b.GetIdx() in A1 or b7b.GetIdx() in A2 or b7b.GetIdx() in A3 or b7b.GetIdx() in A4 or b7b.GetIdx() in A5 or b7b.GetIdx() in A6 or b7b.GetIdx() in A7 or b7b.GetIdx() in A8) and any((b7a.GetIdx() in A8 and any((AmideBondFO(mol, so_elements, b7a, b7o, b7b) or AmideBondFO(mol, so_elements, b7b, b7o, b7a)) for b7o in mol.GetAtoms())) for b7a in mol.GetAtoms())) for b7b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements for A4 in so_elements for A5 in so_elements for A6 in so_elements for A7 in so_elements for A8 in so_elements)

def peptide_10plus(mol: Chem.Mol, so_elements):
    # (peptide_10plus()) <=> (∃[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9]: ((BuildingBlock(A0) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A0)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A0))) & (BuildingBlock(A1) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A1)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A1))) & (BuildingBlock(A2) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A2)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A2))) & (BuildingBlock(A3) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A3)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A3))) & (BuildingBlock(A4) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A4)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A4))) & (BuildingBlock(A5) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A5)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A5))) & (BuildingBlock(A6) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A6)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A6))) & (BuildingBlock(A7) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A7)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A7))) & (BuildingBlock(A8) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A8)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A8))) & (BuildingBlock(A9) & ∃[a_n]: (AminoGroupFO(a_n)) & (is_in(a_n, A9)) & ∃[a_c, a_o, a_s]: ((c(a_c) & o(a_o) & bDOUBLE(a_c, a_o) & bSINGLE(a_c, a_s)) & is_in(a_c, A9))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A1))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A0)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A2))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A1)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A3))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A2)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A4))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A3)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A5))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A4)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A6))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A5)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A6)) & (is_in(a, A7))) & ~(∃[a]: (is_in(a, A6)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A6)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A7)) & (is_in(a, A8))) & ~(∃[a]: (is_in(a, A7)) & (is_in(a, A9))) & ~(∃[a]: (is_in(a, A8)) & (is_in(a, A9))) & ∃[b0b]: ((is_in(b0b, A0) | is_in(b0b, A1)) & ∃[b0a]: (is_in(b0a, A1) & ∃[b0o]: (AmideBondFO(b0a, b0o, b0b)) | (AmideBondFO(b0b, b0o, b0a)))) & ∃[b1b]: ((is_in(b1b, A0) | is_in(b1b, A1) | is_in(b1b, A2)) & ∃[b1a]: (is_in(b1a, A2) & ∃[b1o]: (AmideBondFO(b1a, b1o, b1b)) | (AmideBondFO(b1b, b1o, b1a)))) & ∃[b2b]: ((is_in(b2b, A0) | is_in(b2b, A1) | is_in(b2b, A2) | is_in(b2b, A3)) & ∃[b2a]: (is_in(b2a, A3) & ∃[b2o]: (AmideBondFO(b2a, b2o, b2b)) | (AmideBondFO(b2b, b2o, b2a)))) & ∃[b3b]: ((is_in(b3b, A0) | is_in(b3b, A1) | is_in(b3b, A2) | is_in(b3b, A3) | is_in(b3b, A4)) & ∃[b3a]: (is_in(b3a, A4) & ∃[b3o]: (AmideBondFO(b3a, b3o, b3b)) | (AmideBondFO(b3b, b3o, b3a)))) & ∃[b4b]: ((is_in(b4b, A0) | is_in(b4b, A1) | is_in(b4b, A2) | is_in(b4b, A3) | is_in(b4b, A4) | is_in(b4b, A5)) & ∃[b4a]: (is_in(b4a, A5) & ∃[b4o]: (AmideBondFO(b4a, b4o, b4b)) | (AmideBondFO(b4b, b4o, b4a)))) & ∃[b5b]: ((is_in(b5b, A0) | is_in(b5b, A1) | is_in(b5b, A2) | is_in(b5b, A3) | is_in(b5b, A4) | is_in(b5b, A5) | is_in(b5b, A6)) & ∃[b5a]: (is_in(b5a, A6) & ∃[b5o]: (AmideBondFO(b5a, b5o, b5b)) | (AmideBondFO(b5b, b5o, b5a)))) & ∃[b6b]: ((is_in(b6b, A0) | is_in(b6b, A1) | is_in(b6b, A2) | is_in(b6b, A3) | is_in(b6b, A4) | is_in(b6b, A5) | is_in(b6b, A6) | is_in(b6b, A7)) & ∃[b6a]: (is_in(b6a, A7) & ∃[b6o]: (AmideBondFO(b6a, b6o, b6b)) | (AmideBondFO(b6b, b6o, b6a)))) & ∃[b7b]: ((is_in(b7b, A0) | is_in(b7b, A1) | is_in(b7b, A2) | is_in(b7b, A3) | is_in(b7b, A4) | is_in(b7b, A5) | is_in(b7b, A6) | is_in(b7b, A7) | is_in(b7b, A8)) & ∃[b7a]: (is_in(b7a, A8) & ∃[b7o]: (AmideBondFO(b7a, b7o, b7b)) | (AmideBondFO(b7b, b7o, b7a)))) & ∃[b8b]: ((is_in(b8b, A0) | is_in(b8b, A1) | is_in(b8b, A2) | is_in(b8b, A3) | is_in(b8b, A4) | is_in(b8b, A5) | is_in(b8b, A6) | is_in(b8b, A7) | is_in(b8b, A8) | is_in(b8b, A9)) & ∃[b8a]: (is_in(b8a, A9) & ∃[b8o]: (AmideBondFO(b8a, b8o, b8b)) | (AmideBondFO(b8b, b8o, b8a))))))
    return any(((A0 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A0) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A0) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A1 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A1) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A1) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A2 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A2) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A2) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A3 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A3) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A3) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A4 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A4) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A4) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A5 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A5) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A5) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A6 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A6) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A6) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A7 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A7) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A7) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A8 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A8) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A8) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and (A9 in so_elements and any((AminoGroupFO(mol, so_elements, a_n) and a_n.GetIdx() in A9) for a_n in mol.GetAtoms()) and any(((a_c.GetSymbol() == 'C' and a_o.GetSymbol() == 'O' and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_o.GetIdx()).GetBondType() == Chem.BondType.DOUBLE) and (mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()) is not None and mol.GetBondBetweenAtoms(a_c.GetIdx(), a_s.GetIdx()).GetBondType() == Chem.BondType.SINGLE)) and a_c.GetIdx() in A9) for a_c in mol.GetAtoms() for a_o in mol.GetAtoms() for a_s in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A1) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A0 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A2) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A1 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A3) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A2 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A4) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A3 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A5) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A4 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A6) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A5 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A6 and a.GetIdx() in A7) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A6 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A6 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A7 and a.GetIdx() in A8) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A7 and a.GetIdx() in A9) for a in mol.GetAtoms())) and not(any((a.GetIdx() in A8 and a.GetIdx() in A9) for a in mol.GetAtoms())) and any(((b0b.GetIdx() in A0 or b0b.GetIdx() in A1) and any((b0a.GetIdx() in A1 and any((AmideBondFO(mol, so_elements, b0a, b0o, b0b) or AmideBondFO(mol, so_elements, b0b, b0o, b0a)) for b0o in mol.GetAtoms())) for b0a in mol.GetAtoms())) for b0b in mol.GetAtoms()) and any(((b1b.GetIdx() in A0 or b1b.GetIdx() in A1 or b1b.GetIdx() in A2) and any((b1a.GetIdx() in A2 and any((AmideBondFO(mol, so_elements, b1a, b1o, b1b) or AmideBondFO(mol, so_elements, b1b, b1o, b1a)) for b1o in mol.GetAtoms())) for b1a in mol.GetAtoms())) for b1b in mol.GetAtoms()) and any(((b2b.GetIdx() in A0 or b2b.GetIdx() in A1 or b2b.GetIdx() in A2 or b2b.GetIdx() in A3) and any((b2a.GetIdx() in A3 and any((AmideBondFO(mol, so_elements, b2a, b2o, b2b) or AmideBondFO(mol, so_elements, b2b, b2o, b2a)) for b2o in mol.GetAtoms())) for b2a in mol.GetAtoms())) for b2b in mol.GetAtoms()) and any(((b3b.GetIdx() in A0 or b3b.GetIdx() in A1 or b3b.GetIdx() in A2 or b3b.GetIdx() in A3 or b3b.GetIdx() in A4) and any((b3a.GetIdx() in A4 and any((AmideBondFO(mol, so_elements, b3a, b3o, b3b) or AmideBondFO(mol, so_elements, b3b, b3o, b3a)) for b3o in mol.GetAtoms())) for b3a in mol.GetAtoms())) for b3b in mol.GetAtoms()) and any(((b4b.GetIdx() in A0 or b4b.GetIdx() in A1 or b4b.GetIdx() in A2 or b4b.GetIdx() in A3 or b4b.GetIdx() in A4 or b4b.GetIdx() in A5) and any((b4a.GetIdx() in A5 and any((AmideBondFO(mol, so_elements, b4a, b4o, b4b) or AmideBondFO(mol, so_elements, b4b, b4o, b4a)) for b4o in mol.GetAtoms())) for b4a in mol.GetAtoms())) for b4b in mol.GetAtoms()) and any(((b5b.GetIdx() in A0 or b5b.GetIdx() in A1 or b5b.GetIdx() in A2 or b5b.GetIdx() in A3 or b5b.GetIdx() in A4 or b5b.GetIdx() in A5 or b5b.GetIdx() in A6) and any((b5a.GetIdx() in A6 and any((AmideBondFO(mol, so_elements, b5a, b5o, b5b) or AmideBondFO(mol, so_elements, b5b, b5o, b5a)) for b5o in mol.GetAtoms())) for b5a in mol.GetAtoms())) for b5b in mol.GetAtoms()) and any(((b6b.GetIdx() in A0 or b6b.GetIdx() in A1 or b6b.GetIdx() in A2 or b6b.GetIdx() in A3 or b6b.GetIdx() in A4 or b6b.GetIdx() in A5 or b6b.GetIdx() in A6 or b6b.GetIdx() in A7) and any((b6a.GetIdx() in A7 and any((AmideBondFO(mol, so_elements, b6a, b6o, b6b) or AmideBondFO(mol, so_elements, b6b, b6o, b6a)) for b6o in mol.GetAtoms())) for b6a in mol.GetAtoms())) for b6b in mol.GetAtoms()) and any(((b7b.GetIdx() in A0 or b7b.GetIdx() in A1 or b7b.GetIdx() in A2 or b7b.GetIdx() in A3 or b7b.GetIdx() in A4 or b7b.GetIdx() in A5 or b7b.GetIdx() in A6 or b7b.GetIdx() in A7 or b7b.GetIdx() in A8) and any((b7a.GetIdx() in A8 and any((AmideBondFO(mol, so_elements, b7a, b7o, b7b) or AmideBondFO(mol, so_elements, b7b, b7o, b7a)) for b7o in mol.GetAtoms())) for b7a in mol.GetAtoms())) for b7b in mol.GetAtoms()) and any(((b8b.GetIdx() in A0 or b8b.GetIdx() in A1 or b8b.GetIdx() in A2 or b8b.GetIdx() in A3 or b8b.GetIdx() in A4 or b8b.GetIdx() in A5 or b8b.GetIdx() in A6 or b8b.GetIdx() in A7 or b8b.GetIdx() in A8 or b8b.GetIdx() in A9) and any((b8a.GetIdx() in A9 and any((AmideBondFO(mol, so_elements, b8a, b8o, b8b) or AmideBondFO(mol, so_elements, b8b, b8o, b8a)) for b8o in mol.GetAtoms())) for b8a in mol.GetAtoms())) for b8b in mol.GetAtoms())) for A0 in so_elements for A1 in so_elements for A2 in so_elements for A3 in so_elements for A4 in so_elements for A5 in so_elements for A6 in so_elements for A7 in so_elements for A8 in so_elements for A9 in so_elements)


if __name__ == "__main__":
    # run translate_definitions() once, paste the result above, then run the classification
    #translate_definitions()
    classifier = AlgPeptideSizeClassifierTranslated()
    mol = Chem.MolFromSmiles("[H][C@@]1(O[C@H](OC[C@H](NC(=O)CNC(C)=O)C(=O)NCC(=O)N[C@@H](OC(C)C)C(O)=O)[C@@H](O)[C@@H](O)[C@@H]1O)[C@@H](O)CO")
    #mol = Chem.MolFromSmiles("CC(C)C[C@H](NC(=O)CN)C(O)=O")
    mol = Chem.MolFromSmiles("C[C@H]([NH3+])C(=O)N[C@H](CCC(=O)N[C@H](CCC[C@H]([NH3+])C([O-])=O)C(=O)N[C@H](C)C([O-])=O)C([O-])=O")
    print(classifier.classify(mol))