diff options
author | Hui Lan <lanhui@zjnu.edu.cn> | 2021-02-18 13:35:33 +0800 |
---|---|---|
committer | Hui Lan <lanhui@zjnu.edu.cn> | 2021-02-18 13:35:33 +0800 |
commit | 20de58ba55ecb36fb8eb1529f263b1ee5c9f2d08 (patch) | |
tree | e6d077dab9fb38847195327e4c150b8749144e3f /Code/make_target_tf.py | |
parent | a56956a5db79d947030a74f7ea710fa6e973972c (diff) |
make_target_tf.py and param4net.py: add an option EXISTING_TARGET_TF_PAIRS in parameter_for_net.txt to specify locations of existing Target-TF pairs.
Diffstat (limited to 'Code/make_target_tf.py')
-rw-r--r-- | Code/make_target_tf.py | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/Code/make_target_tf.py b/Code/make_target_tf.py index 06bc769..cb1775b 100644 --- a/Code/make_target_tf.py +++ b/Code/make_target_tf.py @@ -240,32 +240,22 @@ def target_tf(bind_dict, bind_info_dict, input_dict, glb_param_dict): # d has the following format {target:{tf1:[c1,c2], tf2:[c2,c3]}, ... }
# augment d with information from ../Data/information/target_tf_agris.txt and ../Data/information/target_tf.txt.20170629_143000
- if os.path.exists('../Data/information/target_tf_agris.txt'):
- f = open('../Data/information/target_tf_agris.txt')
- lines = f.readlines()
- f.close()
- for line in lines:
- line = line.strip()
- lst = line.split('\t')
- if len(lst) == 3:
- target0 = lst[0]
- tf0 = lst[1]
- cond_lst0 = lst[2].split()
- augment_dict(d, target0, tf0, cond_lst0)
-
- if os.path.exists('../Data/information/target_tf.txt.20170629_143000'):
- f = open('../Data/information/target_tf.txt.20170629_143000')
- lines = f.readlines()
- f.close()
- for line in lines:
- line = line.strip()
- lst = line.split('\t')
- if len(lst) == 3:
- target0 = lst[0]
- tf0 = lst[1]
- cond_lst0 = lst[2].split()
- augment_dict(d, target0, tf0, cond_lst0)
-
+ if glb_param_dict['EXISTING_TARGET_TF_PAIRS'] != None:
+ target_tf_file_lst = glb_param_dict['EXISTING_TARGET_TF_PAIRS'].split()
+ for existing_target_tf_file in target_tf_file_lst:
+ if os.path.exists(existing_target_tf_file):
+ f = open(existing_target_tf_file)
+ lines = f.readlines()
+ f.close()
+ for line in lines:
+ line = line.strip()
+ lst = line.split('\t')
+ if len(lst) == 3:
+ target0 = lst[0]
+ tf0 = lst[1]
+ cond_lst0 = lst[2].split()
+ augment_dict(d, target0, tf0, cond_lst0)
+
for target in sorted(d.keys()):
tf_d = d[target]
if len(tf_d) > 0:
@@ -279,6 +269,7 @@ def target_tf(bind_dict, bind_info_dict, input_dict, glb_param_dict): ########## main ##################################################
param_file = sys.argv[1] # a single prameter file parameter_for_net.txt
glb_param_dict = make_global_param_dict(param_file)
+
#print('Read binding data ...')
bind_dict = read_matrix_data(glb_param_dict['BINDING_MATRIX'])
bind_info_dict = read_info_data(glb_param_dict['BINDING_INFO'])
|