diff options
author | Hui Lan <lanhui@zjnu.edu.cn> | 2024-08-05 16:05:54 +0800 |
---|---|---|
committer | Hui Lan <lanhui@zjnu.edu.cn> | 2024-08-05 16:05:54 +0800 |
commit | c839087231fbae65f0dae5d303f8d2457fa40629 (patch) | |
tree | 0d580d2de7785a0b60ff259445535dd37518e74f | |
parent | f0104defa63e757b3beb93959ae60f06dbc0ca24 (diff) |
update_network_by_force.py: fix runtime error
-rw-r--r-- | Code/update_network_by_force.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Code/update_network_by_force.py b/Code/update_network_by_force.py index 125ca60..cf892ea 100644 --- a/Code/update_network_by_force.py +++ b/Code/update_network_by_force.py @@ -115,12 +115,17 @@ edge_file_lst = [] # collect edge files (file names). most_recent_edge_modification_time = 0 for history_directory in [HISTORY_DIR, HISTORY_DIR2]: - write_log_file('[update_network_by_force.py] Look at edge files in %s.' % (HISTORY_DIR), UPDATE_NETWORK_LOG_FILE) + write_log_file('[update_network_by_force.py] Look at edge files in %s.' % (history_directory), UPDATE_NETWORK_LOG_FILE) for fname in glob.glob(os.path.join(history_directory, 'edges.txt.*')): # many small edges.txt.* are to be merged edge_file_lst.append(fname) if os.path.getmtime(fname) > most_recent_edge_modification_time: most_recent_edge_modification_time = os.path.getmtime(fname) +if not os.path.exists(MERGED_EDGE_FILE): + write_log_file('[update_network_by_force.py] WARNING: missing required file %s.' % (MERGED_EDGE_FILE), UPDATE_NETWORK_LOG_FILE) + with open(MERGED_EDGE_FILE, 'w') as f: + f.write('') + if edge_file_lst == []: write_log_file('[update_network_by_force.py] No edge files to merge in %s and %s.' % (HISTORY_DIR, HISTORY_DIR2), UPDATE_NETWORK_LOG_FILE) elif os.path.getmtime(MERGED_EDGE_FILE) < most_recent_edge_modification_time: # update edges.txt only if there are newer edges to add. @@ -176,6 +181,6 @@ if os.path.exists(gold_standard_file) and os.path.exists(MERGED_EDGE_FILE): BrainEdges_dict[tf+target] = score overlap = Overlap(BrainEdges_dict, 3, AtRegNet_dict, 0) - write_log_file('[update_network_by_force.py] Performance stats - TP:%d, PP:%d, Hit rate: %4.7f while comparing with AtRegNet.20210208.csv.' % (overlap.getTP(), overlap.getNumberOfPositivesInPred(), overlap.getTP()/overlap.getNumberOfPositivesInPred()), UPDATE_NETWORK_LOG_FILE) + write_log_file('[update_network_by_force.py] Performance stats - TP:%d, PP:%d, Hit rate: %4.7f while comparing with AtRegNet.20210208.csv.' % (overlap.getTP(), overlap.getNumberOfPositivesInPred(), overlap.getTP()/(overlap.getNumberOfPositivesInPred()+1)), UPDATE_NETWORK_LOG_FILE) write_log_file('[update_network_by_force.py] Update done at %s.\n\n' % (datetime.now().strftime('%Y-%m-%d %H:%M:%S')), UPDATE_NETWORK_LOG_FILE) |