Clean up line breaks in ligand.py

See https://github.com/jensengroup/propka-3.1/issues/43
This commit is contained in:
Nathan Baker
2020-05-25 19:33:07 -07:00
parent 72851b5498
commit 2658f80906

View File

@@ -123,20 +123,22 @@ def assign_sybyl_type(atom):
n_atom = nitrogens[0] n_atom = nitrogens[0]
o_atom = oxygens[0] o_atom = oxygens[0]
if c_atom and n_atom and o_atom: if c_atom and n_atom and o_atom:
# make sure that the Nitrogen is not aromatic and that it has two heavy atom bonds # make sure that the Nitrogen is not aromatic and that it has two
if not is_aromatic_ring(is_ring_member(n_atom)) \ # heavy atom bonds
and len(n_atom.get_bonded_heavy_atoms()) == 2: if (not is_aromatic_ring(is_ring_member(n_atom))
and len(n_atom.get_bonded_heavy_atoms()) == 2):
set_type(n_atom, 'N.am') set_type(n_atom, 'N.am')
set_type(c_atom, 'C.2') set_type(c_atom, 'C.2')
set_type(o_atom, 'O.2') set_type(o_atom, 'O.2')
return return
if atom.element == 'C': if atom.element == 'C':
# check for carboxyl # check for carboxyl
if len(atom.bonded_atoms) == 3 and list(bonded_elements.values()).count('O') == 2: if (len(atom.bonded_atoms) == 3
and list(bonded_elements.values()).count('O') == 2):
index1 = list(bonded_elements.values()).index('O') index1 = list(bonded_elements.values()).index('O')
index2 = list(bonded_elements.values()).index('O', index1+1) index2 = list(bonded_elements.values()).index('O', index1+1)
if len(atom.bonded_atoms[index1].bonded_atoms) == 1 \ if (len(atom.bonded_atoms[index1].bonded_atoms) == 1
and len(atom.bonded_atoms[index2].bonded_atoms) == 1: and len(atom.bonded_atoms[index2].bonded_atoms) == 1):
set_type(atom.bonded_atoms[index1], 'O.co2-') set_type(atom.bonded_atoms[index1], 'O.co2-')
set_type(atom.bonded_atoms[index2], 'O.co2') set_type(atom.bonded_atoms[index2], 'O.co2')
set_type(atom, 'C.2') set_type(atom, 'C.2')
@@ -144,7 +146,8 @@ def assign_sybyl_type(atom):
# sp carbon # sp carbon
if len(atom.bonded_atoms) <= 2: if len(atom.bonded_atoms) <= 2:
for bonded_atom in atom.bonded_atoms: for bonded_atom in atom.bonded_atoms:
if squared_distance(atom, bonded_atom) < MAX_C_TRIPLE_BOND_SQUARED: if (squared_distance(atom, bonded_atom)
< MAX_C_TRIPLE_BOND_SQUARED):
set_type(atom, 'C.1') set_type(atom, 'C.1')
set_type(bonded_atom, bonded_atom.element + '.1') set_type(bonded_atom, bonded_atom.element + '.1')
if atom.sybyl_assigned: if atom.sybyl_assigned:
@@ -155,8 +158,8 @@ def assign_sybyl_type(atom):
# check for N.pl3 # check for N.pl3
for bonded_atom in atom.bonded_atoms: for bonded_atom in atom.bonded_atoms:
if bonded_atom.element == 'N': if bonded_atom.element == 'N':
if len(bonded_atom.bonded_atoms) < 3 \ if (len(bonded_atom.bonded_atoms) < 3
or is_planar(bonded_atom): or is_planar(bonded_atom)):
set_type(bonded_atom, 'N.pl3') set_type(bonded_atom, 'N.pl3')
return return
# sp3 carbon # sp3 carbon
@@ -181,16 +184,18 @@ def assign_sybyl_type(atom):
# check for carboxyl # check for carboxyl
if atom.bonded_atoms[0].element == 'C': if atom.bonded_atoms[0].element == 'C':
the_carbon = atom.bonded_atoms[0] the_carbon = atom.bonded_atoms[0]
if len(the_carbon.bonded_atoms) == 3 \ if (len(the_carbon.bonded_atoms) == 3
and the_carbon.count_bonded_elements('O') == 2: and the_carbon.count_bonded_elements('O') == 2):
[oxy1, oxy2] = the_carbon.get_bonded_elements('O') [oxy1, oxy2] = the_carbon.get_bonded_elements('O')
if len(oxy1.bonded_atoms) == 1 and len(oxy2.bonded_atoms) == 1: if (len(oxy1.bonded_atoms) == 1
and len(oxy2.bonded_atoms) == 1):
set_type(oxy1, 'O.co2-') set_type(oxy1, 'O.co2-')
set_type(oxy2, 'O.co2') set_type(oxy2, 'O.co2')
set_type(the_carbon, 'C.2') set_type(the_carbon, 'C.2')
return return
# check for X=O # check for X=O
if squared_distance(atom, atom.bonded_atoms[0]) < MAX_C_DOUBLE_BOND_SQUARED: if (squared_distance(atom, atom.bonded_atoms[0])
< MAX_C_DOUBLE_BOND_SQUARED):
set_type(atom, 'O.2') set_type(atom, 'O.2')
if atom.bonded_atoms[0].element == 'C': if atom.bonded_atoms[0].element == 'C':
set_type(atom.bonded_atoms[0], 'C.2') set_type(atom.bonded_atoms[0], 'C.2')
@@ -262,8 +267,8 @@ def identify_ring(this_atom, original_atom, number, past_atoms):
these_return_atoms = identify_ring(atom, original_atom, number, these_return_atoms = identify_ring(atom, original_atom, number,
past_atoms) past_atoms)
if len(these_return_atoms) > 0: if len(these_return_atoms) > 0:
if len(return_atoms) > len(these_return_atoms) \ if (len(return_atoms) > len(these_return_atoms)
or len(return_atoms) == 0: or len(return_atoms) == 0):
return_atoms = these_return_atoms return_atoms = these_return_atoms
return return_atoms return return_atoms