本文整理汇总了Python中mdtraj.load_pdb函数的典型用法代码示例。如果您正苦于以下问题:Python load_pdb函数的具体用法?Python load_pdb怎么用?Python load_pdb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_pdb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pdb_from_url
def test_pdb_from_url():
# load pdb from URL
t1 = load_pdb('http://www.rcsb.org/pdb/files/4K6Q.pdb.gz')
t2 = load_pdb('http://www.rcsb.org/pdb/files/4K6Q.pdb')
eq(t1.n_frames, 1)
eq(t2.n_frames, 1)
eq(t1.n_atoms, 2208)
eq(t2.n_atoms, 2208)
示例2: loader
def loader(file):
try:
md.load_pdb(file)
except:
return None
print(file)
return None
示例3: _construct_traj
def _construct_traj(self):
logger.debug('Loading Trajectory object for model {0} ({1}/{2})'.format(self.df.templateid.iloc[0], 0, len(self.df.model_filepath)))
traj = mdtraj.load_pdb(self.df.model_filepath[0])
remove_disulfide_bonds_from_topology(traj.topology)
self.traj = traj
for m, model_filepath in enumerate(self.df.model_filepath[1:]):
logger.debug('Loading Trajectory object for model {0} ({1}/{2})'.format(self.df.templateid.iloc[m+1], m+1, len(self.df.model_filepath)))
traj = mdtraj.load_pdb(model_filepath)
remove_disulfide_bonds_from_topology(traj.topology)
self.traj += traj
示例4: test_1vii_url_and_gz
def test_1vii_url_and_gz():
t1 = load_pdb('http://www.rcsb.org/pdb/files/1vii.pdb.gz')
t2 = load_pdb('http://www.rcsb.org/pdb/files/1vii.pdb')
t3 = load_pdb(get_fn('1vii.pdb.gz'))
t4 = load_pdb(get_fn('1vii.pdb'))
eq(t1.n_frames, 1)
eq(t1.n_frames, t2.n_frames)
eq(t1.n_frames, t3.n_frames)
eq(t1.n_frames, t4.n_frames)
eq(t1.n_atoms, t2.n_atoms)
eq(t1.n_atoms, t3.n_atoms)
eq(t1.n_atoms, t4.n_atoms)
示例5: test_segment_id
def test_segment_id(get_fn):
pdb = load_pdb(get_fn('ala_ala_ala.pdb'))
pdb.save_pdb(temp)
pdb2 = load_pdb(temp)
correct_segment_id = 'AAL'
# check that all segment ids are set correctly
for ridx,r in enumerate(pdb.top.residues):
assert r.segment_id == correct_segment_id, "residue %i (0-indexed) does not have segment_id set correctly from ala_ala_ala.pdb"%(ridx)
# check that all segment ids are set correctly after a new pdb file is written
for ridx,(r1,r2) in enumerate(zip(pdb.top.residues,pdb2.top.residues)):
assert r1.segment_id == r2.segment_id, "segment_id of residue %i (0-indexed) in ala_ala_ala.pdb does not agree with value in after being written out to a new pdb file"%(ridx)
示例6: _get_models
def _get_models(self):
self.model = {}
root, dirnames, filenames = next(os.walk(self.models_target_dir))
for dirname in dirnames:
if 'implicit' in self.model and 'explicit' in self.model:
break
if 'implicit' not in self.model:
implicit_model_filename = os.path.join(self.models_target_dir, dirname, 'implicit-refined.pdb.gz')
if os.path.exists(implicit_model_filename):
self.model['implicit'] = mdtraj.load_pdb(implicit_model_filename)
if 'explicit' not in self.model:
explicit_model_filename = os.path.join(self.models_target_dir, dirname, 'explicit-refined.pdb.gz')
if os.path.exists(explicit_model_filename):
self.model['explicit'] = mdtraj.load_pdb(explicit_model_filename)
示例7: test_3
def test_3(tmpdir):
# 1COY gives a small error, due to a broken chain.
pdbids = ['1GAI', '6gsv', '2AAC']
for pdbid in pdbids:
t = md.load_pdb('http://www.rcsb.org/pdb/files/%s.pdb' % pdbid)
t = t.atom_slice(t.top.select_atom_indices('minimal'))
assert_(call_dssp(tmpdir, t), md.compute_dssp(t, simplified=False)[0])
示例8: metal_searcher
def metal_searcher(file):
metal_searcher_results = {}
metal_searcher_results['one_atom_residue_names'] = []
metal_searcher_results['ok_file_count'] = 0
metal_searcher_results['error_file_count'] = 0
print(file)
try:
traj = md.load_pdb(file)
metal_searcher_results['ok_file_count'] = 1
except:
metal_searcher_results['error_file_count'] = 1
return metal_searcher_results
topo = traj.topology
one_atom_residue_atoms = [atom for atom in topo.atoms if atom.name == atom.residue.name]
if one_atom_residue_atoms:
for atom in one_atom_residue_atoms:
metal_searcher_results['one_atom_residue_names'].append(str(atom.name))
print(metal_searcher_results)
return metal_searcher_results
示例9: loader
def loader(file):
print(file)
try:
traj = md.load_pdb(file)
except:
return file
示例10: metal_searcher
def metal_searcher(file):
metal_searcher_results = {}
metal_searcher_results['ok_file_count'] = 0
metal_searcher_results['error_file_count'] = 0
metal_searcher_results['metals_in_file'] = {}
metal_searcher_results['any_metal_in_file'] = 0
for i in metals_list:
metal_searcher_results['metals_in_file'][i] = 0
print(file)
try:
traj = md.load_pdb(file)
metal_searcher_results['ok_file_count'] = 1
except:
metal_searcher_results['error_file_count'] = 1
return metal_searcher_results
topo = traj.topology
one_atom_residue_atoms = [atom.name for atom in topo.atoms if atom.name == atom.residue.name and atom.name in metals_list]
if one_atom_residue_atoms:
metal_searcher_results['any_metal_in_file'] = 1
for atom_name in one_atom_residue_atoms:
metal_searcher_results['metals_in_file'][atom_name] += 1
print(metal_searcher_results)
return metal_searcher_results
示例11: get
def get(self, pdbid):
pdbid = pdbid.lower()
if len(pdbid) != 4:
raise Exception("pdb id must be four characters long")
filename = os.path.join(self.temp_dir, '%s.pdb.gz' % pdbid)
with open(filename, 'wb') as filehandler:
self.conn.retrbinary('RETR pub/pdb/data/structures/divided/pdb/%s/pdb%s.ent.gz' % (pdbid[1:3], pdbid),
filehandler.write)
if self.just_files:
return filename
else:
# then we actually want to load it as a pdb file object and return an mdtraj trajectory
with gzip.open(filename) as filehandler:
text = filehandler.read()
with open(filename[:-3], 'w') as filehandler:
filehandler.write(text)
pdb = mdtraj.load_pdb(filename[:-3])
return pdb
示例12: test_refine_explicit_md_short
def test_refine_explicit_md_short():
with integrationtest_context(set_up_project_stage='solvated'):
targetid = 'EGFR_HUMAN_D0'
templateid = 'KC1D_HUMAN_D0_4KB8_D'
refine_explicit_md(
process_only_these_targets=[targetid],
process_only_these_templates=[templateid],
sim_length=2.0*unit.femtosecond,
nsteps_per_iteration=1,
verbose=True
)
explicit_metadata_filepath = os.path.join(
default_project_dirnames.models, targetid, 'refine_explicit_md-meta0.yaml'
)
explicit_model_filepath = os.path.join(
default_project_dirnames.models, targetid, templateid, 'explicit-refined.pdb.gz'
)
explicit_energies_filepath = os.path.join(
default_project_dirnames.models, targetid, templateid, 'explicit-energies.txt'
)
explicit_log_filepath = os.path.join(
default_project_dirnames.models, targetid, templateid, 'explicit-log.yaml'
)
assert all(map(
os.path.exists,
[explicit_model_filepath, explicit_energies_filepath, explicit_log_filepath]
))
with open(explicit_log_filepath) as explicit_log_file:
explicit_log = yaml.load(explicit_log_file)
assert explicit_log.get('finished') is True
assert explicit_log.get('successful') is True
explicit_model_traj = mdtraj.load_pdb(explicit_model_filepath)
示例13: test_1
def test_1():
for fn in ['1bpi.pdb', '1vii.pdb', '4K6Q.pdb', '1am7_protein.pdb']:
t = md.load_pdb(get_fn(fn))
t = t.atom_slice(t.top.select_atom_indices('minimal'))
f = lambda : assert_(call_dssp(t), md.compute_dssp(t, simplified=False)[0])
f.description = 'test_1: %s' % fn
yield f
示例14: test_4
def test_4():
t = md.load_pdb(get_fn('1am7_protein.pdb'))
a = md.compute_dssp(t, simplified=True)
b = md.compute_dssp(t, simplified=False)
assert len(a) == len(b)
assert len(a[0]) == len(b[0])
assert list(np.unique(a[0])) == ['C', 'E', 'H']
示例15: __init__
def __init__(self, PDB_filename, free_energy, expdata_filename=None, use_log_normal_distances=False,
dloggamma=np.log(1.01), gamma_min=0.2, gamma_max=10.0):
"""Initialize the class.
INPUTS
conf A molecular structure as an msmbuilder Conformation() object.
NOTE: For cases where the structure is an ensemble (say, from clustering)
and the modeled NOE distances and coupling constants are averaged,
the structure itself can just be a placeholder with the right atom names
and numbering
free_energy The (reduced) free energy f = beta*F of this conformation
"""
self.PDB_filename = PDB_filename
self.expdata_filename = expdata_filename
self.conf = mdtraj.load_pdb(PDB_filename)
# Convert the coordinates from nm to Angstrom units
self.conf.xyz = self.conf.xyz*10.0
# The (reduced) free energy f = beta*F of this structure, as predicted by modeling
self.free_energy = free_energy
# Flag to use log-normal distance errors log(d/d0)
self.use_log_normal_distances = use_log_normal_distances
# Store info about gamma^(-1/6) scaling parameter array
self.dloggamma = dloggamma
self.gamma_min = gamma_min
self.gamma_max = gamma_max
self.allowed_gamma = np.exp(np.arange(np.log(self.gamma_min), np.log(self.gamma_max), self.dloggamma))
# Store distance restraint info
self.distance_restraints = []
self.distance_equivalency_groups = {}
self.ambiguous_groups = [] # list of pairs of group indices, e.g.: [ [[1,2,3],[4,5,6]], [[7],[8]], ...]
self.ndistances = 0
# Store dihedral restraint info
self.dihedral_restraints = []
self.dihedral_equivalency_groups = {}
self.dihedral_ambiguity_groups = {}
self.ndihedrals = 0
# Create a KarplusRelation object
self.karplus = KarplusRelation()
# variables to store pre-computed SSE and effective degrees of freedom (d.o.f.)
self.sse_distances = np.array([0.0 for gamma in self.allowed_gamma])
self.Ndof_distances = None
self.sse_dihedrals = None
self.Ndof_dihedrals = None
self.betas = None # if reference is used, an array of N_j betas for each distance
self.neglog_reference_priors = None
self.sum_neglog_reference_priors = 0.0
# If an experimental data file is given, load in the information
self.expdata_filename = expdata_filename
if expdata_filename != None:
self.load_expdata(expdata_filename)