Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klinische Genetica
capture-lumc
vtools
Commits
5bfe55f2
There was a problem fetching the pipeline summary.
Commit
5bfe55f2
authored
7 years ago
by
Sander Bollen
Browse files
Options
Downloads
Patches
Plain Diff
immediately return upon hitting one filter criterium by default
parent
4a45e848
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vtools/cli.py
+8
-2
8 additions, 2 deletions
vtools/cli.py
vtools/filter.py
+12
-2
12 additions, 2 deletions
vtools/filter.py
with
20 additions
and
4 deletions
vtools/cli.py
+
8
−
2
View file @
5bfe55f2
...
...
@@ -25,7 +25,13 @@ from .gcoverage import *
help
=
"
Path to filter params json
"
,
required
=
True
)
@click.option
(
'
--index-sample
'
,
type
=
click
.
STRING
,
help
=
"
Name of index sample
"
,
required
=
True
)
def
filter_cli
(
input
,
output
,
trash
,
params_file
,
index_sample
):
@click.option
(
"
--immediate-return/--no-immediate-return
"
,
default
=
True
,
help
=
"
Immediately write filters to file
"
"
upon hitting one filter criterium.
"
"
Default = True
"
)
def
filter_cli
(
input
,
output
,
trash
,
params_file
,
index_sample
,
immediate_return
):
vcf
=
VCF
(
input
,
gts012
=
True
)
idx
=
vcf
.
samples
.
index
(
index_sample
)
...
...
@@ -37,7 +43,7 @@ def filter_cli(input, output, trash, params_file, index_sample):
filter_params
=
FilterParams
(
params_file
)
filter_it
=
Filterer
(
vcf
,
filter_params
,
idx
)
filter_it
=
Filterer
(
vcf
,
filter_params
,
idx
,
immediate_return
)
for
record
,
fi
in
filter_it
:
if
fi
is
None
or
len
(
fi
)
==
0
:
...
...
This diff is collapsed.
Click to expand it.
vtools/filter.py
+
12
−
2
View file @
5bfe55f2
...
...
@@ -103,10 +103,11 @@ class Filterer(object):
We assume gts012 to be set to True in the cyvcf2 readers
"""
def
__init__
(
self
,
vcf_it
,
filter_params
,
index
):
def
__init__
(
self
,
vcf_it
,
filter_params
,
index
,
immediate_return
=
True
):
self
.
vcf_it
=
vcf_it
self
.
filters
=
filter_params
self
.
index
=
index
self
.
immediate_return
=
immediate_return
self
.
canonical_chroms
=
{
"
M
"
,
"
X
"
,
"
Y
"
}.
union
(
set
(
map
(
str
,
range
(
0
,
23
))))
...
...
@@ -123,28 +124,38 @@ class Filterer(object):
if
chrom
.
startswith
(
"
chr
"
):
chrom
=
chrom
.
split
(
"
chr
"
)[
-
1
]
if
chrom
not
in
self
.
canonical_chroms
:
if
self
.
immediate_return
:
return
record
,
[
FilterClass
.
NON_CANONICAL
]
filters
.
append
(
FilterClass
.
NON_CANONICAL
)
if
self
.
filters
.
index_called
:
gt
=
record
.
gt_types
[
self
.
index
]
if
gt
==
0
or
gt
==
3
:
if
self
.
immediate_return
:
return
record
,
[
FilterClass
.
INDEX_UNCALLED
]
filters
.
append
(
FilterClass
.
INDEX_UNCALLED
)
if
self
.
filters
.
min_gq
is
not
None
:
gq
=
record
.
gt_quals
[
self
.
index
]
if
gq
<
self
.
filters
.
min_gq
:
if
self
.
immediate_return
:
return
record
,
[
FilterClass
.
LOW_GQ
]
filters
.
append
(
FilterClass
.
LOW_GQ
)
if
self
.
filters
.
max_gonl_af
is
not
None
:
gonl_af
=
get_af
(
record
,
self
.
filters
.
gonl_vcf
,
self
.
filters
.
gonl_af
)
if
gonl_af
>
self
.
filters
.
max_gonl_af
:
if
self
.
immediate_return
:
return
record
,
[
FilterClass
.
TOO_HIGH_GONL_AF
]
filters
.
append
(
FilterClass
.
TOO_HIGH_GONL_AF
)
if
self
.
filters
.
max_gnomad_af
is
not
None
:
gnomad_af
=
get_af
(
record
,
self
.
filters
.
gnomad_vcf
,
self
.
filters
.
gnomad_af
)
if
gnomad_af
>
self
.
filters
.
max_gnomad_af
:
if
self
.
immediate_return
:
return
record
,
[
FilterClass
.
TOO_HIGH_GNOMAD_AF
]
filters
.
append
(
FilterClass
.
TOO_HIGH_GNOMAD_AF
)
return
record
,
filters
...
...
@@ -154,4 +165,3 @@ class Filterer(object):
def
__iter__
(
self
):
return
self
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment