| 1 | #include <fstream> |
| 2 | #include <iostream> |
| 3 | #include <string> |
| 4 | |
| 5 | #include "../src/allele_functions.h" |
| 6 | #include "../src/call_consensus_pileup.h" |
| 7 | |
| 8 | int call_cns_check_outfile(std::string seq_id, std::string prefix, char gap, |
| 9 | bool call_min_depth, int min_depth) { |
| 10 | std::string path = "../data/test.gap.sorted.mpileup"; |
| 11 | std::string expctd_hdr = ""; |
| 12 | std::ifstream mplp(path); |
| 13 | call_consensus_from_plup(mplp, seq_id, prefix, 20, 0, min_depth, gap, |
| 14 | call_min_depth, 1); |
| 15 | std::ifstream outFile(prefix + ".fa"); |
| 16 | std::string l; |
| 17 | getline(outFile, l); // header |
| 18 | if (seq_id.empty()) { |
| 19 | char *o = new char[prefix.length() + 1]; |
| 20 | strcpy(o, prefix.c_str()); |
| 21 | expctd_hdr = |
| 22 | ">Consensus_" + std::string(basename(o)) + "_threshold_0_quality_20"; |
| 23 | |
| 24 | } else { |
| 25 | expctd_hdr = ">" + seq_id; |
| 26 | } |
| 27 | |
| 28 | return l.compare(expctd_hdr); |
| 29 | } |
| 30 | |
| 31 | int main() { |
| 32 | int num_success = 0; |
| 33 | std::string c_ = |
| 34 | "CTGCTGGGTCATGGGCCCATCATGATGGTCTTGGCGATTCTAGCCTTTTTGAGATTCACGGCAATCAAGCCA" |
| 35 | "TCACTGGGTCTCATCAATAGATGGGGTTCAGTGGGGAAAAAAGAGGCTATGGAAACAATAAAGAAGTTCAAG" |
| 36 | "AAAGAT------------------------------" |
| 37 | "AGGAAGGAGAAGAAGAGACGWGGCGCAGATACTAGTGTCGGAATTGTTGGMCTCCTGCTGACCACAGCTATG" |
| 38 | "GMAGCGGAGGTCACKAGACGTGGGAGTGCATACTATATGTACTTGGACWGAAACGATGCKGGGGAGGCCATA" |
| 39 | "TCTTTTCCAACCACATTGGGGTTGAATAAGTG"; |
| 40 | num_success = |
| 41 | call_cns_check_outfile("TESTID", "../data/test.gap", '-', true, 0); |
| 42 | std::cout << num_success << std::endl; |
| 43 | num_success += call_cns_check_outfile("", "../data/test.gap", 'N', true, 0); |
| 44 | std::cout << num_success << std::endl; |
| 45 | num_success += |
| 46 | call_cns_check_outfile("TESTID2", "../data/test.gap", 'N', false, 0); |
| 47 | std::cout << num_success << std::endl; |
| 48 | if (num_success == 0) return 0; |
| 49 | return -1; |
| 50 | } |