Documentation 
Count = getCounts(BioObj, StartPos, EndPos)
GroupCount = getCounts(BioObj, StartPos, EndPos, Groups)
GroupCount = getCounts(BioObj, StartPos, EndPos, Groups, R)
... = getCounts(..., Name,Value)
Count = getCounts(BioObj, StartPos, EndPos) returns Count, a nonnegative integer specifying the number of read sequences in BioObj, a BioMap object, that align to a specific range or set of ranges in the reference sequence. The range or set of ranges are defined by StartPos and EndPos. StartPos and EndPos can be two nonnegative integers such that StartPos is less than EndPos, and both integers are smaller than the length of the reference sequence. StartPos and EndPos can also be two column vectors representing a set of ranges (overlapping or segmented).
By default, getCounts counts each read only once. Therefore, if a read spans multiple ranges, that read instance is counted only once. When StartPos and EndPos specify overlapping ranges, the overlapping ranges are considered as one range.
GroupCount = getCounts(BioObj, StartPos, EndPos, Groups) specifies Groups, a row vector of integers or strings, the same size as StartPos and EndPos. This vector indicates the group to which each range belongs. GroupCount is a column vector containing a number of elements equal to the number of unique elements in Groups. GroupCount specifies the number of reads that align to each group, in the ascending order of unique groups in Groups.
Each group is treated independently. Therefore, a read can be counted in more than one group.
GroupCount = getCounts(BioObj, StartPos, EndPos, Groups, R) specifies a reference for each of the segmented ranges defined by StartPos, EndPos, and Groups.
... = getCounts(..., Name,Value) returns counts with additional options specified by one or more Name,Value pair arguments.
BioObj 
Object of the BioMap class. 
StartPos 
Either of the following:

EndPos 
Either of the following:

Groups 
Row vector of integers or strings, the same size as StartPos and EndPos. This vector indicates the group to which each range belongs. 
R 
Vector of positive integers indexing the SequenceDictionary property of BioObj, or a cell array of strings specifying the actual names of references. R must be ordered and have the same number of elements as the unique elements in Groups. If R has the same number of elements as Groups, then all of the entries in R for each unique value in Groups must be the same. 
Specify optional commaseparated 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.
Count 
Either of the following:

GroupCount 
Column vector containing a number of elements equal to the number of unique elements in Groups. The vector specifies the number of reads that align to each group, in the order of unique groups in Groups. The groups of ranges are treated independently. Therefore, a single read can be counted in more than one group. 
Construct a BioMap object, and then return the number of reads that align to at least one base position in two ranges of the reference sequence:
% Construct a BioMap object from a SAM file BMObj1 = BioMap('ex1.sam'); % Return the number of reads that align to the segmented range 1:50 and 71:100 counts_1 = getCounts(BMObj1,[1;71],[50;100])
counts_1 = 37
Construct a BioMap object, and then return the number of reads that align to at least one base position in two independent ranges of the reference sequence:
% Construct a BioMap object from a SAM file BMObj1 = BioMap('ex1.sam'); % Return the number of reads that align to each of the ranges, % 1:50 and 71:100, independent of each other counts_2 = getCounts(BMObj1,[1;71],[50;100],'independent',true)
counts_2 = 20 21
Notice that the total number of reads reported in counts_2 is greater than the number of reads reported in counts_1. This difference occurs because there are four reads that span the two ranges, and are counted twice in the second example.
Construct a BioMap object, and then return the number of reads that align to two separate groups of ranges of the reference sequence:
% Construct a BioMap object from a SAM file BMObj1 = BioMap('ex1.sam'); % Return the number of reads that align to a group containing range 30:60, % and also the number of reads that align to a group containing range 1:10 % and range 50:60 counts_3 = getCounts(BMObj1,[1;30;50],[10;60;60],[2 1 2])
counts_3 = 25 22
Construct a BioMap object, and then return the total number of reads aligned to the reference sequence:
% Construct a BioMap object from a SAM file BMObj1 = BioMap('ex1.sam'); % Return the number of sequences that align to the entire reference sequence getCounts(BMObj1,min(getStart(BMObj1)),max(getStop(BMObj1)))
ans = 1482
align2cigar  BioMap  cigar2align  getAlignment  getBaseCoverage  getCompactAlignment  getIndex