Main Content

getFlag

Class: BioMap

Retrieve read sequence flags from BioMap object

Syntax

Flag = getFlag(BioObj)
Flag = getFlag(BioObj, Subset)

Description

Flag = getFlag(BioObj) returns Flag, a vector of nonnegative integers indicating the bit-wise information that specifies the status of the 11 flags described by the SAM format specification. Each integer corresponds to one read sequence from a BioMap object.

Flag = getFlag(BioObj, Subset) returns flag integers for only object elements specified by Subset.

Input Arguments

BioObj

Object of the BioMap class.

Subset

One of the following to specify a subset of the elements in BioObj:

  • Vector of positive integers

  • Logical vector

  • Cell array of character vectors or string vector containing valid sequence headers

Note

If you use a cell array of headers to specify Subset, be aware that a repeated header specifies all elements with that header.

Output Arguments

Flag

Vector of nonnegative integers. Each integer corresponds to one read sequence and indicates the bit-wise information that specifies the status of the 11 flags described by the SAM format specification. These flags describe different sequencing and alignment aspects of a read sequence. Flag includes flag integers for only read sequences specified by Subset.

Examples

Construct a BioMap object, and then retrieve the SAM flag values for different elements in the object:

% Construct a BioMap object from a SAM file 
BMObj1 = BioMap('ex1.sam');
% Retrieve integer specifying bit-wise information for 11
% SAM flags of the second element
flagValue = getFlag(BMObj1, 2)
flagValue =

     73
% Retrieve integers specifying bit-wise information for 11
% SAM flags of the first and third elements
flagValues = getFlag(BMObj1, [1 3])
flagValues =

     73
    137
% Retrieve integers specifying bit-wise information for 11
% SAM flags of all elements
allFlagValues = getFlag(BMObj1);
% Determine the status of the fourth flag (mate is unmapped)
% for the second element, which has a flag value of 73
bitget(73, 4)
ans =

     1

Tips

After using the getFlag method to return the integer specifying the bit-wise information for the SAM flags, use the bitget function to determine the status of a specific SAM flag. For more information, see Examples.

Alternatives

An alternative to using the getFlag method is to use dot indexing with the Flag property:

BioObj.Flag(Indices)

In the previous syntax, Indices is a vector of positive integers or a logical vector. Indices cannot be a cell array of character vectors or string vector containing sequence headers.