File: SeqUtilsImpl.hpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (47 lines) | stat: -rw-r--r-- 1,047 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
37
38
39
40
41
42
43
44
45
46
47
#include <vector>
#include <iostream>
#include <stdint.h>
#include "utils.hpp"
#include "DNASequence.hpp"
#include "NucConversion.hpp"
#include "SeqUtils.hpp"

template< typename T_Sequence>
int OnlyACTG(T_Sequence &seq) {
    DNALength p;
    for (p = 0; p < seq.length; p++) { 
        if (ThreeBit[seq.seq[p]] > 3)
            return 0;
    }
    return 1;
}

template< typename T_Sequence>
DNALength CountMasked(T_Sequence &seq) {
    DNALength p;
    DNALength nMasked = 0;
    for (p = 0; p < seq.length; p++) {
        if ((seq.seq[p] >= 'a' and
                    seq.seq[p] <= 'z') or
                seq.seq[p] == 'N')	{
            nMasked++;
        }
    }
    return nMasked;
}

template< typename T_Sequence>
int CountNotMasked(T_Sequence &seq) {
    int p;
    int nUnmasked = 0;
    for (p = 0; p < seq.length; p++ ) {
        if (seq.seq[p] == 'A' or
                seq.seq[p] == 'C' or
                seq.seq[p] == 'G' or
                seq.seq[p] == 'T') {
            nUnmasked++;
        }
    }

    return nUnmasked;
}