@@ -16,62 +16,59 @@ def in_frame(v):
16
16
return False
17
17
18
18
19
- class NanoporeFilter :
20
- def __init__ (self , no_frameshifts ):
19
+ class Clair3Filter :
20
+ def __init__ (self , no_frameshifts , min_depth ):
21
21
self .no_frameshifts = no_frameshifts
22
- pass
22
+ self .min_depth = min_depth
23
+ self .min_variant_quality = 10
23
24
24
25
def check_filter (self , v ):
25
- total_reads = float (v .INFO ["TotalReads" ])
26
26
qual = v .QUAL
27
- # strandbias = float(v.INFO["StrandFisherTest"])
28
27
29
- if qual / total_reads < 3 :
28
+ if qual < self . min_variant_quality :
30
29
return False
31
30
32
31
if self .no_frameshifts and not in_frame (v ):
33
32
return False
34
33
35
- if v .is_indel :
36
- strand_fraction_by_strand = v .INFO ["SupportFractionByStrand" ]
37
- if float (strand_fraction_by_strand [0 ]) < 0.5 :
38
- return False
39
-
40
- if float (strand_fraction_by_strand [1 ]) < 0.5 :
41
- return False
34
+ try :
35
+ # We don't really care about the depth here, just skip it if it isn't there
36
+ depth = v .INFO ["DP" ]
37
+ except KeyError :
38
+ depth = v .format ("DP" )[0 ][0 ]
42
39
43
- if total_reads < 20 :
40
+ if depth < self . min_depth :
44
41
return False
45
42
46
43
return True
47
44
48
45
49
- class MedakaFilter :
50
- def __init__ (self , no_frameshifts , min_depth , min_variant_quality ):
51
- self .no_frameshifts = no_frameshifts
52
- self .min_depth = min_depth
53
- self .min_variant_quality = min_variant_quality
46
+ # class MedakaFilter:
47
+ # def __init__(self, no_frameshifts, min_depth):
48
+ # self.no_frameshifts = no_frameshifts
49
+ # self.min_depth = min_depth
50
+ # self.min_variant_quality = 20
54
51
55
- def check_filter (self , v , min_depth ):
56
- try :
57
- # We don't really care about the depth here, just skip it if it isn't there
58
- depth = v .INFO ["DP" ]
59
- except KeyError :
60
- depth = v .format ("DP" )[0 ][0 ]
52
+ # def check_filter(self, v, min_depth):
53
+ # try:
54
+ # # We don't really care about the depth here, just skip it if it isn't there
55
+ # depth = v.INFO["DP"]
56
+ # except KeyError:
57
+ # depth = v.format("DP")[0][0]
61
58
62
- if depth < min_depth :
63
- return False
59
+ # if depth < min_depth:
60
+ # return False
64
61
65
- if self .no_frameshifts and not in_frame (v ):
66
- return False
62
+ # if self.no_frameshifts and not in_frame(v):
63
+ # return False
67
64
68
- if v .num_het :
69
- return False
65
+ # if v.num_het:
66
+ # return False
70
67
71
- if v .QUAL < self .min_variant_quality :
72
- return False
68
+ # if v.QUAL < self.min_variant_quality:
69
+ # return False
73
70
74
- return True
71
+ # return True
75
72
76
73
77
74
def go (args ):
@@ -80,7 +77,7 @@ def go(args):
80
77
vcf_writer .write_header ()
81
78
vcf_writer_filtered = Writer (args .output_fail_vcf , vcf_reader , "w" )
82
79
vcf_writer_filtered .write_header ()
83
- filter = MedakaFilter (args .no_frameshifts )
80
+ filter = Clair3Filter (args .no_frameshifts , args . min_depth )
84
81
85
82
variants = [v for v in vcf_reader ]
86
83
@@ -101,15 +98,15 @@ def go(args):
101
98
pass
102
99
103
100
# now apply the filter to send variants to PASS or FAIL file
104
- if filter .check_filter (v , args . min_depth ):
101
+ if filter .check_filter (v ):
105
102
vcf_writer .write_record (v )
106
103
else :
107
104
variant_passes = False
108
105
109
106
indx = "%s-%s" % (v .CHROM , v .POS )
110
107
if len (group_variants [indx ]) > 1 :
111
108
for check_variant in group_variants [indx ]:
112
- if filter .check_filter (check_variant , args . min_depth ):
109
+ if filter .check_filter (check_variant ):
113
110
variant_passes = True
114
111
115
112
if not variant_passes :
@@ -124,7 +121,6 @@ def main():
124
121
125
122
parser = argparse .ArgumentParser ()
126
123
parser .add_argument ("--no-frameshifts" , action = "store_true" )
127
- parser .add_argument ("--min-variant-quality" , type = int )
128
124
parser .add_argument ("--min-depth" , type = int )
129
125
parser .add_argument ("inputvcf" )
130
126
parser .add_argument ("output_pass_vcf" )
0 commit comments