Coverage for /home/pedror/MMS@FCUL/pypka/pypka/tautomer.py : 67%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Tautomers share the same site and atoms Tautomers have different charge sets for the same atoms """ """ Args: name (str): name of the Tautomer site (Site): belonging site molecule (TitratingMolecule): belonging molecule
# Inheritance self._molecule self._site
# Tautomer Details self._name self._charge_set (dict): charge set of the tautomer key is atom name str value is charge float self._natoms (int): number of atoms of the Tautomer Redundant to self._site._natoms as it must be the same between all Tautomers belonging to the same Site.
# Tautomer Energy Details self._esolvation (float): solvation energy self._e_back (float): background interaction energy self._dg (float): pKint energy """
# Set Methods """Reads .st file related to Tautomer with residue name res_name Stores charge set related to both the Tautomer and the Reference Tautomer
.st file named TYRtau1.st has charge set of TY0 and reference TY2 TYRtau2.st has charge set of TY1 and reference TY2 """ config.params['ffID'], res_name, tau_number) else:
print fname, 'anionic' print fname, 'cationic' print self._charge_set print ref_tautomer._charge_set print 'finished reading', fname
"""Set DelPhi parameters to run a calculation of a whole molecule (all sites neutral, except one)""" if x < 0: x -= box_side if y < 0: y -= box_side return x, y
# Could have used empty structures # TODO: quantify time impact of this quick fix
box = molecule.box half_box_xy = self._site.getCenter()[0] site_center = self._site.getCenterOriginal()
offset_x = half_box_xy - site_center[0] offset_y = half_box_xy - site_center[1] offset_z = box[2] * 10 # irrelevant, only for debug
box_x = box[0] * 10 box_y = box[1] * 10
'atom__resnumbc_charge_\n'
#TODO: quick fix, should be done only once per site p_atpos[atom_position][0] += offset_x p_atpos[atom_position][1] += offset_y p_atpos[atom_position][2] += offset_z
if p_atpos[atom_position][0] < 0: p_atpos[atom_position][0] += box_x elif p_atpos[atom_position][0] >= box_x: p_atpos[atom_position][0] -= box_x
if p_atpos[atom_position][1] < 0: p_atpos[atom_position][1] += box_y elif p_atpos[atom_position][1] >= box_y: p_atpos[atom_position][1] -= box_y
# Comment 15 May 2019 # No rounding is better, however, pypka calculations # are no longer comparable to delphiT ones due to this #noregrets #rounding_precision = decimal.Decimal('0.01') #x_dec = decimal.Decimal(p_atpos[atom_position][0]) #y_dec = decimal.Decimal(p_atpos[atom_position][1]) #z_dec = decimal.Decimal(p_atpos[atom_position][2]) #p_atpos[atom_position][0] = float(x_dec.quantize(rounding_precision)) #p_atpos[atom_position][1] = float(y_dec.quantize(rounding_precision)) #p_atpos[atom_position][2] = float(z_dec.quantize(rounding_precision))
pbc_atoms = self.add_pbc(p_atpos[atom_position][0], p_atpos[atom_position][1], p_atpos[atom_position][2], box[0], p_rad3[atom_position], p_chrgv4[atom_position], atinf[atom_position].value) #pbc_atoms = [] new_atoms += pbc_atoms
else:
else:
round(abs(p_chrgv4[atom_position]), 3), signal)
p_chrgv4, atinf, p_iatmed, extra_atoms=new_atoms)
x = molecule.box[0] * 10 / 2 y = x z = self._site._center[2] acent = [x, y, z] else:
aname = aname[1:] resname = 'PBC' resnumb = -666 #if aID == 383: # exit()
"""Set DelPhi parameters to run a calculation of a single site tautomer"""
# Could have used empty structures # TODO: quantify time impact of this quick fix
box = molecule.box half_box_xy = self._site.getCenter()[0] site_center = self._site.getCenterOriginal()
offset_x = half_box_xy - site_center[0] offset_y = half_box_xy - site_center[1] offset_z = box[2] * 10
box_x = box[0] * 10 box_y = box[1] * 10
#print (site_atom_position, atom_id, atom_position, # atom_name, molecule.p_atpos[atom_position][:]) # quick fix, should be done only once per site # TODO: fix ^ p_atpos[site_atom_position][0] += offset_x p_atpos[site_atom_position][1] += offset_y p_atpos[site_atom_position][2] += offset_z
if p_atpos[atom_position][0] < 0: p_atpos[atom_position][0] += box_x elif p_atpos[atom_position][0] >= box_x: p_atpos[atom_position][0] -= box_x
if p_atpos[atom_position][1] < 0: p_atpos[atom_position][1] += box_y elif p_atpos[atom_position][1] >= box_y: p_atpos[atom_position][1] -= box_y
x = molecule.box[0] * 10 / 2 y = x z = self._site._center[2] acent = [x, y, z] else:
box = box * 10 x_new = x y_new = y z_new = z inf = '-' + inf[1:] charge = 0.0 cutoff_x = config.params['slice'] * box cutoff_y = config.params['slice'] * box new_atoms = [] if (x < cutoff_x): x_new = box + x new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) if (y < cutoff_y): y_new = box + y new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) elif (y > box - cutoff_y): y_new = y - box new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) elif (x > box - cutoff_y): x_new = x - box new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) if (y < cutoff_y): y_new = box + y new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) elif (y > box - cutoff_y): y_new = y - box new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) x_new = x if (y < cutoff_y): y_new = box + y new_atoms.append((x_new, y_new, z_new, radius, charge, inf)) elif (y > box - cutoff_y): y_new = y - box new_atoms.append((x_new, y_new, z_new, radius, charge, inf))
return new_atoms
# Get Methods
# Print Methods out = self._name + '\n' for i in self._charge_set.keys(): out += '{0:>7.3f} {1}\n'.format(self._charge_set[i], i) return out
# Assertion Methods else:
# Calculation Methods """Run DelPhi simulation of single site tautomer
Ensures: self._esolvation (float): tautomer solvation energy self._p_sitpot (list): potential on site atoms """ t0 = time.clock() print self._name print self._charge_set
#if self._site._res_number == 770: # exit()
self._site._res_number) #print 'started', self._name, self._site._res_number, 'modelcompound' nonit=0, nlit=500, relpar=0, relfac=0, acent=acent, pbx=False, pby=False, debug=config.debug, filename=filename, outputfile=logfile) #print 'ended', self._name, self._site._res_number, 'modelcompound'
t1 = time.clock() - t0 filename = '{0}_{1}.profl'.format(self._name, self.getSiteResNumber()) with open(filename, 'a') as f_new: f_new.write('time -> {0:10} {1:10}\n'.format(t0, t1))
"""Run DelPhi simulation of the site tautomer within the whole molecule
Ensures: self._esolvation (float): tautomer solvation energy self._p_sitpot (list): potential on site atoms """ start = time.clock()
t0 = time.clock() - start
print self._name, 'starting' p_atpos = delphimol.get_atpos() p_rad3 = delphimol.get_rad3() p_chrgv4 = delphimol.get_chrgv4() atinf = delphimol.get_atinf() #for atom_name, atom_id, atom_position in molecule.iterAtoms(): # print (atinf[atom_position].value, p_chrgv4[atom_position], p_rad3[atom_position], # p_atpos[atom_position][0], p_atpos[atom_position][1], p_atpos[atom_position][2])
self._site._res_number)
#print 'started', self._name, self._site._res_number, 'wholeprotein' delphimol.runDelPhi(scale_prefocus=config.params['scaleP'], scale=config.params['scaleM'], nlit_prefocus=config.params['nlit'], nonit=config.params['nonit'], nlit=500, acent=acent, nonit_focus=0, relfac_focus=0.0, relpar_focus=0.0, relpar=config.params['relpar'], relfac=config.params['relfac'], pbx=True, pby=True, pbx_focus=False, pby_focus=False, debug=config.debug, filename=filename, outputfile=logfile) else: scale=config.params['scaleM'], nlit_prefocus=config.params['nlit'], nonit=0, nlit=500, acent=acent, nonit_focus=0, relfac_focus=0.0, relpar_focus=0.0, relpar=config.params['relpar'], relfac=config.params['relfac'], pbx=False, pby=False, pbx_focus=False, pby_focus=False, debug=config.debug, filename=filename, outputfile=logfile)
#print 'ended', self._name, self._site._res_number, 'wholeprotein'
with open('{0}_{1}.frc'.format(self._name, self._site._res_number), 'w') as f: text = '' for atom_name, atom_id, atom_position in molecule.iterAtoms(): text += '{0} {1} {2} '\ '{3} {4} {5} {6}\n'.format(atinf[atom_position].value, round(p_chrgv4[atom_position], 3), round(p_rad3[atom_position], 4), round(p_atpos[atom_position][0], 3), round(p_atpos[atom_position][1], 3), round(p_atpos[atom_position][2], 3), self._p_sitpot[atom_position]) f.write(text)
t1 = time.clock() - start filename = '{0}_{1}.profl'.format(self._name, self.getSiteResNumber()) with open(filename, 'a') as f_new: f_new.write('time -> {0:10} {1:10}\n'.format(t0, t1))
print self._esolvation, self._name
"""Calculates background energy contribution""" print self._name, 'background energy start' point_energy = round(molecule.p_chrgv4[atom_position], 3) * round(self._sitpotM[atom_position], 4) text += '{} {} {} '\ '{} {} {} {} {}\n'.format(atom_name, atom_id, point_energy, molecule.p_chrgv4[atom_position], self._sitpotM[atom_position], molecule.p_atpos[atom_position][:], distance, cutoff2)
with open('{0}_{1}_eback.xvg'.format(self._name, self._site._res_number), 'w') as f_new: text += str(self._e_back / config.log10) f_new.write(text)
print 'e_back finished'
"""Calculates the pKint of the tautomer"""
else: raise Exception('Site files were poorly interpreted')
print 'pKint ->', self._name, pKint, dg
"""Calculates the interaction energy between self tautomer and tautomer2
Args: tautomer2 (Tautomer) site_atom_list (list): atom numbers belonging to the site iterAtomsList (list): details on the titrating molecule atoms """
#print center, atom_position[:], box #print dx, dy, dz, dx ** 2 + dy ** 2 + dz ** 2 #exit()
|