def index_vcf(self):
"""
Indexes vcf file using tabix. If file does not end in .gz, will
compress with bgzip (by calling self.compress_vcf).
Note: Files MUST be compressed using bgzip.
Returns
-------
bool
True if successful.
Raises
------
RuntimeError
If return code from external call is not 0.
"""
self.logger.info("Indexing vcf file: {}".format(self.filepath))
index_start = time.time()
rc = subprocess.call([self.tabix, "-f", "-p", "vcf", self.filepath])
if rc == 0:
self.logger.info("Indexing complete. Elapsed time: {} seconds.".format(
time.time() - index_start))
return True
else:
self.logger.info("Unable to index vcf file: {}. Exiting".format(
self.filepath))
logging.shutdown()
raise RuntimeError("unable to index vcf file. Exiting.")
评论列表
文章目录