Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
Restore output of unresolved variants during svtk vcf2bed
Browse files Browse the repository at this point in the history
  • Loading branch information
RCollins13 committed Oct 5, 2018
1 parent 05c7dc1 commit b0f10c3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion svtk/annotation/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def annotate_vcf(vcf, gencode, noncoding, annotated_vcf):
fname = vcf.filename.decode()
else:
fname = vcf.filename
sv = svu.vcf2bedtool(fname, split_bnd=True, split_cpx=True, simple_sinks=True)
sv = svu.vcf2bedtool(fname, split_bnd=True, split_cpx=True,
simple_sinks=True, include_unresolved=False)

effects = annotate(sv, gencode, noncoding)
effects = effects.to_dict(orient='index')
Expand Down
10 changes: 9 additions & 1 deletion svtk/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def vcf2bed(argv):
parser.add_argument('--no-sort-coords', dest='no_sort_coords', action='store_true',
default=False, help='Do not sort start/end coordinates '
'per record before writing to bed.')
parser.add_argument('--no-unresolved', dest='no_unresolved', action='store_true',
default=False, help='Do not output unresolved variants.')
parser.add_argument('--simple-sinks', dest='simple_sinks', action='store_true',
default=False, help='Report all INS sinks as 1bp intervals.')

# Print help if no arguments specified
if len(argv) == 0:
Expand All @@ -64,6 +68,8 @@ def vcf2bed(argv):
header = header + args.info
header = '\t'.join(header)

include_unresolved = not args.no_unresolved

bt = svu.vcf2bedtool(vcf,
split_bnd=args.split_bnd,
include_samples=args.include_samples,
Expand All @@ -72,7 +78,9 @@ def vcf2bed(argv):
include_infos=args.info,
annotate_ins=False,
report_alt=True,
no_sort_coords=args.no_sort_coords)
no_sort_coords=args.no_sort_coords,
simple_sinks=args.simple_sinks,
include_unresolved=include_unresolved)

if args.bed in 'stdout -'.split():
if args.header:
Expand Down
14 changes: 9 additions & 5 deletions svtk/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def get_called_samples(record, include_null=False):
def vcf2bedtool(vcf, split_bnd=True, include_samples=False,
include_strands=True, split_cpx=False, include_infos=None,
annotate_ins=True, report_alt=False, svtypes=None,
no_sort_coords=False, simple_sinks=False):
no_sort_coords=False, simple_sinks=False,
include_unresolved=True):
"""
Wrap VCF as a bedtool. Necessary as pybedtools does not support SV in VCF.
Expand All @@ -137,6 +138,8 @@ def vcf2bedtool(vcf, split_bnd=True, include_samples=False,
Do not sort start & end coordinates
simple_sinks : bool, optional
Treat all insertion sinks as single-bp windows
include_unresolved : bool, optional
Output unresolved variants
Returns
-------
Expand Down Expand Up @@ -172,10 +175,11 @@ def _converter():
for record in vcf:
if svtypes is not None and record.info['SVTYPE'] not in svtypes:
continue
if 'UNRESOLVED' in record.info.keys() \
or 'UNRESOLVED_TYPE' in record.info.keys() \
or 'UNRESOLVED' in record.filter:
continue
if not include_unresolved:
if 'UNRESOLVED' in record.info.keys() \
or 'UNRESOLVED_TYPE' in record.info.keys() \
or 'UNRESOLVED' in record.filter:
continue

chrom = record.chrom
name = record.id
Expand Down

0 comments on commit b0f10c3

Please sign in to comment.