def index_bam(self):
"""
Indexes a bam using samtools ('samtools index file.bam').
Returns
-------
bool
True if successful.
Raises
------
RuntimeError
If return code from external call is not 0.
"""
self.logger.info("Indexing bam file: {}".format(self.filepath))
idx_start = time.time()
rc = subprocess.call([self.samtools, "index", self.filepath])
if rc == 0:
self.logger.info("Indexing complete. Elapsed time: {} seconds".format(
time.time() - idx_start))
return True
else:
self.logger.error("Unable to index bamfile {}. Exiting".format(
self.filepath))
logging.shutdown()
raise RuntimeError("Unable to index bamfile. Exiting")
评论列表
文章目录