def _load_model_and_mtz(self, pdb_file, mtz_file): import os if (not os.path.isfile(pdb_file)) or (not os.path.isfile(mtz_file)): raise RuntimeError('One or more output files not found: \n' '{}\n{}'.format(pdb_file, mtz_file)) self.clear_refinement() from chimerax.open_command.cmd import provider_open m = self._current_model = provider_open(self.session, [pdb_file])[0] self.isolde.add_xtal_data(mtz_file, model=m) self.set_default_atom_coloring() self.isolde.change_selected_model(m)
def show_start_model(self, file_name): ''' Load the starting model from file. Takes the filename (including full path) as an argument. ''' if self._start_model is not None and not self._start_model.deleted: self.session.models.close([self._start_model]) from chimerax.open_command.cmd import provider_open m = self._start_model = provider_open(self.session, [file_name])[0] m.bonds.radii=0.05 from chimerax.clipper.symmetry import get_symmetry_handler get_symmetry_handler(m) self.set_default_atom_coloring() return True
def test_xtal_mgr(session): from chimerax.open_command.cmd import provider_open m = provider_open(session, [os.path.join(_basedir, '3io0.pdb')])[0] from ..clipper_mtz import ReflectionDataContainer from .. import atom_list_from_sel from ..clipper_python.ext import Xtal_mgr rdc = ReflectionDataContainer(session, os.path.join(_basedir, '3io0-sf.mtz')) xm = Xtal_mgr(rdc.hklinfo, rdc.free_flags.data, rdc.grid_sampling, rdc.experimental_data.datasets['FOBS, SIGFOBS'].data) xm.generate_fcalc(atom_list_from_sel(m.atoms)) print("Rfree: {}".format(xm.rfree)) print("Rwork: {}".format(xm.rwork)) return xm, rdc
def test_clipper_sym(session, radius=12): import os from chimerax.open_command.cmd import provider_open libdir = os.path.abspath(os.path.dirname(__file__)) m = provider_open(session, [os.path.join(libdir, '3io0.pdb')])[0] m.atoms.displays = True from chimerax.std_commands import cofr cofr.cofr(session, method='center of view', show_pivot=True) from chimerax.clipper import symmetry sym_handler = symmetry.get_symmetry_handler(m, create=True) sym_handler.spotlight_radius = radius sym_handler.map_mgr.add_xmapset_from_mtz(os.path.join( libdir, '3io0_combined.mtz'), oversampling_rate=1.5) sym_handler.map_mgr.nxmapset.add_nxmap_handler_from_file( os.path.join(libdir, '3io0_real_space.ccp4')) return sym_handler
def load_model(session, file_path: 'string'): ''' Load a model from a single PDB or mmCIF file. Multi-model files are not supported. Args: file_path: the full path to a single PDB or mmCIF file Returns: {'manager': model id for the top-level Clipper manager for the model, 'model': model id for the atomic structure itself. } ''' from chimerax.open_command.cmd import provider_open from chimerax.clipper import get_symmetry_handler m = provider_open(session, [file_path])[0] sh = get_symmetry_handler(m, create=True, auto_add_to_session=True) return {'manager': sh.id_string, 'model id': m.id_string}
def count_matches_for_pdb_list(session, pdb_ids, identity_cutoff=0.3, evalue_cutoff=1, log_file='pdb_matches.log'): from chimerax.open_command.cmd import provider_open with open(log_file, 'wt') as log: log.write('PDB ID,Chain ID,Match count,Matching ids\n') for pdb_id in pdb_ids: try: models = provider_open(session, [pdb_id]) m = models[0] except: print(f'Failed on {pdb_id}!') continue matches = get_wwpdb_matches_for_all_chains(m, identity_cutoff, evalue_cutoff) for c, matching in matches.items(): num_matches = len(matching) log.write(f'{pdb_id},{c},{num_matches},{" ".join(matching)}\n') log.flush() session.models.close(models)
import numpy import os dpath = os.path.dirname(os.path.abspath(__file__)) from chimerax.open_command.cmd import provider_open m = provider_open(session, [os.path.join(dpath, '5f4y.pdb')])[0] from chimerax.clipper import CrystalStructure cs = CrystalStructure(session, m, os.path.join('5f4y_map_coeffs.mtz') from chimerax.clipper.crystal import _find_box_corner box_corner_grid, box_corner_xyz = _find_box_corner(cs._sym_box_center, cs.cell, cs.grid, 25) dim = numpy.array([50,50,50], numpy.int32) symops = symops = cs.unit_cell.all_symops_in_box(box_corner_xyz, dim, True) tfs = symops.all_matrices_orth(cs.cell) from chimerax.clipper import geometry m.atoms.displays = True results = geometry.sym_transforms_in_sphere(m.atoms, tfs, session.view.center_of_rotation, 50)