66from lib .misc .warn import wrg_1 , wrg_3 , pop_err_1 , pop_wrg_1
77from lib .misc .file import check_file , debugger_file , fileseeker
88from lib .misc .geometry import rotate , arcos , raiz
9+ from lib .misc .data import isnot_num
910from sys import exit
1011
1112
@@ -162,7 +163,7 @@ def extract_gromacs_data( _data_files_, _autoload_):
162163 ###########################################################################
163164 section = '''---------- .SIDE MOLE FILES. -------------'''
164165 #=========================================================================#
165- #### research in topology for new molecules / side molecules
166+ #### re-search in topology for new molecules / side molecules
166167 if _autoload_ :
167168 data_container , ok_flag , _sidemol_f_ = sidemol_data ( filename_top ,
168169 data_container )
@@ -227,7 +228,7 @@ def extract_gromacs_data( _data_files_, _autoload_):
227228 aux_here = {}
228229
229230 if filename_nb <> filename_ff and filename_nb <> filename_bon :
230- # it is GROMOS there ??
231+ # Is it GROMOS there ??
231232 aux_here = get_gromos_define ( filename_bon )
232233
233234 for key_ in aux_here .keys ():
@@ -282,7 +283,8 @@ def extract_gromacs_data( _data_files_, _autoload_):
282283
283284 if _sidemol_f_ :
284285
285- # A_02 maths
286+ ### A_02 maths
287+ # "previewing / preallocating" // computing side mol size
286288 sidemol = data_container ['sidemol' ]
287289 side_bonds_n = 0
288290 side_angles_n = 0
@@ -301,30 +303,35 @@ def extract_gromacs_data( _data_files_, _autoload_):
301303 side_dihed_n += sm_quantity * dihedr_x_mol
302304 side_improp_n += sm_quantity * improp_x_mol
303305
306+ n_bondsnew = n_bonds + side_bonds_n
307+ n_anglesnew = n_angles + side_angles_n
308+ n_dihednew = n_dihedrals + side_dihed_n
309+ n_impropnew = n_impropers + side_improp_n
310+ #print n_bonds, side_bonds_n, n_bonds + side_bonds_n
311+ #print n_angles, side_angles_n, n_angles + side_angles_n
304312
313+ ### A_03
314+ # tester in case is an asigment for define ore something like that
305315 contentkey = [ 'bond' , 'angle' , 'improper' , 'dihedral' ]
306316 for cont_k in contentkey :
317+ # memorandum:
318+ # 'define' stores in a contentkey dictionary each define key:value
307319 cddd = data_container [ 'define' ][ cont_k ]
308-
309320 if cddd .keys () <> []:
310- for sb in range ( len ( sidemol ['tag' ])):
311- datacont = sidemol ['data' ][sb ][cont_k + 's' ]
312- for dc in range ( len (datacont )):
313- if not datacont [dc ][- 1 ].isdigit ():
321+ for sb in range ( len ( sidemol ['tag' ])): # in each side mol
322+ datacont = sidemol ['data' ][sb ][cont_k + 's' ]# in its cont-key
323+ for dc in range ( len ( datacont )):# lets look their content
324+ if isnot_num ( datacont [dc ][- 1 ]):#
325+ #print( '{} {} {}'.format( cont_k+'s', dc,
326+ # datacont[dc][-1]))
314327 aux = datacont [dc ][:- 1 ] + cddd [ datacont [dc ][- 1 ]]
315328 sidemol ['data' ][sb ][cont_k + 's' ][dc ] = aux
316- #elif 'gb_33' in datacont[dc]:
317329 #else:
318330 #print datacont[dc]
319331
320- n_bondsnew = n_bonds + side_bonds_n
321- n_anglesnew = n_angles + side_angles_n
322- n_dihednew = n_dihedrals + side_dihed_n
323- n_impropnew = n_impropers + side_improp_n
324-
325- #print n_bonds, side_bonds_n, n_bonds + side_bonds_n
326- #print n_angles, side_angles_n, n_angles + side_angles_n
327-
332+ #######################################################################
333+ ### A_04
334+ # I think that this part is deprecated... however I am not sure
328335 # Regarding the itp format:
329336 # charges index 6 in data-atoms
330337 # opls names in index 1
@@ -344,9 +351,11 @@ def extract_gromacs_data( _data_files_, _autoload_):
344351
345352 data_container ['S_charge' ] = _charge_
346353 data_container ['S_translation' ] = _conv_dict_
354+
347355 #######################################################################
356+ ### A_05
348357 ############ Esoteric part ;) ###############
349- ####----------- DEFINING BONDED INTERACTIONS ----------####
358+ #### ----------- DEFINING BONDED INTERACTIONS ---------- ####
350359 # load the side molecules data if exist
351360 #sidemol = _topodata_['sidemol']
352361 smol_extra_bondtypes = []
@@ -460,7 +469,13 @@ def extract_gromacs_data( _data_files_, _autoload_):
460469 return data_container , [ ok_flag , _sidemol_f_ ]
461470
462471def sidemol_data ( _file_top_ , data_container ):
463- ''' getter of the side molecules data'''
472+ ''' -- getter of the side molecules data --
473+ Per each side mole returns a dictionary with:
474+ tag : side mole tag
475+ num : number in this instance of this kind of side mol
476+ data : dictionary with topology data
477+ {atoms bonds angles dihedrals impropers}
478+ '''
464479
465480 sidemol = {'tag' : [],'num' :[], 'data' :[] }# Tag # mol_number
466481 sm_flag = False
@@ -473,7 +488,7 @@ def sidemol_data( _file_top_, data_container):
473488 non_sm = [non_sm [i ][0 ] for i in range (len (non_sm ))]
474489 _buffer_ = ''
475490 else :
476- # non conventional case
491+ # non conventional case // the one in the main top
477492 non_sm = ['' ]
478493 _buffer_ = '0'
479494
@@ -536,10 +551,11 @@ def sidemol_data_gatherer( _sm_files_, _sm_):
536551 ''' collects all the data related with one kind of side molecule
537552 the data types are specified in startstrings
538553 '''
539- print 'Search for: ' , _sm_ , ' in: ' ,_sm_files_
554+ print ( ' \n Searching for: {}' . format ( _sm_ )) # , ' in: ' ,_sm_files_
540555 _flag_ = True
541556 _file_ = ''
542557 _sm_data_c_ = {}
558+
543559 # is sm in sm_file?? in cases with more than one file
544560 for smfile in _sm_files_ :
545561 with open ( smfile , 'r' ) as sm_data :
@@ -570,6 +586,7 @@ def sidemol_data_gatherer( _sm_files_, _sm_):
570586 pop_err_1 ('Error!! side molecule {} not found in itp -- ' .format ( _sm_ ))
571587 _flag_ = False
572588 else :
589+ print ( 'Succes!, found in : {}\n ' .format ( _file_ ))
573590 tag_str = [ 'atoms' , 'bonds' , 'angles' , 'dihedrals' ,'fin' ]
574591 _sm_data_c_ = { x :[] for x in tag_str if x <> 'fin' }
575592 read_flag = False
@@ -591,6 +608,7 @@ def sidemol_data_gatherer( _sm_files_, _sm_):
591608 i = tag_str .index ( j_line [1 ])
592609 cd_tag = tag_str [i ]
593610 iner_flag = True
611+ print ( '** Gathering {} data' .format ( cd_tag ))
594612 elif j_line [1 ] == 'moleculetype' :
595613 break
596614 else :
@@ -599,6 +617,7 @@ def sidemol_data_gatherer( _sm_files_, _sm_):
599617 iner_flag = False
600618 else :
601619 cd_tag = tag_str [i ]
620+ print ( '* Gathering {} data' .format ( cd_tag ))
602621 iner_flag = True
603622
604623 elif iner_flag :
0 commit comments