@@ -314,13 +314,12 @@ def merge_frag_list(to_be_merged):
314314# print(newfraglist)
315315 return newfraglist
316316
317- import re
318317def check_if_radical_near_cutting_label (species_smiles ):
319318 species_fragment = Fragment ().from_smiles_like_string (species_smiles )
320319 for i , atom in enumerate (species_fragment .atoms ):
321320 species_fragment .atoms [i ].id = i
322321 for atom in species_fragment .atoms :
323- if atom .radical_electrons == 1 :
322+ if atom .radical_electrons == 1 :
324323 bonded_atoms = list (atom .bonds .keys ())
325324 bonded_atom_types = [type (x ) for x in bonded_atoms ]
326325 if CuttingLabel in bonded_atom_types :
@@ -358,7 +357,7 @@ def check_if_pibond_near_cutting_label(species_smiles):
358357 else :
359358 return False
360359
361- def merge_fragment_a_to_cutting_label_on_b (smiles_a ,smiles_b ,cuttinglabel ):
360+ def merge_fragment_a_to_cutting_label_on_b (smiles_a , smiles_b , cuttinglabel ):
362361 a_frag = Fragment ().from_smiles_like_string (smiles_a )
363362 b_frag = Fragment ().from_smiles_like_string (smiles_b )
364363 for vertex in b_frag .vertices :
@@ -552,19 +551,19 @@ def generate_add_partial_reattachment_reactions(seed_dir, starting_fragments):
552551 seed_reactions_filename = os .path .join (seed_dir , "reactions.py" )
553552 seed_dictionary_filename = os .path .join (seed_dir , "dictionary.txt" )
554553
555- with open (seed_dictionary_filename ,'r' ) as f :
554+ with open (seed_dictionary_filename , 'r' ) as f :
556555 dictionary_lines = f .readlines ()
557556
558557 fragment_to_name_dictionary = {}
559558
560559 dlines_iter = iter (dictionary_lines )
561- name = next (dlines_iter ,"end" ).strip ().strip ('\n ' )
562- line = next (dlines_iter ,"end" )
560+ name = next (dlines_iter , "end" ).strip ().strip ('\n ' )
561+ line = next (dlines_iter , "end" )
563562 while line != "end" and name != "end" :
564- species_adjlist = ""
563+ species_adjlist = ""
565564 line = next (dlines_iter ,"end" )
566565 while line .strip ().strip ('\n ' ) != "" :
567- species_adjlist += line
566+ species_adjlist += line
568567 line = next (dlines_iter , "end" )
569568
570569 f = Fragment ().from_adjacency_list (species_adjlist )
@@ -576,7 +575,7 @@ def generate_add_partial_reattachment_reactions(seed_dir, starting_fragments):
576575 smiles = f .smiles
577576 try :
578577 for starting_fragment in starting_fragments :
579- options = process_new_fragment (smiles , starting_fragment ,species_cutting_threshold = 12 )
578+ options = process_new_fragment (smiles , starting_fragment , species_cutting_threshold = 12 )
580579 if type (options ) == list :
581580 for option in options :
582581 option_frags = [Fragment ().from_smiles_like_string (x ) for x in option ]
@@ -603,7 +602,7 @@ def generate_add_partial_reattachment_reactions(seed_dir, starting_fragments):
603602 \" \" \" ,
604603 )"""
605604
606- with open (seed_reactions_filename ,"r" ) as f :
605+ with open (seed_reactions_filename , "r" ) as f :
607606 lines = f .readlines ()
608607 for line in lines [::- 1 ]:
609608 if "index = " in line :
@@ -625,7 +624,7 @@ def generate_add_partial_reattachment_reactions(seed_dir, starting_fragments):
625624 entry = seed_reaction_template .format (largest_idx + j ,rxn_str )
626625 seed_reaction_entries .append (entry + "\n " )
627626
628- if seed_reaction_entries != [] :
627+ if seed_reaction_entries :
629628 with open (seed_reactions_filename ,'a' ) as f :
630629 f .writelines (seed_reaction_entries )
631630 return f"Added { len (seed_reaction_entries )} partial reattachment reactions to { seed_reactions_filename } ."
0 commit comments