diff snpEffExtract.R @ 2:dc51db22310c draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/snpfreqplot/ commit d1c54d077cfc0eeb9699719760e668948cb9bbbc"
author iuc
date Fri, 18 Dec 2020 23:48:01 +0000
parents 1062d6ad6503
children
line wrap: on
line diff
--- a/snpEffExtract.R	Thu Dec 10 13:41:29 2020 +0000
+++ b/snpEffExtract.R	Fri Dec 18 23:48:01 2020 +0000
@@ -5,6 +5,12 @@
 
 tsv_eff_from_vcf <- function(input_vcf, output_tab) {
     read_vcf <- readVcf(input_vcf)  # nolint
+    if (!nrow(read_vcf@fixed)) {
+        # no variants in file -> just write a valid header line
+        write(c("CHROM", "POS", "REF", "ALT", "AF", "EFF[*].GENE", "EFF[*].EFFECT"),
+              ncolumns = 7, file = output_tab, sep = "\t")
+        return()
+    }
     chrom_pos <- data.frame(read_vcf@rowRanges)[, c("seqnames", "start")]
     ref_alt_filter <- read_vcf@fixed[, c("REF", "ALT", "FILTER")]
     dp_af <- read_vcf@info[c("DP", "AF")]