write_reads {polyester} | R Documentation

## write sequencing reads to disk

### Description

given a DNAStringSet representing simulated sequencing reads, write FASTA files to disk representing the simulated reads.

### Usage

    write_reads(reads, fname, readlen, paired = TRUE, gzip, offset = 1L)

### Arguments

`reads` | DNAStringSet representing sequencing reads
`fname` | file path/prefix specifying where sequencing reads should be written. Should not contain ".fasta" (this is appended automatically).
`readlen` | maximum length of the reads in `reads`.
`paired` | If `TRUE`, reads are assumed to be in pairs: i.e., read 1 and read 2 in `reads` are the left and right mate (respectively) of a read pair; same with read 3 and read 4, etc. The odd-numbered reads are written to `fname_1.fasta` and the even-numbered reads are written to `fname_2.fasta`. If `FALSE`, reads are assumed to be single-end and just one file, `fname.fasta`, is written.
`gzip` | If `TRUE`, gzip the output fasta files.
`offset` | An integer number greater or equal to 1 to start assigning read numbers at.

### Details

The `get_reads` function returns a DNAStringSet object representing sequencing reads that can be directly passed to `write_reads`. If output other than that from `get_reads` is used and `paired` is `TRUE`, make sure `reads` is ordered properly (i.e., that mate pairs appear together and that the left mate appears first).

### Value

No return, but FASTA file(s) containing the sequences in `reads` are written to `fname.fasta` (if `paired` is FALSE) or `fname_1.fasta` and `fname_2.fasta` if `paired` is TRUE.

### See Also

`get_reads`

### Examples

      library(Biostrings)
      data(srPhiX174) # pretend srPhiX174 represents a DNAStringSet of *reads*
      readlen = unique(width(srPhiX174)) #35
      write_reads(srPhiX174, fname='./srPhiX174', readlen=readlen, paired=FALSE,
          gzip=FALSE)

    ## If the file is too big, you can subset it and write it in chunks.
    ## Here we split our 'reads' into two chunks and save them to the same file.
    write_reads(srPhiX174[1:100], fname='./srPhiX174-offset', readlen=readlen,
       paired=FALSE, gzip=FALSE, offset = 1L)
    write_reads(srPhiX174[101:length(srPhiX174)], fname='./srPhiX174-offset',
       readlen=readlen, paired=FALSE, gzip=FALSE, offset = 101L)

    ## We can verify that we get the same results
    srPhi <- readDNAStringSet('./srPhiX174.fasta')
    srPhiOffset <- readDNAStringSet('./srPhiX174-offset.fasta')
    identical(srPhi, srPhiOffset)

[Package polyester version 1.26.0 Index]