From c4d45900d0a03f1bcdd37f43433a748781d22760 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren (Meren)" Date: Mon, 4 Dec 2023 16:28:35 +0100 Subject: [PATCH] pysam import can take a long time. only do it when necessary? --- anvio/filesnpaths.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/anvio/filesnpaths.py b/anvio/filesnpaths.py index a9d7939cbc..2940d7a372 100644 --- a/anvio/filesnpaths.py +++ b/anvio/filesnpaths.py @@ -5,7 +5,6 @@ import os import json import time -import pysam import shutil import tarfile import tempfile @@ -305,8 +304,10 @@ def is_file_bam_file(file_path, dont_raise=False, ok_if_not_indexed=False): is_file_exists(file_path) + from pysam import AlignmentFile + try: - bam_file = pysam.AlignmentFile(file_path, "rb") + bam_file = AlignmentFile(file_path, "rb") except Exception as e: if dont_raise: return False