From 99ebaab47f6d5d2903d13618746535f93b14ea03 Mon Sep 17 00:00:00 2001 From: Zheng Ruan Date: Sun, 21 Feb 2021 12:45:26 -0500 Subject: [PATCH] Detect relion-style folder organization and store *_topazpicks.star files into the right place --- relion_run_topaz/run_topaz_pick.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/relion_run_topaz/run_topaz_pick.py b/relion_run_topaz/run_topaz_pick.py index 198133e..130ddfa 100644 --- a/relion_run_topaz/run_topaz_pick.py +++ b/relion_run_topaz/run_topaz_pick.py @@ -14,6 +14,8 @@ """Import >>>""" import argparse import os +import subprocess +import re """<<< Import""" """USAGE >>>""" @@ -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.*$)') +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: