Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
biopet.biopet
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
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
Mirrors
biopet.biopet
Commits
2b54d173
Commit
2b54d173
authored
8 years ago
by
Wai Yi Leung
Browse files
Options
Downloads
Patches
Plain Diff
Fix breakdancer tsv converter to vcf
parent
46a8a9fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/biopet-extensions/src/main/resources/nl/lumc/sasc/biopet/extensions/breakdancer/breakdancer2vcf.py
+10
-6
10 additions, 6 deletions
...umc/sasc/biopet/extensions/breakdancer/breakdancer2vcf.py
with
10 additions
and
6 deletions
public/biopet-extensions/src/main/resources/nl/lumc/sasc/biopet/extensions/breakdancer/breakdancer2vcf.py
+
10
−
6
View file @
2b54d173
...
...
@@ -30,19 +30,21 @@ import csv
import
datetime
def
main
(
tsvfile
,
vcffile
):
def
main
(
tsvfile
,
vcffile
,
samplename
):
'''
:param tsvfile: filename of input file.tsv
:type tsvfile: string
:param vcffile: filename of output file.vcf
:type vcffile: string
:param samplename: Name of the sample
:type samplename: string
'''
with
open
(
tsvfile
)
as
reader
:
# Parse file
dictreader
=
_parse_tsvfile
(
reader
)
# Write out file
_format_vcffile
(
dictreader
,
vcffile
)
_format_vcffile
(
dictreader
,
vcffile
,
samplename
)
def
_parse_tsvfile
(
readable
):
'''
...
...
@@ -138,7 +140,7 @@ VCF_HEADER = """##fileformat=VCFv4.1
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description=
"
Genotype Quality
"
>
##FORMAT=<ID=DP,Number=1,Type=Integer,Description=
"
Read Depth
"
>
"""
.
format
(
filedate
=
TS_NOW
.
strftime
(
"
%Y%m%d
"
)
)
def
_format_vcffile
(
dictreader
,
vcffile
):
def
_format_vcffile
(
dictreader
,
vcffile
,
samplename
):
'''
Create a pseudo .vcf file based on values read from DictReader instance.
:param dictreader: DictReader instance to read data from
...
...
@@ -148,7 +150,7 @@ def _format_vcffile(dictreader, vcffile):
'''
FORMAT
=
"
GT:DP
"
with
open
(
vcffile
,
mode
=
'
w
'
)
as
writer
:
writer
.
write
(
'
{header}
\n
#{columns}
\n
'
.
format
(
header
=
VCF_HEADER
,
columns
=
'
\t
'
.
join
(
_vcf_fields
)))
writer
.
write
(
'
{header}
\n
#{columns}
\n
'
.
format
(
header
=
VCF_HEADER
,
columns
=
'
\t
'
.
join
(
_vcf_fields
+
[
samplename
]
)))
output_vcf
=
[]
for
line
in
dictreader
:
CHROM
=
line
[
'
Chr1
'
]
...
...
@@ -163,7 +165,7 @@ def _format_vcffile(dictreader, vcffile):
INFO
+=
'
;SVLEN={}
'
.
format
(
int
(
line
[
'
Size
'
]))
INFO
+=
"
;SVEND={}
"
.
format
(
SVEND
)
INFO
+=
"
;END={}
"
.
format
(
SVEND
)
# write alternate ALT field for Intrachromosomal translocations
if
line
[
'
Type
'
]
in
[
'
CTX
'
]:
ALT
=
"
N[{}:{}[
"
.
format
(
line
[
'
Chr2
'
],
line
[
'
Pos2
'
])
...
...
@@ -187,6 +189,8 @@ if __name__ == '__main__':
help
=
'
Breakdancer TSV outputfile
'
)
parser
.
add_argument
(
'
-o
'
,
'
--outputvcf
'
,
dest
=
'
outputvcf
'
,
type
=
str
,
help
=
'
Output vcf to
'
)
parser
.
add_argument
(
'
-s
'
,
'
--sample
'
,
dest
=
'
sample
'
,
type
=
str
,
help
=
'
sample name
'
)
args
=
parser
.
parse_args
()
main
(
args
.
breakdancertsv
,
args
.
outputvcf
)
main
(
args
.
breakdancertsv
,
args
.
outputvcf
,
args
.
sample
)
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