コード例 #1
0
def getMoleculeFromAtom(atom: Chem.BasicAtom, protein: Chem.BasicMolecule) -> (Chem.BasicMolecule, list):
    """
    Given an atom and a protein structure, find the ligand the atom corresponds to.
    Traverses the molecule by its bonds until no longer any atoms are attached. All atoms and bonds are assigned to a
    new molecule, which is being returned.
    :param atom:
    :param protein:
    :return: The found ligand as well as the atom indices of the ligand in the parent molecule.
    """
    ligand = Chem.Fragment()
    neighbors = set()  # atoms not being added already
    neighborsAdded = set()  # keep track of added atoms to not process twice
    atomsToRemove = []

    neighbors.add(atom)
    while len(neighbors) > 0:
        n = neighbors.pop()
        neighborsAdded.add(n)
        ligand.addAtom(n)
        atomsToRemove.append(protein.getAtomIndex(n))

        # get all the neighbor atoms
        for i, b in enumerate(n.bonds):
            for a in b.atoms:
                if a != n:
                    if a not in neighbors and a not in neighborsAdded:  # new atom
                        neighbors.add(a)

                    ligand.addBond(b)  # ignored if already exists

    Chem.perceiveComponents(ligand, True)
    mol = Chem.BasicMolecule()
    mol.assign(ligand)
    return mol, atomsToRemove
コード例 #2
0
def _CDPLextractProteinFragments(pdb_mol, lig_three_letter_code, radius=6.0):
    lig = Chem.Fragment()
    _CDPLcalcProteinProperties(pdb_mol)

    # extract ligand
    for atom in pdb_mol.atoms:
        if Biomol.getResidueCode(atom) == lig_three_letter_code:
            Biomol.extractResidueSubstructure(atom, pdb_mol, lig, False)
    if lig.numAtoms == 0:
        log.error("The defined three letter code is not existing:",
                  lig_three_letter_code)
    # extract environment
    env = Chem.Fragment()
    Biomol.extractEnvironmentResidues(lig, pdb_mol, env, float(radius))

    return env, lig
コード例 #3
0
def getSurfaceAtoms(mol):
    surfaceATomExtractor = Chem.SurfaceAtomExtractor()
    f = Chem.Fragment()
    surfaceATomExtractor.extract(mol, mol, f)
    surfaceAtoms = Chem.BasicMolecule()
    surfaceAtoms.assign(f)
    return surfaceAtoms
def getPh4InteractionDictionary(cdf_path, ligand_code):

    ph4_interaction_dictionary = {}
    cdf_mol = loadCDFMolecule(cdf_path)
    num_confs = Chem.getNumConformations(cdf_mol)

    ligand = Chem.Fragment()
    for atom in cdf_mol.atoms:
        if Biomol.getResidueCode(atom) == ligand_code:
            Biomol.extractResidueSubstructure(atom, cdf_mol, ligand, False)
            break

    if ligand.numAtoms == 0:
        print('> Could not find ligand {}'.format(ligand_code))
        return 0

    Chem.perceiveSSSR(ligand, True)
    lig_env = Chem.Fragment()

    lig_pharm = Pharm.BasicPharmacophore()
    env_pharm = Pharm.BasicPharmacophore()
    pharm_gen = Pharm.DefaultPharmacophoreGenerator(True)

    analyzer = Pharm.DefaultInteractionAnalyzer()
    interactions = Pharm.FeatureMapping()

    for y in range(num_confs):
        lig_pharm.clear()
        env_pharm.clear()
        interactions.clear()
        lig_env.clear()

        coords_func = Chem.AtomConformer3DCoordinatesFunctor(y)
        pharm_gen.setAtom3DCoordinatesFunction(coords_func)
        Biomol.extractEnvironmentResidues(ligand, cdf_mol, lig_env,
                                          coords_func, 7)
        Chem.perceiveSSSR(lig_env, True)
        pharm_gen.generate(ligand, lig_pharm)

        pharm_gen.generate(lig_env, env_pharm)
        analyzer.analyze(lig_pharm, env_pharm, interactions)
        ph4_interaction_dictionary[y] = getPh4Interactions(
            lig_pharm, interactions)

    return ph4_interaction_dictionary
コード例 #5
0
        def generate_ph(pdb, key):

            ifs = Base.FileIOStream(pdb, 'r')
            tlc = self.ligand_3_letter_code
            pdb_reader = Biomol.PDBMoleculeReader(ifs)
            pdb_mol = Chem.BasicMolecule()

            print '- Reading input: ', pdb, ' ...'

            if not pdb_reader.read(pdb_mol):
                print '!! Could not read input molecule'
                return

            print '- Processing macromolecule', pdb, ' ...'

            i = 0

            while i < pdb_mol.getNumBonds():
                bond = pdb_mol.getBond(i)

                if Chem.isMetal(bond.atoms[0]) or Chem.isMetal(bond.atoms[1]):
                    pdb_mol.removeBond(i)
                else:
                    i += 1

            Chem.calcImplicitHydrogenCounts(pdb_mol, True)
            Chem.perceiveHybridizationStates(pdb_mol, True)
            Chem.makeHydrogenComplete(pdb_mol)
            Chem.setAtomSymbolsFromTypes(pdb_mol, False)
            Chem.calcImplicitHydrogenCounts(pdb_mol, True)
            Biomol.setHydrogenResidueSequenceInfo(pdb_mol, False)
            Chem.setRingFlags(pdb_mol, True)
            Chem.setAromaticityFlags(pdb_mol, True)
            Chem.generateHydrogen3DCoordinates(pdb_mol, True)
            ligand = Chem.Fragment()

            print '- Extracting ligand ', tlc, ' ...'

            for atom in pdb_mol.atoms:
                if Biomol.getResidueCode(atom) == tlc:
                    Biomol.extractResidueSubstructure(atom, pdb_mol, ligand,
                                                      False)
                    break

            if ligand.numAtoms == 0:
                print '!! Could not find ligand', tlc, 'in input file'
                return

            Chem.perceiveSSSR(ligand, True)

            lig_env = Chem.Fragment()

            Biomol.extractEnvironmentResidues(ligand, pdb_mol, lig_env, 7.0)
            Chem.perceiveSSSR(lig_env, True)
            print '- Constructing pharmacophore ...'
            lig_pharm = Pharm.BasicPharmacophore()
            env_pharm = Pharm.BasicPharmacophore()
            pharm_gen = Pharm.DefaultPharmacophoreGenerator(False)
            pharm_gen.generate(ligand, lig_pharm)
            pharm_gen.generate(lig_env, env_pharm)
            analyzer = Pharm.DefaultInteractionAnalyzer()
            interactions = Pharm.FeatureMapping()
            analyzer.analyze(lig_pharm, env_pharm, interactions)

            #------------------------- XVOLS

            int_env_ftrs = Pharm.FeatureSet()
            Pharm.getFeatures(int_env_ftrs, interactions, False)
            int_core_ftrs = Pharm.FeatureSet()
            Pharm.getFeatures(int_core_ftrs, interactions, True)
            int_pharm = Pharm.BasicPharmacophore(int_core_ftrs)

            for ftr in int_env_ftrs:
                if Pharm.getType(
                        ftr
                ) == Pharm.FeatureType.H_BOND_DONOR or Pharm.getType(
                        ftr) == Pharm.FeatureType.H_BOND_ACCEPTOR:
                    Pharm.setTolerance(ftr, 1.0)
                else:
                    Pharm.setTolerance(ftr, 1.5)

            Pharm.createExclusionVolumes(int_pharm, int_env_ftrs, 0.0, 0.1,
                                         False)
            int_env_ftr_atoms = Chem.Fragment()
            Pharm.getFeatureAtoms(int_env_ftrs, int_env_ftr_atoms)
            int_residue_atoms = Chem.Fragment()
            Biomol.extractResidueSubstructures(int_env_ftr_atoms, lig_env,
                                               int_residue_atoms, True)
            Chem.makeHydrogenDeplete(int_residue_atoms)

            def isAlphaAtom(atom):
                return Biomol.getResidueAtomName(atom) == 'CA'

            Chem.removeAtomsIfNot(int_residue_atoms, isAlphaAtom)
            Pharm.createExclusionVolumes(int_pharm, int_residue_atoms,
                                         Chem.Atom3DCoordinatesFunctor(), 1.0,
                                         2.0, False)

            features_in_ph = []
            for int_ftr in int_pharm:
                if Pharm.hasSubstructure(int_ftr) == False:
                    continue
                elif ftype_names[Pharm.getType(int_ftr)] == 'XV':
                    continue
                feature_id = generate_key(int_ftr)
                features_in_ph.append(str(feature_id))
                self.unique_feature_vector.add(str(feature_id))

            int_pharm.fv = features_in_ph
            int_pharm.path_to_pdb = pdb

            return int_pharm
コード例 #6
0
def generate_ph(pdb, args, df_constructor, ts):

    ifs = Base.FileIOStream(pdb, 'r')
    tlc = args.ligand_three_letter_code
    pdb_reader = Biomol.PDBMoleculeReader(ifs)
    pdb_mol = Chem.BasicMolecule()

    print '- Reading input: ', pdb, ' ...'

    if not pdb_reader.read(pdb_mol):
        print '!! Could not read input molecule'
        return

    print '- Processing macromolecule', pdb, ' ...'

    i = 0

    while i < pdb_mol.getNumBonds():
        bond = pdb_mol.getBond(i)

        if Chem.isMetal(bond.atoms[0]) or Chem.isMetal(bond.atoms[1]):
            pdb_mol.removeBond(i)
        else:
            i += 1

    for a in pdb_mol.atoms:
        Chem.setImplicitHydrogenCount(a, 0)

    Chem.calcImplicitHydrogenCounts(pdb_mol, True)
    Chem.perceiveHybridizationStates(pdb_mol, True)
    Chem.makeHydrogenComplete(pdb_mol)
    Chem.setAtomSymbolsFromTypes(pdb_mol, False)
    Chem.calcImplicitHydrogenCounts(pdb_mol, True)
    Biomol.setHydrogenResidueSequenceInfo(pdb_mol, False)
    Chem.setRingFlags(pdb_mol, True)
    Chem.setAromaticityFlags(pdb_mol, True)
    Chem.generateHydrogen3DCoordinates(pdb_mol, True)
    Chem.calcFormalCharges(pdb_mol, True)
    ligand = Chem.Fragment()

    print '- Extracting ligand ', tlc, ' ...'

    for atom in pdb_mol.atoms:
        if Biomol.getResidueCode(atom) == tlc:
            Biomol.extractResidueSubstructure(atom, pdb_mol, ligand, False)
            break

    if ligand.numAtoms == 0:
        print '!! Could not find ligand', tlc, 'in input file'
        return

    Chem.perceiveSSSR(ligand, True)

    lig_env = Chem.Fragment()

    Biomol.extractEnvironmentResidues(ligand, pdb_mol, lig_env, 7.0)
    Chem.perceiveSSSR(lig_env, True)
    print '- Constructing pharmacophore ...'
    lig_pharm = Pharm.BasicPharmacophore()
    env_pharm = Pharm.BasicPharmacophore()
    pharm_gen = Pharm.DefaultPharmacophoreGenerator(True)
    pharm_gen.generate(ligand, lig_pharm)
    pharm_gen.generate(lig_env, env_pharm)
    #Pharm.FilePMLFeatureContainerWriter('./test/lig_ph_' + str(ts) + '.pml').write(lig_pharm)

    analyzer = Pharm.DefaultInteractionAnalyzer()
    interactions = Pharm.FeatureMapping()
    analyzer.analyze(lig_pharm, env_pharm, interactions)
    df_constructor, interaction_at_ts = outputInteractions(
        lig_pharm, env_pharm, interactions, df_constructor)
    #Chem.FileSDFMolecularGraphWriter('./test/ligand_' + str(ts) + '.sdf').write(ligand)

    return df_constructor, interaction_at_ts