From d730c117cf0b1d7c67dc8324fd0871d7aedd8c10 Mon Sep 17 00:00:00 2001 From: Andrew Kern Date: Fri, 24 Feb 2023 13:04:04 -0800 Subject: [PATCH] edge case where segment is completely masked (#46) * edge case where segment is completely masked * Update meta.yaml --- diploshic/makeFeatureVecsForChrArmFromVcfDiploid.py | 4 ++++ diploshic/makeFeatureVecsForChrArmFromVcf_ogSHIC.py | 4 ++++ meta.yaml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/diploshic/makeFeatureVecsForChrArmFromVcfDiploid.py b/diploshic/makeFeatureVecsForChrArmFromVcfDiploid.py index de53aaa..b4f2bd2 100644 --- a/diploshic/makeFeatureVecsForChrArmFromVcfDiploid.py +++ b/diploshic/makeFeatureVecsForChrArmFromVcfDiploid.py @@ -141,6 +141,10 @@ def readSampleToPopFile(sampleToPopFileName): for i in range(len(positions)) if segmentStart <= positions[i] <= segmentEnd ] + if len(snpIndicesToKeep) == 0: + sys.exit( + "Error: no SNPs in the given segment of the chr arm; exiting\n" + ) positions = [positions[i] for i in snpIndicesToKeep] genos = allel.GenotypeArray(genos.subset(sel0=snpIndicesToKeep)) diff --git a/diploshic/makeFeatureVecsForChrArmFromVcf_ogSHIC.py b/diploshic/makeFeatureVecsForChrArmFromVcf_ogSHIC.py index 31b4b8f..4ab6d60 100644 --- a/diploshic/makeFeatureVecsForChrArmFromVcf_ogSHIC.py +++ b/diploshic/makeFeatureVecsForChrArmFromVcf_ogSHIC.py @@ -123,6 +123,10 @@ def getSnpIndicesInSubWins(subWinSize, lastSubWinEnd, snpLocs): for i in range(len(positions)) if segmentStart <= positions[i] <= segmentEnd ] + if len(snpIndicesToKeep) == 0: + sys.exit( + "Error: no SNPs in the given segment of the chr arm; exiting\n" + ) positions = [positions[i] for i in snpIndicesToKeep] refAlleles = [refAlleles[i] for i in snpIndicesToKeep] altAlleles = [altAlleles[i] for i in snpIndicesToKeep] diff --git a/meta.yaml b/meta.yaml index 86d32d7..4f2385f 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,6 +1,6 @@ package: name: diploshic - version: "0.34" + version: "0.4" source: git_url: https://github.com/kr-colab/diploshic