def mask(mrc, top, conf, enrgmd_server, no_cut_box, keep_full): """mask mrc map to fitted atomic model.\n Used to:\n * make minimum box by keeping full data (for manual fit prep)\n * create mask for atomic model MRC is the name of the cryo EM volumetric data file [.mrc]\n TOP is the name of the namd topology file [.top]\n CONF is the name of the namd configuration file [.pdb, .coor]\n """ file_types = { mrc: [".mrc"], top: [".psf"], conf: [".pdb", ".coor"], } for file, types in file_types.items(): _check_path(file, types) model = AtomicModelFit(conf=conf, top=top, mrc=mrc, generated_with_mrdna=enrgmd_server) universe = model.get_universe() mrc_masked = mrc.with_name(f"{mrc.stem}-masked.mrc") write_mrc_from_atoms( path=mrc, atoms=universe.atoms, path_out=mrc_masked, context=40.0, cut_box=no_cut_box, keep_data=keep_full, )
def pdb2cif(pdb, remove_h, is_snupi, flip_fields): """generate atomic model in mmCIF format from namd PDB PDB is the name of the namd configuration file [.pdb]\n """ _check_path(pdb, [".pdb"]) structure = Structure(path=pdb, remove_H=remove_h, is_snupi=is_snupi, flip_fields=flip_fields) structure.parse_pdb() # TODO-low: ask for additional info (name, author, etc) output_name = pdb.with_suffix(".cif") structure.write_cif(output_name)
def center_on_map(mrc, top, conf): """recenter atomic model center-of-mass on mrc cryo map center and write new .pdb. MRC is the name of the cryo EM volumetric data file [.mrc]\n TOP is the name of the namd topology file [.psf]\n CONF is the name of the namd configuration, docked to the map [.pdb, .coor]\n """ file_types = { mrc: [".mrc"], top: [".psf"], conf: [".pdb", ".coor"], } for file, types in file_types.items(): _check_path(file, types) conf_docked = conf.with_name(f"{conf.stem}-docked.pdb") copyfile(conf, conf_docked) mrc_shift = get_mrc_center(mrc) recenter_conf(top=top, conf=conf_docked, to_position=mrc_shift)
def mrdna(cadnano, mrc, sequence, gpu, prefix, multidomain, coarse_steps, bond_cutoff, no_prep): """mrDNA simulation of CADNANO design file with custom settings.\n followed by preperation of files for "dnaFit fit"\n Note1: includes centering of model and masking of map\n Note2: map and model are not rigid body docked "dnaFit vmd_info" CADNANO is the name of the design file [.json]\n SEQUENCE is the scaffold strand sequence file [.txt, .seq]\n MRC is the name of the cryo EM volumetric data file [.mrc]\n """ file_types = { cadnano: [".json"], mrc: [".mrc"], sequence: [".txt", ".seq"], } for file, types in file_types.items(): _check_path(file, types) prefix = cadnano.stem if prefix is None else prefix run_mrdna( cad_file=cadnano, seq_file=sequence, prefix=prefix, gpu=gpu, multidomain=multidomain, coarse_steps=coarse_steps, bond_cutoff=bond_cutoff, ) if not no_prep: prep_cascaded_fitting(prefix, cadnano, sequence, mrc, multidomain=multidomain) logger.info( "Config file is moved to center of mass with mrc map but still \ has to be rotated before fitting. execute vmd_info for additional info" )
def prep(cadnano, mrc, sequence, prefix, multidomain): """prepare mrDNA results for fitting "dnaFit fit".\n Note1: includes centering of model and masking of map\n Note2: map and model are not rigid body docked "dnaFit vmd_info" CADNANO is the name of the design file [.json]\n SEQUENCE is the scaffold strand sequence file [.txt, .seq]\n MRC is the name of the cryo EM volumetric data file [.mrc]\n """ file_types = { cadnano: [".json"], mrc: [".mrc"], sequence: [".txt", ".seq"], } for file, types in file_types.items(): _check_path(file, types) prefix = cadnano.stem if prefix is None else prefix prep_cascaded_fitting(prefix, cadnano, sequence, mrc, multidomain=multidomain)
def link(cadnano, sequence, top, conf, enrgmd_server): """links structural information of the CADNANO designfile to fitted atomic model files TOP, CONF.\n Note: linkage information ist stored in human readable csv format CADNANO is the name of the design file [.json]\n SEQUENCE is the scaffold strand sequence file [.txt, .seq]\n TOP is the name of the namd topology file [.psf]\n CONF is the name of the namd configuration file [.pdb, .coor]\n """ file_types = { cadnano: [".json"], sequence: [".txt", ".seq"], top: [".psf"], conf: [".pdb", ".coor"], } for file, types in file_types.items(): _check_path(file, types) model = AtomicModelFit(conf=conf, top=top, mrc=None, generated_with_mrdna=(not enrgmd_server)) model.write_linkage(json=cadnano, seq=sequence)
def fit( cadnano, sequence, mrc, top, conf, exb, prefix, timesteps, resolution, sr_fitting, include_ss, grid_pdb, ): """Cascaded mrDNA-driven MD flexible fitting (shrink wrap fitting) to MRC cryo data.\n creates dnaFit folder. This folder will contain final results prefix-last.cif\n Note1: run after mrDNA ("dnaFit mrdna") and manual rigid-body-docking ("dnaFit vmd_info")\n Note2: SR-fitting (Short Range). Recommended for maps with resolution >> 10 Angstrom CADNANO is the name of the design file [.json]\n SEQUENCE is the scaffold strand sequence file [.txt, .seq]\n MRC is the name of the cryo EM volumetric data file [.mrc]\n TOP is the name of the namd topology file [.psf]\n CONF is the name of the namd configuration file, docked to map (VMD) [.pdb, .coor]\n EXB is the name of the enrgMD extrabond file (expect mrDNA > march 2021) [.exb] """ file_types = { cadnano: [".json"], sequence: [".seq", ".txt"], mrc: [".mrc"], top: [".psf"], conf: [".pdb", ".coor"], exb: [".exb"], } for file, types in file_types.items(): _check_path(file, types) prefix = cadnano.stem if prefix is None else prefix # TODO-low: gpu support logger.info("GPU currently not supported for fitting. using CPU only.") # create duplicates of input files in dnaFit folder Path("dnaFit").mkdir(parents=True, exist_ok=True) for file, types in file_types.items(): copyfile(file, f"./dnaFit/{prefix}{types[0]}") home_directory = Path.cwd() try: os.chdir("dnaFit") logger.debug("changing directory to: %s", Path.cwd()) # use duplicates instead of input mrc = Path(f"./{prefix}.mrc").resolve() cadnano = Path(f"./{prefix}.json").resolve() sequence = Path(f"./{prefix}.seq").resolve() top = Path(f"./{prefix}.psf").resolve() conf = Path(f"./{prefix}.pdb").resolve() exb = Path(f"./{prefix}.exb").resolve() if not Path("./charmm36.nbfix").exists(): copytree(get_resource("charmm36.nbfix"), "./charmm36.nbfix") cascade = Cascade(conf=conf, top=top, mrc=mrc, exb=exb, json=cadnano, seq=sequence, grid_pdb=grid_pdb) model = cascade.run_cascaded_fitting( base_time_steps=timesteps, resolution=resolution, is_sr=sr_fitting, include_ss=include_ss, ) model.write_linkage(cadnano, sequence) model.write_output(dest=Path(home_directory), write_mmcif=True, mask_mrc=True) finally: os.chdir(home_directory) logger.debug("changing directory to: %s", Path.cwd())