Beispiel #1
0
    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()
Beispiel #2
0
def buildMembrane(xysize, ratioupper, ratiolower, waterbuff=20, minimplatform='CPU', equilibrate=True, equilplatform='CUDA', outdir=None, 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 : dict
        A dict with keys the molecule names and the ratio of that molecule for the upper layer
    ratiolower : dict
        Same as ratioupper but for the lower layer
    waterbuff : float
        The z-dimension size of the water box above and below the membrane
    minimplatform : str
        The platform on which to run the minimization ('CUDA' or 'CPU')
    equilibrate : bool
        If True it equilibrates the membrane
    equilplatform : str
        The platform on which to run the equilibration ('CUDA' or 'CPU')
    outdir : str
        A folder in which to store the psf and pdb files
    lipidf : str
        The path to the folder containing the single-lipid PDB structures as well as the lipid DB file

    Returns
    -------
    mol : :class:`Molecule <moleculekit.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 moleculekit.molecule import Molecule
    from htmd.home import home
    import os
    import pandas as pd

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

    uqlip = np.unique(list(ratioupper.keys()) + list(ratiolower.keys()))
    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)

    # 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)
    memb = _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()
        logger.info('Outdir {}'.format(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(shareDir=True), 'membranebuilder', 'charmm-toppar')
        equilibrateSystem(os.path.join(outdir, 'structure.pdb'), os.path.join(outdir, 'structure.psf'), outpdb,
                          charmmfolder=charmmf, equilplatform=equilplatform, minimplatform=minimplatform)
        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
Beispiel #3
0
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
Beispiel #4
0
3spg
3syq
4csk
4hkr
4kfm
4pe5
4tlm
5an8
""".split()

# Disable this as a test
sys.exit(0)

print(os.getcwd())

for p in cases:
    print("Working on --------------- " + p)
    m, th = opm(p)
    m.filter("not resname DUM")
    m.write("{:s}.pdb".format(p))

    try:
        mo, rd = prepareProtein(m, returnDetails=True, verbose=True)
        mo.write("{:s}-prep.pdb".format(p))
        rd.data.to_excel("{:s}-data.xlsx".format(p))

        mo.set('segid', 'P')
        build(mo, outdir="build-" + p, ionize=False)
    except:
        print("Unexpected error:", sys.exc_info())
Beispiel #5
0
3spg
3syq
4csk
4hkr
4kfm
4pe5
4tlm
5an8
""".split()

# Disable this as a test
sys.exit(0)

print(os.getcwd())

for p in cases:
    print("Working on --------------- " + p)
    m, th = opm(p)
    m.filter("not resname DUM")
    m.write("{:s}.pdb".format(p))

    try:
        mo, rd = prepareProtein(m, returnDetails=True, verbose=True)
        mo.write("{:s}-prep.pdb".format(p))
        rd.data.to_excel("{:s}-data.xlsx".format(p))

        mo.set('segid', 'P')
        build(mo, outdir="build-" + p, ionize=False)
    except:
        print("Unexpected error:", sys.exc_info())