Skip to content

Commit 5ab3530

Browse files
committed
PR fixes V: use metadata to write coordinates file
1 parent 5f96b85 commit 5ab3530

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

xmipptomo/utils.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,7 @@ def writeOutputTiltSeriesCoordinates3dXmdFile(soc, filePath, sr, halfX, halfY, t
302302
its tomo tsId). If no tsId is input the xmd output file will contain all the coordinates belonging to the
303303
set. """
304304

305-
xmdHeader = "# XMIPP_STAR_1 *\n" \
306-
"#\n" \
307-
"data_noname\n" \
308-
"loop_\n" \
309-
" _xcoor\n" \
310-
" _ycoor\n" \
311-
" _zcoor\n"
312-
313305
coordinatesInfo = []
314-
fieldNames = ['x', 'y', 'z']
315306

316307
if tsId is None:
317308
for coord in soc:
@@ -328,14 +319,22 @@ def writeOutputTiltSeriesCoordinates3dXmdFile(soc, filePath, sr, halfX, halfY, t
328319
if len(coordinatesInfo) == 0:
329320
return False
330321

331-
with open(filePath, 'w') as f:
332-
f.write(xmdHeader)
333-
writer = csv.DictWriter(f, delimiter='\t', fieldnames=fieldNames)
322+
print(coordinatesInfo)
334323

335-
for ci in coordinatesInfo:
336-
writer.writerow({'x': ci[0],
337-
'y': ci[1],
338-
'z': ci[2]})
324+
mdCoor = lib.MetaData()
325+
326+
for ci in coordinatesInfo:
327+
nRow = md.Row()
328+
print(ci)
329+
print(ci[0])
330+
print(type(ci[0]))
331+
nRow.setValue(lib.MDL_XCOOR, int(ci[0]))
332+
nRow.setValue(lib.MDL_YCOOR, int(ci[1]))
333+
nRow.setValue(lib.MDL_ZCOOR, int(ci[2]))
334+
335+
nRow.addToMd(mdCoor)
336+
337+
mdCoor.write(filePath)
339338

340339
return True
341340

@@ -520,7 +519,6 @@ def writeMdCoordinates(setOfCoordinates, tomo, fnCoor):
520519
return fnCoor
521520

522521

523-
524522
def parseLandmarkCoordinatesFile(lmFile):
525523
""" This function retrive a list of landmark coordinates form xmd file as generated by xmipp program
526524
xmipp_tomo_detect_landmarks"""

0 commit comments

Comments
 (0)