forked from budkina/VirIdAl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_arguments.py
More file actions
152 lines (137 loc) · 6.98 KB
/
Copy pathparse_arguments.py
File metadata and controls
152 lines (137 loc) · 6.98 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
150
151
152
import argparse
import json
def parse_command_line():
"""Parse command line arguments"""
parser = argparse.ArgumentParser(prog='main.py', formatter_class=argparse.RawTextHelpFormatter)
general_group = parser.add_argument_group('General')
# Input files commands
general_group.add_argument('--unpaired',
help='Input fastq name (unpaired)')
general_group.add_argument('--forward',
help='Input fastq name (paired-end, forward)')
general_group.add_argument('--reverse',
help='Input fastq name (paired-end, reverse)')
general_group.add_argument('--input_dir',
help='Path to input folder, default: "/input/" for docker image',
default='/input/')
general_group.add_argument('--load_config',
help='Use JSON file for configuration (overwrites command line parameters)',
action='store_true')
general_group.add_argument('--config',
help='JSON config file path, default: "/input/config.json" for docker image',
default='/input/config.json')
general_group.add_argument('--steps',
help='Set of steps to perform in analysis (default: merging qc filter cluster virus_search):\n'+
'\tmerging: Paired-end reads merging using fastp, always performed\n'+
'\tqc: Quality filtering using fastp\n'+
'\tfilter: Filter fastq by mapping reads on the reference genomes using bowtie2\n'+
'\tcluster: Fasta file clusterization using vsearch\n'+
'\tvirus_search: Search for virus sequences, always performed\n'+
'\tadditional_search: Search for sequences that were not identified at virus_search step\n'+
'\tall: Perform all steps',
nargs='+',
default=['qc', 'merging', 'filter', 'cluster', 'virus_search'])
# Output files commands
general_group.add_argument('--output_dir',
help='Path to output folder, default: "/output/" for docker image',
default='/output/')
# Other commands
general_group.add_argument('--num_threads',
help='Number of threads',
default="1")
general_group.add_argument('--keep_temp',
help='Keep temporary files in output folder, default: false',
action='store_true')
# Merging commands
merge_group = parser.add_argument_group('Merging (fastp)')
merge_group.add_argument('--save_unmerged',
help="Save unmerged reads for processing, default disabled",
action='store_true')
# Quality control commands
qc_group = parser.add_argument_group('Quality control (fastp)')
qc_group.add_argument('--adapters',
help='Path to the file with the adapter sequences for fastp, default: /input/adapters.fa for docker image',
default="/input/adapters.fa")
qc_group.add_argument('--average_qual',
help='Quality score mean threshold for filtering with fastp, default: 20',
default=20)
qc_group.add_argument('--min_len',
help='Filter sequences shorter than min_len, default 36',
default=36)
qc_group.add_argument('--complexity_threshold',
help='The threshold value (between 0 and 100) for filtering low complexity sequence reads, default: 30',
default=30)
qc_group.add_argument('--cut_front',
help="Move a sliding window from 5' to 3', drop the bases in the window if its mean quality is below cut_mean_quality, default disabled",
action='store_true')
qc_group.add_argument('--cut_tail',
help="Move a sliding window from 3' to 5', drop the bases in the window if its mean quality is below cut_mean_quality, default disabled",
action='store_true')
qc_group.add_argument('--cut_right',
help="move a sliding window from 5' to 3', if meet one window with mean quality < threshold, drop the bases in the window and the right part, default disabled",
action='store_true')
qc_group.add_argument('--cut_window_size',
help="The window size option, default 4",
default=4)
qc_group.add_argument('--cut_mean_quality',
help='The mean quality requirement option by cut_front, cut_tail, and cut_right, default 20',
default=20)
# Filtering commands
filtering_group = parser.add_argument_group('Filtering')
filtering_group.add_argument('--ref_names',
help='Reference genomes for filtering from database folder, default=[]', nargs='+', default=[])
# Clustering commands
clustering_group = parser.add_argument_group('Clustering')
clustering_group.add_argument('--identity',
help='Sequence identity threshold for clustering using vsearch, default: 0.9',
default="0.9")
# Search commands
search_group = parser.add_argument_group('Search')
search_group.add_argument('--virus_search_s1_evalue_n',
help='Megablast search evalue threshold for virus search step 1, default = 1e-3',
default="1e-3")
search_group.add_argument('--virus_search_s1_evalue_p',
help='Diamond search evalue threshold for virus search step 1, default = 1e-3',
default="1e-3")
search_group.add_argument('--virus_search_s2_evalue_n',
help='Megablast search evalue threshold for virus search step 2, default = 1e-10',
default="1e-10")
search_group.add_argument('--virus_search_s2_evalue_p',
help='Diamond search evalue threshold for virus search step 2, default = 1e-10',
default="1e-10")
search_group.add_argument('--additional_search_evalue_n',
help='Megablast evalue threshold for additional search stage, default = 1e-10',
default="1e-10")
search_group.add_argument('--additional_search_evalue_p',
help='Diamond evalue threshold for additional search stage, default = 1e-10',
default="1e-10")
search_group.add_argument('--virus_nucl_db_name',
default='virus_nucl',
help='Nucleotide database with virus sequences, default: virus_nucl')
search_group.add_argument('--virus_prot_db_name',
default='virus_prot_diamond',
help='Protein database with virus sequences, default: virus_prot_diamond')
search_group.add_argument('--nucl_db_name',
default='nt',
help='Nucleotide database with various sequences for search, default: nt')
search_group.add_argument('--prot_db_name',
default='nr_diamond',
help='Protein database with various sequences for search, default: nr_diamond')
search_group.add_argument('--db_dir',
help='Full path to database folder, default: "/database/" for docker image',
default='/database/')
return parser.parse_args()
def get_arguments():
# get arguments from command line
args_namespace = parse_command_line()
args = vars(args_namespace)
# read configuartion file if specified
if args_namespace.load_config:
json_dict = {}
with open(args_namespace.config) as json_file:
json_dict = json.load(json_file)
# overwrite configurations from config
for argument in args:
if argument in json_dict:
args[argument] = json_dict[argument]
return args