write

Write contents of BioRead or BioMap object to file

Description

example

write(object,fName) writes the contents of a BioRead or BioMap object to a file named fName.

example

write(object,fName,Name,Value) uses additional options specified by one or more name-value pair arguments. For example, write(object,'data','Format','FASTQ') saves the contents of the object in the FASTQ-formatted file data.fastq.

Examples

collapse all

Create a BioRead object from an FASTQ file.

BRObj = BioRead('SRR005164_1_50.fastq');

Extract the first 10 elements from BRObj and store them in a new object.

subsetBRObj = getSubset(BRObj, [1:10]);

Write the contents of the subset data to a file named subsetData.fastq in the local C drive. By default, the file is FASTQ-formatted because the object contains the quality data.

write(subsetBRObj, 'C:\subsetData');

Input Arguments

collapse all

Object containing the read data, specified as a BioRead or BioMap object.

Example: bioreadObj

Name of the file where the contents of object are written, specified as a character vector or string.

The function adds the file extension automatically depending on the type of data the object contains. If you provide the extension, the function checks for consistency between the extension and the data format of the object. The file name can be prefixed by a file path. If the path is missing, the function writes the file to the same folder where the source file is located or to the current folder if the data is in memory.

Example: 'output'

Data Types: char

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: write(object,'data','Format','FASTQ') saves the contents of the object in the FASTQ-formatted file data.fastq.

File format, specified as a comma-separated pair consisting of 'Format' and a character vector or string.

For BioRead objects, available formats are 'FASTA' and 'FASTQ'. The default format is 'FASTA' if the object does not contain qualities, that is, the Quality property is empty. Otherwise, the default format is 'FASTQ'.

For BioMap objects, available formats are 'FASTA', 'FASTQ', 'SAM', and 'BAM' (default).

Example: 'Format','FASTA'

Data Types: char

Boolean indicator to overwrite an existing file, specified as a comma-separated pair consisting of 'Overwrite' and true or false. If true, the function overwrites the file and deletes any respective index file (*.idx,*.bai,*.linearindex) or ordered file (*.ordered.bam, *.ordered.sam) that is no longer needed.

Example: 'Overwrite',true

Data Types: logical

Introduced in R2010a