@@ -344,6 +344,7 @@ def AddAABondRestraint(bondRestData):
344344 def AddMogulBondRestraint (bondRestData ):
345345 mogul ,colNums = getMOGULFile ()
346346 badNames = []
347+ badLines = []
347348 badCount = 0
348349 for line in mogul :
349350 items = line .split (',' )
@@ -361,20 +362,29 @@ def AddMogulBondRestraint(bondRestData):
361362 badCount += 1
362363 badNames .append (tName )
363364 continue
364- if items [colNums [2 ]] != 'No hits' :
365- dist = float (items [colNums [4 ]])
366- esd = float (items [colNums [5 ]])
367- else :
368- dist = float (items [colNums [3 ]])
369- esd = 0.02
365+ try :
366+ if items [colNums [2 ]] != 'No hits' :
367+ dist = float (items [colNums [4 ]])
368+ esd = float (items [colNums [5 ]])
369+ else :
370+ dist = float (items [colNums [3 ]])
371+ esd = 0.02
372+ except :
373+ badLines .append (line .strip ()[:15 ])
374+ continue
370375 newBond = [[Ids [oInd ],Ids [tInd ]],['1' ,'1' ],dist ,esd ]
371376 if newBond not in bondRestData ['Bonds' ]:
372377 bondRestData ['Bonds' ].append (newBond )
373378 UpdateBondRestr (bondRestData )
379+ msg = ''
374380 if badNames :
375- msg = f'{ badCount } restraints were skipped beccause these atom(s) were not found: { " " .join (set (badNames ))} '
381+ msg += f'{ badCount } restraints were skipped because these atom(s) were not found: { " " .join (set (badNames ))} . '
382+ if badLines :
383+ msg += f'{ len (badLines )} restraints were skipped because these lines(s) could not be read: { badLines } . '
384+ if msg :
376385 wx .GetApp ().Yield ()
377- G2G .G2MessageBox (G2frame ,msg ,'Missing atoms' )
386+ G2G .G2MessageBox (G2frame ,msg ,'Read problems' )
387+
378388 def AddAngleRestraint (angleRestData ):
379389 Radii = dict (zip (General ['AtomTypes' ],zip (General ['BondRadii' ],General ['AngleRadii' ])))
380390 Lists = {'A-atom' :[],'B-atom' :[],'C-atom' :[]}
@@ -511,23 +521,34 @@ def AddAAAngleRestraint(angleRestData):
511521
512522 def AddMogulAngleRestraint (angleRestData ):
513523 mogul ,colNums = getMOGULFile ()
524+ badLines = []
514525 for line in mogul :
515526 items = line .split (',' )
516527 if 'angle' == items [colNums [0 ]]:
517- aName ,bName ,cName = items [colNums [1 ]].split ()
518- aInd = Names .index (aName )
519- bInd = Names .index (bName )
520- cInd = Names .index (cName )
521- if items [colNums [2 ]] != 'No hits' :
522- angle = float (items [colNums [4 ]])
523- esd = float (items [colNums [5 ]])
524- else :
525- angle = float (items [colNums [3 ]])
526- esd = 2.00
527- newAngle = [[Ids [aInd ],Ids [bInd ],Ids [cInd ]],['1' ,'1' ,'1' ],angle ,esd ]
528- if newAngle not in angleRestData ['Angles' ]:
529- angleRestData ['Angles' ].append (newAngle )
530- UpdateAngleRestr (angleRestData )
528+ try :
529+ aName ,bName ,cName = items [colNums [1 ]].split ()
530+ aInd = Names .index (aName )
531+ bInd = Names .index (bName )
532+ cInd = Names .index (cName )
533+ if items [colNums [2 ]] != 'No hits' :
534+ angle = float (items [colNums [4 ]])
535+ esd = float (items [colNums [5 ]])
536+ else :
537+ angle = float (items [colNums [3 ]])
538+ esd = 2.00
539+ newAngle = [[Ids [aInd ],Ids [bInd ],Ids [cInd ]],['1' ,'1' ,'1' ],angle ,esd ]
540+ if newAngle not in angleRestData ['Angles' ]:
541+ angleRestData ['Angles' ].append (newAngle )
542+ except :
543+ badLines .append (line .strip ()[:30 ])
544+ print (f'Error reading line { line .strip ()!r} ' )
545+ UpdateAngleRestr (angleRestData )
546+ msg = ''
547+ if badLines :
548+ msg += f'{ len (badLines )} restraints were skipped because these lines(s) could not be read: { badLines } . '
549+ if msg :
550+ wx .GetApp ().Yield ()
551+ G2G .G2MessageBox (G2frame ,msg ,'Read problems' )
531552
532553 def AddPlaneRestraint (restrData ):
533554 ids = []
0 commit comments