From 172b2be80b24fc36c0f158a88682e959e8958788 Mon Sep 17 00:00:00 2001 From: Rebecca Torene Date: Fri, 11 Feb 2022 17:05:01 -0500 Subject: [PATCH 1/3] 17-log and exit when no eval argument provided --- cluster_analysis/bin/SCRAMble.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cluster_analysis/bin/SCRAMble.R b/cluster_analysis/bin/SCRAMble.R index 1bd0553..8477466 100644 --- a/cluster_analysis/bin/SCRAMble.R +++ b/cluster_analysis/bin/SCRAMble.R @@ -76,6 +76,12 @@ for(i in 1:length(objects)){ } source("usefulFunctions.R") ############################### +## if no eval options provided log and exit +if(!meis & !deletions){ + cat('No structural variants to evaluate. Please use flags --eval-meis and --eval-dels to indicate analysis.') + stop() +} +############################### ## READ IN DATA AND PRE-PROCESS all = read.delim(clusterFile, as.is=T, header=F, col.names=c("coord", "clipped", "counts", "clipped.consensus", "anchored.consensus")) From 263a26ca1731d67591f85340e56abfffdd2b4f64 Mon Sep 17 00:00:00 2001 From: Rebecca Torene Date: Fri, 11 Feb 2022 17:18:57 -0500 Subject: [PATCH 2/3] 17-return empty, valid VCF when no results --- cluster_analysis/bin/make.vcf.R | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/cluster_analysis/bin/make.vcf.R b/cluster_analysis/bin/make.vcf.R index 4e0aab3..4e71e83 100644 --- a/cluster_analysis/bin/make.vcf.R +++ b/cluster_analysis/bin/make.vcf.R @@ -40,9 +40,22 @@ make.vcf.header = function(fa, blastRef=None){ ############################## write.scramble.vcf = function(winners, fa, meis=F){ + # return empty fixed data when no variants found + if(nrow(winners) == 0){ + fixed = data.frame('#CHROM' = character(), + POS = character(), + ID = character(), + REF = character(), + ALT = character(), + QUAL = character(), + FILTER = character(), + INFO = character(), + check.names = F) + return(fixed) + } + #argument checks if (is.null(winners)) return(NULL) - if (nrow(winners) == 0) return(NULL) if(!meis){ fixed = data.frame('#CHROM' = winners$CONTIG, @@ -75,18 +88,6 @@ write.scramble.vcf = function(winners, fa, meis=F){ } vcf.cols = c('#CHROM', 'POS', 'ID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO') - if(nrow(fixed) > 0){ - return(fixed[,vcf.cols]) - }else{ - fixed = data.frame('#CHROM' = character(), - POS = character(), - ID = character(), - REF = character(), - ALT = character(), - QUAL = character(), - FILTER = character(), - INFO = character(), - check.names = F) - return(fixed) - } + return(fixed[,vcf.cols]) + } From 3a77fdcc352aae9d444c0fe2e8fea0244267d89a Mon Sep 17 00:00:00 2001 From: Rebecca Torene Date: Fri, 11 Feb 2022 17:37:10 -0500 Subject: [PATCH 3/3] 18-return `N` instead of `NULL` when missing data to get ref/alt in VCF --- cluster_analysis/bin/make.vcf.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster_analysis/bin/make.vcf.R b/cluster_analysis/bin/make.vcf.R index 4e71e83..8f7ec91 100644 --- a/cluster_analysis/bin/make.vcf.R +++ b/cluster_analysis/bin/make.vcf.R @@ -12,8 +12,8 @@ get_score = function(right_score, left_score){ } ############################## get_refs = function(fa, chrom, start, end){ - if (missing(fa) | missing(chrom) | missing(start) | missing(end)) return(NULL) - if (! chrom %in% names(fa)) return(NULL) + if (missing(fa) | missing(chrom) | missing(start) | missing(end)) return('N') + if (! chrom %in% names(fa)) return('N') fa = fa[chrom] seq = subseq(fa, start=start, end=end) return(as.vector(seq))