Skip to content

Commit 59dc03e

Browse files
committed
fix reading of MOGUL files with 'no hits' lines
1 parent 94a8ddd commit 59dc03e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

GSASII/GSASIIrestrGUI.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ def getMacroFile(macName):
9898
return macro #advanced past 1st line
9999

100100
def getMOGULFile():
101-
colNums = [0,2,3,5,6,7] # location for these fields:
102-
# Type, Fragment, No. of hits, Query value, Mean, Std. dev.
101+
colNums = [0,2,3,5,6,7] # default location for these fields:
102+
# Type, Fragment, Classification, Query value, Mean, Std. dev.
103+
# but potentially overridden below
103104
dlg = wx.FileDialog(G2frame,message='Choose MOGUL csv file',
104105
defaultDir='.',defaultFile="",wildcard="MOGUL csv file (*.csv)|*.csv",
105106
style=wx.FD_OPEN | wx.FD_CHANGE_DIR)
@@ -114,8 +115,8 @@ def getMOGULFile():
114115
print ('**** ERROR - file selected is not a MOGUL csv file, try again ****')
115116
mogul = []
116117
else:
117-
for i,k in enumerate(('Type','Fragment',
118-
'No. of hits','Query value','Mean','Std. dev.')):
118+
for i,k in enumerate(('Type','Fragment','Classification',
119+
'Query value','Mean','Std. dev.')):
119120
try:
120121
colNums[i] = head.split(',').index(k)
121122
except ValueError:
@@ -370,17 +371,19 @@ def AddMogulBondRestraint(bondRestData):
370371
dist = float(items[colNums[3]])
371372
esd = 0.02
372373
except:
373-
badLines.append(line.strip()[:15])
374+
print(f'Error reading line {line.strip()!r}')
375+
badLines.append(line.strip()[:30])
374376
continue
375377
newBond = [[Ids[oInd],Ids[tInd]],['1','1'],dist,esd]
376378
if newBond not in bondRestData['Bonds']:
377379
bondRestData['Bonds'].append(newBond)
378380
UpdateBondRestr(bondRestData)
379381
msg = ''
380382
if badNames:
381-
msg += f'{badCount} restraints were skipped because these atom(s) were not found: {" ".join(set(badNames))}. '
383+
msg += f'{badCount} restraints were skipped because these atom(s) were not found: {" ".join(set(badNames))}'
382384
if badLines:
383-
msg += f'{len(badLines)} restraints were skipped because these lines(s) could not be read: {badLines}. '
385+
lines = "\n".join(badLines)
386+
msg += f'{len(badLines)} restraints were skipped because these lines(s) could not be read:\n{lines}. '
384387
if msg:
385388
wx.GetApp().Yield()
386389
G2G.G2MessageBox(G2frame,msg,'Read problems')
@@ -545,7 +548,8 @@ def AddMogulAngleRestraint(angleRestData):
545548
UpdateAngleRestr(angleRestData)
546549
msg = ''
547550
if badLines:
548-
msg += f'{len(badLines)} restraints were skipped because these lines(s) could not be read: {badLines}. '
551+
lines = "\n".join(badLines)
552+
msg += f'{len(badLines)} restraints were skipped because these lines(s) could not be read:\n{lines}'
549553
if msg:
550554
wx.GetApp().Yield()
551555
G2G.G2MessageBox(G2frame,msg,'Read problems')

0 commit comments

Comments
 (0)