Skip to content

Commit fb3328d

Browse files
committed
Added comments
1 parent 192fce5 commit fb3328d

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Trapnell_pipeline/Trapnell_wrapper.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import sys
44
import numpy as np
55

6+
# Parse the options from command line
67
try:
78
opts, args = getopt.getopt(sys.argv[1:],"i:n:k:t:",["idir=","njobs=","hacked-kallisto-path=","reference-transcriptome="])
89
except getopt.GetoptError:
910
print ("getopterrror")
1011
print ('usage is : \n python Trapnell_wrapper.py -i input_SRA_dir -k path-to-hacked-kallisto -t path-to-human-reference-transcriptome [-n number-of-processes-to-use]')
1112
sys.exit(1)
12-
13+
14+
# The four options used in this pipeline are
1315
SRA_dir=''
1416
num_proc=1
1517
kallipso_path=''
@@ -25,23 +27,25 @@
2527
elif opt in ("-t","--reference-transcriptome"):
2628
ref_transcriptome=arg
2729

28-
30+
# Error message if function not called correctly
2931
if (not SRA_dir) or (not kallipso_path) or (not ref_transcriptome):
3032
print ('usage is : \n python Trapnell_wrapper.py -i input_SRA_dir -k path-to-hacked-kallisto -t path-to-human-reference-transcriptome [-n number-of-processes-to-use]')
3133
sys.exit(1)
3234

35+
# Execute process_SRA, which converts SRA to fastq
3336
print('Extracting reads from SRAs...')
3437
os.system('mkdir -p ./reads/')
3538
os.system('rm -f ./reads/*')
3639
os.system('python process_SRA.py -i '+SRA_dir+' -o ./reads/ -n '+str(num_proc))
3740

41+
# This removes files that Trapnell didn't use. (Specific for analysis of this dataset)
3842
print('Removing files that Trapnell throws...')
3943
relevant_fls=np.loadtxt('Files_to_keep.txt',dtype=str)
4044
fls_to_remove=[cells for cells in os.listdir('./reads/') if cells.split('_')[0] not in relevant_fls ]
4145
for fl in fls_to_remove:
4246
os.system('rm '+'./reads/'+fl)
4347

44-
48+
# Use kallisto to build index. should return same results as hacked kallisto
4549
print('Generating the Kallisto index (with hacked kallisto)...')
4650
os.system('mkdir -p ./kallisto_index')
4751
os.system('rm -f ./kallisto_index/*')
@@ -52,15 +56,16 @@
5256
num_ec = sum(1 for line in open('./kallisto_index/Trapnell_index.idx_ecmap.txt'))
5357
print(num_ec)
5458

59+
# Use hacked kallisto to generate TCCs (output is .class file that contains counts of ECs)
5560
print('Generating TCC (with hacked kallisto)...')
5661
os.system('mkdir -p ./transcript_compatibility_counts/')
5762
os.system('rm -f ./transcript_compatibility_counts/*')
5863
os.system('python get_pseudoalignments_paired_end.py -i ./reads/ -o ./transcript_compatibility_counts/ -k '+kallipso_path+ ' -t '+ index_path +' -n '+ str(num_proc))
5964

65+
# Process the .class file into a matrix. normalize such that each row sums to 1
6066
print('Generating TCC distribution...')
61-
6267
os.system('python get_tcc_dist.py -i ./transcript_compatibility_counts/ -m '+str(num_ec)+' -t ./Trapnell_TCC.dat -d ./Trapnell_TCC_distribution.dat')
6368

69+
# Process the TCC distribution matrix to get pairwise distributions
6470
print('Generating pairwise distances...')
65-
6671
os.system('python get_pairwise_distances.py ./Trapnell_TCC_distribution.dat ./Trapnell_TCC_pairwise_distance.dat '+str(num_proc))

0 commit comments

Comments
 (0)