示例#1
0
def calc_deshaw_centroid_alpha_cartesian(ptlist=None):
    """ Calc RMSD from list of trajectories
  """
    if ptlist is None:
        pts = deshaw.loadpts(skip=100, filt=deshaw.FILTER['alpha'])
    else:
        pts = ptlist
    # sums = np.zeros(shape=(5, 58, 3))
    # cnts = [0 for i in range(5)]
    groupby = [[] for i in range(5)]
    label = deshaw.loadlabels_aslist()
    for idx, pt in enumerate(pts):
        # idx = math.floor(i/10)
        try:
            state = label[idx]
            if state == label[idx - 2] == label[idx - 1] == label[
                    idx + 1] == label[idx + 2]:
                # sums[state] += pt
                # cnts[state] += 1
                groupby[state].append(pt)
        except IndexError as err:
            pass  # ignore idx errors due to tail end of DEShaw data

    # cent = [sums[i] / cnts[i] for i in range(5)]
    cent = np.zeros(shape=(5, 58, 3))
    for i in range(5):
        cent[i] = ndimage.measurements.center_of_mass(np.array(groupby[i]))
    return np.array(cent)
示例#2
0
文件: rmsd.py 项目: DaMSL/ddc
def calc_deshaw_centroid_alpha_cartesian(ptlist=None):
  """ Calc RMSD from list of trajectories
  """
  if ptlist is None:
    pts = deshaw.loadpts(skip=100, filt=deshaw.FILTER['alpha'])
  else:
    pts = ptlist
  # sums = np.zeros(shape=(5, 58, 3))
  # cnts = [0 for i in range(5)]
  groupby = [[] for i in range(5)]
  label = deshaw.loadlabels_aslist()
  for idx, pt in enumerate(pts):
      # idx = math.floor(i/10)
      try:
        state = label[idx]
        if state == label[idx-2] == label[idx-1] == label[idx+1] == label[idx+2]:
          # sums[state] += pt
          # cnts[state] += 1
          groupby[state].append(pt)
      except IndexError as err:
        pass # ignore idx errors due to tail end of DEShaw data

  # cent = [sums[i] / cnts[i] for i in range(5)]
  cent = np.zeros(shape=(5, 58,3))
  for i in range(5):
    cent[i] = ndimage.measurements.center_of_mass(np.array(groupby[i]))
  return np.array(cent)
示例#3
0
文件: dolattice.py 项目: DaMSL/ddc
import mdtools.deshaw as DE
import itertools as it
import pickle, string
from collections import defaultdict, OrderedDict
import datatools.lattice as lat
import numpy as np
import os
import logging

home = os.getenv('HOME')
k_domain = string.ascii_lowercase + string.ascii_uppercase
tok   = lambda x: ''.join(sorted([k_domain[i] for i in x]))

DS = 10*np.load('../data/de_ds_mu.npy')
label = DE.loadlabels_aslist()

scale = 5
blabel = [label[int(i/22.09)] for i in range(91116)]
bL = [blabel[i] for i in range(0, 90000, scale)]
D = DS[range(0, 90000, scale)]

cutoff = 8.
CM = (D<cutoff).astype(int)
K2 = lat.reduced_feature_set(CM, .02); len(K2)
F2 = [i for i in K2 if D[:,i].clip(0, cutoff).std() > .2]; len(F2)
F2std = [x[0] for x in sorted([(i, D[:,i].clip(0, cutoff).std()) for i in F2], key = lambda x: x[1])]
prs = list(it.combinations(range(58), 2))
plist = [prs[i] for i in F2std]
restrack = [[] for i in range(58)]
for a, b in plist:
  restrack[a].append((a,b))
示例#4
0
import itertools as it
from collections import defaultdict, OrderedDict
import datatools.lattice as lat
import datatools.datareduce as DR
import mdtools.timescape as TS

TBIN10 = ['%s%d'%(a,b) for a in ['W', 'T'] for b in range(5)]
# ['W0', 'W1', 'W2', 'W3', 'W4', 'T0', 'T1', 'T2', 'T3', 'T4']

REF = 

afilt,hfilt = DE.FILTER['alpha'], DE.FILTER['heavy']
cent = np.load('../data/bpti-alpha-dist-centroid.npy')
topo = md.load(home+'/work/jc/serial2/de0_0/de0_0.pdb')
topoa = topo.atom_slice(topo.top.select_atom_indices('alpha'))
deL = DE.loadlabels_aslist()
bL = [deL[int(i/22.09)] for i in range(91116)]

traj, rmsd = [], []
for tnum in range(42):
  p, d = DE.getHistoricalTrajectory_prot(tnum)
  traj.append(md.load(d, top=p).atom_slice(afilt))

resrms = []
ccent = np.load('../data/bpti-alpha-cartesian-centroid.npy')
for tnum, tr in enumerate(detraj):
  minlist = TS.TimeScape.read_log(home+'/work/timescape/desh_%02d_minima.log'%tnum)
  minima = tr.slice(minlist)
  minima.superpose(topoa)
  for m in minima.xyz:
    resrms.append(LA.norm(ref - m, axis=1))
示例#5
0
def generateDEShawJC(fileno, frame, jcid=None):
    """Creates input parameters for a running explcit solvenet simulation
    from D.E.Shaw 1ms source trajectory. Index is the global index # from the
    entire 1.0375ms data set.
    """
    config = systemsettings()
    index = fileno * 1000 + frame
    logging.debug(
        "Generating new simulation coordinates from D.E.Shaw index #:  %s",
        str(index))
    label = DE.loadlabels_aslist()

    # Get a new uid (if needed)
    jcuid = getUID() if jcid is None else jcid

    # Prep file structure
    jobdir = os.path.join(config.JOBDIR, jcuid)

    # 1. Load starting coordinate from source traj and save to pdb file
    filename = DE.getDEShawfilename(fileno) % fileno
    src_file = os.path.join(config.workdir, 'bpti', filename)
    tmpdir = 'tmp_%d%d' % (fileno, frame)  #gettempdir()
    logging.info('Loading Source Coordinate from file: %s  (frame # %d)',
                 src_file, frame)
    logging.info("LABELED_STATE:   %d   (seq # %d/4125)", label[fileno],
                 fileno)
    coord = md.load_frame(src_file, frame, top=DE.PDB_ALL)
    logging.info('Coord Loaded: %s', str(coord))
    os.makedirs(tmpdir, exist_ok=True)
    tmpfile = tmpdir + '/coord.pdb'
    # tmpfile = 'coord.pdb'
    coord.save_pdb(tmpfile)

    # 2. Convert topology PDB file (in place)
    logging.info(
        "Converting Topology to Charmm compatiable Force Fields on: %s",
        tmpfile)
    DE.convert_topology(tmpfile, split_dir=tmpdir)

    # 3. Prepare new job metadata

    coordFile = newPdbFile = os.path.join(jobdir, '%s.pdb' % jcuid)
    newPsfFile = os.path.join(jobdir, '%s.psf' % jcuid)
    newsimJob = dict(
        workdir=jobdir,
        name=jcuid,
        tmploc=tmpdir,
        coord=coordFile,
        pdb=newPdbFile,
        psf=newPsfFile,
        src_traj=src_file,
    )

    # Add in the force field data from global config and pre-set constraint file:
    newsimJob['ffield_dir'] = os.path.join(config.workdir,
                                           config.sim_params['ffield_dir'])

    if not os.path.exists(jobdir):
        os.makedirs(jobdir)

    # 4. Run PSFGEN to set up start coords and structure file
    logging.info("  Running PSFGen to set up simulation pdf/pdb files.")
    stdout = executecmd(DE.psfgen(newsimJob))
    logging.debug("  PSFGen COMPLETE!!")
    # logging.debug(stdout)

    # 5. Update PDB file with unitcell data and temperature control factors
    logging.info('Updating Unit Cell data and setting contraints in PDB')
    DE.reset_pdb(newPdbFile)

    # 5. Clean up
    del newsimJob['tmploc']
    # shutil.rmtree(tmpdir)

    return jcuid, newsimJob
示例#6
0
文件: simtool.py 项目: DaMSL/ddc
def generateDEShawJC(fileno, frame, jcid=None):
    """Creates input parameters for a running explcit solvenet simulation
    from D.E.Shaw 1ms source trajectory. Index is the global index # from the
    entire 1.0375ms data set.
    """
    config = systemsettings()
    index = fileno * 1000 + frame
    logging.debug("Generating new simulation coordinates from D.E.Shaw index #:  %s", str(index))
    label = DE.loadlabels_aslist()

    # Get a new uid (if needed)
    jcuid = getUID() if jcid is None else jcid

    # Prep file structure
    jobdir = os.path.join(config.JOBDIR,  jcuid)

    # 1. Load starting coordinate from source traj and save to pdb file
    filename = DE.getDEShawfilename(fileno) % fileno
    src_file = os.path.join(config.workdir, 'bpti', filename) 
    tmpdir = 'tmp_%d%d' % (fileno, frame) #gettempdir()
    logging.info('Loading Source Coordinate from file: %s  (frame # %d)', src_file, frame)
    logging.info("LABELED_STATE:   %d   (seq # %d/4125)", label[fileno], fileno)
    coord = md.load_frame(src_file, frame, top=DE.PDB_ALL)
    logging.info('Coord Loaded: %s', str(coord))
    os.makedirs(tmpdir, exist_ok=True)
    tmpfile = tmpdir + '/coord.pdb'
    # tmpfile = 'coord.pdb'
    coord.save_pdb(tmpfile)

    # 2. Convert topology PDB file (in place)
    logging.info("Converting Topology to Charmm compatiable Force Fields on: %s", tmpfile)
    DE.convert_topology(tmpfile, split_dir=tmpdir)

    # 3. Prepare new job metadata

    coordFile = newPdbFile = os.path.join(jobdir, '%s.pdb' % jcuid)
    newPsfFile = os.path.join(jobdir, '%s.psf' % jcuid)
    newsimJob = dict(workdir=jobdir,
        name    = jcuid,
        tmploc  = tmpdir,
        coord   = coordFile,
        pdb     = newPdbFile,
        psf     = newPsfFile,
        src_traj = src_file,
        )

    # Add in the force field data from global config and pre-set constraint file:
    newsimJob['ffield_dir'] = os.path.join(config.workdir, config.sim_params['ffield_dir'])

    if not os.path.exists(jobdir):
      os.makedirs(jobdir)

    # 4. Run PSFGEN to set up start coords and structure file
    logging.info("  Running PSFGen to set up simulation pdf/pdb files.")
    stdout = executecmd(DE.psfgen(newsimJob))
    logging.debug("  PSFGen COMPLETE!!")
    # logging.debug(stdout)

    # 5. Update PDB file with unitcell data and temperature control factors
    logging.info('Updating Unit Cell data and setting contraints in PDB')
    DE.reset_pdb(newPdbFile)

    # 5. Clean up
    del newsimJob['tmploc']
    # shutil.rmtree(tmpdir)

    return jcuid, newsimJob