Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

scanFa

Operations on indexed 'fasta' files.


Description

Scan indexed fasta (or compressed fasta) files and their indicies.

Usage

indexFa(file, ...)
## S4 method for signature 'character'
indexFa(file, ...)

scanFaIndex(file, ...)
## S4 method for signature 'character'
scanFaIndex(file, ...)

countFa(file, ...)
## S4 method for signature 'character'
countFa(file, ...)

scanFa(file, param, ...,
    as=c("DNAStringSet", "RNAStringSet", "AAStringSet"))
## S4 method for signature 'character,GRanges'
scanFa(file, param, ...,
    as=c("DNAStringSet", "RNAStringSet", "AAStringSet"))
## S4 method for signature 'character,IntegerRangesList'
scanFa(file, param, ...,
    as=c("DNAStringSet", "RNAStringSet", "AAStringSet"))
## S4 method for signature 'character,missing'
scanFa(file, param, ...,
    as=c("DNAStringSet", "RNAStringSet", "AAStringSet"))

Arguments

file

A character(1) vector containing the fasta file path.

param

An optional GRanges or IntegerRangesList instance to select reads (and sub-sequences) for input.

as

A character(1) vector indicating the type of object to return; default DNAStringSet.

...

Additional arguments, passed to readDNAStringSet / readRNAStringSet / readAAStringSet when param is ‘missing’.

Value

indexFa visits the path in file and create an index file at the same location but with extension ‘.fai’).

scanFaIndex reads the sequence names and and widths of recorded in an indexed fasta file, returning the information as a GRanges object.

countFa returns the number of records in the fasta file.

scanFa return the sequences indicated by param as a DNAStringSet, RNAStringSet, AAStringSet instance. seqnames(param) selects the sequences to return; start(param) and end{param} define the (1-based) region of the sequence to return. Values of end(param) greater than the width of the sequence are set to the width of the sequence. When param is missing, all records are selected. When param is GRanges(), no records are selected.

Author(s)

Martin Morgan <mtmorgan@fhcrc.org>.

References

http://samtools.sourceforge.net/ provides information on samtools.

Examples

fa <- system.file("extdata", "ce2dict1.fa", package="Rsamtools",
                  mustWork=TRUE)
countFa(fa)
(idx <- scanFaIndex(fa))
(dna <- scanFa(fa, idx[1:2]))
ranges(idx) <- narrow(ranges(idx), -10)  # last 10 nucleotides
(dna <- scanFa(fa, idx[1:2]))

Rsamtools

Binary alignment (BAM), FASTA, variant call (BCF), and tabix file import

v2.6.0
Artistic-2.0 | file LICENSE
Authors
Martin Morgan, Hervé Pagès, Valerie Obenchain, Nathaniel Hayden
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.