コード例 #1
0
def hot_calc(inputs):
    pdb, het, pdir = inputs
    p = Protein.from_file(os.path.join(pdir, f"{pdb}.pdb"))
    mol = MoleculeReader(os.path.join(pdir, f"{pdb}_{het}.mol2"))[0]

    runner = Runner()
    hr = runner.from_protein(p, nprocesses=3, cavities=mol)

    for p, g in hr.super_grids.items():
        hr.super_grids[p] = g.max_value_of_neighbours()

    # with HotspotReader(os.path.join(pdir, "out.zip")) as r:
    #     hr = [h for h in r.read() if h.identifier == "hotspot"][0]

    e = Extractor(hr)
    bv = e.extract_volume(volume=250)

    # smoothing
    for p, g in bv.super_grids.items():
        bv.super_grids[p] = g.gaussian(sigma=0.5)

    bv.identifier = "bestvol"
    hr.identifier = "hotspot"

    with HotspotWriter(pdir) as w:
        w.write([hr, bv])
コード例 #2
0
def tractability_workflow(protein, tag):
    """
    A very simple tractability workflow.

    :param str protein: PDB identification code
    :param str tag: Tractability tag: either 'druggable' or 'less-druggable'
    :return: `pandas.DataFrame`
    """
    # 1) calculate Fragment Hotspot Result
    runner = Runner()
    result = runner.from_pdb(pdb_code=protein,
                             nprocesses=1,
                             buriedness_method='ghecom')

    # 2) calculate Best Continuous Volume
    extractor = Extractor(hr=result)
    bcv_result = extractor.extract_volume(volume=500)

    # 3) find the median score
    grid = Grid.get_single_grid(bcv_result.super_grids, mask=False)
    values = grid.grid_values(threshold=5)
    median = np.median(values)

    # 4) return the data
    return pd.DataFrame({
        'scores': values,
        'pdb': [protein] * len(values),
        'median': [median] * len(values),
        'tractability': [tag] * len(values),
    })
コード例 #3
0
    def _get_bcv(self, cav_id, other_id, lig_id):
        """
        generate a BCV for each cavity, and each required volume

        :param cav_id:
        :return:
        """
        # inputs
        hr = HotspotReader(path=os.path.join(self.hotspot[cav_id], "out.zip")).read()
        with open(self.ligand_volume[other_id][lig_id], 'r') as f:
            target_volume = f.read()

        # task
        start = time.time()
        extractor = Extractor(hr)
        bcv = extractor.extract_volume(volume=int(float(target_volume)))
        finish = time.time()

        # output
        out = self.bcv[cav_id][other_id][lig_id]

        create_directory(os.path.dirname(out))
        create_directory(out)

        with HotspotWriter(path=out, grid_extension=".grd", zip_results=True) as writer:
            writer.write(bcv)

        with open(self.bcv_time[cav_id][other_id][lig_id], 'w') as t:
            t.write(str(finish - start))

        with open(self.bcv_threshold[cav_id][other_id][lig_id], 'w') as s:
            s.write(str(bcv.step_threshold))
コード例 #4
0
    def testconstruction(self):
        extractor = Extractor(self.result)

        # extractor.single_grid.write(os.path.join(self.out, "2vta_single_grid.grd"))

        hr = extractor.extract_volume()

        with HotspotWriter(self.bin) as w:
            w.write(hr)
コード例 #5
0
def calc(args):
    prot_file, hotspot_file = args

    prot = Protein.from_file(prot_file)
    #  pre prepared
    runner = Runner()
    settings = Runner.Settings()
    settings.apolar_translation_threshold = 8
    settings.polar_translation_threshold = 10

    # pdb = os.path.basename(prot_file)[0][:4]
    #
    # mol_path = os.path.join(os.path.dirname(prot_file))

    hr = runner.from_protein(prot,
                             nprocesses=3,
                             settings=settings,
                             probe_size=3)

    for p, g in hr.super_grids.items():
        hr.super_grids[p] = g.dilate_by_atom()

    try:
        e = Extractor(hr)
        bv = e.extract_volume(volume=250)

    except:
        bv = Results(
            protein=hr.protein.copy(),
            super_grids={p: g.copy()
                         for p, g in hr.super_grids.items()})

    hr.identifier = "hotspot"
    bv.identifier = "bcv"

    with HotspotWriter(hotspot_file) as w:
        w.write([hr, bv])