-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest_nxtrim.cpp
71 lines (52 loc) · 2.87 KB
/
test_nxtrim.cpp
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
#include <iostream>
#include "gtest/gtest.h"
#include "matepair.h"
TEST(HammingMatch,PerfectMatches)
{
string adapter1 = "CTGTCTCTTATACACATCT";
string adapter2 = "AGATGTGTATAAGAGACAG";
int min_overlap=12;
float similarity=0.85;
string target = "AGATGTGTATAAGAGACAGGCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCCTGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGGCCTGGGCATTGGCGATGCCGCCAGTAACCCGA";
string query = "AGATGTGTATAAGAGACAG";
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),0);
target = "GCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCCTGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGGCCTGGGCATTGGCGATGCCGCCAGTAACCCGACGCCAGATGTGTATAAGAGACAG";
query = "AGATGTGTATAAGAGACAG";
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),target.size()-query.size());
string s1 = "GCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCC";
string s2 = "TGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGG";
query = adapter1+adapter2;
target = s1 + query + s2;
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),s1.size());
}
TEST(HammingMatch,NoisyMatches)
{
string adapter1 = "CTGTCTCTTATACACATCT";
string adapter2 = "AGATGTGTATAAGAGACAG";
int min_overlap=12;
float similarity=0.85;
string target = "AGGTGTGCATAAGAGACAGGCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCCTGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGGCCTGGGCATTGGCGATGCCGCCAGTAACCCGA";
string query = "AGATGTGTATAAGAGACAG";
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),0);
target = "GCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCCTGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGGCCTGGGCATTGGCGATGCCGCCAGTAACCCGACGCCAGATGTGTATATCAGACAG";
query = "AGATGTGTATAAGAGACAG";
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),target.size()-query.size());
string s1 = "GCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCC";
string s2 = "TGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGG";
query = "CTGTCTCTTATAGTCATCTAGATGTGTATAAGACACAG";
target = s1 + query + s2;
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),s1.size());
}
TEST(HammingMatch,PartialMatches)
{
string adapter1 = "CTGTCTCTTATACACATCT";
string adapter2 = "AGATGTGTATAAGAGACAG";
int min_overlap=12;
float similarity=0.85;
string target =adapter2.substr(4) + "GATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCCTGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGGCCTGGGCATTGGCGATGCCGCCAGTAACCCGA";
string query = adapter2;
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),-4);
target = "GCGATTTCCTTACATTGACGTTTTTATTACTCACTGTCCTGTTCCTGTTATCACATTATCTGCTGAACAATTACTGATAGGTTAAAGAGAACCAGGCCTGGGCATTGGCGATGCCGCCAGTAACCCGACG" + adapter1.substr(0,15);
query = adapter1;
ASSERT_EQ(hamming_match(target,query,min_overlap,similarity),target.size()-15);
}