Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Patch to GFF3 reader in rtracklayer
--- 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