IMP  2.0.0
The Integrative Modeling Platform
convert_spider_to_jpg.py
1 #!/usr/bin/env python
2 
3 import IMP
4 import IMP.em2d as em2d
5 import os
6 from math import *
7 import re
8 
9 parser = IMP.OptionParser(usage="""%prog [options] selfile
10 
11 selfile is the selection file with the names of the the EM images""",
12  imp_module=em2d)
13 opts, args = parser.parse_args()
14 if len(args) != 1:
15  parser.error("wrong number of arguments")
16 
17 fn_images_names = args[0]
18 images_names = em2d.read_selection_file(fn_images_names)
19 srw = em2d.SpiderImageReaderWriter()
20 images=em2d.read_images(images_names,srw)
21 # Replace the extension .spi for .jpg
22 jpg_names=[]
23 for s in images_names:
24  jpg_names.append(re.sub(".spi",".jpg",s))
25 jrw = em2d.JPGImageReaderWriter()
26 em2d.save_images(images,jpg_names,jrw)