本文整理汇总了Python中Geometry.geometry方法的典型用法代码示例。如果您正苦于以下问题:Python Geometry.geometry方法的具体用法?Python Geometry.geometry怎么用?Python Geometry.geometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry.geometry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evolve
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def evolve(self):
""" Run evolution.
"""
pop_size = 100
seeds = []
seed = []
for aa in self.sequence:
geo = Geometry.geometry(aa)
seed.append(geo.phi)
seed.append(geo.psi_im1)
template_seeds = self.create_seeds(self.path + "/pdbs2")
seeds += template_seeds
seeds += [seed for x in range(100 - len(template_seeds))]
self.es.terminator = terminators.evaluation_termination
self.es.evolve(generator=self.generator,
evaluator=self.eval_func,
pop_size=pop_size,
maximize=False,
max_evaluations=2000000000,
bounder=self.bounder,
seeds=seeds,
neighborhood_size=10,
cognitive_rate=1,
social_rate=1,
num_inputs=self.c_size)
示例2: build_all_angles_model
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def build_all_angles_model(pdb_filename):
parser=PDBParser()
structure=parser.get_structure('sample', \
path.join(PDBdir, pdb_filename))
model=structure[0]
chain=model['A']
model_structure_geo=[]
prev="0"
N_prev="0"
CA_prev="0"
CO_prev="0"
prev_res=""
rad=180.0/math.pi
for res in chain:
if(res.get_resname() in resdict.keys()):
geo=Geometry.geometry(resdict[res.get_resname()])
if(prev=="0"):
N_prev=res['N']
CA_prev=res['CA']
C_prev=res['C']
prev="1"
else:
n1=N_prev.get_vector()
ca1=CA_prev.get_vector()
c1=C_prev.get_vector()
C_curr=res['C']
N_curr=res['N']
CA_curr=res['CA']
c=C_curr.get_vector()
n=N_curr.get_vector()
ca=CA_curr.get_vector()
geo.CA_C_N_angle=calc_angle(ca1, c1, n)*rad
geo.C_N_CA_angle=calc_angle(c1, n, ca)*rad
psi= calc_dihedral(n1, ca1, c1, n) ##goes to current res
omega= calc_dihedral(ca1, c1, n, ca) ##goes to current res
phi= calc_dihedral(c1, n, ca, c) ##goes to current res
geo.psi_im1=psi*rad
geo.omega=omega*rad
geo.phi=phi*rad
geo.N_CA_C_angle= calc_angle(n, ca, c)*rad
##geo.CA_C_O_angle= calc_angle(ca, c, o)*rad
##geo.N_CA_C_O= calc_dihedral(n, ca, c, o)*rad
N_prev=res['N']
CA_prev=res['CA']
C_prev=res['C']
##O_prev=res['O']
model_structure_geo.append(geo)
return model_structure_geo
示例3: build_linear_model
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def build_linear_model(pdb_filename):
parser=PDBParser()
structure=parser.get_structure('sample', \
path.join(PDBdir, pdb_filename) )
model=structure[0]
chain=model['A']
model_structure_geo=[]
for res in chain:
if(res.get_resname() in resdict.keys()):
tempgeo=Geometry.geometry(resdict[res.get_resname()])
model_structure_geo.append(tempgeo)
model_structure=PeptideBuilder.initialize_res(model_structure_geo[0])
for i in range(1,len(model_structure_geo)):
model_structure=PeptideBuilder.add_residue(model_structure, model_structure_geo[i])
return model_structure
示例4: run
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def run(self):
""" Run MC simulation.
"""
seed = []
for aa in self.sequence:
geo = Geometry.geometry(aa)
seed.append(geo.phi)
seed.append(geo.psi_im1)
self.conformation = seed
if self.local:
while self.steps < self.max_steps:
for n in range(self.c_size):
self.local_mover(n)
else:
while self.steps < self.max_steps:
self.mover()
示例5: build_exact_model
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def build_exact_model(structure, chain_index):
model=structure[0]
chain=model[chain_index]
model_structure_geo=[]
prev="0"
N_prev="0"
CA_prev="0"
C_prev="0"
O_prev="0"
prev_res=""
rad=180.0/math.pi
for res in chain:
name=res.get_resname()
if(name !="HOH"):
geo=Geometry.geometry(resdict[name])
if(prev=="0"):
N_prev= res['N']
CA_prev= res['CA']
C_prev= res['C']
O_prev= res['O']
prev="1"
else:
n1=N_prev.get_vector()
ca1=CA_prev.get_vector()
c1=C_prev.get_vector()
o1=O_prev.get_vector()
O_curr=res['O']
C_curr=res['C']
N_curr=res['N']
CA_curr=res['CA']
o=O_curr.get_vector()
c=C_curr.get_vector()
n=N_curr.get_vector()
ca=CA_curr.get_vector()
geo.CA_C_N_angle=calc_angle(ca1, c1, n)*rad
geo.C_N_CA_angle=calc_angle(c1, n, ca)*rad
geo.peptide= N_curr-C_prev
psi= calc_dihedral(n1, ca1, c1, n) ##goes to current res
omega= calc_dihedral(ca1, c1, n, ca) ##goes to current res
phi= calc_dihedral(c1, n, ca, c) ##goes to current res
geo.psi_im1=psi*rad
geo.omega=omega*rad
geo.phi=phi*rad
geo.CA_N_length= CA_curr - N_curr
geo.CA_C_length= CA_curr - C_curr
geo.C_O_length= C_curr - O_curr
geo.N_CA_C_angle= calc_angle(n, ca, c)*rad
geo.CA_C_O_angle= calc_angle(ca, c, o)*rad
geo.N_CA_C_O= calc_dihedral(n, ca, c, o)*rad
N_prev= res['N']
CA_prev= res['CA']
C_prev= res['C']
O_prev= res['O']
if(name=='ALA'):
geo.CA_CB_length=CA_curr-res['CB']
geo.C_CA_CB_angle= calc_angle(c, ca, res['CB'].get_vector())*rad
geo.N_C_CA_CB_diangle= calc_dihedral(n, c, ca, res['CB'].get_vector())*rad
elif(name=='GLU'):
geo.CA_CB_length=CA_curr-res['CB']
geo.C_CA_CB_angle=calc_angle(c, ca, res['CB'].get_vector())*rad
geo.N_C_CA_CB_diangle=calc_dihedral(n, c, ca, res['CB'].get_vector() )*rad
geo.CB_CG_length=res['CB']-res['CG']
geo.CA_CB_CG_angle=calc_angle(ca, res['CB'].get_vector(), res['CG'].get_vector())*rad
geo.N_CA_CB_CG_diangle=calc_dihedral(n, ca, res['CB'].get_vector(), res['CG'].get_vector())*rad
geo.CG_CD_length=res['CG']-res['CD']
geo.CB_CG_CD_angle=calc_angle(res['CB'].get_vector(), res['CG'].get_vector(), res['CD'].get_vector() )*rad
geo.CA_CB_CG_CD_diangle=calc_dihedral(ca, res['CB'].get_vector(), res['CG'].get_vector(), res['CD'].get_vector())*rad
geo.CD_OE1_length=res['CD']-res['OE1']
geo.CG_CD_OE1_angle=calc_angle(res['CG'].get_vector(), res['CD'].get_vector(), res['OE1'].get_vector() )*rad
geo.CB_CG_CD_OE1_diangle= calc_dihedral(res['CB'].get_vector(), res['CG'].get_vector(),res['CD'].get_vector(), res['OE1'].get_vector())*rad
geo.CD_OE2_length=res['CD']-res['OE2']
geo.CG_CD_OE2_angle=calc_angle(res['CG'].get_vector(), res['CD'].get_vector(), res['OE2'].get_vector() )*rad
geo.CB_CG_CD_OE2_diangle= calc_dihedral(res['CB'].get_vector(), res['CG'].get_vector(),res['CD'].get_vector(), res['OE2'].get_vector())*rad
elif(name=='HIS'):
geo.CA_CB_length=CA_curr-res['CB']
geo.CB_CG_length=(res['CB']-res['CG'])
geo.CG_ND1_length=(res['CG']-res['ND1'])
geo.CG_CD2_length=(res['CG']-res['CD2'])
geo.ND1_CE1_length=(res['ND1']-res['CE1'])
geo.CD2_NE2_length=(res['CD2']-res['NE2'])
#.........这里部分代码省略.........
示例6: eval_func
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def eval_func(self, candidates, args):
""" :param candidates: Current population being evaluated.
"""
scores_list = []
scores = []
print "Calculating scores... "
for conformation in candidates:
score = 0.0
surf_area = 0.0
phobic_area = 0.0
philic_area = 0.0
e_score = 0.0
# Create PeptideBuilder structure for conformation
geo = Geometry.geometry(self.sequence[0])
geo.phi = conformation[0]
geo.psi_im1 = conformation[1]
if self.sequence[0] != "G" and self.sequence[0] != "P" and self.sequence[0] != "A":
if 0 in self.mod_dict:
geo.inputRotamers(self.mod_dict[0])
structure = PeptideBuilder.initialize_res(geo)
i = 2
j = 1
for aa in self.sequence[1:]:
geo = Geometry.geometry(aa)
geo.phi = conformation[i]
geo.psi_im1 = conformation[i + 1]
if aa != "G" and aa != "P" and aa != "A":
if j in self.mod_dict:
geo.inputRotamers(self.mod_dict[j])
j += 1
structure = PeptideBuilder.add_residue(structure, geo)
i += 2
out = Bio.PDB.PDBIO()
out.set_structure(structure)
out.save(self.path + "/msms/prot" + str(self.id) + ".pdb")
# Add hydrogens with pybel
mol = pybel.readfile("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb").next()
mol.OBMol.AddHydrogens()
pybelmol = pybel.Molecule(mol)
pybelmol.write("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb",
overwrite=True)
# Convert to xyzrn with msms executable
subprocess.call('cd ' + self.path + '/msms; ./pdb_to_xyzrn prot' + str(self.id) +
'.pdb > prot' + str(self.id) + '.xyzrn', shell=True)
# Enforce constraints (atoms can't come closer than van-der-waals radii)
check = []
with open(self.path + "/msms/prot" + str(self.id) + ".xyzrn") as f:
check = f.readlines()
atoms_check = []
unk = False
for atom in check:
entries = atom.split()
name = entries[5]
ent = name.split("_")
resid = ent[2]
atname = ent[0]
res = ent[1]
try:
r = get_radius(atname, res)[0]
except KeyError:
unk = True
score = 1000000
break
atoms_check.append([resid, entries[0], entries[1], entries[2], r, atname, res])
if not unk:
clash = False
for atom in atoms_check:
id1 = int(atom[0])
atname1 = atom[5]
x = float(atom[1])
y = float(atom[2])
z = float(atom[3])
r = float(atom[4])
for atom2 in atoms_check:
id2 = int(atom2[0])
atname2 = atom2[5]
if (id1 != id2) and not (((id2 == (id1 + 1)) or (id2 == (id1 - 1)))
and (((atname1 == "CA") or (atname1 == "C") or (atname1 == "N")) and
((atname2 == "CA") or (atname2 == "C") or (atname2 == "N")))):
x2 = float(atom2[1])
#.........这里部分代码省略.........
示例7: rebuild
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def rebuild(self, id1, id2, it, conformation):
"""Rebuilds clashing residues.
:param id1: First residue id.
:param id2: Second residue id.
:param it: Number of iterations.
:param conformation: Current conformation.
:return: :type boolean: True if successfully rebuilt, False if not.
"""
print "Adjusting rotamers..."
new_rot1 = []
new_rot2 = []
aa1 = self.sequence[id1 - 1]
aa2 = self.sequence[id2 - 1]
solved = False
if (aa1 != "G" and aa1 != "P" and aa1 != "A") or (aa2 != "G" and aa2 != "P" and aa2 != "A"):
for n in range(it):
if solved:
break
if n == 0:
new_rot1 = self.make_rot_list(aa1)
new_rot2 = self.make_rot_list(aa2)
else:
moves1 = []
for j in range(len(new_rot1)):
rand = random.random()
if rand < 0.33:
moves1.append(-self.rot_mover_size)
elif rand < 0.66:
moves1.append(0)
else:
moves1.append(self.rot_mover_size)
new_rot1 = [new_rot1[i] + moves1[i] for i in range(len(new_rot1))]
moves2 = []
for j in range(len(new_rot2)):
rand = random.random()
if rand < 0.33:
moves2.append(-self.rot_mover_size)
elif rand < 0.66:
moves2.append(0)
else:
moves2.append(self.rot_mover_size)
new_rot2 = [new_rot2[i] + moves2[i] for i in range(len(new_rot2))]
geo = Geometry.geometry(self.sequence[0])
geo.phi = conformation[0]
geo.psi_im1 = conformation[1]
if id1 - 1 == 0:
if aa1 != "G" and aa1 != "P" and aa1 != "A":
geo.inputRotamers(new_rot1)
elif id2 - 1 == 0:
if aa2 != "G" and aa2 != "P" and aa2 != "A":
geo.inputRotamers(new_rot2)
elif 0 in self.mod_dict:
if self.sequence[0] != "G" and self.sequence[0] != "P" and self.sequence[0] != "A":
geo.inputRotamers(self.mod_dict[0])
structure = PeptideBuilder.initialize_res(geo)
i = 2
j = 1
for aa in self.sequence[1:]:
geo = Geometry.geometry(aa)
geo.phi = conformation[i]
geo.psi_im1 = conformation[i + 1]
if id1 == j + 1:
if aa1 != "G" and aa1 != "P" and aa1 != "A":
geo.inputRotamers(new_rot1)
elif id2 == j + 1:
if aa2 != "G" and aa2 != "P" and aa2 != "A":
geo.inputRotamers(new_rot2)
elif j in self.mod_dict:
geo.inputRotamers(self.mod_dict[j])
j += 1
structure = PeptideBuilder.add_residue(structure, geo)
i += 2
out = Bio.PDB.PDBIO()
out.set_structure(structure)
out.save(self.path + "/msms/prot" + str(self.id) + ".pdb")
mol = pybel.readfile("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb").next()
mol.OBMol.AddHydrogens()
pybelmol = pybel.Molecule(mol)
pybelmol.write("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb",
overwrite=True)
subprocess.call('cd ' + self.path + '/msms; ./pdb_to_xyzrn prot' + str(self.id) +
'.pdb > prot' + str(self.id) + '.xyzrn', shell=True)
check = []
with open(self.path + "/msms/prot" + str(self.id) + ".xyzrn") as f:
check = f.readlines()
atoms_check = []
clash = False
unk = False
#.........这里部分代码省略.........
示例8: local_mover
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def local_mover(self, n):
""" :param candidates: Current population being evaluated.
"""
conformation = self.conformation
move = 0
score = 0.0
surf_area = 0.0
phobic_area = 0.0
philic_area = 0.0
e_score = 0.0
if self.steps != 0:
rand = random.random()
if rand < 0.33:
move = -self.mover_size
elif rand < 0.66:
move = 0
else:
move = self.mover_size
conformation[n] += move
geo = Geometry.geometry(self.sequence[0])
geo.phi = conformation[0]
geo.psi_im1 = conformation[1]
if self.sequence[0] != "G" and self.sequence[0] != "P" and self.sequence[0] != "A":
if 0 in self.mod_dict:
geo.inputRotamers(self.mod_dict[0])
structure = PeptideBuilder.initialize_res(geo)
i = 2
j = 1
for aa in self.sequence[1:]:
geo = Geometry.geometry(aa)
geo.phi = conformation[i]
geo.psi_im1 = conformation[i + 1]
if aa != "G" and aa != "P" and aa != "A":
if j in self.mod_dict:
geo.inputRotamers(self.mod_dict[j])
j += 1
structure = PeptideBuilder.add_residue(structure, geo)
i += 2
out = Bio.PDB.PDBIO()
out.set_structure(structure)
out.save(self.path + "/msms/prot" + str(self.id) + ".pdb")
mol = pybel.readfile("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb").next()
mol.OBMol.AddHydrogens()
pybelmol = pybel.Molecule(mol)
pybelmol.write("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb",
overwrite=True)
subprocess.call('cd ' + self.path + '/msms; ./pdb_to_xyzrn prot' + str(self.id) +
'.pdb > prot' + str(self.id) + '.xyzrn', shell=True)
check = []
with open(self.path + "/msms/prot" + str(self.id) + ".xyzrn") as f:
check = f.readlines()
atoms_check = []
unk = False
for atom in check:
entries = atom.split()
name = entries[5]
ent = name.split("_")
resid = ent[2]
atname = ent[0]
res = ent[1]
try:
r = get_radius(atname, res)[0]
except KeyError:
unk = True
score = 1000000
break
atoms_check.append([resid, entries[0], entries[1], entries[2], r, atname, res])
if not unk:
clash = False
for atom in atoms_check:
id1 = int(atom[0])
atname1 = atom[5]
x = float(atom[1])
y = float(atom[2])
z = float(atom[3])
r = float(atom[4])
for atom2 in atoms_check:
id2 = int(atom2[0])
atname2 = atom2[5]
if (id1 != id2) and not (((id2 == (id1 + 1)) or (id2 == (id1 - 1)))
and (((atname1 == "CA") or (atname1 == "C") or (atname1 == "N")) and
((atname2 == "CA") or (atname2 == "C") or (atname2 == "N")))):
x2 = float(atom2[1])
y2 = float(atom2[2])
z2 = float(atom2[3])
#.........这里部分代码省略.........
示例9: rotamer_mover
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
def rotamer_mover(self, conformation, n):
if n == 0:
self.rot_conf_local = self.rot_conformation
for i in range(len(self.rot_conf_local)):
aa = self.rot_conf_local[i]
moves = []
for j in range(len(aa)):
rand = random.random()
if rand < 0.33:
moves.append(-self.rot_mover_size)
elif rand < 0.66:
moves.append(0)
else:
moves.append(self.rot_mover_size)
aa = [aa[i] + moves[i] for i in range(len(aa))]
self.rot_conf_local[i] = aa
geo = Geometry.geometry(self.sequence[0])
geo.phi = conformation[0]
geo.psi_im1 = conformation[1]
geo.inputRotamers(self.rot_conf_local[0])
structure = PeptideBuilder.initialize_res(geo)
i = 2
j = 1
for aa in self.sequence[1:]:
geo = Geometry.geometry(aa)
geo.phi = conformation[i]
geo.psi_im1 = conformation[i + 1]
if aa != "G" and aa != "P" and aa != "A":
geo.inputRotamers(self.rot_conf_local[j])
j += 1
structure = PeptideBuilder.add_residue(structure, geo)
i += 2
out = Bio.PDB.PDBIO()
out.set_structure(structure)
out.save(self.path + "/msms/prot" + str(self.id) + ".pdb")
mol = pybel.readfile("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb").next()
mol.OBMol.AddHydrogens()
pybelmol = pybel.Molecule(mol)
pybelmol.write("pdb", self.path + "/msms/prot" + str(self.id) + ".pdb",
overwrite=True)
subprocess.call('cd ' + self.path + '/msms; ./pdb_to_xyzrn prot' + str(self.id) +
'.pdb > prot' + str(self.id) + '.xyzrn', shell=True)
check = []
with open(self.path + "/msms/prot" + str(self.id) + ".xyzrn") as f:
check = f.readlines()
atoms_check = []
for atom in check:
entries = atom.split()
name = entries[5]
ent = name.split("_")
resid = ent[2]
atname = ent[0]
res = ent[1]
try:
r = get_radius(atname, res)[0]
except KeyError:
self.threshold += 1
return False
atoms_check.append([resid, entries[0], entries[1], entries[2], r, atname, res])
for atom in atoms_check:
id1 = int(atom[0])
atname1 = atom[5]
x = float(atom[1])
y = float(atom[2])
z = float(atom[3])
r = float(atom[4])
for atom2 in atoms_check:
id2 = int(atom2[0])
atname2 = atom2[5]
if (id1 != id2) and not (((id2 == (id1 + 1)) or (id2 == (id1 - 1)))
and (((atname1 == "CA") or (atname1 == "C") or (atname1 == "N")) and
((atname2 == "CA") or (atname2 == "C") or (atname2 == "N")))):
x2 = float(atom2[1])
y2 = float(atom2[2])
z2 = float(atom2[3])
r2 = float(atom2[4])
distance = np.sqrt((x2 - x)**2 + (y2 - y)**2 + (z2 - z)**2)
if distance < r + r2:
self.threshold += 1
self.rot_conformation = self.rot_conf_local
self.new_conf = True
print "Success."
return True
示例10:
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
# Build a peptide containing all 20 amino acids
structure = PeptideBuilder.initialize_res('A')
for aa in "CDEFGHIKLMNPQRSTVWY":
structure = PeptideBuilder.add_residue(structure, aa)
out = Bio.PDB.PDBIO()
out.set_structure(structure)
out.save("test1.pdb")
# Build a helix containing all 20 amino acids, with slowly varying backbone angles
phi = -60
psi_im1 = -40
geo = Geometry.geometry('A')
geo.phi = phi
geo.psi_im1 = psi_im1
structure = PeptideBuilder.initialize_res(geo)
for aa in "CDEFGHIKLMNPQRSTVWY":
phi += 1
psi_im1 -= 1
geo = Geometry.geometry(aa)
geo.phi = phi
geo.psi_im1 = psi_im1
structure = PeptideBuilder.add_residue(structure, geo)
out.set_structure(structure)
out.save("test2.pdb")
示例11: range
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import geometry [as 别名]
#!/usr/bin/python
'''
Simple example script demonstrating how to use the PeptideBuilder library.
The script generates a peptide consisting of six arginines in alpha-helix
conformation, and it stores the peptide under the name "example.pdb".
'''
from __future__ import print_function
import Geometry
import PeptideBuilder
geo = Geometry.geometry('G')
geo.phi=-60
geo.psi_im1=-40
structure = PeptideBuilder.initialize_res(geo)
for i in range(5):
structure = PeptideBuilder.add_residue(structure, geo)
import Bio.PDB
out = Bio.PDB.PDBIO()
out.set_structure(structure)
out.save( "example.pdb" )