samread
Read data from SAM file
Syntax
SAMStruct = samread(File)
[SAMStruct, HeaderStruct]=
samread(File)
... = samread(File,'ParameterName',ParameterValue)
Description
reads
a SAM-formatted file and returns the data in a MATLAB® array of
structures.SAMStruct = samread(File)
[ returns the alignment
and header data in two separate variables.SAMStruct, HeaderStruct]=
samread(File)
... = samread( accepts
one or more comma-separated parameter name/value pairs. Specify File,'ParameterName',ParameterValue)ParameterName inside
single quotes.
Input Arguments
| Character vector or string specifying a file name, path and file name of a SAM-formatted file, or the text of a SAM-formatted file. If you specify only a file name, that file must be on the MATLAB search path or in the current folder. |
Name-Value Arguments
Output Arguments
| An N-by-1 array of structures containing sequence alignment and mapping information from a SAM-formatted file, where N is the number of alignment records stored in the SAM-formatted file. Each structure contains the following fields.
| ||||||||||||||||||||||||||
| Structure containing header information for the SAM-formatted file in the following fields.
* — These structures and their fields appear in the output structure only if they are present in the SAM file. The information in these structures depends on the information present in the SAM file. |
Examples
Read the header information and the alignment data from the ex1.sam file
included with Bioinformatics Toolbox™, and then return the information
in two separate variables:
[data header] = samread('ex1.sam');Read a block of entries, excluding the tags, from the ex1.sam file,
and then return the information in an array of structures:
% Read entries 5 through 10 and do not include the tags
data = samread('ex1.sam','blockread', [5 10], 'tags', false);Tips
Use the
saminfofunction to investigate the size and content of a SAM-formatted file before using thesamreadfunction to read the file contents into a MATLAB array of structures.If your SAM-formatted file is too large to read using available memory, try one of the following:
Use the
BlockReadparameter with thesamreadfunction to read a subset of entries.Create a BioIndexedFile object from the SAM-formatted file, then access the entries using methods of the
BioIndexedFileclass.
Use the
SAMStructoutput argument thatsamreadreturns to create aBioMapobject, which lets you explore, access, filter, and manipulate all or a subset of the data, before doing subsequent analyses or viewing the data.
Version History
Introduced in R2010a
See Also
saminfo | soapread | fastqread | bamread | baminfo | fastqwrite | fastqinfo | fastainfo | fastaread | fastawrite | sffinfo | sffread | BioIndexedFile | BioMap