diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index 6e12b0cc6ea..fefb82f13a4 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -749,13 +749,13 @@ class Bam(BamNative): cmd = [ "python", "-c", - f"import pysam; pysam.set_verbosity(0); pysam.index('{file_name}', '{index_name}')", + f"import pysam; pysam.set_verbosity(0); pysam.index('-o', '{index_name}', '{file_name}')", ] else: cmd = [ "python", "-c", - f"import pysam; pysam.set_verbosity(0); pysam.index('{index_flag}', '{file_name}', '{index_name}')", + f"import pysam; pysam.set_verbosity(0); pysam.index('{index_flag}', '-o', '{index_name}', '{file_name}')", ] with open(os.devnull, "w") as devnull: subprocess.check_call(cmd, stderr=devnull, shell=False) @@ -786,9 +786,9 @@ class Bam(BamNative): ) if index_flag == "-b": # IOError: No such file or directory: '-b' if index_flag is set to -b (pysam 0.15.4) - pysam.index(dataset.file_name, index_file.file_name) # type: ignore [attr-defined] + pysam.index("-o", index_file.file_name, dataset.file_name) # type: ignore [attr-defined] else: - pysam.index(index_flag, dataset.file_name, index_file.file_name) # type: ignore [attr-defined] + pysam.index(index_flag, "-o", index_file.file_name, dataset.file_name) # type: ignore [attr-defined] dataset.metadata.bam_index = index_file def sniff(self, filename: str) -> bool: @@ -979,7 +979,7 @@ class CRAM(Binary): def set_index_file(self, dataset: "DatasetInstance", index_file) -> bool: try: - pysam.index(dataset.file_name, index_file.file_name) # type: ignore [attr-defined] + pysam.index("-o", index_file.file_name, dataset.file_name) # type: ignore [attr-defined] return True except Exception as exc: log.warning("%s, set_index_file Exception: %s", self, exc) diff --git a/lib/galaxy/datatypes/converters/cram_to_bam_converter.xml b/lib/galaxy/datatypes/converters/cram_to_bam_converter.xml index ee464bb12b9..837bd2efb4b 100644 --- a/lib/galaxy/datatypes/converters/cram_to_bam_converter.xml +++ b/lib/galaxy/datatypes/converters/cram_to_bam_converter.xml @@ -16,7 +16,7 @@ python '$__tool_directory__/cram_to_bam.py' '$input' '$output' - + diff --git a/lib/galaxy/dependencies/dev-requirements.txt b/lib/galaxy/dependencies/dev-requirements.txt index b7f5dcb1ca7..8a48ee27d59 100644 --- a/lib/galaxy/dependencies/dev-requirements.txt +++ b/lib/galaxy/dependencies/dev-requirements.txt @@ -27,7 +27,7 @@ commonmark==0.9.1 ; python_version >= "3.7" and python_version < "3.11" coverage[toml]==7.0.1 ; python_version >= "3.7" and python_version < "3.11" cwltest==2.2.20210901154959 ; python_version >= "3.7" and python_version < "3.11" cycler==0.11.0 ; python_version >= "3.7" and python_version < "3.11" -darker==1.6.0 ; python_version >= "3.7" and python_version < "3.11" +darker==1.6.1 ; python_version >= "3.7" and python_version < "3.11" defusedxml==0.7.1 ; python_version >= "3.7" and python_version < "3.11" deprecated==1.2.13 ; python_version >= "3.7" and python_version < "3.11" docutils==0.16 ; python_version >= "3.7" and python_version < "3.11" @@ -66,7 +66,7 @@ packaging==21.3 ; python_version >= "3.7" and python_version < "3.11" pathspec==0.10.3 ; python_version >= "3.7" and python_version < "3.11" pillow==9.3.0 ; python_version >= "3.7" and python_version < "3.11" pkce==1.0.3 ; python_version >= "3.7" and python_version < "3.11" -platformdirs==2.6.0 ; python_version >= "3.7" and python_version < "3.11" +platformdirs==2.6.2 ; python_version >= "3.7" and python_version < "3.11" pluggy==1.0.0 ; python_version >= "3.7" and python_version < "3.11" port-for==0.6.3 ; python_version >= "3.7" and python_version < "3.11" prettytable==3.5.0 ; python_version >= "3.7" and python_version < "3.11" diff --git a/lib/galaxy/dependencies/pinned-requirements.txt b/lib/galaxy/dependencies/pinned-requirements.txt index 19042d07779..888f69e5a06 100644 --- a/lib/galaxy/dependencies/pinned-requirements.txt +++ b/lib/galaxy/dependencies/pinned-requirements.txt @@ -77,7 +77,7 @@ h5py==3.7.0 ; python_version >= "3.7" and python_version < "3.11" humanfriendly==10.0 ; python_version >= "3.7" and python_version < "3.11" idna==3.4 ; python_version >= "3.7" and python_version < "3.11" importlib-metadata==4.13.0 ; python_version >= "3.7" and python_version < "3.10" -importlib-resources==5.10.1 ; python_version >= "3.7" and python_version < "3.11" +importlib-resources==5.10.2 ; python_version >= "3.7" and python_version < "3.11" isa-rwval==0.10.10 ; python_version >= "3.7" and python_version < "3.11" isodate==0.6.1 ; python_version >= "3.7" and python_version < "3.11" jinja2==3.1.2 ; python_version >= "3.7" and python_version < "3.11" @@ -118,8 +118,8 @@ pyasn1==0.4.8 ; python_version >= "3.7" and python_version < "3.11" pycparser==2.21 ; python_version >= "3.7" and python_version < "3.11" pycryptodome==3.16.0 ; python_version >= "3.7" and python_version < "3.11" pydantic-tes==0.1.5 ; python_version >= "3.7" and python_version < "3.11" -pydantic==1.10.2 ; python_version >= "3.7" and python_version < "3.11" -pydantic[email]==1.10.2 ; python_version >= "3.7" and python_version < "3.11" +pydantic==1.10.4 ; python_version >= "3.7" and python_version < "3.11" +pydantic[email]==1.10.4 ; python_version >= "3.7" and python_version < "3.11" pydot==1.4.2 ; python_version >= "3.7" and python_version < "3.11" pyeventsystem==0.1.0 ; python_version >= "3.7" and python_version < "3.11" pyfaidx==0.7.1 ; python_version >= "3.7" and python_version < "3.11" @@ -131,8 +131,8 @@ pynacl==1.5.0 ; python_version >= "3.7" and python_version < "3.11" pyparsing==3.0.9 ; python_version >= "3.7" and python_version < "3.11" pyreadline3==3.4.1 ; sys_platform == "win32" and python_version >= "3.8" and python_version < "3.11" pyreadline==2.1 ; sys_platform == "win32" and python_version < "3.8" and python_version >= "3.7" -pyrsistent==0.19.2 ; python_version >= "3.7" and python_version < "3.11" -pysam==0.19.1 ; python_version >= "3.7" and python_version < "3.11" +pyrsistent==0.19.3 ; python_version >= "3.7" and python_version < "3.11" +pysam==0.20.0 ; python_version >= "3.7" and python_version < "3.11" python-dateutil==2.8.2 ; python_version >= "3.7" and python_version < "3.11" python-jose==3.3.0 ; python_version >= "3.7" and python_version < "3.11" python-magic==0.4.27 ; python_version >= "3.7" and python_version < "3.11" @@ -147,7 +147,7 @@ repoze-lru==0.7 ; python_version >= "3.7" and python_version < "3.11" requests-oauthlib==1.3.1 ; python_version >= "3.7" and python_version < "3.11" requests-toolbelt==0.10.1 ; python_version >= "3.7" and python_version < "3.11" requests==2.28.1 ; python_version >= "3.7" and python_version < "3.11" -rich==12.6.0 ; python_version >= "3.7" and python_version < "3.11" +rich==13.0.0 ; python_version >= "3.7" and python_version < "3.11" rocrate==0.7.0 ; python_version >= "3.7" and python_version < "3.11" routes==2.5.1 ; python_version >= "3.7" and python_version < "3.11" rsa==4.9 ; python_version >= "3.7" and python_version < "3.11" diff --git a/lib/galaxy/tool_util/deps/mulled/get_tests.py b/lib/galaxy/tool_util/deps/mulled/get_tests.py index 895995264a7..3780739b6ce 100644 --- a/lib/galaxy/tool_util/deps/mulled/get_tests.py +++ b/lib/galaxy/tool_util/deps/mulled/get_tests.py @@ -142,6 +142,7 @@ def find_anaconda_versions(name, anaconda_channel="bioconda"): Find a list of available anaconda versions for a given container name """ r = requests.get(f"https://anaconda.org/{anaconda_channel}/{name}/files", timeout=MULLED_SOCKET_TIMEOUT) + r.raise_for_status() urls = [] for line in r.text.split("\n"): if "download/linux" in line: @@ -173,12 +174,9 @@ def get_alternative_versions(filepath, filename, recipes_path=None, github_repo= return [n.replace(f"{recipes_path}/", "") for n in glob(f"{recipes_path}/{filepath}/*/{filename}")] # else use the GitHub API: versions = [] - r = json.loads( - requests.get( - f"https://api.github.com/repos/{github_repo}/contents/{filepath}", timeout=MULLED_SOCKET_TIMEOUT - ).text - ) - for subfile in r: + r = requests.get(f"https://api.github.com/repos/{github_repo}/contents/{filepath}", timeout=MULLED_SOCKET_TIMEOUT) + r.raise_for_status() + for subfile in json.loads(r.text): if subfile["type"] == "dir": if ( requests.get( @@ -295,6 +293,7 @@ def hashed_test_search( containers = [] for package in packages: r = requests.get(f"https://anaconda.org/bioconda/{package[0]}/files", timeout=MULLED_SOCKET_TIMEOUT) + r.raise_for_status() p = "-".join(package) for line in r.text.split("\n"): if p in line: diff --git a/packages/app/setup.cfg b/packages/app/setup.cfg index 0fa9ead3739..adc8796fce2 100644 --- a/packages/app/setup.cfg +++ b/packages/app/setup.cfg @@ -60,7 +60,7 @@ install_requires = pebble pulsar-galaxy-lib>=0.15.0.dev0 pydantic - pysam + pysam>=0.20 PyJWT PyYAML refgenconf>=0.12.0 diff --git a/packages/data/setup.cfg b/packages/data/setup.cfg index 9a540dd6dc5..27e9fc753dd 100644 --- a/packages/data/setup.cfg +++ b/packages/data/setup.cfg @@ -49,7 +49,7 @@ install_requires = pydantic[email] pylibmagic python-magic - pysam + pysam>=0.20 rocrate social-auth-core[openidconnect]==4.0.3 SQLAlchemy>=1.4.25,<2 diff --git a/pyproject.toml b/pyproject.toml index d17f8ccce67..f3ff6111d42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,7 +83,7 @@ PyJWT = "*" pykwalify = "*" pylibmagic = "*" pyparsing = "*" -pysam = "*" +pysam = ">=0.20" python = ">=3.7,<3.11" # Keep maximum version strict to appease numpy and scipy python-dateutil = "*" python-magic = "*" diff --git a/test-data/2.cram b/test-data/2.cram index dacd2d459e3..5176d57f864 100644 Binary files a/test-data/2.cram and b/test-data/2.cram differ diff --git a/test/unit/data/datatypes/test_cram.py b/test/unit/data/datatypes/test_cram.py index a2908d9b45b..bf40c1b5a82 100644 --- a/test/unit/data/datatypes/test_cram.py +++ b/test/unit/data/datatypes/test_cram.py @@ -1,5 +1,3 @@ -import os - import pysam from galaxy.datatypes.binary import CRAM @@ -12,9 +10,7 @@ from .util import ( def test_cram(): c = CRAM() with get_input_files("2.cram") as input_files, get_dataset(input_files[0], index_attr="cram_index") as dataset: - assert os.path.exists(dataset.metadata.cram_index.file_name) is False - c.set_index_file(dataset=dataset, index_file=dataset.metadata.cram_index) - assert os.path.exists(dataset.metadata.cram_index.file_name) is True + assert c.set_index_file(dataset=dataset, index_file=dataset.metadata.cram_index) is True c.set_meta(dataset) pysam.AlignmentFile(dataset.file_name, index_filename=dataset.metadata.cram_index.file_name) assert dataset.metadata.cram_version == "3.0" diff --git a/test/unit/data/datatypes/util.py b/test/unit/data/datatypes/util.py index b77b2513541..5defbc5aaac 100644 --- a/test/unit/data/datatypes/util.py +++ b/test/unit/data/datatypes/util.py @@ -36,7 +36,7 @@ class MockDataset: @contextmanager def get_dataset(filename, index_attr="bam_index", dataset_id=1, has_data=True): dataset = MockDataset(dataset_id) - with get_input_files(filename) as input_files, get_tmp_path() as index_path: + with get_input_files(filename) as input_files, get_tmp_path(should_exist=True) as index_path: dataset.file_name = input_files[0] index = MockMetadata() index.file_name = index_path @@ -64,6 +64,6 @@ def get_input_files(*args): yield test_files new_md5_sums = [md5_hash_file(f) for f in test_files] for old_hash, new_hash, f in zip(md5_sums, new_md5_sums, test_files): - assert old_hash == new_hash, "Unexpected change of content for file %s" % f + assert old_hash == new_hash, f"Unexpected change of content for file {f}" finally: shutil.rmtree(temp_dir, ignore_errors=True)