Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
popsim
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SVdetection
popsim
Commits
fdd36918
Commit
fdd36918
authored
7 years ago
by
Floreal Cabanettes
Browse files
Options
Downloads
Patches
Plain Diff
Add type of variant as input
parent
a746f623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
genotype_results.py
+18
-8
18 additions, 8 deletions
genotype_results.py
with
18 additions
and
8 deletions
genotype_results.py
+
18
−
8
View file @
fdd36918
...
...
@@ -26,10 +26,10 @@ def passed_variant(record):
return
record
.
filter
is
None
or
len
(
record
.
filter
)
==
0
or
"
PASS
"
in
record
.
filter
def
readgenotypes
(
vcffile
:
str
,
variants
:
dict
,
dofilter
:
bool
=
False
):
def
readgenotypes
(
vcffile
:
str
,
variants
:
dict
,
type_v
,
dofilter
:
bool
=
False
):
vcfin
=
VariantFile
(
vcffile
)
for
r
in
vcfin
:
if
not
dofilter
or
passed_variant
(
r
):
if
(
not
dofilter
or
passed_variant
(
r
)
)
and
r
.
sv_type
.
lower
()
==
type_v
:
variants
[
r
.
id
]
=
r
return
variants
...
...
@@ -65,17 +65,24 @@ def getvarsize(variant):
return
variant
.
stop
-
variant
.
start
+
1
def
main
(
genotypes
,
predicted
,
filtered
,
output
,
verbose
=
False
):
true_genotypes
=
readgenotypes
(
genotypes
,
{})
def
main
(
genotypes
,
predicted
,
filtered
,
output
,
type_v
=
"
del
"
,
verbose
=
False
):
true_genotypes
=
readgenotypes
(
vcffile
=
genotypes
,
variants
=
{},
type_v
=
type_v
)
pred_genotypes
=
{}
filtered_genotypes
=
{}
with
open
(
predicted
,
"
r
"
)
as
preds
:
for
pred
in
preds
:
pred
=
pred
.
rstrip
()
if
pred
!=
""
:
readgenotypes
(
pred
,
pred_genotypes
)
readgenotypes
(
vcffile
=
pred
,
variants
=
pred_genotypes
,
type_v
=
type_v
)
if
filtered
:
readgenotypes
(
pred
,
filtered_genotypes
,
True
)
readgenotypes
(
vcffile
=
pred
,
variants
=
filtered_genotypes
,
type_v
=
type_v
,
dofilter
=
True
)
true_pybed
=
variants_to_pybed
(
true_genotypes
)
pred_pybed
=
variants_to_pybed
(
pred_genotypes
)
...
...
@@ -93,8 +100,9 @@ def main(genotypes, predicted, filtered, output, verbose=False):
soft
=
sv
[
3
].
split
(
'
_
'
)[
0
]
if
sv
[
3
]
in
filtered_genotypes
:
out
.
write
(
"
%s
\t
%s
\t
%d
\t
%3.2f
\t
%d
\t
%d
\n
"
%
(
sv
[
3
],
"
pass
"
,
varsize
,
correct
/
(
wrong
+
correct
),
left_prec
,
right_prec
))
out
.
write
(
"
%s
\t
%s
\t
%d
\t
%3.2f
\t
%d
\t
%d
\n
"
%
(
sv
[
3
],
soft
,
varsize
,
correct
/
(
wrong
+
correct
),
left_prec
,
right_prec
))
(
sv
[
3
],
"
pass
"
,
varsize
,
correct
/
(
wrong
+
correct
),
left_prec
,
right_prec
))
out
.
write
(
"
%s
\t
%s
\t
%d
\t
%3.2f
\t
%d
\t
%d
\n
"
%
(
sv
[
3
],
soft
,
varsize
,
correct
/
(
wrong
+
correct
),
left_prec
,
right_prec
))
if
verbose
:
print
(
"
%d variants
"
%
(
len
(
true_genotypes
)))
...
...
@@ -112,6 +120,7 @@ if __name__ == '__main__':
help
=
'
File listing VCF files containing the predicted results, with genotypes
'
)
parser
.
add_argument
(
'
--filter
'
,
action
=
'
store_const
'
,
const
=
True
,
default
=
False
,
help
=
'
Predicted results has filter information
'
)
parser
.
add_argument
(
'
-t
'
,
'
--type
'
,
type
=
str
,
required
=
True
,
choices
=
[
"
inv
"
,
"
del
"
],
help
=
"
Type of variant
"
)
parser
.
add_argument
(
'
-o
'
,
'
--output
'
,
type
=
str
,
required
=
True
,
help
=
"
Output file
"
)
parser
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_const
'
,
const
=
True
,
default
=
False
,
help
=
'
Verbose mode
'
)
...
...
@@ -122,4 +131,5 @@ if __name__ == '__main__':
predicted
=
args
.
predictions_vcf
,
filtered
=
args
.
filter
,
output
=
args
.
output
,
type_v
=
args
.
type
,
verbose
=
args
.
verbose
)
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