forked from jcao89757/TESSA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tessa_main.py
70 lines (68 loc) · 3.12 KB
/
Tessa_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
"""
03/26/2020 Tessa_main.py: This script serves as a wrapper of BriseisEncoder and Tessa, to generate TCR sequence embeding,
and/or to estimate functional landscape of TCR repertoire when combined with single-cell sequencing of T cells. Please
find more details in our paper: Mapping the Functional Landscape of TCR Repertoire. Zhang Z, Xiong D, et al.
"""
__author__='Ze Zhang'
__maintainer__='Ze Zhang'
__copyright__='Wang Lab, UT Southwestern Medical Center'
__version__='1.0.0'
__email__='[email protected]'
import sys
import os
from os.path import dirname
args = sys.argv
sys.path.append(dirname(args[0]))
sys.path.append(dirname(args[0])+'/BriseisEncoder')
sys.path.append(dirname(args[0])+'/Tessa')
if dirname(args[0]) is '':
base_path='.'
else:
base_path=dirname(args[0])
if '-tcr' in args:
#Mode 1: Briseis encoder + Tessa
# #Step 1: Run BriseisEncoder
tcr_dir = args[args.index('-tcr')+1]
model_dir=args[args.index('-model')+1]
aa_dict_dir=args[args.index('-embeding_vectors')+1]
output_encodedTCR_dir=args[args.index('-output_TCR')+1]
output_log_dir = args[args.index('-output_log') + 1]
if '-output_VJ' in args:
output_encodedVJ_dir=args[args.index('-output_VJ')+1]
cmd_encoder = ' '.join(['python3', base_path+'/BriseisEncoder/BriseisEncoder.py', '-tcr', tcr_dir, '-model',
model_dir, '-embeding_vectors', aa_dict_dir,'-output_TCR',
output_encodedTCR_dir, '-output_VJ', output_encodedVJ_dir,
'-output_log', output_log_dir])
else:
cmd_encoder = ' '.join(['python', base_path+'/BriseisEncoder/BriseisEncoder.py', '-tcr', tcr_dir, '-model',
model_dir, '-embeding_vectors', aa_dict_dir, '-output_TCR',
output_encodedTCR_dir,'-output_log', output_log_dir])
os.system(cmd_encoder)
#Step 2: Run Tessa
exp_file = args[args.index('-exp')+1]
contigs_file = output_encodedTCR_dir
cdr3_file = tcr_dir
save_tessa = args[args.index('-output_tessa')+1]
is_sampleCluster = args[args.index('-within_sample_networks')+1]
if '-predefined_b' in args:
fixed_b = args[args.index('-predefined_b')+1]
else:
fixed_b='NA'
cmd_tessa1 = ' '.join(['Rscript', base_path+'/Tessa/real_data.R', base_path+'/Tessa',exp_file, contigs_file, cdr3_file,
save_tessa, is_sampleCluster, fixed_b])
os.system(cmd_tessa1)
if '-embeding' in args:
#Mode 2: Tessa only
exp_file = args[args.index('-exp') + 1]
contigs_file = args[args.index('-embeding') + 1]
cdr3_file = args[args.index('-meta') + 1]
save_tessa = args[args.index('-output_tessa') + 1]
is_sampleCluster = args[args.index('-within_sample_networks') + 1]
if '-predefined_b' in args:
fixed_b = args[args.index('-predefined_b') + 1]
else:
fixed_b = 'NA'
cmd_tessa2 = ' '.join(['Rscript', base_path+'/Tessa/real_data.R', base_path+'/Tessa',exp_file, contigs_file, cdr3_file,
save_tessa, is_sampleCluster, fixed_b])
os.system(cmd_tessa2)