Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DarwinAwardWinner
Created August 27, 2012 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarwinAwardWinner/3490557 to your computer and use it in GitHub Desktop.
Save DarwinAwardWinner/3490557 to your computer and use it in GitHub Desktop.
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