def test_api_penta_lys(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ LYS 4 None ('undefined', 'pk Not In Range') (2, (0.651625, 0.219385)) 3 {10.7: 0.348375} """ params = { "structure": "penta/LYS/protein_000.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "10.7", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["4"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=10.7, extended=True) results = """ LYS 4 None ('undefined', 'pk Not In Range') (2, (0.898065, 0.71377)) 3 {10.7: 0.101935} """ params["structure"] = "penta/LYS/protein_006.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=10.7, extended=True)
def test_api_penta_ntr(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ NTR 5001 None ('undefined', 'pk Not In Range') (4, (0.608115, 0.608115)) 3 {7.7: 0.608115} """ params = { "structure": "penta/NTR/protein_000.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "7.7", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["1N"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=7.7, extended=True) results = """ NTR 5001 None ('undefined', 'pk Not In Range') (2, (0.736045, 0.447095)) 2 {7.7: 0.263955} """ params["structure"] = "penta/NTR/protein_007.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=7.7, extended=True)
def test_api_penta_tyr(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ TYR 4 None ('undefined', 'pk Not In Range') (3, (0.52272, 0.52272)) 0 {9.5: 0.47728} """ params = { "structure": "penta/TYR/protein_001.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "9.5", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["4"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=9.5, extended=True) results = """ TYR 4 None ('undefined', 'pk Not In Range') (2, (0.7652749999999999, 0.390635)) 0 {9.5: 0.765275} """ params["structure"] = "penta/TYR/protein_005.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=9.5, extended=True)
def test_api_penta_asp(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ ASP 4 None ('undefined', 'pk Not In Range') (5, (0.879815, 0.879815)) 4 {4.2: 0.120185} """ params = { "structure": "penta/ASP/asp1.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "4.2", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": [4]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=4.2, extended=True) results = """ ASP 4 None ('undefined', 'pk Not In Range') (1, (0.5596, 0.33636)) 4 {4.2: 0.5596} """ params["structure"] = "penta/ASP/asp2.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=4.2, extended=True)
def test_api_penta_glu(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ GLU 4 None ('undefined', 'pk Not In Range') (5, (0.73255, 0.73255)) 4 {4.5: 0.26745} """ params = { "structure": "penta/GLU/protein_000.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "4.5", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["4"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=4.5, extended=True) results = """ GLU 4 None ('undefined', 'pk Not In Range') (5, (0.55045, 0.55045)) 4 {4.5: 0.44955} """ params["structure"] = "penta/GLU/protein_003.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=4.5, extended=True)
def test_api_penta_his(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ HIS 4 None ('undefined', 'pk Not In Range') (3, (0.859865, 0.859865)) 0 {6.2: 0.859865} """ params = { "structure": "penta/HIS/protein_000.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "6.2", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["4"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=6.2, extended=True) results = """ HIS 4 None ('undefined', 'pk Not In Range') (2, (0.933485, 0.900285)) 1 {6.2: 0.066515} """ params["structure"] = "penta/HIS/protein_003.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=6.2, extended=True)
def test_api_penta_cys(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ CYS 4 None ('undefined', 'pk Not In Range') (3, (0.925685, 0.479055)) 2 {8.2: 0.925685} """ params = { "structure": "penta/CYS/protein_000.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "8.2", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["4"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=8.2, extended=True) results = """ CYS 4 None ('undefined', 'pk Not In Range') (2, (0.61114, 0.28937)) 3 {8.2: 0.61114} """ params["structure"] = "penta/CYS/protein_001.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=8.2, extended=True)
def test_api_penta_ctr(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ CTR 5006 None ('undefined', 'pk Not In Range') (5, (0.886665, 0.886665)) 4 {4.0: 0.113335} """ params = { "structure": "penta/CTR/ctr1.gro", "ncpus": ncpus, "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "4.0", "clean_pdb": False, "sts": "sts_cphmd", } sites = {"A": ["6C"]} pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=4.0, extended=True) results = """ CTR 5006 None ('undefined', 'pk Not In Range') (5, (0.57106, 0.57106)) 4 {4.0: 0.42894} """ params["structure"] = "penta/CTR/ctr2.gro" pKa = Titration(params, sites=sites) checkAPIResult(pKa, results, pH=4.0, extended=True)
def test_api_ktp_pdb_onlytermini_noclean(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ NTR 5001 8.199054937290231 ('protonated', 0.9405274528487423) CTR 5002 3.099830508474576 ('deprotonated', 0.00012582758427877238) """ parameters = { "structure": "ktp/ktp_pdb_onlytermini_noclean/ktp_noclean.pdb", # MANDATORY "clean_pdb": "no", "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "temp": 310, "grid_fill": 0.8, # FUTURE VERSION "ncpus": ncpus, "pH": "0,15", "pHstep": 0.25, "logfile": "LOGFILE", "scaleM": 4, "scaleP": 1, "gsize": 81, "convergence": 0.01, "nlit": 300, "cutoff": -1, "relfac": 0.0, "output": "pKas.out", "clean_pdb": False, } sites = {" ": ("1N", "2C")} pKa = Titration(parameters, sites=sites) checkAPIResult(pKa, results)
def test_api_ktp_pdb_onlytermini(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ NTR 5001 7.931056701030927 ('undefined', 0.8950914882162796) CTR 5002 3.0073796144818266 ('deprotonated', 0.00010170339324314826) """ parameters = { "structure": "ktp/ktp_pdb_onlytermini/ktp.pdb", # MANDATORY "clean_pdb": "yes", "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "temp": 310, "grid_fill": 0.8, # FUTURE VERSION "ncpus": ncpus, "pH": "0,15", "pHstep": 0.25, "logfile": "LOGFILE", "scaleM": 4, "scaleP": 1, "gsize": 81, "convergence": 0.01, "nlit": 300, "cutoff": -1, "relfac": 0.0, "output": "pKas.out", "clean_pdb": True, "remove_hs": False, } sites = {" ": ("1N", "2C")} pKa = Titration(parameters, sites=sites) checkAPIResult(pKa, results)
def test_api_ktp_gro(self): os.system( "rm -f LOG* *out *gro *pdb *pqr *crg *sites cent contributions interactions.dat pkint" ) results = """ NTR 5001 7.932515230635335 ('undefined', 0.8954064318344567) TYR 1 9.884779718110096 ('protonated', 0.9986978698182121) CTR 5002 2.8373655675051106 ('deprotonated', 6.875997409570579e-05) """ parameters = { "structure": "ktp/ktp_gro/ktp.gro", "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "temp": 310, "grid_fill": 0.8, # FUTURE VERSION "ncpus": ncpus, "pH": "-5,15", "pHstep": 0.2, "logfile": "LOGFILE", "scaleM": 4, "scaleP": 1, "gsize": 81, "convergence": 0.01, "nlit": 500, "cutoff": -1, "relfac": 0.0, "output": "pKas.out", "clean_pdb": False, } sites = {"A": ("1N", "1", "2C")} pKa = Titration(parameters, sites=sites) checkAPIResult(pKa, results)
def save_residues(tit: pypka.Titration, pid: int) -> pypka.Titration: # Save residue-level details ( all_sites, _, _, _, ) = tit.getSiteInteractions() for site in all_sites: residue_details = { "pid": pid, "residue_number": site.getResNumber(), "residue_type": site.res_name, "chain": site.molecule.chain, } res_insert = insert(Residue).values(residue_details) res_insert = res_insert.on_conflict_do_update( index_elements=["pid", "residue_number", "residue_type", "chain"], set_={ "pid": pid }, ).returning(Residue.resid) result = session.execute(res_insert) resid = result.fetchall()[0][0] site.resid = resid session.commit() return tit
def test_api_antibody(self): os.system("rm -rf LOG* *out *gro *pdb *pqr *crg *sites cent " "contributions interactions.dat pkint LOG* __pycache__ *pyc") results = """ NTR 5001 None ('undefined', 'pk Not In Range') (4, (0.883505, 0.883505)) 3 {7.0: 0.883505} GLU 6 None ('undefined', 'pk Not In Range') (5, (0.998505, 0.998505)) 4 {7.0: 0.001495} SER 7 None ('undefined', 'pk Not In Range') (3, (1.0, 0.45602)) 2 {7.0: 1.0} SER 17 None ('undefined', 'pk Not In Range') (1, (1.0, 0.33859)) 0 {7.0: 1.0} SER 21 None ('undefined', 'pk Not In Range') (3, (1.0, 0.46141)) 1 {7.0: 1.0} CYS 22 None ('undefined', 'pk Not In Range') (2, (0.99653, 0.360205)) 1 {7.0: 0.99653} SER 25 None ('undefined', 'pk Not In Range') (2, (1.0, 0.460985)) 1 {7.0: 1.0} LYS 218 None ('undefined', 'pk Not In Range') (4, (0.999715, 0.999715)) 3 {7.0: 0.999715} SER 219 None ('undefined', 'pk Not In Range') (1, (0.9999999999999999, 0.44376)) 0 {7.0: 1.0} CTR 5220 None ('undefined', 'pk Not In Range') (5, (0.999825, 0.999825)) 4 {7.0: 0.000175} CYS 220 None ('undefined', 'pk Not In Range') (3, (0.9984500000000001, 0.376525)) 2 {7.0: 0.99845} NTR 5001 None ('undefined', 'pk Not In Range') (4, (0.89596, 0.89596)) 3 {7.0: 0.89596} THR 5 None ('undefined', 'pk Not In Range') (3, (1.0, 0.50905)) 0 {7.0: 1.0} SER 7 None ('undefined', 'pk Not In Range') (1, (1.0, 0.44146)) 1 {7.0: 1.0} SER 9 None ('undefined', 'pk Not In Range') (3, (1.0, 0.41821)) 2 {7.0: 1.0} SER 12 None ('undefined', 'pk Not In Range') (3, (1.0, 0.36406)) 0 {7.0: 1.0} SER 14 None ('undefined', 'pk Not In Range') (2, (1.0, 0.382485)) 2 {7.0: 1.0} ASP 17 None ('undefined', 'pk Not In Range') (5, (0.99974, 0.99974)) 4 {7.0: 0.00026} THR 20 None ('undefined', 'pk Not In Range') (2, (1.0, 0.39265)) 0 {7.0: 1.0} THR 22 None ('undefined', 'pk Not In Range') (3, (1.0, 0.365115)) 2 {7.0: 1.0} CYS 23 None ('undefined', 'pk Not In Range') (2, (0.99302, 0.358615)) 2 {7.0: 0.99302} GLU 214 None ('undefined', 'pk Not In Range') (5, (0.99813, 0.99813)) 4 {7.0: 0.00187} CTR 5215 None ('undefined', 'pk Not In Range') (5, (0.999775, 0.999775)) 4 {7.0: 0.000225} CYS 215 None ('undefined', 'pk Not In Range') (2, (0.99854, 0.37496)) 1 {7.0: 0.99854} NTR 5332 None ('undefined', 'pk Not In Range') (4, (0.854645, 0.854645)) 3 {7.0: 0.854645} HIS 332 None ('undefined', 'pk Not In Range') (2, (0.875545, 0.70737)) 1 {7.0: 0.124455} THR 333 None ('undefined', 'pk Not In Range') (2, (1.0, 0.46669)) 2 {7.0: 1.0} CYS 336 None ('undefined', 'pk Not In Range') (3, (0.985125, 0.336865)) 0 {7.0: 0.985125} GLU 340 None ('undefined', 'pk Not In Range') (5, (0.99765, 0.99765)) 4 {7.0: 0.00235} CYS 525 None ('undefined', 'pk Not In Range') (1, (0.9649099999999999, 0.335965)) 0 {7.0: 0.96491} CTR 5527 None ('undefined', 'pk Not In Range') (5, (0.99998, 0.99998)) 4 {7.0: 2e-05} LYS 527 None ('undefined', 'pk Not In Range') (4, (0.999805, 0.999805)) 3 {7.0: 0.999805} """ params = { "structure": "proteins/Ab269/Ab269-RBD.pdb", "ncpus": ncpus, "epsin": 15, "ionicstr": 0.1, "pbc_dimensions": 0, "pH": "7", "structure_output": ("proteins/Ab269/Ab269-RBD_7.pdb", 7, "AMBER"), } pKa = Titration(params) checkAPIResult(pKa, results, extended=True) check_file_diff("builder/Ab269-RBD_7.pdb", "proteins/Ab269/Ab269-RBD_7.pdb")
def test_lyso_pH12_gromos(self): outfile = "gromos12.pdb" parameters = { "structure": "builder/4lzt.pdb", "epsin": 15, "ionicstr": 0.1, "pbc_dimensions": 0, "ncpus": ncpus, "output": "pKas.out", "titration_output": "titration.out", "structure_output": (outfile, 12, "gromos_CpH"), } pKa = Titration(parameters) checkStructureOutput(outfile)
def test_api_ktp_pdb_allsites_clean(self): os.system( "rm -f *out *gro *pdb *pqr *crg *sites cent contributions interactions.dat pkint" ) results = """ NTR 5001 7.934819040827242 ('undefined', 0.8959021976401332) TYR 1 9.78114442380826 ('protonated', 0.9983475157921265) CTR 5002 3.010253456221198 ('deprotonated', 0.00010237855405755827) """ parameters = { "structure": "ktp/ktp_pdb_allsites/ktp.pdb", "clean_pdb": "yes", "epsin": 2, "ionicstr": 0.1, "pbc_dimensions": 0, "temp": 310, "grid_fill": 0.8, "ncpus": ncpus, "pH": "0,15", "pHstep": 0.2, "logfile": "LOGFILE", "scaleM": 4, "scaleP": 1, "gsize": 81, "convergence": 0.01, "nlit": 300, "cutoff": -1, "relfac": 0.0, "output": "pKas.out", "clean_pdb": True, "remove_hs": False, } sites = "all" pKa = Titration(parameters, sites=sites) checkAPIResult(pKa, results)
"ionicstr": 0.1, "pbc_dimensions": 0, "ncpus": sys.argv[1], "output": "pKas.out", "titration_output": "titration.out", "ser_thr_titration": False, "structure_output": ("out4.pdb", 4.5, "gromos_cph"), } #'gsize' : 91, #'bndcon' : 4, #'nanoshaper' : 0, #'precision' : 'single'} sites = {"A": ["1N", 1, 7, 15, 18, 35, 48, 52, 66, 87, 101, 119, "129C"]} pKa = Titration(parameters, sites=sites) # , debug=True) # exit() # Run each step separately # pKa = Titration(parameters, run='preprocess') # pKa.DelPhiLaunch() # pKa.calcSiteInteractionsParallel() # pKa.run_mc() # print(pKa) # from IPython import embed; embed() # for pH in pKa.getTitrationCurve('total').keys(): # print(pH, pKa.getTitrationCurve('total')[pH]) # for site in pKa:
def save_settings(tit: pypka.Titration) -> None: # Save settings pypka_params, delphi_params, mc_params = tit.getParametersDict() to_keep = [ "CpHMD_mode", "ffID", "ff_family", "ffinput", "clean_pdb", "LIPIDS", "keep_ions", "ser_thr_titration", "cutoff", "slice", ] pypka_params = { key: value for key, value in pypka_params.items() if key in to_keep } pypka_params["version"] = pypka_version mc_params["pH_values"] = list(mc_params["pH_values"]) bool_params = [ "CpHMD_mode", "ser_thr_titration", "clean_pdb", "keep_ions", "pbx", "pby", ] query = session.query(Sim_settings.settid) for param in pypka_params: to_compare = str(pypka_params[param]) if param in bool_params: to_compare = to_compare.lower() query = query.filter( Sim_settings.pypka_params[param].as_string() == to_compare) for param in delphi_params: to_compare = str(delphi_params[param]) if param in bool_params: to_compare = to_compare.lower() query = query.filter( Sim_settings.delphi_params[param].as_string() == to_compare) for param in mc_params: to_compare = str(mc_params[param]) if param in bool_params: to_compare = to_compare.lower() query = query.filter( Sim_settings.mc_params[param].as_string() == to_compare) settid = query.first() if not settid: new_sim_settings = Sim_settings(pypka_params=pypka_params, delphi_params=delphi_params, mc_params=mc_params) session.add(new_sim_settings) session.flush() settid = new_sim_settings.settid else: settid = settid[0] NEW_PK_SIM.settid = settid session.commit()
from pypka import Titration params = { "structure": "4lzt.pdb", # Input structure file name "ncpus": -1, # Number of processes (-1 for maximum allowed) "epsin": 15, # Dielectric constant of the protein "ionicstr": 0.1, # Ionic strength of the medium (M) "pbc_dimensions": 0, # PB periodic boundary conditions (0 for solvated proteins and 2 for lipidic systems) } tit = Titration(params) pH = 7.0 for site in tit: state = site.getProtState(pH)[0] print(site.res_name, site.res_number, site.pK, state)
#import os #pdbl = PDBList() #pdbl.retrieve_pdb_file('1LSE', file_format="pdb", pdir=".") #pdbl.retrieve_pdb_file('4LZT', file_format="pdb", pdir=".") #os.rename('pdb1lse.ent', '1lse.pdb') #os.rename('pdb4lzt.ent', '4lzt.pdb') import sys sys.path.insert(1, '../../') from pypka import Titration parameters = {'structure' : '4lzt.pdb', 'epsin' : 10, 'ionicstr' : 0.1, 'pbc_dimensions': 0, 'temp' : 100, 'grid_fill' : 0.8, # FUTURE VERSION 'ncpus' : 4, 'pH' : '0, 15', 'maxc' : 0.01, 'pHstep' : 0.5, 'output': 'pkas.out'} sites = {'A': ('1N', '18', '35', '48', '66', '129C')} pKa = Titration(parameters, sites=sites, debug=True) for site in pKa: print site, pKa[site], pKa.getProtState(site, 7) print pKa.getParameters()
'epsin': 10, 'ionicstr': 0.1, 'pbc_dimensions': 0, 'ncpus': 2, 'output': 'pKas.out', 'titration_output': 'titration.out', 'structure_output': ('gromos.pdb', pH, 'amber'), 'gsize': 41, 'convergence': 0.2, 'pHstep': 1.0, 'clean_pdb': True } #pKa = Titration(parameters, sites={'A': ['1N', '1', '7', '129C']}) tit = Titration(parameters) for site in tit: pK = site.pK #taut = site.getMostProbTaut(pH) state = site.getProtState(pH)[0] #site.molecule.chain, print(site.res_name, site.res_number, pK, state) # # print(site.getFinalState(pH)) # print(site.getTitrationCurve()) #print(tit.getTitrationCurve()) #print(tit.getParameters()) import matplotlib.pyplot as plt