def show_constraints(self, mardi_path, pdb_path): midas.process(self.session).unshow_objects('constraints') if not mardi_path or not pdb_path: return show_satisfied = self.satisfied.get() show_violated = self.violated.get() if not (show_satisfied or show_violated): return lines = midas.midas_object_file('constraints') model = pdb.model(self.session, pdb_path) mardi = mardigras.bounds(self.session, mardi_path) for (num_atom_1, num_atom_2), (rmin, rmax) in mardi.bounds_table.items(): num_atom_1 = translate_atom_name(num_atom_1, mardi, model) num_atom_2 = translate_atom_name(num_atom_2, mardi, model) pdb_atom_1 = model.num_atom_to_pdb_atom(num_atom_1) pdb_atom_2 = model.num_atom_to_pdb_atom(num_atom_2) if pdb_atom_1 and pdb_atom_2: d = pyutil.distance(pdb_atom_1.xyz, pdb_atom_2.xyz) if ((show_satisfied and d >= rmin and d <= rmax) or (show_violated and (d < rmin or d > rmax))): if d < .8 * rmin: color = 'blue' elif d < rmin: color = 'cyan' elif d <= rmax: color = 'green' elif d < 1.2 * rmax: color = 'magenta' else: color = 'red' pdb_atom_1 = model.num_atom_to_pdb_atom(num_atom_1) pdb_atom_2 = model.num_atom_to_pdb_atom(num_atom_2) lines.add_line(pdb_atom_1.xyz, pdb_atom_2.xyz, color) lines.show_objects(self.session)
def chimera_open_model(self, pdb_path): if pdb_path == self.pdb_path: return if self.model: chimera = self.chimera() chimera.openModels.close([self.model]) self.model = None # I suspect closing the model also eliminates all constraint pseudobonds self.num_atom_pair_to_pseudobond = {} self.pdb_path = pdb_path chimera = self.chimera() models = chimera.openModels.open(pdb_path, type='PDB') self.model = models[0] # assume just one molecule in the PDB file self.model.color = chimera.Color_lookup('gray') trans = pdb.model(self.session, pdb_path).atom_translations self.make_atom_tables(self.model.atoms, trans) if self.pseudobond_group == None: m = chimera.PseudoBondMgr_mgr() self.pseudobond_group = m.newPseudoBondGroup('NOESY constraints') del m chimera.openModels.add([self.pseudobond_group], sameAs=self.model)
def show_constraint_lines(self, mardi_path, pdb_path, range_colors): # unshow previous constraints if not mardi_path or not pdb_path: return show_satisfied = self.show_satisfied.get() show_violated = self.show_violated.get() if not (show_satisfied or show_violated): return pdb_model = pdb.model(self.session, pdb_path) mardi = mardigras.bounds(self.session, mardi_path) for (num_atom_1, num_atom_2), (rmin, rmax) in mardi.bounds_table.items(): num_atom_1 = translate_atom_name(num_atom_1, mardi, pdb_model) num_atom_2 = translate_atom_name(num_atom_2, mardi, pdb_model) pdb_atom_1 = pdb_model.num_atom_to_pdb_atom(num_atom_1) pdb_atom_2 = pdb_model.num_atom_to_pdb_atom(num_atom_2) if pdb_atom_1 and pdb_atom_2: d = pyutil.distance(pdb_atom_1.xyz, pdb_atom_2.xyz) if ((show_satisfied and d >= rmin and d <= rmax) or (show_violated and (d < rmin or d > rmax))): if d < .8 * rmin: color = range_colors[0] elif d < rmin: color = range_colors[1] elif d <= rmax: color = range_colors[2] elif d < 1.2 * rmax: color = range_colors[3] else: color = range_colors[4] self.show_constraint(num_atom_1, num_atom_2, color)
def chimera_open_model(self, pdb_path): if pdb_path == self.pdb_path: return if self.model: chimera = self.chimera() chimera.openModels.close([self.model]) self.model = None # I suspect closing the model also eliminates all constraint pseudobonds self.num_atom_pair_to_pseudobond = {} self.pdb_path = pdb_path chimera = self.chimera() models = chimera.openModels.open(pdb_path, type='PDB') self.model = models[0] # assume just one molecule in the PDB file self.model.color = chimera.Color_lookup('gray') trans = pdb.model(self.session, pdb_path).atom_translations self.make_atom_tables(self.model.atoms, trans) if self.pseudobond_group == None: m = chimera.PseudoBondMgr_mgr() self.pseudobond_group = m.newPseudoBondGroup('NOESY constraints') del m chimera.openModels.add([self.pseudobond_group], sameAs = self.model)
def assigned_pdb_atoms(session, pdb_path, condition): assigned = [] model = pdb.model(session, pdb_path) for a in model.pdb_atoms: if model.find_resonance(a, condition): assigned.append(a) return assigned
def get_models(self, pdb_paths): models = [] bad_paths = '' for pdb_path in pdb_paths: model = pdb.model(self.session, pdb_path) if model == None: bad_paths = bad_paths + pdb_path + '\n' else: models.append(model) if bad_paths: self.progress_report("Couldn't open\n" + bad_paths) return models
def midas_pick_to_pdb_atom(self, midas_atom_spec): match = re.match('(#)(\d+)(:)(\d+)(@)(.+)', midas_atom_spec) if match: g = match.groups() model_number = string.atoi(g[1]) path = self.model_path(model_number) if path: residue_number = string.atoi(g[3]) atom_name = g[5] model = pdb.model(self.session, path) num_atom = (residue_number, atom_name) pdb_atom = model.num_atom_to_pdb_atom(num_atom) return model, pdb_atom return None, None
def initialize(self, session, peaks, stoppable): self.models = [] for pdb_path in self.pdb_path_list: m = pdb.model(session, pdb_path, stoppable) # read pdb files self.models.append(m)