@@ -55,7 +55,7 @@ def plot_3D():
5555 def plot_2D ():
5656 fig = plt .figure ()
5757 ax = fig .add_subplot (111 )
58- ax .scatter (xs , zs , alpha = 0.7 )
58+ ax .scatter (xs , zs , alpha = 0.5 , s = 5.0 )
5959 ax .set_xlabel ('Atom Number' )
6060 ax .set_ylabel ('Timing (s)' )
6161
@@ -104,6 +104,8 @@ def try_plotting_molecule(mol2_str: str) -> None:
104104 raise Exception ()
105105
106106 SAME_BOND_ORDER , DIFFERENT_BOND_ORDER , WRONG_MOL2 , SOLVER_FAILURE = 'S' , 'F' , 'F_MOL2' , 'F_SOLVER'
107+ NO_SECOND_RUN = '-'
108+ SAME_NET_CHARGE , DIFFERENT_NET_CHARGE = 'C' , 'NC'
107109 status , timings = {}, {}
108110 try :
109111 for (i , mol2_str ) in enumerate (test_mol2_str , start = 1 ):
@@ -120,23 +122,23 @@ def try_plotting_molecule(mol2_str: str) -> None:
120122 status [molecule_name (mol2_str )] = WRONG_MOL2
121123 continue
122124
123- if CONSTRAINT_TOTAL_CHARGE :
124- net_charge = int (
125- round (
126- sum (
127- float (line .split ()[8 ])
128- for line in mol2_str .splitlines ()
129- if len (line .split ()) == 9 and match ('^ *[0-9]+ ' , line ) is not None
130- ),
131- )
125+ net_charge = int (
126+ round (
127+ sum (
128+ float (line .split ()[8 ])
129+ for line in mol2_str .splitlines ()
130+ if len (line .split ()) == 9 and match ('^ *[0-9]+ ' , line ) is not None
131+ ),
132132 )
133- else :
134- net_charge = None
133+ )
135134
136- molecule .net_charge = net_charge
135+ molecule .net_charge = net_charge if CONSTRAINT_TOTAL_CHARGE else None
137136 old_molecule = deepcopy (molecule )
138137 old_bond_orders = deepcopy (molecule .bond_orders )
139- _ , graph , pos = molecule .write_graph ('RAW' , graph_kwargs = dict (include_atom_index = True ))
138+ _ , graph , pos = molecule .write_graph (
139+ 'RAW' ,
140+ graph_kwargs = {'include_atom_index' : False , 'vertex_color_scheme' : 'elements' , 'vertex_label_template' : '' },
141+ )
140142
141143
142144 try :
@@ -155,7 +157,12 @@ def try_plotting_molecule(mol2_str: str) -> None:
155157 continue
156158
157159 new_bond_orders = deepcopy (molecule .bond_orders )
158- molecule .write_graph ('ILP' , g = graph , pos = pos , graph_kwargs = dict (include_atom_index = True ))
160+ molecule .write_graph (
161+ 'ILP' ,
162+ g = graph ,
163+ pos = pos ,
164+ graph_kwargs = {'include_atom_index' : False , 'vertex_color_scheme' : 'elements' , 'vertex_label_template' : '{charge_str}' },
165+ )
159166
160167 def assert_bond_orders_match (e : Optional ['AssertionError' ]) -> None :
161168 assert are_graphs_isomorphic (
@@ -170,11 +177,12 @@ def assert_bond_orders_match(e: Optional['AssertionError']) -> None:
170177 ), (
171178 molecule .name ,
172179 {bond : (old_bond_orders [bond ], new_bond_orders [bond ]) for bond in old_bond_orders .keys () if old_bond_orders [bond ] != new_bond_orders [bond ]},
180+ SAME_NET_CHARGE if molecule .netcharge () == net_charge else DIFFERENT_NET_CHARGE ,
173181 )
174182 if e is None :
175- status [molecule .name ] = SAME_BOND_ORDER + '0' + ',' + '-'
183+ status [molecule .name ] = ',' . join (( SAME_BOND_ORDER , '0' + ( SAME_NET_CHARGE if molecule . netcharge () == net_charge else DIFFERENT_NET_CHARGE ), NO_SECOND_RUN ))
176184 else :
177- status [molecule .name ] = SAME_BOND_ORDER + str (len (e .args [0 ][1 ])) + ', ' + '0'
185+ status [molecule .name ] = ',' . join (( SAME_BOND_ORDER , '{0}{1}' . format (len (e .args [0 ][1 ]), e . args [ 0 ][ 2 ]), '0 ' + ( SAME_NET_CHARGE if molecule . netcharge () == net_charge else DIFFERENT_NET_CHARGE )))
178186
179187 try :
180188 assert_bond_orders_match (None )
@@ -199,7 +207,13 @@ def assert_bond_orders_match(e: Optional['AssertionError']) -> None:
199207 assert_bond_orders_match (e )
200208 except AssertionError as f :
201209 print (str (e ))
202- status [molecule .name ] = DIFFERENT_BOND_ORDER + str (len (e .args [0 ][1 ])) + ',' + str (len (f .args [0 ][1 ]))
210+ status [molecule .name ] = ',' .join (
211+ (
212+ DIFFERENT_BOND_ORDER ,
213+ '{0}{1}' .format (len (e .args [0 ][1 ]), e .args [0 ][2 ]),
214+ '{0}{1}' .format (len (f .args [0 ][1 ]), f .args [0 ][2 ]),
215+ ),
216+ )
203217 finally :
204218 get_molecule_name , on_status = itemgetter (0 ), itemgetter (1 )
205219 grouped = {
0 commit comments