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


Python mdtraj.load方法代码示例

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


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

示例1: func

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def func(args, parser):
    # delay import of the rest of the module to improve `mdentropy -h` performance
    import pickle
    import mdtraj as md
    import pandas as pd
    from ..utils import parse_files
    from ..metrics import DihedralMutualInformation

    files = parse_files(args.traj)
    traj = md.load(files, top=args.top, stride=args.stride)

    mi = DihedralMutualInformation(n_bins=args.nbins, types=args.types,
                                   method=args.method, threads=args.n_threads,
                                   normed=True)

    M = mi.partial_transform(traj, shuffle=iter, verbose=True)

    df = pd.DataFrame(M, columns=mi.labels)

    pickle.dump(df, open(args.out, 'wb')) 
开发者ID:msmbuilder,项目名称:mdentropy,代码行数:22,代码来源:dmutinf.py

示例2: func

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def func(args, parser):
    # delay import of the rest of the module to improve `mdentropy -h`
    # performance
    import pickle
    import mdtraj as md
    import pandas as pd
    from ..utils import parse_files
    from ..metrics import DihedralTransferEntropy

    f1, f2 = parse_files(args.current), parse_files(args.past)

    current = md.load(f1, top=args.top, stride=args.stride)
    past = md.load(f2, top=args.top, stride=args.stride)

    tent = DihedralTransferEntropy(n_bins=args.nbins, types=args.types,
                                   method=args.method, threads=args.n_threads,
                                   normed=True)

    T = tent.partial_transform((past, current), shuffle=iter, verbose=True)

    df = pd.DataFrame(T, columns=tent.labels)

    pickle.dump(df, open(args.out, 'wb')) 
开发者ID:msmbuilder,项目名称:mdentropy,代码行数:25,代码来源:dtent.py

示例3: test_convex_find_pockets

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def test_convex_find_pockets(self):
    """Test that some pockets are filtered out."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
    protein_file = os.path.join(current_dir, "1jld_protein.pdb")
    ligand_file = os.path.join(current_dir, "1jld_ligand.sdf")

    import mdtraj as md
    protein = md.load(protein_file)

    finder = dc.dock.ConvexHullPocketFinder()
    all_pockets = finder.find_all_pockets(protein_file)
    pockets = finder.find_pockets(protein_file)
    # Test that every atom in pocket maps exists
    n_protein_atoms = protein.xyz.shape[1]
    for pocket in pockets:
      assert isinstance(pocket, box_utils.CoordinateBox)

    assert len(pockets) < len(all_pockets) 
开发者ID:deepchem,项目名称:deepchem,代码行数:20,代码来源:test_binding_pocket.py

示例4: visualize_complex

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def visualize_complex(complex_mdtraj):
  ligand_atoms = [a.index for a in complex_mdtraj.topology.atoms if "LIG" in str(a.residue)]
  binding_pocket_atoms = md.compute_neighbors(complex_mdtraj, 0.5, ligand_atoms)[0]
  binding_pocket_residues = list(set([complex_mdtraj.topology.atom(a).residue.resSeq for a in binding_pocket_atoms]))
  binding_pocket_residues = [str(r) for r in binding_pocket_residues]
  binding_pocket_residues = " or ".join(binding_pocket_residues)

  traj = nglview.MDTrajTrajectory( complex_mdtraj ) # load file from RCSB PDB
  ngltraj = nglview.NGLWidget( traj )
  ngltraj.representations = [
  { "type": "cartoon", "params": {
  "sele": "protein", "color": "residueindex"
  } },
  { "type": "licorice", "params": {
  "sele": "(not hydrogen) and (%s)" %  binding_pocket_residues
  } },
  { "type": "ball+stick", "params": {
  "sele": "LIG"
  } }
  ]
  return ngltraj 
开发者ID:deepchem,项目名称:deepchem,代码行数:23,代码来源:utils.py

示例5: prepare_example

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def prepare_example():
    """
    Prepare the host-guest example relative calculation.
    """
    #load in the host and guest molecules
    host_traj = extract_molecule(host_guest_path, "HST")
    guest_traj = extract_molecule(host_guest_path, "GST")

    #convert the trajs to mols
    host_mol = convert_mdtraj_to_oemol(host_traj)
    guest_mol = convert_mdtraj_to_oemol(guest_traj)

    #make the other guest molecule:
    new_guest_molecule = iupac_to_oemol(alternate_guest)

    #write out the host molecule:
    write_host(host_mol, host_vacuum_path)

    #write out the guest molecules:
    write_guest_molecules(guest_mol, new_guest_molecule, guests_vacuum_path) 
开发者ID:choderalab,项目名称:perses,代码行数:22,代码来源:prepare_host_guest.py

示例6: _initialise_frame

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def _initialise_frame(self, frame):
        """
        Parse a GROMACS GRO file and create Residues/Atoms
        Required before reading coordinates from XTC file

        :param frame: Frame instance to initialise from GRO file
        """
        import mdtraj
        top = mdtraj.load(self._topname)

        frame.name = ""
        self.num_atoms = top.n_atoms
        frame.natoms = top.n_atoms

        frame.residues = [Residue(name=res.name, num=res.resSeq) for res in top.topology.residues]

        for atom in top.topology.atoms:
            new_atom = Atom(name=atom.name, num=atom.serial,
                            coords=top.xyz[0][atom.index])
            frame.residues[atom.residue.index].add_atom(new_atom)

        frame.box = top.unitcell_lengths[0] 
开发者ID:jag1g13,项目名称:pycgtool,代码行数:24,代码来源:framereader.py

示例7: _load_to_position

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def _load_to_position(spec, arr_shape):
    '''
    Load a specified file into a specified position by spec. The
    arr_shape parameter lets us know how big the final array should be.
    '''
    (position, filename, load_kwargs) = spec

    xyz = md.load(filename, **load_kwargs).xyz

    # mp.Array must be converted to numpy array and reshaped
    arr = _tonumpyarray(shared_array).reshape(arr_shape)

    # dump coordinates in.
    arr[position:position+len(xyz)] = xyz

    return xyz.shape 
开发者ID:bowman-lab,项目名称:enspara,代码行数:18,代码来源:load.py

示例8: test_assign_to_nearest_center_few_centers

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def test_assign_to_nearest_center_few_centers():

    # assign_to_nearest_center takes two code paths, one for
    # n_centers > n_frames and one for n_frames > n_centers. This tests
    # the latter.
    trj = md.load(get_fn('frame0.xtc'), top=get_fn('native.pdb'))
    center_frames = [0, int(len(trj)/3), int(len(trj)/2)]

    assigns, distances = util.assign_to_nearest_center(
        trj, trj[center_frames], md.rmsd)

    alldists = np.zeros((len(center_frames), len(trj)))
    for i, center_frame in enumerate(trj[center_frames]):
        alldists[i] = md.rmsd(trj, center_frame)

    assert_allclose(np.min(alldists, axis=0), distances, atol=1e-3)
    assert_array_equal(np.argmin(alldists, axis=0), assigns) 
开发者ID:bowman-lab,项目名称:enspara,代码行数:19,代码来源:test_cluster_util.py

示例9: test_reassign_script

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def test_reassign_script():

    topologies = [get_fn('native.pdb'), get_fn('native.pdb')]
    trajectories = [get_fn('frame0.xtc'), get_fn('frame0.xtc')]

    centers = [c for c in md.load(trajectories[0], top=topologies[0])[::50]]

    with tempfile.NamedTemporaryFile(suffix='.pkl') as ctrs_f:
        pickle.dump(centers, ctrs_f)
        ctrs_f.flush()

        runhelper(
            ['--centers', ctrs_f.name,
             '--trajectories', trajectories[0], trajectories[1],
             '--atoms', '(name N or name C or name CA or name H or name O)',
             '--topology', topologies]) 
开发者ID:bowman-lab,项目名称:enspara,代码行数:18,代码来源:test_apps_reassign.py

示例10: test_load_as_concatenated_stride

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def test_load_as_concatenated_stride(self):

        t1 = md.load(self.trj_fname, top=self.top)
        t2 = md.load(self.trj_fname, top=self.top)
        t3 = md.load(self.trj_fname, top=self.top)

        print(len(t1))
        print(len(md.load(self.trj_fname, top=self.top, stride=10)))

        lengths, xyz = load_as_concatenated(
            [self.trj_fname]*3,
            top=self.top,
            stride=10,
            processes=2)

        expected = np.concatenate([t1.xyz[::10],
                                   t2.xyz[::10],
                                   t3.xyz[::10]])

        self.assertTrue(np.all(expected == xyz))
        self.assertEqual(expected.shape, xyz.shape) 
开发者ID:bowman-lab,项目名称:enspara,代码行数:23,代码来源:test_ra.py

示例11: test_selection_load_as_concatenated

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def test_selection_load_as_concatenated(self):
        '''
        **kwargs should work with load_as_concatenated

        Verify that when *kwargs is used in load_as_concatenated, it is
        applied to each trajectory as it's loaded (e.g. for the purposes
        of selection).
        '''

        selection = np.array([1, 3, 6])

        t1 = md.load(self.trj_fname, top=self.top, atom_indices=selection)
        t2 = md.load(self.trj_fname, top=self.top, atom_indices=selection)
        t3 = md.load(self.trj_fname, top=self.top, atom_indices=selection)

        lengths, xyz = load_as_concatenated(
            [self.trj_fname]*3,
            top=self.top,
            atom_indices=selection,
            processes=3)
        expected = np.concatenate([t1.xyz, t2.xyz, t3.xyz])

        self.assertTrue(np.all(expected == xyz))
        self.assertEqual(expected.shape, xyz.shape) 
开发者ID:bowman-lab,项目名称:enspara,代码行数:26,代码来源:test_ra.py

示例12: load_trajs

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def load_trajs(args):
    """ Creates a generator object that can be then passed to the CARDS framework.
    """
    trajectories = args.trajectories[0]
    topology = args.topology[0]
    #filenames = glob(trajectories)
    targets = {os.path.basename(topf): "%s files" % len(trjfs) for topf, trjfs
               in zip(args.topology, args.trajectories)}
    logger.info("Starting CARDS; targets:\n%s",
                json.dumps(targets, indent=4))

    #gen = (md.load(traj, top=topology) for traj in args.trajectories)
    gen = load_trajectory_generator(trajectories, topology)

    logger.info("Created generator")

    return gen 
开发者ID:bowman-lab,项目名称:enspara,代码行数:19,代码来源:collect_cards.py

示例13: read_xtc

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def read_xtc(trajfile, top, **kwargs):
    """ read the trajectrory using mdtraj module from the xtc file """

    print("Read trajectory file: ", trajfile)
    print("Read topology from:   ", top)

    t1 = time.time()
    trajectory = md.load(trajfile, top=top)
    t2 = time.time() - t1

    nframes, natoms = trajectory.xyz.shape[:2]
    print("# frames: ", nframes)
    print("# atoms:  ", natoms)
    print("Read trajecory in %.0f s\n" % t2)

    return trajectory 
开发者ID:gVallverdu,项目名称:myScripts,代码行数:18,代码来源:hbonds.py

示例14: featurize

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def featurize(self, protein_file, pockets):
    """
    Calculate atomic coodinates.

    Params
    ------
    protein_file: str
      Location of PDB file. Will be loaded by MDTraj
    pockets: list[CoordinateBox]
      List of `dc.utils.CoordinateBox` objects.

    Returns
    -------
    A numpy array of shale `(len(pockets), n_residues)`
    """
    import mdtraj
    protein_coords = rdkit_util.load_molecule(
        protein_file, add_hydrogens=False, calc_charges=False)[0]
    mapping = boxes_to_atoms(protein_coords, pockets)
    protein = mdtraj.load(protein_file)
    n_pockets = len(pockets)
    n_residues = len(BindingPocketFeaturizer.residues)
    res_map = dict(zip(BindingPocketFeaturizer.residues, range(n_residues)))
    all_features = np.zeros((n_pockets, n_residues))
    for pocket_num, pocket in enumerate(pockets):
      pocket_atoms = mapping[pocket]
      for ind, atom in enumerate(pocket_atoms):
        atom_name = str(protein.top.atom(atom))
        # atom_name is of format RESX-ATOMTYPE
        # where X is a 1 to 4 digit number
        residue = atom_name[:3]
        if residue not in res_map:
          logger.info("Warning: Non-standard residue in PDB file")
          continue
        atomtype = atom_name.split("-")[1]
        all_features[pocket_num, res_map[residue]] += 1
    return all_features 
开发者ID:deepchem,项目名称:deepchem,代码行数:39,代码来源:binding_pocket_features.py

示例15: visualize_ligand

# 需要导入模块: import mdtraj [as 别名]
# 或者: from mdtraj import load [as 别名]
def visualize_ligand(ligand_mdtraj):
  traj = nglview.MDTrajTrajectory( ligand_mdtraj ) # load file from RCSB PDB
  ngltraj = nglview.NGLWidget( traj )
  ngltraj.representations = [
    { "type": "ball+stick", "params": {"sele": "all" } } ]
  return ngltraj 
开发者ID:deepchem,项目名称:deepchem,代码行数:8,代码来源:utils.py


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