Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow csi-indexed vcf files #209

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])