def test_cleanup(urea, water): mixture = mdapackmol.packmol([ mdapackmol.PackmolStructure( water, number=2, instructions=['inside box 0. 0. 0. 40. 40. 40.'], ), mdapackmol.PackmolStructure( urea, number=2, instructions=['inside box 0. 0. 0. 40. 40. 40.'], ), ]) assert not os.path.exists(mdapackmol.mdapackmol.PACKMOL_INP) assert not os.path.exists('output.pdb')
def mixture(in_tmpdir, water, urea): # PS(ag, number, instructions) mixture = mdapackmol.packmol([ mdapackmol.PackmolStructure( water, number=1000, instructions=['inside box 0. 0. 0. 40. 40. 40.'], ), mdapackmol.PackmolStructure( urea, number=400, instructions=['inside box 0. 0. 0. 40. 40. 40.'], ), ]) return mixture
def test_bonds(urea, water): urea.atoms.guess_bonds() water.atoms.guess_bonds() mixture = mdapackmol.packmol([ mdapackmol.PackmolStructure( water, number=50, instructions=['inside box 0. 0. 0. 40. 40. 40.'], ), mdapackmol.PackmolStructure( urea, number=50, instructions=['inside box 0. 0. 0. 40. 40. 40.'], ), ]) assert hasattr(mixture, 'bonds') assert len(mixture.bonds) == len(water.bonds) * 50 + len(urea.bonds) * 50
def set_positions(self, simulation, *args): import MDAnalysis as mda import mdapackmol # Get topology options topology_options = args[0] # Create default instructions box_vectors = simulation.context.getState().getPeriodicBoxVectors() a = box_vectors[0][0].value_in_unit(angstrom) b = box_vectors[1][1].value_in_unit(angstrom) c = box_vectors[2][2].value_in_unit(angstrom) default_instructions = ["inside box 0. 0. 0. {:.1f} {:.1f} {:.1f}".format(a, b, c)] # Create input for packmol mdapackmol_input = [] for chain_options in topology_options.chains: instructions = chain_options.instructions if instructions is None: instructions = default_instructions chain_filepath = "data/{}.pdb".format(chain_options.sequence_str) if topology_options.forceField_str == 'OPLS-AA': chain_filepath = "data/{}_aa.pdb".format(chain_options.sequence_str) molecule = mda.Universe( os.path.join(os.path.dirname(__file__), chain_filepath) ) packmol_structure = mdapackmol.PackmolStructure( molecule, number=chain_options.num, instructions=instructions ) mdapackmol_input.append(packmol_structure) for branched_chain_options in topology_options.branched_chains: instructions = branched_chain_options.instructions if instructions is None: instructions = default_instructions molecule = mda.Universe( branched_chain_options.pdb ) packmol_structure = mdapackmol.PackmolStructure( molecule, number=branched_chain_options.num, instructions=instructions ) mdapackmol_input.append(packmol_structure) if topology_options.numDodecane > 0: instructions = topology_options.dodecaneInstructions if instructions is None: instructions = default_instructions dodecane_pdb_filepath = "data/C12.pdb" if topology_options.forceField_str == 'OPLS-AA': dodecane_pdb_filepath = "data/C12_aa.pdb" molecule = mda.Universe( os.path.join(os.path.dirname(__file__), dodecane_pdb_filepath) ) packmol_structure = mdapackmol.PackmolStructure( molecule, number=topology_options.numDodecane, instructions=instructions ) mdapackmol_input.append(packmol_structure) if topology_options.numSqualane > 0: instructions = default_instructions if topology_options.forceField_str == 'TraPPE-UA': squalane_pdb_filepath = "data/squalane_ua.pdb" else: raise NotImplementedError("force field not implemented for squalane") molecule = mda.Universe( os.path.join(os.path.dirname(__file__), squalane_pdb_filepath) ) packmol_structure = mdapackmol.PackmolStructure( molecule, number=topology_options.numSqualane, instructions=instructions ) mdapackmol_input.append(packmol_structure) # Call Packmol system = mdapackmol.packmol(mdapackmol_input) # Set positions to simulation positions = system.coord.positions/10.0 simulation.context.setPositions(positions) # Save to PDB file if self.file is not None: PDBReporter(self.file, 1).report(simulation, simulation.context.getState(getPositions=True))
with open('selex.00.pdb', 'w') as outfile: PDBFile.writeFile( simulation.topology, state.getPositions(), outfile) ### # Mutant ### """ Model components """ water = mda.Universe(f'{PDB_DIR}/water.pdb').select_atoms('resname *') ligand = mda.Universe('selex.00.pdb').select_atoms('resname UNL') protein = mda.Universe('selex.00.pdb').select_atoms('protein') """ Crteate the solvent box """ num,rho = pkm.tools.molecules_for_target_density( {protein:1, ligand:1}, water, SOLVENT_BOX_RHO, SOLVENT_BOX_DIM) solvent = pkm.packmol([ pkm.PackmolStructure(water, num, [SOLVENT_BOX_CMD])]) """ Center components """ complejo = mda.Merge(ligand, protein) protein = complejo.select_atoms('protein') ligand = complejo.select_atoms('resname UNL') point = [d/2 for d in SOLVENT_BOX_DIM] complejo.trajectory.add_transformations( mtx.center_in_box(complejo.atoms, point=point, wrap=False)) """ Dissolve complex """ uni_selex00 = mda.Merge(complejo.atoms, solvent.atoms) """ Construct mutation strings by chain for PDBFixer """ wtgroup_A = uni_selex00.select_atoms('segid A and (around 3.0 resname UNL)')