R/read.gff.R

Defines functions read.gff

Documented in read.gff

## read.gff.R (2018-05-22)

##   Read GFF Files

## Copyright 2016-2018 Emmanuel Paradis

## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.

read.gff <- function(file, na.strings = c(".", "?"), GFF3 = TRUE)
{
    w <- list("", "", "", 0L, 0L, 0, "", "", "")
    x <- scan(file, w, sep = "\t", quote = "", quiet = TRUE,
              na.strings = na.strings, comment.char = "#")
    for (i in c(1, 2, 3, 7, 8)) x[[i]] <- factor(x[[i]])
    names(x) <- c("seqid", "source", "type", "start", "end",
                  "score", "strand", "phase", "attributes")
    if (!GFF3) {
        names(x) <- c("seqname", "source", "feature", "start", "end",
                      "score", "strand", "frame", "attributes")
    }
    n <- length(x[[1]])
    attr(x, "row.names") <- as.character(seq_len(n))
    class(x) <- "data.frame"
    x
}

Try the ape package in your browser

Any scripts or data that you put into this service are public.

ape documentation built on March 31, 2023, 6:56 p.m.