Exemplo n.º 1
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),
    })
Exemplo n.º 2
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])
Exemplo n.º 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))
Exemplo n.º 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)
    def run(self):
        hs = HotspotReader(self.input().path).read()

        settings = Extractor.Settings()
        settings.cutoff = 12
        settings.mvon = False

        extractor = Extractor(hs, settings)
        best = extractor.extract_best_volume(volume=100)[0]

        out_settings = HotspotWriter.Settings()
        out_settings.charged = False

        with HotspotWriter(os.path.dirname(self.output().path),
                           grid_extension=".grd",
                           zip_results=True,
                           settings=out_settings) as w:
            w.write(best)
Exemplo n.º 6
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])
Exemplo n.º 7
0
    def generate_fitting_points(self,
                                hr,
                                volume=400,
                                threshold=17,
                                mode='threshold'):
        """
        uses the Fragment Hotspot Maps to generate GOLD fitting points.

        GOLD fitting points are used to help place the molecules into the protein cavity. Pre-generating these fitting
        points using the Fragment Hotspot Maps helps to biast results towards making Hotspot interactions.

        :param `hotspots.result.Result` hr: a Fragment Hotspot Maps result
        :param int volume: volume of the occupied by fitting points in Angstroms ^ 3
        :param float threshold: points above this value will be included in the fitting points
        :param str mode: 'threshold'- assigns fitting points based on a score cutoff or 'bcv'- assigns fitting points from best continuous volume analysis (recommended)
        """
        temp = tempfile.mkdtemp()
        mol = molecule.Molecule(identifier="fitting_pts")

        if mode == 'threshold':
            dic = hr.super_grids["apolar"].grid_value_by_coordinates(
                threshold=threshold)

        elif mode == 'bcv':
            extractor = Extractor(hr=hr, volume=volume, mode="global")
            bv = extractor.extracted_hotspots[0].best_island
            dic = bv.grid_value_by_coordinates(threshold=17)

        else:
            raise TypeError(
                "{} not supported, see documentation for details".format(mode))

        for score, v in dic.items():
            for pts in v:
                atm = molecule.Atom(atomic_symbol='C',
                                    atomic_number=14,
                                    label='{:.2f}'.format(score),
                                    coordinates=pts)
                atm.partial_charge = score
                mol.add_atom(atom=atm)

        fname = os.path.join(temp, 'fit_pts.mol2')
        with io.MoleculeWriter(fname) as w:
            w.write(mol)

        self.fitting_points_file = fname