Main Content

setFlag

Class: BioMap

Set read sequence flags for BioMap object

Description

NewObj = setFlag(BioObj, FlagValues) returns NewObj, a new BioMap object, constructed from BioObj, an existing BioMap object, with the Flag property set to FlagValues, a vector of nonnegative integers indicating the bit-wise information that specifies the status of each of the 11 flags described by the SAM format specification.

NewObj = setFlag(BioObj, FlagValues, Subset) sets the Flag property of the elements specified by Subset to FlagValues.

Input Arguments

expand all

Object of the BioMap class, specified as a BioMap object

Note

If BioObj was constructed from a BioIndexedFile object, you cannot set its Flag property.

SAM flag values, specified as vector of nonnegative integers. Each integer corresponds to one read sequence and indicates the bit-wise information that specifies the status of each of the 11 flags described by the SAM format specification. These flags describe different sequencing and alignment aspects of a read sequence.

Subset of elements in BioObj, specified as one of the following:

  • vector of positive integers

  • logical vector

  • cell array of character vectors containing valid sequence headers

Note

A one-to-one relationship must exist between the number and order of elements in FlagValues and Subset. 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

expand all

Object of the BioMap class, returned as a BioMap object.

Examples

expand all

Create a BioMap object from a SAM file. Set 'InMemory' to true to allow modifying the object properties.

bm = BioMap('ex2.sam','InMemory',true);

Check the SAM flag value of the 5th read sequence.

bm.Flag(5)
ans = uint16
    137

Update the flag value.

bm2 = setFlag(bm,75,5);
bm2.Flag(5)
ans = uint16
    75

Update the flag values of the first and third elements.

bm3 = setFlag(bm,[0 0],[1 3]);
bm3.Flag(1)
ans = uint16
    0
bm3.Flag(3)
ans = uint16
    0

Alternatives

An alternative to using the setFlag method to update an existing object is to use dot indexing with the Flag property:

BioObj.Flag(Indices) = NewFlag

In the previous syntax, Indices is a vector of positive integers or a logical vector. Indices cannot be a cell array of character vectors containing sequence headers. NewFlag is a vector of nonnegative integers indicating the bit-wise information that specifies the status of each of the 11 flags described by the SAM format specification. Each integer corresponds to one read sequence in a BioMap object. Indices and NewFlag must have the same number and order of elements.