Skip to content

Commit

Permalink
Merge pull request #209 from ctsa/csi_index
Browse files Browse the repository at this point in the history
Allow csi-indexed vcf files

Added some changes to it in branch `csidx`. Will need to merge that next since I don't know how to commit directly to a pr.
  • Loading branch information
ACEnglish committed Apr 8, 2024
2 parents a8dbd30 + f5d53e0 commit 9663645
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions truvari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
HEADERMAT,
LogFileStderr,
bed_ranges,
check_vcf_index,
cmd_exe,
compress_index_vcf,
help_unknown_cmd,
Expand Down
10 changes: 4 additions & 6 deletions truvari/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,15 @@ def check_params(args):
logging.error("Comparison vcf %s does not end with .gz. Must be bgzip'd",
args.comp)
check_fail = True
if not os.path.exists(args.comp + '.tbi'):
logging.error("Comparison vcf index %s.tbi does not exist. Must be indexed",
args.comp)
if not truvari.check_vcf_index(args.comp):
logging.error("Comparison vcf '%s' must be indexed.", args.comp)
check_fail = True
if not args.base.endswith(".gz"):
logging.error("Base vcf %s does not end with .gz. Must be bgzip'd",
args.base)
check_fail = True
if not os.path.exists(args.base + '.tbi'):
logging.error("Base vcf index %s.tbi does not exist. Must be indexed",
args.base)
if not truvari.check_vcf_index(args.base):
logging.error("Base vcf '%s' must be indexed.", args.base)
check_fail = True
if args.includebed and not os.path.exists(args.includebed):
logging.error("Include bed %s does not exist", args.includebed)
Expand Down
8 changes: 4 additions & 4 deletions truvari/phab.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,17 +459,17 @@ def check_params(args):
logging.error(
"Comparison vcf %s does not end with .gz. Must be bgzip'd", args.comp)
check_fail = True
if args.comp is not None and not os.path.exists(args.comp + '.tbi'):
if args.comp is not None and not truvari.check_vcf_index(args.comp):
logging.error(
"Comparison vcf index %s.tbi does not exist. Must be indexed", args.comp)
"Comparison vcf %s must be indexed", args.comp)
check_fail = True
if not args.base.endswith(".gz"):
logging.error(
"Base vcf %s does not end with .gz. Must be bgzip'd", args.base)
check_fail = True
if not os.path.exists(args.base + '.tbi'):
if not truvari.check_vcf_index(args.base):
logging.error(
"Base vcf index %s.tbi does not exist. Must be indexed", args.base)
"Base vcf %s must be indexed", args.base)
check_fail = True
if not os.path.exists(args.reference):
logging.error("Reference %s does not exist", args.reference)
Expand Down
9 changes: 9 additions & 0 deletions truvari/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,12 @@ def compress_index_vcf(fn, fout=None, remove=True):
if remove:
os.remove(fn)
os.remove(m_tmp)


def check_vcf_index(vcf_path):
"""
Return true if an index file is found for the vcf
"""
vcf_index_ext = ['tbi','csi']
return any([os.path.exists(vcf_path + '.' + x) for x in vcf_index_ext])

0 comments on commit 9663645

Please sign in to comment.