From 30d451126bf1f484b343f98066ff89a03098b7f1 Mon Sep 17 00:00:00 2001 From: mnshgl0110 Date: Wed, 11 Dec 2024 16:00:04 +0100 Subject: [PATCH] Catch exception when there are no short variations between the genomes. --- syri/__init__.py | 2 +- syri/pyxFiles/findshv.pyx | 12 ++++++++++-- syri/pyxFiles/findsv.pyx | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/syri/__init__.py b/syri/__init__.py index 16c83d8..83b020e 100644 --- a/syri/__init__.py +++ b/syri/__init__.py @@ -1 +1 @@ -__version__ = "1.7.0" \ No newline at end of file +__version__ = "1.7.1" \ No newline at end of file diff --git a/syri/pyxFiles/findshv.pyx b/syri/pyxFiles/findshv.pyx index 98ad88a..40c6a59 100644 --- a/syri/pyxFiles/findshv.pyx +++ b/syri/pyxFiles/findshv.pyx @@ -190,8 +190,16 @@ def getshv(args, coords, chrlink): logger.error('Error in finding SNPs using show-snps: ' + out[1].decode()) sys.exit() else: - allsnps = pd.read_table(cwdpath + prefix + fname, header = None) - logger.debug('finished writing SNPs') + try: + allsnps = pd.read_table(cwdpath + prefix + fname, header = None) + logger.debug('finished writing SNPs') + except pd.errors.EmptyDataError as e: + logger.warning('No SNPs or small indels were identified in the alignments.') + if mapit == 1: + fileRemove(cwdpath + prefix + fname) + with open(cwdpath + prefix + 'snps.txt', "w") as fout: + pass + return None achrs = pd.unique(allAlignments['aChr']) bchrs = pd.unique(allAlignments['bChr']) diff --git a/syri/pyxFiles/findsv.pyx b/syri/pyxFiles/findsv.pyx index 942bcc2..2a01f1e 100644 --- a/syri/pyxFiles/findsv.pyx +++ b/syri/pyxFiles/findsv.pyx @@ -109,8 +109,7 @@ def getSV(cwdPath, allAlignments, prefix, offset): logger = logging.getLogger("getSV") offset = -abs(offset) fout = open(cwdPath + prefix + "sv.txt", "w") - allAlignments["id"] = allAlignments.group.astype( - "str") + 'Chr' + allAlignments.aChr + 'Chr' + allAlignments.bChr + allAlignments.state + allAlignments["id"] = allAlignments.group.astype("str") + 'Chr' + allAlignments.aChr + 'Chr' + allAlignments.bChr + allAlignments.state allBlocks = pd.unique(allAlignments.id) for i in allBlocks: