Skip to content

Commit

Permalink
fix issue for empty map
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Zhu committed May 8, 2024
1 parent 0a4d49b commit 5c5fd69
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CryoREAD/data_processing/Resize_Map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def my_reform_1a(input_mrc, output_mrc, use_gpu=False):
with torch.no_grad() and torch.cuda.amp.autocast(enabled=use_gpu):

with mrcfile.open(input_mrc, permissive=True) as orig_map:

if np.allclose(orig_map.data, 0.0):
print("Input map is all zeros, exiting")
exit()

orig_voxel_size = np.array([orig_map.voxel_size.x, orig_map.voxel_size.y, orig_map.voxel_size.z])

Expand Down
2 changes: 2 additions & 0 deletions CryoREAD/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def init_save_path(origin_map_path):
os.chdir(running_dir)
from data_processing.Unify_Map import Unify_Map

print("Unifying map", cur_map_path, "to", os.path.join(save_path, map_name + "_unified.mrc"))
cur_map_path = Unify_Map(cur_map_path, os.path.join(save_path, map_name + "_unified.mrc"))
from data_processing.Resize_Map import Resize_Map

print("Resizing map", cur_map_path, "to", os.path.join(save_path, map_name + ".mrc"))
cur_map_path = Resize_Map(cur_map_path, os.path.join(save_path, map_name + ".mrc"))
if params["contour"] < 0:
# change contour level to 0 and increase all the density
Expand Down
14 changes: 11 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@
break
if err:
logger.error(err.strip()) # Log stderr

real_space_cc = calc_map_ccc(seg_map_path, prot_prob_path)[0]
x, fsc, cutoff_05, cutoff_0143 = calculate_fsc(seg_map_path, prot_prob_path)
try:
real_space_cc = calc_map_ccc(seg_map_path, prot_prob_path)[0]
except:
logger.warning("Failed to calculate real space CC, maybe the map is empty")
real_space_cc = 0.0

try:
x, fsc, cutoff_05, cutoff_0143 = calculate_fsc(seg_map_path, prot_prob_path)
except:
logger.warning("Failed to calculate FSC, maybe the map is empty")
cutoff_05 = 0.0
map_list.append([mrc_file, real_space_cc, cutoff_05])

map_list.sort(key=lambda x: x[1], reverse=True)
Expand Down

0 comments on commit 5c5fd69

Please sign in to comment.