-
Notifications
You must be signed in to change notification settings - Fork 0
/
scifi
executable file
·66 lines (53 loc) · 2.15 KB
/
scifi
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
#!/usr/bin/env python3
"""
The entry point to running the scifi_pipeline on several samples.
"""
import sys
from argparse import ArgumentParser
import subprocess
import pandas as pd
def main():
print("scifi-RNA-seq pipeline")
parser = ArgumentParser()
cmds = [
'trim', 'map', 'maketracks', 'filter', 'join',
'barcodes', 'fix',
'filter_corrected', 'join_corrected',
'report']
parser.add_argument("cmd", choices=cmds)
parser.add_argument("-d", "--dry-run", action="store_true")
_help = "Whether to only run samples marked with '1' in toggle column."
parser.add_argument("-t", "--toggle", action="store_true", help=_help)
_help = "Samples to subset. Comma delimited."
parser.add_argument("-s", "--samples", help=_help, default="")
parser.add_argument("annotation")
args = parser.parse_args()
args.samples = args.samples.split(",") if args.samples != "" else []
print(args)
df = pd.read_csv(args.annotation)
if args.toggle and "toggle" in df.columns:
df = df.query("toggle == 1")
if args.samples:
df = df.loc[df['sample_name'].isin(args.samples), :]
s = '\n\t - ' + '\n\t - '.join(df['sample_name'])
print(f"Samples to submit:{s}")
if args.dry_run:
print("Dry run, not submitting anything.")
return
for i, sample in df.iterrows():
print(f"Doing sample {sample['sample_name']}")
cmd = f"make {args.cmd} "
cmd += f"RUN_NAME={sample['sample_name']} "
cmd += f"FLOWCELL={sample['flowcell']} "
cmd += f"N_LANES={int(sample['nlanes'])} "
cmd += f"N_BARCODES={int(sample['nbarcodes'])} "
cmd += f"ANNOTATION={sample['annotation']} "
cmd += f"VARIABLES={sample['variables']} "
cmd += f"SPECIES_MIXING={int(sample['species_mixing'])} "
cmd += f"IS_MOUSE={1 if sample['organism']=='mouse' else 0}"
if not pd.isnull(sample['expected_cell_number']):
cmd += f" EXPECTED_CELL_NUMBER={int(sample['expected_cell_number'])}"
print(" \\\n".join(cmd.split(" ")) + "\n")
subprocess.Popen(cmd.split(" "))
if __name__ == "__main__":
sys.exit(main())