-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_electron_assignment.py
111 lines (94 loc) · 3.24 KB
/
test_electron_assignment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from sys import stderr
import unittest
from fragment_capping.helpers.types_helpers import Atom
from fragment_capping.helpers.molecule import Molecule, molecule_from_pdb_str
class Test_Capping(unittest.TestCase):
def test_carbon_dioxide(self) -> None:
with open('pdbs/carbon_dioxide.pdb') as fh:
input_molecule = molecule_from_pdb_str(
fh.read(),
name='carbon_dioxide',
)
input_molecule.assign_bond_orders_and_charges_with_ILP(
enforce_octet_rule=True,
)
input_molecule.write_graph(
'',
output_size=(400, 400),
graph_kwargs={'include_atom_index': True},
)
def test_cyano(self) -> None:
with open('pdbs/cyano.pdb') as fh:
input_molecule = molecule_from_pdb_str(
fh.read(),
name='cyano',
)
input_molecule.assign_bond_orders_and_charges_with_ILP(
enforce_octet_rule=True,
)
input_molecule.write_graph(
'',
output_size=(400, 400),
graph_kwargs={'include_atom_index': True},
)
def test_guanidinium(self) -> None:
with open('pdbs/guanidinium.pdb') as fh:
input_molecule = molecule_from_pdb_str(
fh.read(),
name='guanidinium_fail',
)
input_molecule.assign_bond_orders_and_charges_with_ILP(
enforce_octet_rule=True,
debug=stderr,
)
input_molecule.write_graph(
'',
output_size=(400, 400),
graph_kwargs={
'include_atom_index': False,
'vertex_color_scheme': 'elements',
'vertex_label_template': '{charge_str}',
},
)
def test_guanidinium_with_charge(self) -> None:
with open('pdbs/guanidinium.pdb') as fh:
input_molecule = molecule_from_pdb_str(
fh.read(),
name='guanidinium_charge',
)
input_molecule.assign_bond_orders_and_charges_with_ILP(
net_charge=+1,
enforce_octet_rule=True,
debug=stderr,
)
input_molecule.write_graph(
'',
output_size=(400, 400),
graph_kwargs={
'include_atom_index': False,
'vertex_color_scheme': 'elements',
'vertex_label_template': '{charge_str}',
},
)
def test_guanidinium_with_total_electrons(self) -> None:
with open('pdbs/guanidinium.pdb') as fh:
input_molecule = molecule_from_pdb_str(
fh.read(),
name='guanidinium_electrons',
)
input_molecule.assign_bond_orders_and_charges_with_ILP(
total_electrons=24,
enforce_octet_rule=True,
debug=stderr,
)
input_molecule.write_graph(
'',
output_size=(400, 400),
graph_kwargs={
'include_atom_index': False,
'vertex_color_scheme': 'elements',
'vertex_label_template': '{charge_str}',
},
)
if __name__ == '__main__':
unittest.main(warnings='ignore', verbosity=2)