Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output performed with loggers. Adds options --no-print. #12

Merged
merged 2 commits into from Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions Tests/pdb/1HPX-warn.pdb
@@ -0,0 +1,18 @@
ATOM 1 N PRO A 1 12.435 14.677 30.369 1.00 35.93 N
ATOM 2 CA PRO A 1 11.739 15.379 29.269 1.00 34.94 C
ATOM 2 CA PRO A 1 11.739 15.379 29.269 1.00 34.94 C
ATOM 3 C PRO A 1 10.309 14.853 29.143 1.00 32.24 C
ATOM 4 O PRO A 1 10.035 13.743 29.578 1.00 32.11 O
ATOM 5 CB PRO A 1 12.566 15.121 27.988 1.00 34.34 C
ATOM 6 CG PRO A 1 13.973 14.970 28.518 1.00 35.36 C
ATOM 7 CD PRO A 1 13.768 14.261 29.859 1.00 35.14 C
ATOM 8 N GLN A 2 9.436 15.666 28.552 1.00 29.85 N
ATOM 9 CA GLN A 2 8.117 15.184 28.193 1.00 29.27 C
ATOM 10 C GLN A 2 7.939 15.392 26.711 1.00 28.61 C
ATOM 11 O GLN A 2 8.147 16.506 26.246 1.00 31.02 O
ATOM 12 CB GLN A 2 7.108 15.981 28.932 1.00 28.24 C
ATOM 13 CG GLN A 2 5.789 15.599 28.365 1.00 32.41 C
ATOM 14 CD GLN A 2 4.735 16.247 29.153 1.00 37.59 C
ATOM 15 OE1 GLN A 2 4.403 15.796 30.243 1.00 39.05 O
ATOM 16 NE2 GLN A 2 4.210 17.303 28.540 1.00 39.28 N
END
2,327 changes: 2,327 additions & 0 deletions Tests/pdb/3SGB-subset.pdb

Large diffs are not rendered by default.

2,327 changes: 2,327 additions & 0 deletions Tests/pdb/3SGB.pdb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Tests/results/1HPX-warn.dat
@@ -0,0 +1 @@
7.95
2 changes: 2 additions & 0 deletions Tests/results/3SGB-subset.dat
@@ -0,0 +1,2 @@
3.51
12.80
57 changes: 57 additions & 0 deletions Tests/results/3SGB.dat
@@ -0,0 +1,57 @@
3.21
4.29
3.47
3.85
4.22
4.59
3.55
2.61
4.48
5.27
4.26
5.11
4.60
3.63
3.24
8.04
6.15
7.14
99.99
99.99
99.99
99.99
99.99
99.99
99.99
99.99
99.99
99.99
10.27
10.00
10.33
10.82
13.96
13.90
10.28
10.96
12.23
12.62
10.25
10.52
12.31
9.50
10.92
10.35
10.44
10.67
11.74
12.84
11.95
12.36
11.05
12.89
12.19
12.17
12.16
7.38
7.56
1 change: 1 addition & 0 deletions Tests/runtest.py
Expand Up @@ -17,6 +17,7 @@
('4DFR', []),
('3SGB', []),
('3SGB-subset', ['--titrate_only', 'E:17,E:18,E:19,E:29,E:44,E:45,E:46,E:118,E:119,E:120,E:139']),
('1HPX-warn', ['--quiet']),
]

for pdb, args in pdbs:
Expand Down
29 changes: 15 additions & 14 deletions propka/bonds.py
Expand Up @@ -5,6 +5,7 @@
import pickle,sys,os,math,propka.calculations

import pkg_resources
from propka.lib import info, warning

class bondmaker:
def __init__(self):
Expand Down Expand Up @@ -111,14 +112,14 @@ def find_bonds_for_protein(self, protein):
""" Finds bonds proteins based on the way atoms
normally bond in proteins"""

print('++++ Side chains ++++')
info('++++ Side chains ++++')
# side chains
for chain in protein.chains:
for residue in chain.residues:
if residue.resName.replace(' ','') not in ['N+','C-']:
self.find_bonds_for_side_chain(residue.atoms)

print('++++ Backbones ++++')
info('++++ Backbones ++++')
# backbone
last_residues = []
for chain in protein.chains:
Expand All @@ -128,12 +129,12 @@ def find_bonds_for_protein(self, protein):
self.connect_backbone(chain.residues[i-1], chain.residues[i])
last_residues.append(chain.residues[i])

print('++++ terminal oxygen ++++')
info('++++ terminal oxygen ++++')
# terminal OXT
for last_residue in last_residues:
self.find_bonds_for_terminal_oxygen(last_residue)

print('++++ cysteines ++++')
info('++++ cysteines ++++')
# Cysteines
for chain in protein.chains:
for i in range(0,len(chain.residues)):
Expand Down Expand Up @@ -349,9 +350,9 @@ def find_bonds_for_atoms_using_boxes(self, atoms):
ylen = ymax-ymin
zlen = zmax-zmin

#print('x range: [%6.2f;%6.2f] %6.2f'%(xmin,xmax,xlen))
#print('y range: [%6.2f;%6.2f] %6.2f'%(ymin,ymax,ylen))
#print('z range: [%6.2f;%6.2f] %6.2f'%(zmin,zmax,zlen))
#info('x range: [%6.2f;%6.2f] %6.2f'%(xmin,xmax,xlen))
#info('y range: [%6.2f;%6.2f] %6.2f'%(ymin,ymax,ylen))
#info('z range: [%6.2f;%6.2f] %6.2f'%(zmin,zmax,zlen))

# how many boxes do we need in each dimension?
# NOTE: math.ceil() returns an int in python3 and a float in
Expand All @@ -361,9 +362,9 @@ def find_bonds_for_atoms_using_boxes(self, atoms):
self.no_box_y = max(1, int(math.ceil(ylen/box_size)))
self.no_box_z = max(1, int(math.ceil(zlen/box_size)))

#print('No. box x: %6.2f'%self.no_box_x)
#print('No. box y: %6.2f'%self.no_box_y)
#print('No. box z: %6.2f'%self.no_box_z)
#info('No. box x: %6.2f'%self.no_box_x)
#info('No. box y: %6.2f'%self.no_box_y)
#info('No. box z: %6.2f'%self.no_box_z)

# initialize boxes
self.boxes = {}
Expand Down Expand Up @@ -400,7 +401,7 @@ def put_atom_in_box(self,x,y,z,atom):
# No box exists for this coordinate
pass

#print(atom,'->',key,':',len(self.boxes[key]))
#info(atom,'->',key,':',len(self.boxes[key]))

return

Expand All @@ -415,7 +416,7 @@ def make_bond(self, atom1, atom2):
if atom1 == atom2:
return

#print('making bond for',atom1,atom2)
#info('making bond for',atom1,atom2)
if not atom1 in atom2.bonded_atoms:
atom2.bonded_atoms.append(atom1)

Expand Down Expand Up @@ -465,12 +466,12 @@ def generate_protein_bond_dictionary(self, atoms):
import protein, pdb, sys,os
arguments = sys.argv
if len(arguments) != 2:
print('Usage: bonds.py <pdb_file>')
info('Usage: bonds.py <pdb_file>')
sys.exit(0)

filename = arguments[1]
if not os.path.isfile(filename):
print('Error: Could not find \"%s\"'%filename)
info('Error: Could not find \"%s\"' % filename)
sys.exit(1)

pdblist = pdb.readPDB(filename)
Expand Down
33 changes: 17 additions & 16 deletions propka/calculations.py
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function

import math, propka.protonate, propka.bonds,copy, sys
from propka.lib import info, warning


#
Expand Down Expand Up @@ -60,7 +61,7 @@ def setup_bonding_and_protonation_30_style(parameters, molecular_container):

def protonate_30_style(molecular_container):
for name in molecular_container.conformation_names:
print('Now protonating',name)
info('Now protonating', name)
# split atom into residues
curres = -1000000
residue = []
Expand Down Expand Up @@ -96,7 +97,7 @@ def addArgHydrogen(residue):
"""
Adds Arg hydrogen atoms to residues according to the 'old way'.
"""
#print('Adding arg H',residue)
#info('Adding arg H',residue)
for atom in residue:
if atom.name == "CD":
CD = atom
Expand Down Expand Up @@ -159,7 +160,7 @@ def addTrpHydrogen(residue):
CE = atom
if CD == None or NE == None or CE == None:
str = "Did not find all atoms in %s%4d - in %s" % (self.resName, self.resNumb, "addTrpHydrogen()")
print(str)
info(str)
sys.exit(0)

HE = protonateSP2([CD, NE, CE])
Expand All @@ -184,7 +185,7 @@ def addAmdHydrogen(residue):

if C == None or O == None or N == None:
str = "Did not find N, C and/or O in %s%4d - in %s" % (atom.resName, atom.resNumb, "addAmdHydrogen()")
print(str)
info(str)
sys.exit(0)

H1 = protonateDirection([N, O, C])
Expand Down Expand Up @@ -387,7 +388,7 @@ def radial_volume_desolvation(parameters, group):



#print('%s %5.2f %5.2f %4d'%(group, group.buried, group.Emass, group.Nmass))
#info('%s %5.2f %5.2f %4d'%(group, group.buried, group.Emass, group.Nmass))
return


Expand Down Expand Up @@ -573,7 +574,7 @@ def hydrogen_bond_interaction(group1, group2, version):
[closest_atom1, distance, closest_atom2] = propka.calculations.get_smallest_distance(atoms1, atoms2)

if None in [closest_atom1, closest_atom2]:
print('Warning: Side chain interaction failed for %s and %s'%(group1.label, group2.label))
warning('Side chain interaction failed for %s and %s' % (group1.label, group2.label))
return None

# get the parameters
Expand Down Expand Up @@ -627,17 +628,17 @@ def hydrogen_bond_interaction(group1, group2, version):
#exception = False # circumventing exception
if exception == True:
""" do nothing, value should have been assigned """
#print(" exception for %s %s %6.2lf" % (group1.label, group2.label, value))
#info(" exception for %s %s %6.2lf" % (group1.label, group2.label, value))
else:
value = version.calculateSideChainEnergy(distance, dpka_max, cutoff, weight, f_angle)

# print('distance',distance)
# print('dpka_max',dpka_max)
# print('cutoff',cutoff)
# print('f_angle',f_angle)
# print('weight',weight)
# print('value',value)
# print('===============================================')
# info('distance',distance)
# info('dpka_max',dpka_max)
# info('cutoff',cutoff)
# info('f_angle',f_angle)
# info('weight',weight)
# info('value',value)
# info('===============================================')

return value

Expand Down Expand Up @@ -786,7 +787,7 @@ def checkCooArgException(group_coo, group_arg, version):
#cutoff = parameters.sidechain_cutoffs.get_value(group_coo.type,group_arg.type)

# needs to be this way since you want to find shortest distance first
#print("--- exception for %s %s ---" % (group_coo.label, group_arg.label))
#info("--- exception for %s %s ---" % (group_coo.label, group_arg.label))
atoms_coo = []
atoms_coo.extend(group_coo.get_interaction_atoms(group_arg))
atoms_arg = []
Expand All @@ -804,7 +805,7 @@ def checkCooArgException(group_coo, group_arg, version):
distance, f_angle, nada = AngleFactorX(closest_coo_atom, closest_arg_atom, atom3)

value = HydrogenBondEnergy(distance, dpka_max, cutoff, f_angle)
#print(iter, closest_coo_atom, closest_arg_atom,distance,value)
#info(iter, closest_coo_atom, closest_arg_atom,distance,value)
value_tot += value
# remove closest atoms before we attemp to find the runner-up pair
atoms_coo.remove(closest_coo_atom)
Expand Down
15 changes: 8 additions & 7 deletions propka/conformation_container.py
Expand Up @@ -6,6 +6,7 @@
from __future__ import print_function

import propka.group, propka.determinants, propka.determinant, propka.ligand, propka.output, propka.coupled_groups, functools
from propka.lib import info, warning

class Conformation_container:
def __init__(self, name='', parameters=None, molecular_container=None):
Expand Down Expand Up @@ -50,7 +51,7 @@ def additional_setup_when_reading_input_file(self):
map = propka.output.make_interaction_map('Covalent coupling map for %s'%self,
self.get_covalently_coupled_groups(),
lambda g1,g2: g1 in g2.covalently_coupled_groups)
print(map)
info(map)

# check if we should set a common charge centre as well
if self.parameters.common_charge_centre:
Expand Down Expand Up @@ -96,7 +97,7 @@ def find_covalently_coupled_groups(self):
#self.get_titratable_groups(),
self.get_covalently_coupled_groups(),
lambda g1,g2: g1 in g2.covalently_coupled_groups)
print(map)
info(map)


return
Expand Down Expand Up @@ -168,7 +169,7 @@ def init_group(self, group):
#

def calculate_pka(self, version, options):
print('\nCalculating pKas for',self)
info('\nCalculating pKas for', self)

# calculate desolvation
for group in self.get_titratable_groups()+self.get_ions():
Expand All @@ -193,7 +194,7 @@ def calculate_pka(self, version, options):
penalised_labels = self.coupling_effects()

if self.parameters.remove_penalised_group and len(penalised_labels)>0:
print('Removing penalised groups!!!')
info('Removing penalised groups!!!')

for g in self.get_titratable_groups():
g.remove_determinants(penalised_labels)
Expand Down Expand Up @@ -297,7 +298,7 @@ def get_a_coupled_system_of_groups(self, new_group, coupled_groups, get_coupled_
def calculate_folding_energy(self, pH=None, reference=None):
ddg = 0.0
for group in self.groups:
#print('Folding energy for %s at pH %f: %f'%(group,pH,group.calculate_folding_energy(self.parameters, pH=pH, reference=reference)))
#info('Folding energy for %s at pH %f: %f'%(group,pH,group.calculate_folding_energy(self.parameters, pH=pH, reference=reference)))
ddg += group.calculate_folding_energy(self.parameters, pH=pH, reference=reference)

return ddg
Expand Down Expand Up @@ -379,7 +380,7 @@ def get_chain(self,chain):


def add_atom(self, atom):
#print(self,'adding',atom)
#info(self,'adding',atom)
self.atoms.append(atom)
if not atom.conformation_container:
atom.conformation_container = self
Expand Down Expand Up @@ -446,5 +447,5 @@ def sort_atoms_key(self, atom):
key += atom.resNumb*1000
if len(atom.name) > len(atom.element):
key += ord(atom.name[len(atom.element)])
#print(atom,ord(atom.name[len(atom.element)]), '|%s||%s|'%(atom.name,atom.element))
#info(atom,ord(atom.name[len(atom.element)]), '|%s||%s|'%(atom.name,atom.element))
return key