Created
August 27, 2012 17:22
-
-
Save DarwinAwardWinner/3490557 to your computer and use it in GitHub Desktop.
Patch to GFF3 reader in rtracklayer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/R/gff.R 2012-03-30 15:59:39.000000000 -0700 | |
+++ b/R/gff.R 2012-05-11 17:36:59.208145562 -0700 | |
@@ -286,13 +286,12 @@ | |
lines <- rep(seq_along(attrSplit), elementLengths(attrSplit)) | |
attrs <- sub(" *$", "", sub("^ *", "", unlist(attrSplit))) | |
if (is(file, "GFF3File")) { | |
- attrs <- paste(attrs, "=", sep = "") | |
- tvSplit <- strsplit(attrs, "=", fixed=TRUE) | |
- if (any(elementLengths(tvSplit) != 2)) | |
+ | |
+ equals.pos <- regexpr("=", attrs, fixed=TRUE) | |
+ if (any(equals.pos == -1)) | |
stop("Some attributes do not conform to 'tag=value' format") | |
- tvMat <- matrix(unlist(tvSplit), nrow = 2) | |
- tags <- tvMat[1,] | |
- vals <- tvMat[2,] | |
+ tags <- substr(attrs,1, equals.pos-1) | |
+ vals <- substr(attrs,equals.pos+1, nchar(attrs)) | |
} else { # split on first space (FIXME: not sensitive to quotes) | |
tags <- sub(" .*", "", attrs) # strip surrounding quotes | |
vals <- sub("^\"([^\"]*)\"$", "\\1", | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment