Clean up line breaks.
See https://github.com/jensengroup/propka-3.1/issues/43.
This commit is contained in:
@@ -57,7 +57,8 @@ class ConformationContainer:
|
|||||||
"""Generate interaction map and charge centers."""
|
"""Generate interaction map and charge centers."""
|
||||||
# if a group is coupled and we are reading a .propka_input file, then
|
# if a group is coupled and we are reading a .propka_input file, then
|
||||||
# some more configuration might be needed
|
# some more configuration might be needed
|
||||||
map_ = make_interaction_map('Covalent coupling map for %s' % self,
|
map_ = make_interaction_map(
|
||||||
|
'Covalent coupling map for %s' % self,
|
||||||
self.get_covalently_coupled_groups(),
|
self.get_covalently_coupled_groups(),
|
||||||
lambda g1, g2: g1 in g2.covalently_coupled_groups)
|
lambda g1, g2: g1 in g2.covalently_coupled_groups)
|
||||||
info(map_)
|
info(map_)
|
||||||
@@ -67,13 +68,14 @@ class ConformationContainer:
|
|||||||
|
|
||||||
def set_common_charge_centres(self):
|
def set_common_charge_centres(self):
|
||||||
"""Assign charge centers to groups."""
|
"""Assign charge centers to groups."""
|
||||||
for system in self.get_coupled_systems(self.get_covalently_coupled_groups(),
|
for system in self.get_coupled_systems(
|
||||||
|
self.get_covalently_coupled_groups(),
|
||||||
Group.get_covalently_coupled_groups):
|
Group.get_covalently_coupled_groups):
|
||||||
# make a list of the charge centre coordinates
|
# make a list of the charge centre coordinates
|
||||||
all_coordinates = list(map(lambda g: [g.x, g.y, g.z], system))
|
all_coordinates = list(map(lambda g: [g.x, g.y, g.z], system))
|
||||||
# find the common charge center
|
# find the common charge center
|
||||||
ccc = functools.reduce(lambda g1, g2: [g1[0]+g2[0], g1[1]+g2[1],
|
ccc = functools.reduce(
|
||||||
g1[2]+g2[2]],
|
lambda g1, g2: [g1[0]+g2[0], g1[1]+g2[1], g1[2]+g2[2]],
|
||||||
all_coordinates)
|
all_coordinates)
|
||||||
ccc = list(map(lambda c: c/len(system), ccc))
|
ccc = list(map(lambda c: c/len(system), ccc))
|
||||||
# set the ccc for all coupled groups in this system
|
# set the ccc for all coupled groups in this system
|
||||||
@@ -85,8 +87,8 @@ class ConformationContainer:
|
|||||||
"""Find covalently coupled groups and set common charge centres."""
|
"""Find covalently coupled groups and set common charge centres."""
|
||||||
for group in self.get_titratable_groups():
|
for group in self.get_titratable_groups():
|
||||||
# Find covalently bonded groups
|
# Find covalently bonded groups
|
||||||
bonded_groups = self.find_bonded_titratable_groups(group.atom, 1,
|
bonded_groups = self.find_bonded_titratable_groups(
|
||||||
group.atom)
|
group.atom, 1, group.atom)
|
||||||
# coupled groups
|
# coupled groups
|
||||||
for bond_group in bonded_groups:
|
for bond_group in bonded_groups:
|
||||||
if bond_group in group.covalently_coupled_groups:
|
if bond_group in group.covalently_coupled_groups:
|
||||||
@@ -97,7 +99,8 @@ class ConformationContainer:
|
|||||||
if self.parameters.common_charge_centre:
|
if self.parameters.common_charge_centre:
|
||||||
self.set_common_charge_centres()
|
self.set_common_charge_centres()
|
||||||
# print coupling map
|
# print coupling map
|
||||||
map_ = make_interaction_map('Covalent coupling map for %s' % self,
|
map_ = make_interaction_map(
|
||||||
|
'Covalent coupling map for %s' % self,
|
||||||
self.get_covalently_coupled_groups(),
|
self.get_covalently_coupled_groups(),
|
||||||
lambda g1, g2: g1 in g2.covalently_coupled_groups)
|
lambda g1, g2: g1 in g2.covalently_coupled_groups)
|
||||||
info(map_)
|
info(map_)
|
||||||
@@ -134,14 +137,14 @@ class ConformationContainer:
|
|||||||
if bond_atom == original_atom:
|
if bond_atom == original_atom:
|
||||||
continue
|
continue
|
||||||
# check if this atom has a titratable group
|
# check if this atom has a titratable group
|
||||||
if bond_atom.group and bond_atom.group.titratable \
|
if (bond_atom.group and bond_atom.group.titratable
|
||||||
and num_bonds <= self.parameters.coupling_max_number_of_bonds:
|
and num_bonds
|
||||||
|
<= self.parameters.coupling_max_number_of_bonds):
|
||||||
res.add(bond_atom.group)
|
res.add(bond_atom.group)
|
||||||
# check for titratable groups bonded to this atom
|
# check for titratable groups bonded to this atom
|
||||||
if num_bonds < self.parameters.coupling_max_number_of_bonds:
|
if num_bonds < self.parameters.coupling_max_number_of_bonds:
|
||||||
res |= self.find_bonded_titratable_groups(bond_atom,
|
res |= self.find_bonded_titratable_groups(
|
||||||
num_bonds+1,
|
bond_atom, num_bonds+1, original_atom)
|
||||||
original_atom)
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def setup_and_add_group(self, group):
|
def setup_and_add_group(self, group):
|
||||||
@@ -190,22 +193,23 @@ class ConformationContainer:
|
|||||||
for group in self.get_titratable_groups() + self.get_ions():
|
for group in self.get_titratable_groups() + self.get_ions():
|
||||||
version.calculate_desolvation(group)
|
version.calculate_desolvation(group)
|
||||||
# calculate backbone interactions
|
# calculate backbone interactions
|
||||||
set_backbone_determinants(self.get_titratable_groups(),
|
set_backbone_determinants(
|
||||||
self.get_backbone_groups(), version)
|
self.get_titratable_groups(), self.get_backbone_groups(), version)
|
||||||
# setting ion determinants
|
# setting ion determinants
|
||||||
set_ion_determinants(self, version)
|
set_ion_determinants(self, version)
|
||||||
# calculating the back-bone reorganization/desolvation term
|
# calculating the back-bone reorganization/desolvation term
|
||||||
version.calculate_backbone_reorganization(self)
|
version.calculate_backbone_reorganization(self)
|
||||||
# setting remaining non-iterative and iterative side-chain & Coulomb
|
# setting remaining non-iterative and iterative side-chain & Coulomb
|
||||||
# interaction determinants
|
# interaction determinants
|
||||||
set_determinants(self.get_sidechain_groups(), version=version,
|
set_determinants(
|
||||||
options=options)
|
self.get_sidechain_groups(), version=version, options=options)
|
||||||
# calculating the total pKa values
|
# calculating the total pKa values
|
||||||
for group in self.groups:
|
for group in self.groups:
|
||||||
group.calculate_total_pka()
|
group.calculate_total_pka()
|
||||||
# take coupling effects into account
|
# take coupling effects into account
|
||||||
penalised_labels = self.coupling_effects()
|
penalised_labels = self.coupling_effects()
|
||||||
if self.parameters.remove_penalised_group and len(penalised_labels) > 0:
|
if (self.parameters.remove_penalised_group
|
||||||
|
and len(penalised_labels) > 0):
|
||||||
info('Removing penalised groups!!!')
|
info('Removing penalised groups!!!')
|
||||||
for group in self.get_titratable_groups():
|
for group in self.get_titratable_groups():
|
||||||
group.remove_determinants(penalised_labels)
|
group.remove_determinants(penalised_labels)
|
||||||
@@ -227,7 +231,8 @@ class ConformationContainer:
|
|||||||
titrate.
|
titrate.
|
||||||
"""
|
"""
|
||||||
penalised_labels = []
|
penalised_labels = []
|
||||||
for all_groups in self.get_coupled_systems(self.get_covalently_coupled_groups(),
|
for all_groups in self.get_coupled_systems(
|
||||||
|
self.get_covalently_coupled_groups(),
|
||||||
Group.get_covalently_coupled_groups):
|
Group.get_covalently_coupled_groups):
|
||||||
# check if we should share determinants
|
# check if we should share determinants
|
||||||
if self.parameters.shared_determinants:
|
if self.parameters.shared_determinants:
|
||||||
@@ -236,15 +241,19 @@ class ConformationContainer:
|
|||||||
first_group = max(all_groups, key=lambda g: g.pka_value)
|
first_group = max(all_groups, key=lambda g: g.pka_value)
|
||||||
# In case of acids
|
# In case of acids
|
||||||
if first_group.charge < 0:
|
if first_group.charge < 0:
|
||||||
first_group.coupled_titrating_group = min(all_groups, key=lambda g: g.pka_value)
|
first_group.coupled_titrating_group = min(
|
||||||
penalised_labels.append(first_group.label) # group with the highest pKa is penalised
|
all_groups, key=lambda g: g.pka_value)
|
||||||
|
# group with the highest pKa is penalised
|
||||||
|
penalised_labels.append(first_group.label)
|
||||||
# In case of bases
|
# In case of bases
|
||||||
else:
|
else:
|
||||||
for group in all_groups:
|
for group in all_groups:
|
||||||
if group == first_group:
|
if group == first_group:
|
||||||
continue # group with the highest pKa is allowed to titrate...
|
# group with the highest pKa is allowed to titrate...
|
||||||
|
continue
|
||||||
group.coupled_titrating_group = first_group
|
group.coupled_titrating_group = first_group
|
||||||
penalised_labels.append(group.label) #... and the rest is penalised
|
#... and the rest are penalised
|
||||||
|
penalised_labels.append(group.label)
|
||||||
return penalised_labels
|
return penalised_labels
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -287,7 +296,8 @@ class ConformationContainer:
|
|||||||
while len(groups) > 0:
|
while len(groups) > 0:
|
||||||
# extract a system of coupled groups ...
|
# extract a system of coupled groups ...
|
||||||
system = set()
|
system = set()
|
||||||
self.get_a_coupled_system_of_groups(groups.pop(), system, get_coupled_groups)
|
self.get_a_coupled_system_of_groups(
|
||||||
|
groups.pop(), system, get_coupled_groups)
|
||||||
# ... and remove them from the list
|
# ... and remove them from the list
|
||||||
groups -= system
|
groups -= system
|
||||||
yield system
|
yield system
|
||||||
@@ -356,7 +366,8 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [group for group in self.groups \
|
return [
|
||||||
|
group for group in self.groups
|
||||||
if ('BB' not in group.type and not group.atom.cysteine_bridge)]
|
if ('BB' not in group.type and not group.atom.cysteine_bridge)]
|
||||||
|
|
||||||
def get_covalently_coupled_groups(self):
|
def get_covalently_coupled_groups(self):
|
||||||
@@ -365,7 +376,8 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [g for g in self.groups \
|
return [
|
||||||
|
g for g in self.groups
|
||||||
if len(g.covalently_coupled_groups) > 0]
|
if len(g.covalently_coupled_groups) > 0]
|
||||||
|
|
||||||
def get_non_covalently_coupled_groups(self):
|
def get_non_covalently_coupled_groups(self):
|
||||||
@@ -374,7 +386,8 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [g for g in self.groups \
|
return [
|
||||||
|
g for g in self.groups
|
||||||
if len(g.non_covalently_coupled_groups) > 0]
|
if len(g.non_covalently_coupled_groups) > 0]
|
||||||
|
|
||||||
def get_backbone_nh_groups(self):
|
def get_backbone_nh_groups(self):
|
||||||
@@ -401,7 +414,8 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [group for group in self.groups if group.residue_type == residue]
|
return [
|
||||||
|
group for group in self.groups if group.residue_type == residue]
|
||||||
|
|
||||||
def get_titratable_groups(self):
|
def get_titratable_groups(self):
|
||||||
"""Get all titratable groups needed for pKa calculations.
|
"""Get all titratable groups needed for pKa calculations.
|
||||||
@@ -429,8 +443,9 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [group for group in self.groups \
|
return [
|
||||||
if (group.residue_type in self.parameters.acid_list \
|
group for group in self.groups
|
||||||
|
if (group.residue_type in self.parameters.acid_list
|
||||||
and not group.atom.cysteine_bridge)]
|
and not group.atom.cysteine_bridge)]
|
||||||
|
|
||||||
def get_backbone_reorganisation_groups(self):
|
def get_backbone_reorganisation_groups(self):
|
||||||
@@ -439,8 +454,10 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [group for group in self.groups \
|
return [
|
||||||
if (group.residue_type in self.parameters.backbone_reorganisation_list \
|
group for group in self.groups
|
||||||
|
if (group.residue_type
|
||||||
|
in self.parameters.backbone_reorganisation_list
|
||||||
and not group.atom.cysteine_bridge)]
|
and not group.atom.cysteine_bridge)]
|
||||||
|
|
||||||
def get_ions(self):
|
def get_ions(self):
|
||||||
@@ -449,7 +466,8 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of groups
|
list of groups
|
||||||
"""
|
"""
|
||||||
return [group for group in self.groups \
|
return [
|
||||||
|
group for group in self.groups
|
||||||
if group.residue_type in self.parameters.ions.keys()]
|
if group.residue_type in self.parameters.ions.keys()]
|
||||||
|
|
||||||
def get_group_names(self, group_list):
|
def get_group_names(self, group_list):
|
||||||
@@ -476,7 +494,8 @@ class ConformationContainer:
|
|||||||
Returns:
|
Returns:
|
||||||
list of atoms
|
list of atoms
|
||||||
"""
|
"""
|
||||||
return [atom for atom in self.atoms \
|
return [
|
||||||
|
atom for atom in self.atoms
|
||||||
if atom.type == 'hetatm' and atom.element != 'H']
|
if atom.type == 'hetatm' and atom.element != 'H']
|
||||||
|
|
||||||
def get_chain(self, chain):
|
def get_chain(self, chain):
|
||||||
@@ -556,9 +575,9 @@ class ConformationContainer:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""String that lists statistics of atoms and groups."""
|
"""String that lists statistics of atoms and groups."""
|
||||||
str_ = 'Conformation container %s with %d atoms and %d groups' % (self.name,
|
str_ = (
|
||||||
len(self),
|
'Conformation container %s with %d atoms and %d groups'
|
||||||
len(self.groups))
|
% (self.name, len(self), len(self.groups)))
|
||||||
return str_
|
return str_
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user