Skip to content

Commit

Permalink
bfactor.py, relion_it.py: repaired split file names (bug reported by …
Browse files Browse the repository at this point in the history
…Shaun Rawson)
  • Loading branch information
biochem-fan committed Jun 29, 2019
1 parent cc1cde7 commit c58438c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 11 additions & 1 deletion scripts/bfactor_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ def WaitForJob(wait_for_this_job, seconds_wait):
CheckForExit()
time.sleep(seconds_wait)

def find_split_job_output(prefix, n, max_digits=6):
import os.path
for i in xrange(max_digits):
filename = prefix + str(n).rjust(i, '0') + '.star'
if os.path.isfile(filename):
return filename
return None

def line_fit(xs, ys):
n = len(xs)
assert n == len(ys)
Expand Down Expand Up @@ -341,7 +349,9 @@ def run_pipeline(opts):
WaitForJob(split_job, 30)

# B. Run Refine3D
refine_options = ['Input images STAR file: == {}particles_split001.star'.format(split_job),
split_filename = find_split_job_output('{}particles_split'.format(split_job), 1)
assert split_filename is not None
refine_options = ['Input images STAR file: == {}'.format(split_filename),
'Number of pooled particles: == {}'.format(opts.refine_nr_pool),
'Which GPUs to use: == {}'.format(opts.refine_gpu),
'Number of MPI procs: == {}'.format(opts.refine_mpi),
Expand Down
15 changes: 12 additions & 3 deletions scripts/relion_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,14 @@ def WaitForJob(wait_for_this_job, seconds_wait):
CheckForExit()
time.sleep(seconds_wait)

def find_split_job_output(prefix, n, max_digits=6):
import os.path
for i in xrange(max_digits):
filename = prefix + str(n).rjust(i, '0') + '.star'
if os.path.isfile(filename):
return filename
return None

def writeManualPickingGuiFile(my_part_diam):
if not os.path.isfile('.gui_manualpickrun.job'):
with open('.gui_manualpickrun.job', 'w') as g:
Expand Down Expand Up @@ -1774,9 +1782,10 @@ def run_pipeline(opts):

# It could be that this is a restart, so check previous_batch1_size in the output directory.
# Also check the presence of class2d_job_batch_001 in case the first job was not submitted yet.
first_split_file = find_split_job_output(split_job + 'particles_split', 1)
if getJobName("class2d_job_batch_001", SETUP_CHECK_FILE) is not None and \
os.path.isfile(split_job + 'particles_split001.star'):
batch1 = safe_load_star(split_job + 'particles_split001.star', expected=['', 'rlnMicrographName'])
first_split_file is not None:
batch1 = safe_load_star(first_split_file, expected=['', 'rlnMicrographName'])
previous_batch1_size = len(batch1['']['rlnMicrographName'])
else:
previous_batch1_size = 0
Expand All @@ -1788,7 +1797,7 @@ def run_pipeline(opts):
nr_batches = len(glob.glob(split_job + "particles_split*.star"))
for ibatch in range(0, nr_batches):
iibatch = ibatch + 1
batch_name = split_job + 'particles_split%03d.star' % iibatch
batch_name = find_split_job_output(split_job + "particles_split", iibatch)

batch = safe_load_star(batch_name, expected=['', 'rlnMicrographName'])
batch_size = len(batch['']['rlnMicrographName'])
Expand Down

0 comments on commit c58438c

Please sign in to comment.