-
Notifications
You must be signed in to change notification settings - Fork 5
/
RNAseq
139 lines (116 loc) · 3.7 KB
/
RNAseq
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
#!/usr/bin/env python
import argparse
import os
import sys
import pandas as pd
import config
#from metapi import config
workflow_steps = [
"trimming_fastp",
"multiqc_fastp",
"kraken2_bracken",
"rmHost",
"sortmerna",
"kraken2x",
"metaphlan2",
"all"
]
def initialization(args):
if args.workdir:
project = config.metaconfig(args.workdir)
print(project.__str__())
project.create_dirs()
configuration, cluster = project.get_config()
if args.samples:
configuration["params"]["samples"] = args.samples
else:
print("please supply a samples list!")
if args.queue:
cluster["__default__"]["queue"] = args.queue
if args.project:
cluster["__default__"]["project"] = args.project
config.update_config(
project.config_file, project.new_config_file, configuration, remove=False)
config.update_config(
project.cluster_file,
project.new_cluster_file,
cluster,
remove=False)
else:
print("please supply a workdir!")
sys.exit(1)
def workflow(args):
if args.workdir:
config_file = os.path.join(args.workdir, "config.yaml")
configuration = config.parse_yaml(config_file)
if not os.path.exists(configuration["params"]["samples"]):
print("please specific samples list on initialization step")
sys.exit(1)
else:
print("please supply a workdir!")
sys.exit(1)
snakecmd = "snakemake --snakefile %s --configfile %s --until %s" % (
configuration["snakefile"], configuration["configfile"], args.step)
print(snakecmd)
def main():
parser = argparse.ArgumentParser(
prog='RNAseq',
usage='RNAseq [subcommand] [options]',
description='RNAseq, a pipeline to process RNA data')
parser.add_argument(
'-v',
'--version',
action='store_true',
default=False,
help='print software version and exit')
parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument(
'-d', '--workdir', type=str, metavar='<str>', help='project workdir')
subparsers = parser.add_subparsers(
title='available subcommands', metavar='')
parser_init = subparsers.add_parser(
'init',
parents=[parent_parser],
prog='RNAseq init',
description='project initialization',
help='project initialization')
parser_workflow = subparsers.add_parser(
"commandline",
parents=[parent_parser],
prog="main_command_line",
description="main command line ",
help="print a command line"
)
parser_init.add_argument(
'-q', '--queue', default='st.q', help='cluster queue')
parser_init.add_argument(
'-p', '--project', default='st.m', help='project id')
parser_init.add_argument('-s', '--samples', help='raw fastq samples list')
parser_init._optionals.title = 'arguments'
parser_init.set_defaults(func=initialization)
parser_workflow.add_argument(
"-u",
"--step",
type=str,
choices=workflow_steps,
default="checkm",
help="run step",
)
#parser_workflow.add_argument(
# "-t",
# "--threads",
# help="threads",
#)
parser_workflow._optionals.title = 'arguments'
parser_workflow.set_defaults(func=workflow)
args = parser.parse_args()
try:
if args.version:
print("RNAseq version %s" % __version__)
sys.exit(0)
args.func(args)
except AttributeError as e:
print(e)
parser.print_help()
if __name__ == '__main__':
main()