write

Class: BioRead

Write contents of BioRead or BioMap object to file

Syntax

write(BioObj,FileName)
write(BioObj,FileName,Name,Value)

Description

write(BioObj,FileName) writes the contents of a BioRead or BioMap object BioObj to a file called FileName.

write(BioObj,FileName,Name,Value) writes the contents of BioRead or BioMap object to a file with additional options specified by Name,Value pair arguments.

Input Arguments

BioObj

Object of the BioRead or BioMap class.

FileName

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

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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Format'

String specifying the type of file format. Available formats are 'FASTA', 'FASTQ', 'SAM', and 'BAM' for BioMap objects, and'FASTA' and 'FASTQ' for BioRead objects. Default format for BioRead objects is 'FASTA' when the objects do not contain qualities, i.e., the Quality property of the object is empty. Otherwise, the default is 'FASTQ'. Default format for BioMap objects is 'BAM'.

'Overwrite'

Boolean indicator specifying whether an existing file can be overwritten. Default is false. If true, the method overwrites the file and deletes any respective index file (*.idx,*.bai,*.linearindex) or ordered file (*.ordered.bam, *.ordered.sam) that has become stale.

Default: false

Tip

    Note:   When you have an object that contains a subset of information from the source file, use this method to save the object in a separate file. Having a compact file only for the object can be more efficient and helpful in processing data or sharing among collaborators.

Examples

Write the Contents of BioRead Object to a File

Create a BioRead object from a FASTQ file.

BRObj = BioRead('SRR005164_1_50.fastq');

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

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

Write the contents of the subset object subsetBRObj to a file named subsetBRObj.fastq in a project folder (or any other folder) on a local C (or any other) drive.

write(subsetBRObj, 'C:\project\subsetBRObj');
Was this topic helpful?