def main(argv=[__name__]):
    if len(argv) != 2:
        oechem.OEThrow.Usage("%s <infile>" % argv[0])

    ifs = oechem.oemolistream(argv[1])

    for mol in ifs.GetOEGraphMols():
        oechem.OEThrow.Info("              Title: %s" % mol.GetTitle())
        oechem.OEThrow.Info("             Volume: %8.2f" %
                            oeshape.OECalcVolume(mol))
        oechem.OEThrow.Info("Volume: (without H): %8.2f\n" %
                            oeshape.OECalcVolume(mol, False))

        smult = oeshape.OECalcShapeMultipoles(mol)

        oechem.OEThrow.Info("  Steric multipoles:")
        oechem.OEThrow.Info("           monopole: %8.2f" % smult[0])
        oechem.OEThrow.Info("        quadrupoles: %8.2f %8.2f %8.2f" %
                            (smult[1], smult[2], smult[3]))
        oechem.OEThrow.Info("          octopoles:")
        oechem.OEThrow.Info(
            "                xxx: %8.2f  yyy: %8.2f  zzz: %8.2f" %
            (smult[4], smult[5], smult[6]))
        oechem.OEThrow.Info(
            "                xxy: %8.2f  xxz: %8.2f  yyx: %8.2f" %
            (smult[7], smult[8], smult[9]))
        oechem.OEThrow.Info(
            "                yyz: %8.2f  zzx: %8.2f  zzy: %8.2f" %
            (smult[10], smult[11], smult[12]))
        oechem.OEThrow.Info("                xyz: %8.2f\n" % smult[13])
Exemple #2
0
    for molecule in tqdm(docked_molecules):
        shapeFunc.SetupRef(molecule)

        # Compute overlaps
        score = 0.0
        result = oeshape.OEOverlapResults()
        overlapping_fragments = list()
        for fragment_name, fragment in fragments.items():
            #overlap, volume = compute_fragment_overlap(molecule, fragment)
            shapeFunc.Overlap(fragment, result)
            # Compute overlap
            overlap = result.GetTanimoto()
            if overlap > max_overlap:
                max_overlap = overlap
            # Compute volume
            volume = oeshape.OECalcVolume(fragment)
            # Accumulate score
            score += volume * overlap
            # Store fragment
            if overlap > OVERLAP_THRESHOLD:
                overlapping_fragments.append(fragment_name)
            # DEBUG
            #print(f'  {fragment_name} {overlap:8.3f} {volume:10.3f}')

            # Correct for fragment-fragment overlap

        n_overlapping_fragments = len(overlapping_fragments)
        #print(f'{directory:16} {index:6} {molecule.GetTitle():18} {covalent_id:8} {score:10.3f} {overlapping_fragments}')

        # Attach scores
        oechem.OESetSDData(molecule, 'number_of_overlapping_fragments',
                # Store it
                fragments[fragment_name] = fragment.CreateCopy()
    print(f'{len(fragments)} fragments loaded.')

    # Get appropriate function to calculate analytic shape
    prep = oeshape.OEOverlapPrep()
    result = oeshape.OEOverlapResults()
    fragment_func = oeshape.OEExactColorFunc()
    print('Computing overlap scores...')
    for molecule in tqdm(docked_molecules):
        # Compute overlap with merged query
        refmol = molecule.CreateCopy()
        prep.Prep(refmol)
        fragment_func.SetupRef(refmol)
        volume = oeshape.OECalcVolume(molecule)

        # Compute overlaps
        overlapping_fragments = list()
        fragment_overlap_scores = dict()
        score = 0.0
        inspiration_fragment_names = oechem.OEGetSDData(molecule, 'fragments').split(',')
        for fragment_name in inspiration_fragment_names:
            if fragment_name not in fragments:
                continue
            fragment = fragments[fragment_name]
            fitmol = fragment.CreateCopy()
            prep.Prep(fitmol)
            fragment_func.Overlap(fitmol, result)
            # Compute overlap (fraction of the fragment covered)
            fragment_overlap = result.GetRefTverskyCombo()