forked from DaehwanKimLab/hisat-genotype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhisatgenotype
executable file
·773 lines (681 loc) · 30.4 KB
/
hisatgenotype
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
#!/usr/bin/env python
# --------------------------------------------------------------------------- #
# Copyright 2017, Daehwan Kim <infphilo@gmail.com> #
# #
# This file is part of HISAT-genotype. The purpose of this script is to wrap #
# the main functions if HISAT-genotype into a usable pipeline. #
# #
# HISAT-genotype is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# HISAT-genotype is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with HISAT-genotype. If not, see <http://www.gnu.org/licenses/>. #
# --------------------------------------------------------------------------- #
import sys
import os
import subprocess
import re
import datetime
import traceback
import glob
import multiprocessing
import random
import hisatgenotype_args as arguments
import hisatgenotype_typing_common as typing_common
from datetime import datetime, date, time
from argparse import ArgumentParser, FileType
from hisatgenotype_typing_core import genotyping_locus
from hisatgenotype_typing_process import extract_reads, extract_vars
# --------------------------------------------------------------------------- #
# Auxillary functions for wraper script #
# --------------------------------------------------------------------------- #
""" Build Namespace to hold combine set of Arguments: Necessary due to arg """
class Namespace:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def __repr__(self):
keys = sorted(self.__dict__)
items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys)
return "{}({})".format(type(self).__name__, ", ".join(items))
def __eq__(self, other):
return self.__dict__ == other.__dict__
""" Initialize Global lock for use with multithread processes """
def init(l):
global lock
lock = l
l = multiprocessing.Lock()
# --------------------------------------------------------------------------- #
# Base functions to ensuring proper files are present for HISATgenotype #
# --------------------------------------------------------------------------- #
""" Extract Variants from hisatgenotype database """
def run_vars(base_fname,
ix_dir,
threads,
locus_list,
inter_gap,
intra_gap,
whole_haplotype,
min_var_freq,
ext_seq_len,
leftshift,
partial,
verbose):
# Clone hisatgenotype database from git
typing_common.clone_hisatgenotype_database(ix_dir)
if not base_fname:
base_fname = []
for database in os.listdir("%s/hisatgenotype_db" % ix_dir):
database = database.split("/")[-1]
if database in ['.git', 'README.md']:
continue
base_fname.append(database.lower())
pool = multiprocessing.Pool(int(threads), initializer=init, initargs=(l,))
for base in base_fname:
err = pool.apply_async(extract_vars,
args=(base,
ix_dir,
locus_list,
inter_gap,
intra_gap,
whole_haplotype,
min_var_freq,
ext_seq_len,
leftshift,
partial,
verbose))
err.get()
pool.close()
pool.join()
# --------------------------------------------------------------------------- #
# Main functions for handling exsisting bam files/alignments #
# --------------------------------------------------------------------------- #
""" Need to index the bam file """
def index_bam(bam_fname,
verbose):
print("%s Indexing %s ..." % (str(datetime.now()), bam_fname),
file=sys.stderr)
bamindex_cmd = ["samtools",
"index",
bam_fname]
if verbose:
print("\t%s" % ' '.join(bamindex_cmd),
file=sys.stderr)
bamindex_proc = subprocess.call(bamindex_cmd)
""" Builds read file from the SAM lines that overlap the locus regions """
def reads_from_bam(bam_fname,
out_read_dname,
chr,
left,
right,
read_base_fname, # sample => sample.1.fq.gz and sample.2.fq.gz
paired,
fastq,
verbose):
lock.acquire()
if not os.path.exists(out_read_dname):
os.mkdir(out_read_dname)
lock.release()
read_fnames = []
if paired:
read_fnames = [out_read_dname + "/" + read_base_fname + "-extracted-1.fq.gz",
out_read_dname + "/" + read_base_fname + "-extracted-2.fq.gz"]
else:
read_fnames = [out_read_dname + "/" + read_base_fname + "-extracted.fq.gz"]
if paired:
gzip1_proc = subprocess.Popen(["gzip"],
stdin=subprocess.PIPE,
stdout=open(read_fnames[0], 'w'),
stderr=open("/dev/null", 'w'))
gzip2_proc = subprocess.Popen(["gzip"],
stdin=subprocess.PIPE,
stdout=open(read_fnames[1], 'w'),
stderr=open("/dev/null", 'w'))
else:
gzip1_proc = subprocess.Popen(["gzip"],
stdin=subprocess.PIPE,
stdout=open(read_fnames[0], 'w'),
stderr=open("/dev/null", 'w'))
def write_read(gzip_proc, read_name, seq, qual):
if fastq:
gzip_proc.stdin.write("@%s\n" % read_name)
gzip_proc.stdin.write("%s\n" % seq)
gzip_proc.stdin.write("+\n")
gzip_proc.stdin.write("%s\n" % qual)
else:
gzip_proc.stdin.write(">%s\n" % prev_read_name)
gzip_proc.stdin.write("%s\n" % seq)
bamview_cmd = ["samtools",
"view",
bam_fname,
"%s:%d-%d" % (chr, left+1, right+1)]
if verbose:
print("\t%s" % ' '.join(bamview_cmd), file=sys.stderr)
bamview_proc = subprocess.Popen(bamview_cmd,
stdout=subprocess.PIPE,
stderr=open("/dev/null", 'w'))
sort_read_cmd = ["sort", "-k", "1,1", "-s"] # -s for stable sorting
alignview_proc = subprocess.Popen(sort_read_cmd,
stdin=bamview_proc.stdout,
stdout=subprocess.PIPE,
stderr=open("/dev/null", 'w'))
prev_read_name = ""
extract_read = False
read1 = []
read2 = []
for line in alignview_proc.stdout:
if line.startswith('@'):
continue
line = line.strip()
cols = line.split()
read_name, flag, chr, pos, mapQ, cigar, _, _, _, read, qual = cols[:11]
flag, pos = int(flag), int(pos)
strand = '-' if flag & 0x10 else '+'
AS, NH = "", ""
for i in range(11, len(cols)):
col = cols[i]
if col.startswith("AS"):
AS = int(col[5:])
elif col.startswith("NH"):
NH = int(col[5:])
if NH == 1:
extract_read = True
if flag & 0x40 or not paired: # left read
if not read1:
if flag & 0x10: # reverse complement
read1 = [typing_common.reverse_complement(read), qual[::-1]]
else:
read1 = [read, qual]
else:
assert flag & 0x80 # right read
if flag & 0x10: # reverse complement
read2 = [typing_common.reverse_complement(read), qual[::-1]]
else:
read2 = [read, qual]
if extract_read:
if paired:
if len(read1) == 2 and len(read2) == 2:
write_read(gzip1_proc, prev_read_name, read1[0], read1[1])
write_read(gzip2_proc, prev_read_name, read2[0], read2[1])
else:
write_read(gzip1_proc, prev_read_name, read1[0], read1[1])
gzip1_proc.stdin.close()
if paired:
gzip2_proc.stdin.close()
return read_fnames
""" Extract reads from BAM alignment files in range of locus """
def extract_bam(file_lists,
base,
ix_dir,
out_dir,
target_locus_list,
fastq,
paired,
alignment_fname,
aligner,
verbose):
full_base = ix_dir + "/" + base
# variants, backbone sequence, and other sequeces
if not typing_common.check_base(base, aligner, ix_dir):
sys.exit(1)
# Read locus alleles (names and sequences)
regions = {}
region_loci = {}
for line in open("%s.locus" % full_base):
family, allele_name, chr, left, right = line.strip().split()[:5]
family = family.lower()
if len(target_locus_list) > 0 \
and family not in target_locus_list:
continue
locus_name = allele_name.split('*')[0]
if family in target_locus_list \
and len(target_locus_list[family]) > 0 \
and locus_name not in target_locus_list[family]:
continue
left = int(left)
right = int(right)
if family not in region_loci:
region_loci[family] = []
region_loci[family].append([locus_name, allele_name, chr, left, right])
if len(region_loci) <= 0:
print("Warning: no loci exists!", file=sys.stderr)
sys.exit(1)
# Sort the BAM file
assert alignment_fname != "" and os.path.exists(alignment_fname)
if not os.path.exists(alignment_fname + ".bai"):
index_bam(alignment_fname,
verbose)
assert os.path.exists(alignment_fname + ".bai")
# Extract reads and perform genotyping
for family, loci in region_loci.items():
for locus_name, allele_name, chr, left, right in loci:
out_read_fname = "%s.%s" % (family, locus_name)
if verbose:
print("\tExtracting reads beloning to %s-%s ..." % \
(family, locus_name), file=sys.stderr)
extracted_read_fnames = reads_from_bam(alignment_fname,
out_dir,
chr,
left,
right,
out_read_fname,
paired,
fastq,
verbose)
lock.acquire()
if family not in file_lists:
file_lists.update({ family : [] })
file_lists[family].append(out_read_fname)
lock.release()
print("\n", file=sys.stderr)
# --------------------------------------------------------------------------- #
# Main function for typing. Requires all arguments in a Namespace that can #
# be parsed #
# --------------------------------------------------------------------------- #
def typing_process(args):
""" Set-up: Everything in section is required """
# Begin parsing bases and locus lists into a single variable: region_list
region_list = {}
if args.base_fname != "":
args.base_fname = args.base_fname.lower().split(',')
else:
args.base_fname = []
if args.locus_list != "" :
args.locus_list = args.locus_list.upper().split(';')
else:
args.locus_list = []
if (len(args.base_fname) != len(args.locus_list)) and args.locus_list:
print("Error: --base and --locus-list not correct format \
(ex. --base hla,rbg --locus-list A,B,C;ABO,RHD)",
file=sys.stderr)
exit(1)
for itr in range(len(args.base_fname)):
family = args.base_fname[itr]
if args.locus_list:
loci_names = args.locus_list[itr].split(',')
else:
loci_names = []
region_list.update({ family : loci_names })
# Confirm correct aligner and set block_size
if args.aligner not in ["hisat2", "bowtie2"]:
print("Error: --aligner should be either hisat2 or bowtie2.",
file=sys.stderr)
sys.exit(1)
block_size = 20000000 if args.extract_whole else 0
# set only_locus_list filter for extracting the database
# (used in typing_common.extract_database_if_not_exists)
if args.only_locus_list == "":
only_locus_list = []
else:
if len(args.base_fname) != 1:
only_locus_list = args.only_locus_list.split(',')
if args.verbose and args.verbose_level == 0:
args.verbose_level = 1
# Parse debug options and parameters
debug = {}
debug_opts = set(["basic", # Run only single alleles
"full", # Run only full alleles
"pair", # Pair alleles
"test_list", # Give list of allele pairs to test
"test_id", # Only run Test IDs in this list
"single-end", # Use single end synthetic reads
"set_seed", # Set seed for random selection
"test_size"]) # Set size of test to run
if args.debug != "":
for item in args.debug.split(','):
if ':' in item:
fields = item.split(':')
assert len(fields) >= 2
key, value = fields[0], ':'.join(fields[1:])
else:
key = item
value = None
if key not in debug_opts:
print("Warning: %s not valid option for debug" % key,
file=sys.stderr)
exit(1)
debug[key] = value
# Advanced setting alerts for users
if not args.partial:
print("Warning: --no-partial is recommended for debugging purpose only",
file=sys.stderr)
if args.read_len * 2 > args.fragment_len:
print("Warning: fragment might be too short (%d)" % (args.fragment_len),
file=sys.stderr)
skip_fragment_regions = []
if args.skip_fragment_regions != "":
prev_left = -1
prev_right = -1
for region in args.skip_fragment_regions.split(','):
left, right = region.split('-')
left = int(left)
right = int(right)
assert left < right
assert prev_right < left
prev_left = left
prev_right = right
skip_fragment_regions.append([left, right])
# Set display alleles for assembly
if args.display_alleles == "":
display_alleles = []
else:
display_alleles = args.display_alleles.split(',')
# Critical since this will preserve the input files
# after bypass of read extraction
if args.already_extract:
args.keep_extract = True
# Set default output and make final changes before beginning
if args.out_dir == ".":
args.out_dir += "/hisatgenotype_out"
if not args.ix_dir:
args.ix_dir = "."
if not os.path.exists(args.out_dir):
os.makedirs(args.out_dir)
if not os.path.exists(args.ix_dir):
print("Error: Index directory %s not found") % args.ix_dir
exit(1)
if args.ix_dir[-1] == "/":
args.ix_dir = args.ix_dir[:-1]
if args.read_dir:
if '/' != args.read_dir[-1]:
args.read_dir += '/'
""" Read Extraction: Optional selection performed by default """
is_bam = False
single_run = False
paired = args.paired
read_fnames = []
fq_fname_base = {}
if args.debug == "":
if args.read_fname_U != "":
read_fnames = ['%s%s' % (args.read_dir, args.read_fname_U)]
single_run = True
paired = False
args.discordant = True
elif args.read_fname_1 != "" or args.read_fname_2 != "":
if args.read_fname_1 == "" or args.read_fname_2 == "":
print("Error: please specify both -1 and -2.",
file=sys.stderr)
sys.exit(1)
read_fnames = ['%s%s' % (args.read_dir, args.read_fname_1),
'%s%s' % (args.read_dir, args.read_fname_2)]
single_run = True
if not paired:
print("Warning! Using --single-end with -1 and -2 options. "\
"Ignoring!")
paired = True
elif args.alignment_fname != "":
alignment_fnames = ['%s%s' % (args.read_dir, args.alignment_fname)]
is_bam = True
else:
if args.read_dir == '' or not os.path.exists(args.read_dir):
print("Error: please specify read file names correctly: \
-U or -1 and -2 or --bamfile or --read-dir",
file=sys.stderr)
sys.exit(1)
alignment_fnames = glob.glob("./%s/*.bam" % (args.read_dir))
is_bam = True if alignment_fnames else False
if not args.already_extract:
# Geno_genome is only needed for extract reads
if args.genotype_genome != '':
geno_genome = args.genotype_genome
else:
geno_genome = 'genotype_genome'
if not is_bam:
job_range = []
for num in args.job_range.split(','):
job_range.append(int(num))
fq_fname_base = extract_reads(geno_genome,
args.ix_dir,
args.base_fname,
"" if single_run else args.read_dir,
args.out_dir,
args.suffix,
read_fnames,
args.fastq,
paired,
args.simulation,
args.threads,
args.threads_aprocess,
args.max_sample,
job_range,
args.aligner,
block_size,
args.verbose)
else:
pool = multiprocessing.Pool(int(args.threads),
initializer=init,
initargs=(l,))
for bam_file in alignment_fnames:
err = pool.apply_async(extract_bam,
args = (fq_fname_base,
geno_genome,
args.ix_dir,
args.out_dir,
region_list,
args.fastq,
args.paired,
args.alignment_fname,
args.aligner,
args.verbose))
err.get()
pool.close()
pool.join()
else:
_, _, filename_base = typing_common.get_filename_match(read_fnames)
for base in args.base_fname:
fq_fname_base[base] = filename_base
assert fq_fname_base
""" Genotyping: Core of HISATgenotype """
if ',' not in args.aligner and '.' not in args.aligner:
if args.graph_index:
args.aligner += '.graph'
else:
args.aligner += '.linear'
args.aligner = args.aligner.split(',')
for i in range(len(args.aligner)):
args.aligner[i] = args.aligner[i].split('.')
if args.force_build_index:
run_vars(args.base_fname,
args.ix_dir,
args.threads,
[], # Empty Locus-list
args.inter_gap,
args.intra_gap,
args.whole_haplotype,
args.min_var_freq,
args.ext_seq_len,
args.leftshift,
args.partial,
args.verbose)
if not region_list:
region_list.update({ "ALL" : "ALL" })
discard_list = set()
random.seed(args.random_seed) # TODO Find other instances and remove/replace with debug
if not fq_fname_base:
if args.debug == '':
print("No --debug or -U -1 -2 --in-dir options set",
file=sys.stderr)
exit(1)
for base, loci in region_list.items():
if base == "ALL":
base = []
loci = []
genotyping_locus(base,
loci if not only_locus_list else only_locus_list,
args.genotype_genome,
args.ix_dir,
only_locus_list,
args.partial,
args.aligner,
read_fnames,
args.fastq,
args.alignment_fname,
args.threads,
args.simulate_interval,
args.read_len,
args.fragment_len,
args.best_alleles,
args.num_editdist,
args.perbase_errorrate,
args.perbase_snprate,
skip_fragment_regions,
args.assembly,
args.output_base,
args.error_correction,
args.keep_alignment,
args.discordant,
args.type_primary_exons,
args.remove_low_abundance_alleles,
display_alleles,
args.verbose_level,
args.assembly_verbose,
args.out_dir,
args.output_allele_counts,
debug)
else:
log = {} # build log to capture errors
pool = multiprocessing.Pool(int(args.threads),
initializer=init,
initargs=(l,))
for base, file_list in fq_fname_base.items():
for fname in file_list:
entry = base # naming for log
if args.already_extract:
fasta_fname = glob.glob("%s*" % (fname))
else:
fasta_fname = glob.glob("%s/%s*" % (args.out_dir, fname))
assert len(fasta_fname) < 3, "Too many files found"
for fn in fasta_fname:
entry = entry + ' ' + fn.split('/')[-1]
discard_list.add(fn)
locus_list = region_list[base] if "ALL" not in region_list else []
log[entry] = pool.apply_async(
genotyping_locus,
args = (base,
locus_list,
args.genotype_genome,
args.ix_dir,
only_locus_list,
args.partial,
args.aligner,
fasta_fname,
args.fastq,
args.alignment_fname,
args.threads_aprocess,
args.simulate_interval,
args.read_len,
args.fragment_len,
args.best_alleles,
args.num_editdist,
args.perbase_errorrate,
args.perbase_snprate,
skip_fragment_regions,
args.assembly,
args.output_base,
args.error_correction,
args.keep_alignment,
args.discordant,
args.type_primary_exons,
args.remove_low_abundance_alleles,
display_alleles,
args.verbose_level,
args.assembly_verbose,
args.out_dir,
args.output_allele_counts,
debug)
)
# Generate Log files for errors
pool.close()
runtime = str(date.today())
ofnlog = open("%s_hisat-genotype.log" % (runtime), 'w')
for entry, x in log.items():
ofnlog.write('> Base and Files:' + entry + '\n')
try:
ofnlog.write(str(x.get()))
except Exception:
err_msg = traceback.format_exc()
ofnlog.write(err_msg)
ofnlog.write('\n')
ofnlog.close()
pool.join()
if not args.keep_extract:
for fname in discard_list:
os.remove(fname)
# --------------------------------------------------------------------------- #
# Full Wrapper of HISATgenotype to enter script and options #
# --------------------------------------------------------------------------- #
if __name__ == '__main__':
version_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1])
try:
h2_v = open(version_dir + "/hisat2/VERSION", "r").read().strip()
hg_v = open(version_dir + "/VERSION", "r").read().strip()
version_info = [h2_v, hg_v]
except:
version_info = ['', '']
parser = ArgumentParser(
description='HISAT-Genotype %s (Built on HISAT2 %s)' \
% (version_info[1], version_info[0]),
epilog='See --advanced-help for further options available')
arguments.args_databases(parser,
genome=True, # Add option to change genome name
location=True) # Add option to set location
arguments.args_aligner_inputs(parser,
keep=True) # Add option to keep alignments
arguments.args_input_output(parser)
arguments.args_bamfile(parser)
parser.add_argument('--pass-extract',
dest='already_extract',
action='store_true',
help='Skip read extraction if the read files '\
'input are already extracted by --base')
parser.add_argument('--output-allele-counts',
dest='output_allele_counts',
action='store_true',
help='Output all allele read counts for each gene in '\
'report file.')
arguments.args_single_end(parser)
arguments.args_assembly(parser)
arguments.args_common(parser)
### Advanced parser information
parser_advanced = ArgumentParser(
description='Advanced Options',
add_help=False)
parser_advanced.add_argument('--advanced-help',
action='help',
help='Show Advanced Options')
parser_advanced.add_argument('--keep-extract',
dest='keep_extract',
action='store_true',
help='Keep extracted fastq read files')
parser_advanced.add_argument('--force-build-base',
dest='force_build_index',
action='store_true',
help='Build the indexes listed in --base-fname')
arguments.args_set_aligner(parser_advanced)
arguments.args_var_gaps(parser_advanced)
arguments.args_extract_vars(parser_advanced)
arguments.args_extract_reads(parser_advanced)
arguments.args_no_partial(parser_advanced)
arguments.args_locus(parser_advanced)
parser_advanced.add_argument("--debug",
dest="debug",
type=str,
default="",
help="Test database or code (options: basic, " \
"pair, full, single-end, test_list,"\
"test_id)(e.g., test_id:10,basic)")
## Setup arguments into a new namespace for parsing
arg_dict = {}
unknown = []
args2, unused = parser_advanced.parse_known_args()
args1 = parser.parse_args(unused)
arg_dict.update(vars(args1))
arg_dict.update(vars(args2))
args = Namespace(**arg_dict)
typing_process(args)