File: LISQValueWeightor.hpp

package info (click to toggle)
pbseqlib 5.3.1%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,136 kB
  • sloc: cpp: 77,246; python: 570; makefile: 312; sh: 111; ansic: 9
file content (36 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef _BLASR_LIS_QVALUE_WEIGHTOR_HPP_
#define _BLASR_LIS_QVALUE_WEIGHTOR_HPP_

#include <pbdata/DNASequence.hpp>
#include <pbdata/FASTQSequence.hpp>
#include <pbdata/qvs/QualityValue.hpp>

template <typename T_MatchList, typename T_Sequence>
class LISQValueWeightor
{
public:
    T_Sequence *seq;
    float operator()(const T_MatchList &matchList);
};

template <typename T_MatchList, typename T_Sequence>
float LISQValueWeightor<T_MatchList, T_Sequence>::operator()(const T_MatchList &matchList)
{
    float totalQ;
    DNALength nBases;
    VectorIndex i;
    totalQ = 0.0;
    nBases = 0;
    for (i = 0; i < matchList.size(); i++) {
        DNALength mp;
        for (mp = matchList[i].q; mp < matchList[i].q + matchList[i].w; mp++) {
            totalQ += (*seq).qual[mp];
        }
        nBases += matchList[i].w;
    }
    if (nBases > 0) {
        return totalQ / nBases;
    }
}

#endif