# Make target_tf from AtRegNet.txt # Usage: python make_target_tf_agris.py > ../Data/information/target_tf_agris.txt fname = '../Data/information/AtRegNet.txt' sample_id = 'C0000000000001' f = open(fname) lines = f.readlines() f.close() d = {} count = 2 duplicate = 0 for line in lines[1:]: line = line.strip() lst = line.split('\t') if len(lst) >= 5: tf0 = lst[1].upper().strip() target0 = lst[4].upper().strip() tf_lst = tf0.split('/') target_lst = target0.split('/') for tf in tf_lst: for target in target_lst: if tf.startswith('AT') and target.startswith('AT'): k = target + '.' + tf if k in d: #print('Warning at line %d ' % (count)) duplicate += 1 else: d[k] = [target, tf, sample_id] count += 1 print('pairs %d' % len(d)) print('duplicate %d' % (duplicate)) for k in sorted(d.keys()): print('\t'.join(d[k]))