Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add try/except around extraction to accommodate failing uncompression in pyani download #385

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
20 changes: 17 additions & 3 deletions pyani/scripts/subcommands/subcmd_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"""Provides the download subcommand for pyani."""

import logging
import subprocess

from argparse import Namespace
from typing import Dict, List, NamedTuple, Optional, Tuple
Expand Down Expand Up @@ -98,7 +99,9 @@ def dl_info_to_str(esummary, uid_class) -> str:


def download_data(
args: Namespace, api_key: Optional[str], asm_dict: Dict[str, List],
args: Namespace,
api_key: Optional[str],
asm_dict: Dict[str, List],
) -> Tuple[List, List, List]:
"""Download the accessions indicated in the passed dictionary.

Expand Down Expand Up @@ -131,7 +134,14 @@ def download_data(
exc_info=True,
)
skippedlist.append(
Skipped(tid, uid, "", "", None, "RefSeq",)
Skipped(
tid,
uid,
"",
"",
None,
"RefSeq",
)
) # pylint: disable=no-member
continue

Expand Down Expand Up @@ -182,7 +192,11 @@ def extract_genomes(args: Namespace, dlstatus: download.DLStatus, esummary) -> N
logger.warning("Output file %s exists, not extracting", ename)
else:
logger.debug("Extracting archive %s to %s", dlstatus.outfname, ename)
download.extract_contigs(dlstatus.outfname, ename)
try:
download.extract_contigs(dlstatus.outfname, ename)
except subprocess.CalledProcessError:
logger.warning("Could not extract %s; continuing", dlstatus.outfname)
pass

# Modify sequence ID header if Kraken option active
if args.kraken:
Expand Down