\name{gtf2gr}
\alias{gtf2gr}

\title{
GTF file parsing
}
\description{

Conversion of a gtf file from UCSC or ENSEMBL to a \linkS4class{GRanges} object maintaining the exon structure per transcript.

}
\usage{
gtf2gr(gtf_file, chromosomes=NA, refseq_nm=F, gtf_feature=c("exon"),transcript_id="transcript_id",gene_id="gene_id")
}

\arguments{
  \item{gtf_file}{
Character string with the filename of the gtf file. Fileformats from USCS and ENSEMBL are supported and gzip compression is supported.
}
  \item{chromosomes}{
A character vector with the chromosomes. Restricts the output to the case insensitive matching chromosomes.
}
  \item{refseq_nm}{
An option for GTF files based on RefSeq annotation. If TRUE only identifiers beginning with NM_ will be used.
}
  \item{gtf_feature}{
Defines the GTF feature types to be returned.
}
  \item{transcript_id}{
Defines name of the attribute within the attribute list which should be used as transcript IDs.
}
  \item{gene_id}{
Defines name of the attribute within the attribute list which should be used as gene IDs.
}
}
\details{
This function parses GTF files generated by the UCSC table browser or downloaded from the ENSEMBL ftp server. It uses only rows with a 'exon' tag in the feature column (3rd column). The transcript name will be generated from the 'transcript' entry in the attribute column (9th column). The exons of each transcript are numbered using the \code{make.unique} function on the transcript name and used as row names.
}

\value{
GenomicRanges object with one row per exon. \code{rownames} are transcript IDs and an exon_id is provided.
}
\author{Julius Muller \email{ju-mu@alumni.ethz.ch}}
\examples{

exgtf<-dir(system.file("extdata", package="TransView"),full=TRUE,patt="gtf.gz$")

GTF.mm9<-gtf2gr(exgtf[2])

head(GTF.mm9)

}


