-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannovar_tools.py
executable file
·76 lines (63 loc) · 3.65 KB
/
annovar_tools.py
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
#! /usr/bin/env python3
import argparse
from process_annovar import avinput_to_vcf, avinput_to_bed, split_annovar_by_gene, add_cnv_entrez_id, check
def vcf_parser(subparsers):
sub_parser = subparsers.add_parser('vcf', help='convert snv avinput to vcf')
sub_parser.add_argument('--avinput', '-i', help='avinput infile')
sub_parser.add_argument('--reference', '-r', help='reference fasta')
sub_parser.add_argument('--vcf', '-o', help='vcf outfile')
sub_parser.set_defaults(func=lambda args: avinput_to_vcf(avinput=args.avinput, reference=args.reference, vcf=args.vcf))
def bed_parser(subparsers):
sub_parser = subparsers.add_parser('bed', help='convert cnv avinput to bed')
sub_parser.add_argument('--avinput', '-i', help='avinput infile')
sub_parser.add_argument('--bed', '-o', help='vcf outfile')
sub_parser.set_defaults(func=lambda args: avinput_to_bed(avinput=args.avinput, bed=args.bed))
def split_parser(subparsers):
sub_parser = subparsers.add_parser('split', help='split annovar result by gene')
sub_parser.add_argument('--avoutput', '-i', required=True, help='avoutput infile')
sub_parser.add_argument('--gene_based', '-g', required=True, help='the gene_based name of annovar, this execute will split annovar result by this gene_based')
sub_parser.add_argument('--outfile', '-o', required=True, help='the split outfile')
sub_parser.add_argument('--refgenes', '-r', required=True, action="append", help='refgene files')
sub_parser.add_argument('--gene2refseq', '-m', help='gene2refseq file')
sub_parser.add_argument('--ncbi_gene_info', '-n', help='ncbi gene info file')
sub_parser.add_argument('--gene_hgnc_name', '-x', help='(mito) gene hgnc name file')
sub_parser.set_defaults(func=lambda args: split_annovar_by_gene(
avoutput=args.avoutput,
gene_based=args.gene_based,
outfile=args.outfile,
refgenes=args.refgenes,
ncbi_gene_info=args.ncbi_gene_info,
gene2refseq=args.gene2refseq,
gene_hgnc_name=args.gene_hgnc_name
))
def cnv_parser(subparsers):
sub_parser = subparsers.add_parser('cnv', help='split annovar result by gene')
sub_parser.add_argument('--avoutput', '-i', required=True, help='avoutput infile')
sub_parser.add_argument('--colnames', '-c', required=True, action="append", help='the colnames in annovar output need add entrez_id')
sub_parser.add_argument('--outfile', '-o', required=True, help='the split outfile')
sub_parser.add_argument('--refgenes', '-r', required=True, action="append", help='refgene files')
sub_parser.add_argument('--gene2refseq', '-m', help='gene2refseq file')
sub_parser.add_argument('--ncbi_gene_info', '-n', help='ncbi gene info file')
sub_parser.set_defaults(func=lambda args: add_cnv_entrez_id(
avoutput=args.avoutput,
colnames=args.colnames,
outfile=args.outfile,
refgenes=args.refgenes,
ncbi_gene_info=args.ncbi_gene_info,
gene2refseq=args.gene2refseq
))
def check_parser(subparsers):
sub_parser = subparsers.add_parser('check', help='check avoutput format')
sub_parser.add_argument('--input', '-i', required=True, help='avoutput infile')
sub_parser.add_argument('--output', '-o', required=True, help='avoutput outfile')
sub_parser.set_defaults(func=lambda args: check(input=args.input, output=args.output))
if __name__ == '__main__':
parser = argparse.ArgumentParser('ANNOVAR tools')
subparsers = parser.add_subparsers(help='ANNOVAR tools')
vcf_parser(subparsers)
bed_parser(subparsers)
split_parser(subparsers)
cnv_parser(subparsers)
check_parser(subparsers)
args = parser.parse_args()
args.func(args)