From d5b793f6ca4e2714edd2bee75409f05ba173fb08 Mon Sep 17 00:00:00 2001 From: "David A. Parry" Date: Fri, 24 Apr 2015 12:46:03 +0100 Subject: [PATCH] Detect sort mode for B/SAM files with GO tags Many BAM files (e.g. those sorted with picard) have a header line that looks like the following: @HD VN:1.4 GO:none SO:coordinate The original code to capture the sort order will not identify that these are coordinate sorted files and will capture "GO:none" instead, stopping the run. Using grep instead allows for the sort order to be captured correctly. --- R/CopywriteR.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/CopywriteR.R b/R/CopywriteR.R index 3cd820f..71de32e 100644 --- a/R/CopywriteR.R +++ b/R/CopywriteR.R @@ -135,7 +135,7 @@ CopywriteR <- function(sample.control, destination.folder, reference.folder, tryCatch({ for (samp in sample.paths) { header <- scanBamHeader(samp) - chr.sort.mode <- c(chr.sort.mode, list(header[[1]]$text$'@HD')) + chr.sort.mode <- c(chr.sort.mode, grep("SO:[a-zA-Z]+", x=header[[1]]$text$"@HD", value=TRUE)) current.chr.names <- names(header[[1]]$targets) chr.names <- c(chr.names, current.chr.names) chr.lengths <- c(chr.lengths, header[[1]]$targets)