def __call__(self, pars, namespace, values, option_string=None): """This function is executed when build is called.""" pro = Protein(values) # print the QUBE general FF to use in the parametrisation qube_general() # now we want to add the connections and parametrise the protein XMLProtein(pro) # this updates the bonded info that is now in the object # finally we need the non-bonded parameters from onetep # TODO should we also have the ability to get DDEC6 charges from the cube file? pro.charge = 0 pro.charges_engine = 'onetep' pro.density_engine = 'onetep' lj = LennardJones(pro) pro.NonbondedForce = lj.calculate_non_bonded_force() # now we write out the final parameters # we should also calculate the charges and lj at this point! printf('Writing pdb file with connections...') pro.write_pdb(name='QUBE_pro') printf('Writing XML file for the system...') pro.write_parameters(name='QUBE_pro', is_protein=True) # now remove the qube general file os.remove('QUBE_general_pi.xml') printf('Done') sys.exit()
def __call__(self, pars, namespace, values, option_string=None): printf("starting protein prep, reading pdb file...") protein = Protein(values) printf(f"{len(protein.residues)} residues found!") # TODO find the magic numbers for the box for onetep protein.write_xyz(name="protein") printf(f"protein.xyz file made for ONETEP\n Run this file") sys.exit()
def __call__(self, pars, namespace, values, option_string=None): """This function is executed when setup is called.""" printf('starting protein prep, reading pdb file...') protein = Protein(values) printf(f'{len(protein.Residues)} residues found!') # TODO find the magic numbers for the box for onetep protein.write_xyz(name='protein') printf(f'protein.xyz file made for ONETEP\n Run this file') sys.exit()
def __call__(self, pars, namespace, values, option_string=None): pro = Protein(values) # print the QUBE general FF to use in the parametrisation qube_general() # now we want to add the connections and parametrise the protein XMLProtein(pro) # finally we need the non-bonded parameters from onetep # TODO should we also have the ability to get DDEC6 charges from the cube file? pro.charge = 0 pro.charges_engine = "onetep" pro.density_engine = "onetep" ExtractChargeData(pro).extract_charge_data() LennardJones(pro).calculate_non_bonded_force() # Write out the final parameters printf("Writing pdb file with connections...") pro.write_pdb(name=f"QUBE_pro_{pro.name}") printf("Writing XML file for the system...") pro.write_parameters(name=f"QUBE_pro_{pro.name}") # now remove the qube general file os.remove("QUBE_general_pi.xml") printf("Done") sys.exit()
def test_from_pdb(): """ Make sure we can make a protein from a pdb file. """ pro = Protein.from_file(file_name=get_data("capped_leu.pdb")) assert pro.n_atoms == 31 assert pro.coordinates.shape == (pro.n_atoms, 3)
def test_protein_params(tmpdir): """ Load up the small protein and make sure it is parametrised with the general qube forcefield. """ with tmpdir.as_cwd(): pro = Protein.from_file(file_name=get_data("capped_leu.pdb")) shutil.copy(get_data("capped_leu.pdb"), "capped_leu.pdb") XMLProtein(protein=pro)
def setUpClass(cls): """ Write the big string in test_structures to a file to be used for testing. Cannot use actual files as pathing causes issues. """ with open('aceleunme.pdb', 'w+') as pdb_test_file: pdb_test_file.write(aceleunme) cls.molecule = Protein('aceleunme.pdb')
def setUpClass(cls): """Create temp working directory and copy across test files.""" cls.files_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files') os.mkdir('temp') os.chdir('temp') copy(os.path.join(cls.files_folder, 'capped_leu.pdb'), 'capped_leu.pdb') cls.molecule = Protein('capped_leu.pdb') cls.molecule.testing = True
def test_pdb_round_trip(tmpdir): """ Make sure we can round trip a protein to pdb. """ with tmpdir.as_cwd(): pro = Protein.from_file(file_name=get_data("capped_leu.pdb")) pro.write_pdb(name="test") pro2 = Protein.from_file("test.pdb") assert pro.n_atoms == pro2.n_atoms assert pro.n_bonds == pro.n_bonds for bond in pro.bonds: assert bond in pro2.bonds for angle in pro.angles: assert angle in pro2.angles for central_bond, torsions in pro.dihedrals.items(): for d in torsions: assert d in pro2.dihedrals[central_bond]
def setUp(self): """ Set up a protein testing class, make temp folder and copy capped leu file """ self.home = os.getcwd() self.test_folder = os.path.join(os.path.dirname(__file__), 'files') # Make the temp folder and move there with the required files with tempfile.TemporaryDirectory() as temp: os.chdir(temp) copy(os.path.join(self.test_folder, 'capped_leu.pdb'), 'capped_leu.pdb') self.molecule = Protein('capped_leu.pdb')
def setUpClass(cls): cls.files_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files') os.mkdir('temp') os.chdir('temp') copy(os.path.join(cls.files_folder, 'capped_leu.pdb'), 'capped_leu.pdb') cls.molecule = Protein('capped_leu.pdb')
def test_not_pdb(): """ Make sure an error is raised if we try and make a protein from a non pdb file. """ with pytest.raises(FileTypeError): _ = Protein.from_file(file_name=get_data("bace0.xyz"))
def test_normal_init(): """ Make sure a pdb file is directed to the from pdb path. """ pro = Protein(get_data("capped_leu.pdb")) assert pro.n_atoms == 31