-
Notifications
You must be signed in to change notification settings - Fork 1
ExportPos
Adrian Quintana edited this page Dec 11, 2017
·
1 revision
#!/usr/bin/env xmipp_python
"""/***************************************************************************
*
* Authors: J.M. de la Rosa Trevin (jmdelarosa@cnb.csic.es)
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* All comments concerning this program package may be sent to the
* e-mail address 'xmipp@cnb.csic.es'
***************************************************************************/
"""
#!/usr/bin/env xmipp_python
import os
from glob import glob
from xmipp import MetaData, MDL_XCOOR, MDL_YCOOR
from protlib_xmipp import XmippScript
from protlib_filesystem import replaceFilenameExt, removeBasenameExt
class ScriptExportPicking(XmippScript):
def __init__(self):
XmippScript.__init__(self)
def defineParams(self):
self.addUsageLine('Export pos files to old Xmipp 2.4 format')
## params
self.addParamsLine(' [-i <template=\"*.pos\">]: pos file template')
## examples
self.addExampleLine('export all *.pos in directory', False)
self.addExampleLine('xmipp_export_picking')
def run(self):
template = self.getParam('-i')
md = MetaData()
for file in glob(template):
print "Procesing file:", file
dirName = removeBasenameExt(file)
if not os.path.exists(dirName):
os.makedirs(dirName)
md.read("particles@"+file)
fOut = open(os.path.join(dirName,file),'w')
for objId in md:
x = float(md.getValue(MDL_XCOOR, objId))
y = float(md.getValue(MDL_YCOOR, objId))
print >> fOut, "%(x)d %(y)d" % locals()
fOut.close()
if __name__ == '__main__':
ScriptExportPicking().tryRun()