Skip to content

Commit

Permalink
Merge pull request #26 from kdm9/check-index
Browse files Browse the repository at this point in the history
Check for a vcf index before indexing
  • Loading branch information
frankvogt committed May 24, 2023
2 parents 9b4ee5f + 53e0fc4 commit 0a4028c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vcf2gwas/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,14 @@

#index VCF
Log.print_log("\nIndexing VCF file..")
timer = time.perf_counter()
Converter.index_vcf(snp_file2)
timer_end = time.perf_counter()
timer_total = round(timer_end - timer, 2)
Log.print_log(f'VCF file successfully indexed (Duration: {runtime_format(timer_total)})')
if not os.path.exists(f"{snp_file2}.csi"):
timer = time.perf_counter()
Converter.index_vcf(snp_file2)
timer_end = time.perf_counter()
timer_total = round(timer_end - timer, 2)
Log.print_log(f'VCF file successfully indexed (Duration: {runtime_format(timer_total)})')
else:
Log.print_log(f'VCF file already indexed')

chr2, chr_num = Converter.check_chrom(snp_file2, chr)
chr_list = chr2
Expand Down Expand Up @@ -889,4 +892,4 @@
if model != None:
shutil.move(os.path.join(path, f'vcf2gwas{pc_prefix}.log.txt'), os.path.join(path, f'vcf2gwas_{snp_prefix}{pc_prefix2}_{timestamp2}.log.txt'))

shutil.rmtree(dir_temp, ignore_errors=True)
shutil.rmtree(dir_temp, ignore_errors=True)

0 comments on commit 0a4028c

Please sign in to comment.