diff options
author | Hui Lan <lanhui@zjnu.edu.cn> | 2024-08-07 15:13:14 +0800 |
---|---|---|
committer | Hui Lan <lanhui@zjnu.edu.cn> | 2024-08-07 15:13:14 +0800 |
commit | 1c4b5c0208bd8335b685e594b146605e4453722e (patch) | |
tree | 873f77dd353ea57fe378c6b5b5f797835a9aa2cd | |
parent | cec522c7c60771fd6da011e3e6eecb2ac607744b (diff) |
[update_network.py] Rename FILE_TIMESTAMP to TIMESTAMP_FILE
-rw-r--r-- | Code/configure.py | 2 | ||||
-rw-r--r-- | Code/local_network.py | 9 | ||||
-rwxr-xr-x | Code/update_network.py | 15 |
3 files changed, 12 insertions, 14 deletions
diff --git a/Code/configure.py b/Code/configure.py index 41c791a..43dff60 100644 --- a/Code/configure.py +++ b/Code/configure.py @@ -18,7 +18,7 @@ RAW_RDATA_DIR = '/disk1/Data/R/Raw' # downloaded files go here # Don'T change the following paths and names
HISTORY_DIR = '../Data/history/edges/many_targets' # each edge file contains edges for many targets
HISTORY_DIR2 = '../Data/history/edges/one_target' # edges.txt.* files are here, all edge files have the name edges.txt.*, the leading string 'edges.txt' must be present.
-FILE_TIMESTAMP = '../Data/log/file_timestamp.txt' # record last modified time of several important files
+TIMESTAMP_FILE = '../Data/log/file_timestamp.txt' # record last modified time of several important files
SAMPLE_SIZE_FILE = '../Data/log/total.samples.txt' # each line contains a date and the number of samples on and after that date
TEMP_DIR = '../Data/temp'
diff --git a/Code/local_network.py b/Code/local_network.py index e05e7a0..6ac38d5 100644 --- a/Code/local_network.py +++ b/Code/local_network.py @@ -32,7 +32,7 @@ from datetime import datetime from param4net import make_global_param_dict, get_key_value from log import write_log_file from utils import make_paths - +from configure import TIMESTAMP_FILE FORCE_MAKE_EDGES = 'NO' CODE_DIR = os.getcwd() # Get current working directory. It is important that you execute this script under it directory. @@ -40,7 +40,6 @@ CODE_DIR = os.getcwd() # Get current working directory. It is importa # DON'T CHANGE THE FOLLOWING PATHS AND NAMES HISTORY_DIR = '../Data/history/edges/many_targets' # each edge file contains edges for many targets HISTORY_DIR2 = '../Data/history/edges/one_target' # edges.txt.* files are here, all edge files have the name edges.txt.*, the leading string 'edges.txt' must be present. -FILE_TIMESTAMP = '../Data/log/file_timestamp.txt' SAMPLE_SIZE_FILE = '../Data/log/total.samples.txt' # each line contains a date and the number of samples on and after that date TEMP_DIR = '../Data/temp' @@ -143,7 +142,7 @@ def all_files_present(lst): return missing_file_lst def record_file_time(lst): - f = open(FILE_TIMESTAMP, 'w') + f = open(TIMESTAMP_FILE, 'w') s = '' for x in lst: if os.path.exists(x): @@ -1031,11 +1030,11 @@ if os.path.exists(BINDING_FILE): os.system(cmd) # if the file timestamp does not exist, create one -if not os.path.exists(FILE_TIMESTAMP): +if not os.path.exists(TIMESTAMP_FILE): record_file_time(FILE_LIST_TO_CHECK) # get update time of must-have files -timestamp_dict = read_file_timestamp(FILE_TIMESTAMP) +timestamp_dict = read_file_timestamp(TIMESTAMP_FILE) # update edges.txt, a merged file from several sources, HISTORY_DIR and HISTORY_DIR2. edge_file_lst = [] # collect edge files. diff --git a/Code/update_network.py b/Code/update_network.py index 373703d..82c8cb9 100755 --- a/Code/update_network.py +++ b/Code/update_network.py @@ -44,12 +44,11 @@ import os, sys import numpy as np import glob import time -import subprocess from datetime import datetime from param4net import make_global_param_dict, get_key_value from log import write_log_file from utils import make_paths -from configure import HISTORY_DIR, HISTORY_DIR2, FILE_TIMESTAMP, SAMPLE_SIZE_FILE, TEMP_DIR, \ +from configure import HISTORY_DIR, HISTORY_DIR2, TIMESTAMP_FILE, SAMPLE_SIZE_FILE, TEMP_DIR, \ PARAMETER_FOR_BUILDCMATRIX, PARAMETER_FOR_BUILDRMATRIX, \ PARAMETER_FOR_NET, PARAMETER_FOR_NET_TRAVADB_STRESS, PARAMETER_FOR_NET_TRAVADB_MAP, PARAMETER_FOR_NET_MILD_DROUGHT, PARAMETER_FOR_NET_WIGGELAB_DIURNAL, \ BINDING_FILE, TPM_FILE, \ @@ -605,11 +604,11 @@ validate_parameter_for_net(PARAMETER_FOR_NET) # If the file timestamp does not exist, create one -if not os.path.exists(FILE_TIMESTAMP): - record_file_time(FILE_LIST_TO_CHECK, FILE_TIMESTAMP) +if not os.path.exists(TIMESTAMP_FILE): + record_file_time(FILE_LIST_TO_CHECK, TIMESTAMP_FILE) # Get update time of mandatory files -timestamp_dict = read_file_timestamp(FILE_TIMESTAMP) +timestamp_dict = read_file_timestamp(TIMESTAMP_FILE) @@ -714,8 +713,8 @@ if 'TPM.txt' in updated_file_list: # we could _touch_ TPM.txt to make it recent. cmd = 'python3 update_rnaseq_info_json.py' os.system(cmd) - # Compute edges. This could take a lot of time so update FILE_TIMESTAMP first. - record_file_time(FILE_LIST_TO_CHECK, FILE_TIMESTAMP) + # Compute edges. This could take a lot of time so update TIMESTAMP_FILE first. + record_file_time(FILE_LIST_TO_CHECK, TIMESTAMP_FILE) create_edges0() create_edges0B() wedge() @@ -745,6 +744,6 @@ cmd = 'find %s -mtime +2 -name \"*.R\" -delete' % (TEMP_DIR) os.system(cmd) # update time stamp file -record_file_time(FILE_LIST_TO_CHECK, FILE_TIMESTAMP) +record_file_time(FILE_LIST_TO_CHECK, TIMESTAMP_FILE) write_log_file('[update_network.py] Update done at %s.\n\n' % (datetime.now().strftime('%Y-%m-%d %H:%M:%S')), UPDATE_NETWORK_LOG_FILE) |