Write to file using FASTQ format
fastqwrite(File, Header, Sequence, Qual)
fastqwrite(File, FASTQStruct) writes the contents of a MATLAB® structure or array of structures to a FASTQ-formatted file. If you specify an existing FASTQ-formatted file, fastqwrite appends the data to the file, instead of overwriting the file.
fastqwrite(File, Header, Sequence, Qual) writes header, sequence, and quality information to a FASTQ-formatted file.
Tip To append FASTQ-formatted data to an existing file, simply specify that file name. fastqwrite adds the data to the end of the file.
If you are using fastqwrite in a script, you can disable the append warning message by entering the following command lines before the fastqwrite command:
warnState = warning %Save the current warning state warning('off','Bioinfo:fastqwrite:AppendToFile');
Then enter the following command line after the fastqwrite command:
warning(warnState) %Reset warning state to previous settings
String specifying either a file name or a path and file name for saving the FASTQ-formatted data. If you specify only a file name, fastqwrite saves the file to the MATLAB Current Folder. If you specify an existing file, fastqwrite appends the data to the file, instead of overwriting the file.
MATLAB structure or array of structures containing the fields Header, Sequence, and Quality, such as returned by fastqread.
String or name of a variable containing information about the nucleotide sequence. This text appears in the header of the FASTQ-formatted file, File.
String or name of a variable containing ASCII representation of per-base quality scores for a nucleotide sequence.
A FASTQ-formatted file contains nucleotide sequence and quality information on four lines:
Line 1 — Header information prefixed with an @ symbol
Line 2 — Nucleotide sequence
Line 3 — Header information prefixed with a + symbol
Line 4 — ASCII representation of per-base quality scores for the nucleotide sequence using Phred or Solexa encoding
Write multiple sequences to a FASTQ file from an array of structures:
% Read the contents of a FASTQ-formatted file into % an array of structures reads = fastqread('SRR005164_1_50.fastq'); % Create another array of structures for the first five reads reads5 = reads(1:5); % Write the first five reads to a separate FASTQ-formatted file fastqwrite('fiveReads.fastq', reads5)
Write a single sequence to a FASTQ file from separate variables:
% Create separate variables for the header, sequence, and % quality information of a nucleotide sequence h = 'MYSEQ-000_1_1_1_953_493'; s = 'GTTACCATGATGTTATTTCTTCATTTGGAGGTAAAA'; q = ']]]]]]]]]]]]]]]]]]]]]]T]]]]RJRZTQLOA'; % Write the information to a FASTQ-formatted file fastqwrite('oneRead.fastq', h, s, q)