当前位置: 首页>>代码示例>>Python>>正文


Python Molecule.center方法代码示例

本文整理汇总了Python中htmd.molecule.molecule.Molecule.center方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.center方法的具体用法?Python Molecule.center怎么用?Python Molecule.center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htmd.molecule.molecule.Molecule的用法示例。


在下文中一共展示了Molecule.center方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _prep_and_run

# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import center [as 别名]
    def _prep_and_run(self, mol, rtf, prm, outdir, solvated):
        from htmd.builder.solvate import solvate
        from htmd.apps.acemdlocal import AcemdLocal
        # Do a simple solvation then run for 50ns
        ionize = True

        mol = Molecule(mol)
        mol.center()
        mol.set("segid", "L")
        d = maxDistance(mol, 'all') + 6

        if solvated:
            mol = solvate(mol, minmax=[[-d, -d, -d], [d, d, d]])

        if not solvated:
            ionize = False

        build_dir = os.path.join(outdir, "build")
        equil_dir = os.path.join(outdir, "equil")

        rtfs = ['top/top_water_ions.rtf', rtf]
        prms = ['par/par_water_ions.prm', prm]
        charmm.build(mol, topo=rtfs, param=prms, outdir=build_dir, ionize=ionize)
        md = Equilibration()
        md.runtime = 50
        md.timeunits = 'ns'
        md.temperature = 300
        md.write(build_dir, equil_dir)
        mdx = AcemdLocal()
        mdx.submit(equil_dir)
        mdx.wait()
开发者ID:jeiros,项目名称:htmd,代码行数:33,代码来源:sample.py

示例2: buildMembrane

# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import center [as 别名]
def buildMembrane(xysize, ratioupper, ratiolower, waterbuff=20, equilibrate=True, outdir='./buildmemb/', lipidf=None):
    """ Construct a membrane containing arbitrary lipids and ratios of them.

    Parameters
    ----------
    xysize : list
        A list containing the size in x and y dimensions of the membrane in Angstroms
    ratioupper : list of lists
        A list containing sublists indicating the molecule name and the ratio of that molecule for the upper layer
    ratiolower : list of lists
        Same as ratioupper but for the lower layer
    waterbuff : float
        The z-dimension size of the water box above and below the membrane
    equilibrate : bool
        If True it equilibrates the membrane
    outdir : str
        A folder in which to store the psf and pdb files
    lipidf : str
        The path to the starting lipid conformations

    Returns
    -------
    mol : :class:`Molecule <htmd.molecule.molecule.Molecule`
        The resulting membrane including surrounding waters

    Examples
    --------
    >>> lipidratioupper = [['popc', 10], ['chl1', 1]]
    >>> lipidratiolower = [['popc', 8], ['chl1', 2]]
    >>> width = [50, 100]
    >>> res = buildMembrane(width, lipidratioupper, lipidratiolower)
    """
    from htmd.membranebuilder.ringpenetration import resolveRingPenetrations
    from htmd.builder.solvate import solvate
    from htmd.builder.charmm import build
    from htmd.util import tempname
    from htmd.molecule.molecule import Molecule
    from htmd.home import home
    import os
    import pandas as pd

    if lipidf is None:
        lipidf = os.path.join(home(), 'membranebuilder', 'lipids')
    lipiddb = pd.read_csv(os.path.join(home(), 'membranebuilder', 'lipiddb.csv'), index_col='Name')

    uqlip = np.unique([x[0] for x in ratioupper] + [x[0] for x in ratiolower])
    files = _locateLipidFiles(lipidf, uqlip)

    area = np.prod(xysize)
    lipids = _createLipids(ratioupper, area, lipiddb, files, leaflet='upper')
    lipids += _createLipids(ratiolower, area, lipiddb, files, leaflet='lower')

    _setPositionsLJSim(xysize, [l for l in lipids if l.xyz[2] > 0])
    _setPositionsLJSim(xysize, [l for l in lipids if l.xyz[2] < 0])

    _findNeighbours(lipids, xysize)

    _loadMolecules(lipids, files)

    resolveRingPenetrations(lipids, xysize)
    memb = _createMembraneMolecule(lipids)

    # from globalminimization import minimize
    # newpos, newrot = minimize(lipids, xysize + [100], stepxy=0.5, steprot=50, contactthresh=1)
    # for i in range(len(lipids)):
    #     lipids[i].xyz[:2] = newpos[i]
    #     lipids[i].rot = newrot[i]
    #
    # resolveRingPenetrations(lipids, xysize)
    # endmemb = _createMembraneMolecule(lipids)

    minc = memb.get('coords', 'name P').min(axis=0) - 5
    maxc = memb.get('coords', 'name P').max(axis=0) + 5

    mm = [[0, 0, maxc[2] - 2], [xysize[0], xysize[1], maxc[2] + waterbuff]]
    smemb = solvate(memb, minmax=mm)
    mm = [[0, 0, minc[2] - waterbuff], [xysize[0], xysize[1], minc[2] + 2]]
    smemb = solvate(smemb, minmax=mm)

    smemb.moveBy([0, 0, -smemb.coords[:, 2, 0].min()])

    if outdir is None:
        outdir = tempname()
        print('Outdir ', outdir)
    res = build(smemb, ionize=False, stream=['str/lipid/toppar_all36_lipid_cholesterol_model_1.str'], outdir=outdir)

    if equilibrate:
        from htmd.membranebuilder.simulate_openmm import equilibrateSystem
        from shutil import copy, move
        outpdb = tempname(suffix='.pdb')
        charmmf = os.path.join(home(), 'membranebuilder', 'charmm-toppar')
        equilibrateSystem(os.path.join(outdir, 'structure.pdb'), os.path.join(outdir, 'structure.psf'), outpdb, charmmfolder=charmmf)
        res = Molecule(outpdb)
        res.center()
        move(os.path.join(outdir, 'structure.pdb'), os.path.join(outdir, 'starting_structure.pdb'))
        copy(outpdb, os.path.join(outdir, 'structure.pdb'))

    return res
开发者ID:alejandrovr,项目名称:htmd,代码行数:100,代码来源:build_membrane.py


注:本文中的htmd.molecule.molecule.Molecule.center方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。