| 1 |
#include <fstream> |
| 2 |
#include <iostream> |
| 3 |
#include <string> |
| 4 |
|
| 5 |
#include "../src/allele_functions.h" |
| 6 |
#include "../src/call_variants.h" |
| 7 |
|
| 8 |
int call_var_check_outfile(std::string prefix, uint8_t min_qual, |
| 9 |
uint8_t min_depth, double min_threshold, |
| 10 |
std::string out[], int len) { |
| 11 |
std::string path = "../data/test.indel.mpileup"; |
| 12 |
std::ifstream mplp(path); |
| 13 |
call_variants_from_plup(mplp, prefix, min_qual, min_threshold, min_depth, |
| 14 |
"../data/db/test_ref.fa", "../data/test.gff", false); |
| 15 |
std::ifstream outFile(prefix + ".tsv"); |
| 16 |
std::string l; |
| 17 |
getline(outFile, l); // Ignore first line |
| 18 |
int comp = 0, ctr = 0; |
| 19 |
|
| 20 |
while (ctr < len) { |
| 21 |
getline(outFile, l); |
| 22 |
std::cout << l << std::endl; |
| 23 |
std::cout << out[ctr] << " -> CORRECT" << std::endl; |
| 24 |
comp += l.compare(out[ctr]); |
| 25 |
std::cout << l.compare(out[ctr]) << "\n"; |
| 26 |
ctr++; |
| 27 |
} |
| 28 |
return comp; |
| 29 |
} |
| 30 |
|
| 31 |
int main() { |
| 32 |
int num_success = 0; |
| 33 |
// Quality threshold 20. Frequency threshold: 0.03. Total_DP = 3. Indel passes |
| 34 |
// filters with total_depth 4. Has two lines. |
| 35 |
std::string t_20_02_1[4] = { |
| 36 |
"test\t210\tA\tT\t1\t1\t41\t2\t1\t40\t0.666667\t3\t0." |
| 37 |
"2\tFALSE\tgeneKatyPerry:id-test3\tAAG\tK\tATG\tM\t70", |
| 38 |
"test\t210\tA\tT\t1\t1\t41\t2\t1\t40\t0.666667\t3\t0.2\tFALSE\tid-" |
| 39 |
"testedit1\tGAA\tE\tGAT\tD\t70", |
| 40 |
"test\t210\tA\tT\t1\t1\t41\t2\t1\t40\t0.666667\t3\t0." |
| 41 |
"2\tFALSE\tgeneTaylorSwift:id-testedit2\tAGA\tR\tTGA\t*\t70", |
| 42 |
"test\t210\tA\t+GT\t1\t1\t41\t1\t0\t20\t0.25\t4\t0." |
| 43 |
"4\tFALSE\tNA\tNA\tNA\tNA\tNA\tNA"}; |
| 44 |
// Quality threshold 3-. Frequency threshold: 0.03. Total_DP = 3. Freq = |
| 45 |
// 0.666667 No Indel |
| 46 |
std::string t_20_03[3] = { |
| 47 |
"test\t210\tA\tT\t1\t1\t41\t2\t1\t40\t0.666667\t3\t0." |
| 48 |
"2\tFALSE\tgeneKatyPerry:id-test3\tAAG\tK\tATG\tM\t70", |
| 49 |
"test\t210\tA\tT\t1\t1\t41\t2\t1\t40\t0.666667\t3\t0.2\tFALSE\tid-" |
| 50 |
"testedit1\tGAA\tE\tGAT\tD\t70", |
| 51 |
"test\t210\tA\tT\t1\t1\t41\t2\t1\t40\t0.666667\t3\t0." |
| 52 |
"2\tFALSE\tgeneTaylorSwift:id-testedit2\tAGA\tR\tTGA\t*\t70"}; |
| 53 |
// Quality threshold 25. Frequency threshold: 0.03. Total_DP = 2. Freq = 0.5 |
| 54 |
// No Indel. |
| 55 |
std::string t_25_03[3] = { |
| 56 |
"test\t210\tA\tT\t1\t1\t41\t1\t1\t58\t0.5\t2\t0.4\tFALSE\tgeneKatyPerry:" |
| 57 |
"id-test3\tAAG\tK\tATG\tM\t70", |
| 58 |
"test\t210\tA\tT\t1\t1\t41\t1\t1\t58\t0.5\t2\t0.4\tFALSE\tid-" |
| 59 |
"testedit1\tGAA\tE\tGAT\tD\t70", |
| 60 |
"test\t210\tA\tT\t1\t1\t41\t1\t1\t58\t0.5\t2\t0." |
| 61 |
"4\tFALSE\tgeneTaylorSwift:id-testedit2\tAGA\tR\tTGA\t*\t70"}; |
| 62 |
// Minimum depth threshold. Should be empty |
| 63 |
std::string t_25_03_20[] = {}; |
| 64 |
num_success = |
| 65 |
call_var_check_outfile("../data/test.indel", 20, 0, 0.02, t_20_02_1, 4); |
| 66 |
std::cout << num_success << std::endl; |
| 67 |
num_success += |
| 68 |
call_var_check_outfile("../data/test.indel2", 20, 0, 0.03, t_20_03, 3); |
| 69 |
std::cout << num_success << std::endl; |
| 70 |
num_success += |
| 71 |
call_var_check_outfile("../data/test.indel3", 25, 0, 0.03, t_25_03, 3); |
| 72 |
std::cout << num_success << std::endl; |
| 73 |
num_success += call_var_check_outfile("../data/test.indel4", 25, 20, 0.03, |
| 74 |
t_25_03_20, 0); |
| 75 |
std::cout << num_success << std::endl; |
| 76 |
if (num_success == 0) return 0; |
| 77 |
return -1; |
| 78 |
} |