-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsc_count_normal_3.1.0
More file actions
executable file
·149 lines (125 loc) · 4.36 KB
/
Copy pathsc_count_normal_3.1.0
File metadata and controls
executable file
·149 lines (125 loc) · 4.36 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/env python3
import json
import glob
from subprocess import call
from pathlib import Path
import argparse
DEBUG = None
def get_sample_names_from(simple_csv_filename):
samples = []
with open(simple_csv_filename) as fh:
data_started = False
for line in fh:
if data_started:
fields = line.split(',')
samples.append(fields[1])
if line.startswith('Lane'):
data_started = True
return samples
def main(args):
config = args.config
DEBUG = args.debug
with open(config) as json_data:
datasets = json.load(json_data)
if DEBUG:
print(datasets)
for dataset in datasets:
if DEBUG:
print("data set: " + dataset)
transcriptome_path = datasets[dataset]["reference"]
if DEBUG:
print("transcriptome_path: " + transcriptome_path)
fastq_dirs = []
for run_folder in datasets[dataset]["run_folders"]:
flowcell = datasets[dataset]["run_folders"][run_folder]
fastq_path_string_short = run_folder + '/' + flowcell + '/outs/fastq_path'
fastq_path_string = fastq_path_string_short + '/' + flowcell
fastq_path = Path(fastq_path_string)
if fastq_path.is_dir():
pass
# Try shorter if longer one didn't work
else:
fastq_path_string = fastq_path_string_short
fastq_path = Path(fastq_path_string)
if fastq_path.is_dir():
pass
else:
print("Cannot find FASTQ path")
exit(1)
fastq_dirs.append(fastq_path_string)
fastqs_string = ','.join(fastq_dirs)
if DEBUG:
print(fastqs_string)
samples = datasets[dataset]["samples"]
if DEBUG:
print(samples)
for sample in samples:
script_text = """#!/bin/bash
#SBATCH --partition=BioCompute,Lewis,hpc5
#SBATCH --account={account}
#SBATCH --time=2-00:00:00
#SBATCH -J cellranger_count_{sample}
#SBATCH -o cellranger_count_{sample}_%j_o.txt
#SBATCH --cpus-per-task {cores}
#SBATCH --mem {mem}G
module load biocompute/biocompute-modules
module load bcl2fastq/bcl2fastq-2.20.0.422
module load cellranger/cellranger-3.1.0
source /cluster/biocompute/software/cellranger/cellranger-3.1.0/sourceme.bash
cellranger count \
--id sample_{sample} \
--transcriptome {transcriptome_path} \
--fastqs {fastqs_string} \
--sample {sample} \
--jobmode local \
--localcores $SLURM_CPUS_PER_TASK \
--localmem {mem}
""".format(sample=sample,fastqs_string=fastqs_string,transcriptome_path=transcriptome_path,mem=args.mem,cores=args.cores,account=args.account)
script_path = 'dataset_' + dataset + '__sample' + sample + '.sbatch'
with open(script_path, 'w') as fh:
fh.write(script_text)
if DEBUG:
print(['sbatch',script_path])
else:
call(['sbatch',script_path])
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Create FASTQ files for sets of 10X single-cell Illumina data (more functionality forthcoming)'
)
parser.add_argument(
'config',
type=str,
help='Name of JSON config file containing a dictionary of sets of lists of run folders to process',
)
parser.add_argument(
'--debug',
dest='debug',
action='store_true',
default=False,
)
parser.add_argument(
'--cores',
type=str,
default='24',
help='Number of cores(threads) to use to process data',
)
parser.add_argument(
'--mem',
type=str,
default='120',
help='GB of memory to use to process data',
)
parser.add_argument(
'--pre_mRNA',
type=str,
default=False,
help='Whether this is a "pre_mRNA" count job',
)
parser.add_argument(
'--account',
type=str,
default="warrenlab",
help='SLURM account towards which time should be debited',
)
args = parser.parse_args()
main(args)