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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#ifndef _BLASR_LISPVALUE_WEIGHTOR_IMPL_HPP_
#define _BLASR_LISPVALUE_WEIGHTOR_IMPL_HPP_
#include <alignment/algorithms/anchoring/LISPValue.hpp>
#include <alignment/tuples/TupleMetrics.hpp>
template <typename T_RefSequence, typename T_MatchList>
LISSumOfLogPWeightor<T_RefSequence, T_MatchList>::LISSumOfLogPWeightor(T_RefSequence &targetGenome)
{
genomeLength = targetGenome.length;
}
template <typename T_RefSequence, typename T_MatchList>
float LISSumOfLogPWeightor<T_RefSequence, T_MatchList>::ComputePValue(T_MatchList &matchList,
int &noOvpLisNBases,
int &noOvpLisSize)
{
float pMatch = 0;
size_t i;
T_MatchList noOvpLis;
StoreNonOverlappingIndices(matchList, noOvpLis);
noOvpLisSize = noOvpLis.size();
noOvpLisNBases = 0;
for (i = 0; i < noOvpLis.size(); i++) {
noOvpLisNBases += noOvpLis[i].l;
}
for (i = 0; i < noOvpLis.size(); i++) {
pMatch += -1 * ((int)noOvpLis[i].l);
// log(matchList[i].GetMultiplicity() / (1.0*genomeLength));
}
noOvpLisNBases = 0;
for (i = 0; i < matchList.size(); i++) {
noOvpLisNBases += matchList[i].l;
}
return pMatch;
}
template <typename T_RefSequence, typename T_MatchList>
float LISSumOfLogPWeightor<T_RefSequence, T_MatchList>::operator()(T_MatchList &matchList)
{
int temp;
return ComputePValue(matchList, temp, temp);
}
template <typename T_RefSequence, typename T_Tuple, typename T_MatchList>
LISSMatchFrequencyPValueWeightor<
T_RefSequence, T_Tuple, T_MatchList>::LISSMatchFrequencyPValueWeightor(T_RefSequence &_target)
{
target.seq = _target.seq;
target.length = _target.length;
}
template <typename T_RefSequence, typename T_Tuple, typename T_MatchList>
float LISSMatchFrequencyPValueWeightor<T_RefSequence, T_Tuple, T_MatchList>::ComputePValue(
T_MatchList &lis, int &noOvpLisNBases, int &noOvpLisSize)
{
T_MatchList noOvpLis;
StoreNonOverlappingIndices(lis, noOvpLis);
noOvpLisSize = noOvpLis.size();
size_t i;
noOvpLisNBases = 0;
for (i = 0; i < noOvpLis.size(); i++) {
noOvpLisNBases += noOvpLis[i].l;
}
if (noOvpLis.size() == 0) {
return 1;
}
float pMatch = 0;
for (i = 0; i < noOvpLis.size(); i++) {
assert(noOvpLis[i].GetMultiplicity() > 0);
pMatch += log((1.0 * noOvpLis[i].GetMultiplicity()) / target.length) * noOvpLis[i].l;
}
return pMatch;
}
template <typename T_RefSequence, typename T_Tuple, typename T_MatchList>
float LISSMatchFrequencyPValueWeightor<T_RefSequence, T_Tuple, T_MatchList>::operator()(
T_MatchList &lis)
{
int noOvpLisSize = 0;
return ComputePValue(lis, noOvpLisSize, noOvpLisSize);
}
template <typename T_RefSequence, typename T_Tuple, typename T_MatchList>
LISPValueWeightor<T_RefSequence, T_Tuple, T_MatchList>::LISPValueWeightor(
FASTASequence &_query, T_RefSequence &_target, TupleMetrics _tm,
TupleCountTable<T_RefSequence, T_Tuple> *_ct)
{
query.seq = _query.seq;
query.length = _query.length;
target.seq = _target.seq;
target.length = _target.length;
ct = _ct;
tm = _tm;
}
template <typename T_RefSequence, typename T_Tuple, typename T_MatchList>
float LISPValueWeightor<T_RefSequence, T_Tuple, T_MatchList>::ComputePValue(T_MatchList &matchList,
int &noOvpLisNBases,
int &noOvpLisSize)
{
return ComputeLISPValue(matchList, target, query, tm, *ct, noOvpLisNBases, noOvpLisSize);
}
template <typename T_RefSequence, typename T_Tuple, typename T_MatchList>
float LISPValueWeightor<T_RefSequence, T_Tuple, T_MatchList>::operator()(T_MatchList &matchList)
{
int noOvpLisSize = 0, noOvpLisNBases = 0;
return ComputeLISPValue(matchList, target, query, tm, *ct, noOvpLisNBases, noOvpLisSize);
}
#endif
|