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

Resolve cyclic import issues #50

Merged
merged 6 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 3 additions & 3 deletions propka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"""
__all__ = ["atom", "bonds", "calculations", "conformation_container",
"coupled_groups", "determinant", "determinants", "group",
"hybrid36", "iterative", "lib", "ligand_pka_values", "ligand",
"molecular_container", "output", "parameters", "pdb", "protonate",
"run", "vector_algebra", "version"]
"hybrid36", "iterative", "input", "lib", "ligand_pka_values",
"ligand", "molecular_container", "output", "parameters",
"protonate", "run", "vector_algebra", "version"]
34 changes: 13 additions & 21 deletions propka/atom.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Atom class - contains all atom information found in the PDB file"""
import string
import propka.lib
import propka.group
from propka.lib import make_tidy_atom_label
from . import hybrid36


Expand All @@ -26,7 +25,7 @@
"({r.chain_id:1s}) [{r.x:>8.3f} {r.y:>8.3f} {r.z:>8.3f}] {r.element:s}")


class Atom(object):
class Atom:
"""Atom class - contains all atom information found in the PDB file"""

def __init__(self, line=None):
Expand All @@ -50,6 +49,9 @@ def __init__(self, line=None):
self.z = None
self.group = None
self.group_type = None
self.group_label = None
self.group_model_pka = None
self.group_model_pka_set = None
self.number_of_bonded_elements = {}
self.cysteine_bridge = False
self.bonded_atoms = []
Expand Down Expand Up @@ -267,7 +269,7 @@ def make_input_line(self):
model_pka = PKA_FMT.format(self.group.model_pka)
str_ = INPUT_LINE_FMT.format(
type=self.type.upper(), r=self,
atom_label=propka.lib.make_tidy_atom_label(self.name, self.element),
atom_label=make_tidy_atom_label(self.name, self.element),
group=group, pka=model_pka)
return str_

Expand Down Expand Up @@ -313,21 +315,11 @@ def get_input_parameters(self):
self.occ = self.occ.replace('ALG', 'titratable_ligand')
self.occ = self.occ.replace('BLG', 'titratable_ligand')
self.occ = self.occ.replace('LG', 'non_titratable_ligand')
# try to initialise the group
try:
group_attr = "{0:s}_group".format(self.occ)
group_attr = getattr(propka.group, group_attr)
self.group = group_attr(self)
except:
# TODO - be more specific with expection handling here
str_ = (
'{0:s} in input_file is not recognized as a group'.format(
self.occ))
raise Exception(str_)
self.group_label = "{0:s}_group".format(self.occ)
# set the model pKa value
if self.beta != '-':
self.group.model_pka = float(self.beta)
self.group.model_pka_set = True
self.group_model_pka = float(self.beta)
self.group_model_pka_set = True
# set occ and beta to standard values
self.occ = '1.00'
self.beta = '0.00'
Expand All @@ -344,7 +336,7 @@ def make_pdb_line(self):
"""
str_ = PDB_LINE_FMT1.format(
type=self.type.upper(), r=self,
atom_label=propka.lib.make_tidy_atom_label(self.name, self.element))
atom_label=make_tidy_atom_label(self.name, self.element))
return str_

def make_mol2_line(self, id_):
Expand All @@ -359,7 +351,7 @@ def make_mol2_line(self, id_):
"""
str_ = MOL2_LINE_FMT.format(
id=id_, r=self,
atom_label=propka.lib.make_tidy_atom_label(self.name, self.element))
atom_label=make_tidy_atom_label(self.name, self.element))
return str_

def make_pdb_line2(self, numb=None, name=None, res_name=None, chain_id=None,
Expand Down Expand Up @@ -397,7 +389,7 @@ def make_pdb_line2(self, numb=None, name=None, res_name=None, chain_id=None,
str_ = PDB_LINE_FMT2.format(
numb=numb, res_name=res_name, chain_id=chain_id, res_num=res_num,
x=x, y=y, z=z, occ=occ, beta=beta,
atom_label=propka.lib.make_tidy_atom_label(name, self.element)
atom_label=make_tidy_atom_label(name, self.element)
)
return str_

Expand All @@ -408,7 +400,7 @@ def get_tidy_label(self):

Returns:
String with label"""
return propka.lib.make_tidy_atom_label(self.name, self.element)
return make_tidy_atom_label(self.name, self.element)

def __str__(self):
"""Return an undefined-format string version of this atom."""
Expand Down