Skip to content

Commit

Permalink
Detect relion-style folder organization and store *_topazpicks.star f…
Browse files Browse the repository at this point in the history
…iles into the right place
  • Loading branch information
zruan committed Feb 21, 2021
1 parent 617547c commit 99ebaab
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions relion_run_topaz/run_topaz_pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"""Import >>>"""
import argparse
import os
import subprocess
import re
"""<<< Import"""

"""USAGE >>>"""
Expand Down Expand Up @@ -93,10 +95,15 @@
"""make star files >>>"""
#make star files in the right folder
print('Making star files...')
os.system(str('''relion_star_printtable ''')+inargsMics+str(''' data_micrographs _rlnMicrographName | awk -F"/" 'NR==1{print $(NF-1)}' > ''')+tmpfile)
tmpdf=open(tmpfile).readline().rstrip('\n')
file_path = subprocess.check_output(' '.join(['relion_star_printtable', inargsMics, 'data_micrographs _rlnMicrographName | head -n 1']), shell=True, encoding='utf-8').strip()
job_pattern = re.compile('/job[0-9]{3}/(?P<suffix>.*$)')
match = job_pattern.search(file_path)
if match:
tmpdf = os.path.dirname(match['suffix'])
else:
tmpdf = os.path.basename(os.path.dirname(file_path))
outopaz_path=outargsPath+tmpdf+'/'
os.system(str('mkdir ')+outopaz_path+str(';rm ')+tmpfile)
os.system(str('mkdir -p ')+outopaz_path)
mic_filenames=list(set([x.split('\t')[0] for x in open(outargsResults2).readlines()[1:]]))
topaz_picks=[x.split('\t') for x in open(outargsResults2).readlines()[1:]]
for name in mic_filenames:
Expand Down

0 comments on commit 99ebaab

Please sign in to comment.