Mercurial > repos > iuc > ivar_consensus
annotate ivar_variants_to_vcf.py @ 16:17f911830a8c draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
author | iuc |
---|---|
date | Tue, 27 Jun 2023 17:14:55 +0000 |
parents | 3bc2ef3d4a17 |
children |
rev | line source |
---|---|
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
2 import argparse |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
3 import errno |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
4 import os |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
5 import re |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
6 import sys |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
7 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
8 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
9 def parse_args(args=None): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
10 Description = "Convert iVar variants tsv file to vcf format." |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
11 Epilog = """Example usage: python ivar_variants_to_vcf.py <FILE_IN> <FILE_OUT>""" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
12 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
13 parser = argparse.ArgumentParser(description=Description, epilog=Epilog) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
14 parser.add_argument("FILE_IN", help="Input tsv file.") |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
15 parser.add_argument("FILE_OUT", help="Full path to output vcf file.") |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
16 parser.add_argument( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
17 "-po", |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
18 "--pass_only", |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
19 dest="PASS_ONLY", |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
20 help="Only output variants that PASS all filters.", |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
21 action="store_true", |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
22 ) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
23 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
24 return parser.parse_args(args) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
25 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
26 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
27 def make_dir(path): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
28 if not len(path) == 0: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
29 try: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
30 os.makedirs(path) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
31 except OSError as exception: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
32 if exception.errno != errno.EEXIST: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
33 raise |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
34 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
35 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
36 def info_line(info_keys, kv): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
37 info_strings = [] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
38 for key in info_keys: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
39 if key not in kv: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
40 raise KeyError( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
41 'Expected key {} missing from INFO field key value pairs' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
42 .format(key) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
43 ) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
44 if kv[key] is False: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
45 # a FLAG element, which should not be set |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
46 continue |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
47 if kv[key] is True: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
48 # a FLAG element => write the key only |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
49 info_strings.append(key) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
50 else: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
51 info_strings.append('{}={}'.format(key, kv[key])) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
52 return ';'.join(info_strings) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
53 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
54 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
55 def ivar_variants_to_vcf(FileIn, FileOut, passOnly=False): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
56 filename = os.path.splitext(FileIn)[0] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
57 header = ( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
58 "##fileformat=VCFv4.2\n" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
59 "##source=iVar\n" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
60 '##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
61 '##INFO=<ID=REF_DP,Number=1,Type=Integer,Description="Depth of reference base">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
62 '##INFO=<ID=REF_RV,Number=1,Type=Integer,Description="Depth of reference base on reverse reads">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
63 '##INFO=<ID=REF_QUAL,Number=1,Type=Integer,Description="Mean quality of reference base">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
64 '##INFO=<ID=ALT_DP,Number=1,Type=Integer,Description="Depth of alternate base">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
65 '##INFO=<ID=ALT_RV,Number=1,Type=Integer,Description="Deapth of alternate base on reverse reads">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
66 '##INFO=<ID=ALT_QUAL,Number=1,Type=Integer,Description="Mean quality of alternate base">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
67 '##INFO=<ID=AF,Number=1,Type=Float,Description="Frequency of alternate base">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
68 '##INFO=<ID=INDEL,Number=0,Type=Flag,Description="Indicates that the variant is an INDEL.">\n' |
16
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
69 '##INFO=<ID=DP4,Number=4,Type=Integer,Description="Counts for ref-forward bases, ref-reverse, alt-forward and alt-reverse bases">' |
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
70 '##FILTER=<ID=PASS,Description="Result of p-value <= 0.05">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
71 '##FILTER=<ID=FAIL,Description="Result of p-value > 0.05">\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
72 ) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
73 info_keys = [ |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
74 re.match(r'##INFO=<ID=([^,]+),', line).group(1) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
75 for line in header.splitlines() |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
76 if line.startswith('##INFO=') |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
77 ] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
78 header += ( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
79 "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
80 ) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
81 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
82 vars_seen = set() |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
83 varCountDict = {"SNP": 0, "INS": 0, "DEL": 0} |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
84 OutDir = os.path.dirname(FileOut) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
85 make_dir(OutDir) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
86 with open(FileIn) as f, open(FileOut, "w") as fout: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
87 fout.write(header) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
88 for line in f: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
89 if line.startswith("REGION"): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
90 continue |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
91 |
16
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
92 # fields: |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
93 # 0 REGION |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
94 # 1 POS |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
95 # 2 REF |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
96 # 3 ALT |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
97 # 4 REF_DP |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
98 # 5 REF_RV |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
99 # 6 REF_QUAL |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
100 # 7 ALT_DP |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
101 # 8 ALT_RV |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
102 # 9 ALT_QUAL |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
103 # 10 ALT_FREQ |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
104 # 11 TOTAL_DP |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
105 # 12 PVAL |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
106 # 13 PASS |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
107 # 14 GFF_FEATURE |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
108 # 15 REF_CODON |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
109 # 16 REF_AA |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
110 # 17 ALT_CODON |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
111 # 18 ALT_AA |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
112 # 19 POS_AA |
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
113 line = line.split("\t") |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
114 CHROM = line[0] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
115 POS = line[1] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
116 ID = "." |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
117 REF = line[2] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
118 ALT = line[3] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
119 if ALT[0] == "+": |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
120 ALT = REF + ALT[1:] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
121 var_type = "INS" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
122 elif ALT[0] == "-": |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
123 REF += ALT[1:] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
124 ALT = line[2] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
125 var_type = "DEL" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
126 else: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
127 var_type = "SNP" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
128 QUAL = "." |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
129 pass_test = line[13] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
130 if pass_test == "TRUE": |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
131 FILTER = "PASS" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
132 else: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
133 FILTER = "FAIL" |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
134 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
135 if (passOnly and FILTER != "PASS"): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
136 continue |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
137 var = (CHROM, POS, REF, ALT) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
138 if var in vars_seen: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
139 continue |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
140 |
16
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
141 ref_dp = int(line[4]) |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
142 ref_dp_rev = int(line[5]) |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
143 ref_dp_fwd = ref_dp - ref_dp_rev |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
144 |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
145 alt_dp = int(line[7]) |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
146 alt_dp_rev = int(line[8]) |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
147 alt_dp_fwd = alt_dp - alt_dp_rev |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
148 |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
149 dp4 = f'{ref_dp_fwd},{ref_dp_rev},{alt_dp_fwd},{alt_dp_rev}' |
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
150 info_elements = { |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
151 'DP': line[11], |
16
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
152 'REF_DP': ref_dp, |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
153 'REF_RV': ref_dp_rev, |
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
154 'REF_QUAL': line[6], |
16
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
155 'ALT_DP': alt_dp, |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
156 'ALT_RV': alt_dp_rev, |
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
157 'ALT_QUAL': line[9], |
16
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
158 'AF': line[10], |
17f911830a8c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 9d25797b06335056930bddede98a2f3f9a303470
iuc
parents:
6
diff
changeset
|
159 'DP4': dp4 |
6
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
160 } |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
161 if var_type in ['INS', 'DEL']: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
162 # add INDEL FLAG |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
163 info_elements['INDEL'] = True |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
164 else: |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
165 info_elements['INDEL'] = False |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
166 INFO = info_line(info_keys, info_elements) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
167 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
168 vars_seen.add(var) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
169 varCountDict[var_type] += 1 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
170 fout.write( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
171 '\t'.join( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
172 [CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
173 ) + '\n' |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
174 ) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
175 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
176 # Print variant counts to pass to MultiQC |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
177 varCountList = [(k, str(v)) for k, v in sorted(varCountDict.items())] |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
178 print("\t".join(["sample"] + [x[0] for x in varCountList])) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
179 print("\t".join([filename] + [x[1] for x in varCountList])) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
180 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
181 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
182 def main(args=None): |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
183 args = parse_args(args) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
184 ivar_variants_to_vcf( |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
185 args.FILE_IN, args.FILE_OUT, args.PASS_ONLY |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
186 ) |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
187 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
188 |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
189 if __name__ == "__main__": |
3bc2ef3d4a17
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 847ec10cd36ea4f3cd4c257d5742f0fb401e364e"
iuc
parents:
diff
changeset
|
190 sys.exit(main()) |