DP-HLS
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
host_utils.h
Go to the documentation of this file.
1 
12 #ifndef HOST_H
13 #define HOST_H
14 
15 #include <string>
16 #include <vector>
17 #include <array>
18 #include <complex>
19 #include <random>
20 #include <stack>
21 #include <map>
22 #include <iostream>
23 
24 using namespace std;
25 
26 #define AL_END_H 0b000 // 0 stopping condition
27 #define AL_INS_H 0b001 // 1 Align Insertion
28 #define AL_MMI_H 0b010 // 2 Align Match/Mismatch
29 #define AL_DEL_H 0b011 // 3 Align Deletion
30 #define AL_NULL_H 0b100 // 4 Do not change coordinate
31 
32 namespace Random
33 {
34  // Generate a random sequence of length `length` with alphabet size `alphabet_size`.
35  // The alphabet is [0, alphabet_size).
36  template <int N>
37  string Sequence(char alphabet[N], int length)
38  {
39  std::random_device rd;
40 
41  // Use the seed from random_device to seed the random engine
42  std::mt19937 rng(rd());
43 
44  // Create a uniform distribution for random numbers between 1 and 100
45  std::uniform_int_distribution<int> dist(1, 100);
46 
47  string seq = "";
48  for (int i = 0; i < length; i++)
49  {
50  seq += alphabet[dist(rng) % N];
51  }
52  return seq;
53  }
54 
55  template <typename T>
56  std::vector<T> SequenceComplex(int length)
57  {
58  std::random_device rd;
59 
60  // Use the seed from random_device to seed the random engine
61  std::mt19937 rng(rd());
62 
63  // Create a uniform distribution for random numbers between 1 and 100
64  std::uniform_int_distribution<int> dist(1, 100);
65 
66  std::vector<T> seq;
67  for (int i = 0; i < length; i++)
68  {
69  seq.push_back(T(dist(rng) % 10, dist(rng) % 10));
70  }
71  return seq;
72  }
73 
82  template <int WID>
83  std::vector<std::array<int, 5>> SequenceProfileAlignment(int len)
84  {
85  std::vector<std::array<int, 5>> profile;
86  for (int i = 0; i < len; i++)
87  {
88  int remaining = WID;
89  std::array<int, 5> col;
90  for (int j = 0; j < 4; j++)
91  {
92  col[j] = rand() % remaining;
93  remaining -= col[j];
94  }
95  col[4] = WID - remaining;
96  profile.push_back(col);
97  }
98  return profile;
99  }
100 
101 }
102 
103 namespace HostUtils
104 {
105  namespace IO
106  {
114  map<string, std::vector<string>> read_sequences_from_json(string file_path);
115 
116  std::vector<std::string> readFasta(const std::string &filePath);
117 
118  template <typename T, size_t M, size_t N>
119  void SwitchDimension(T (&src)[M][N], T (&dst)[N][M])
120  {
121  for (int i = 0; i < M; i++)
122  {
123  for (int j = 0; j < N; j++)
124  {
125  dst[j][i] = src[i][j];
126  }
127  }
128  }
129  }
130 
131  namespace Generate
132  {
138  }
139 
140  namespace Sequence
141  {
149  int base_to_num(char base);
150 
151  char num_to_base(int num);
152 
153  char num_to_aa(int num);
154  int aa_to_num(char aa);
155 
156  template <typename T>
157  string nav_to_string(T nav)
158  {
159  // Copilot, please write the above switch statement in to if statement
160  if (nav == (T) AL_NULL_H)
161  {
162  return "";
163  }
164  else if (nav == (T) AL_MMI_H)
165  {
166  return "D";
167  }
168  else if (nav == (T) AL_INS_H)
169  {
170  return "L";
171  }
172  else if (nav == (T) AL_DEL_H)
173  {
174  return "U";
175  }
176  else if (nav == (T) AL_END_H)
177  {
178  return "*";
179  }
180  else
181  {
182  return "?";
183  }
184  }
185 
195  template <typename T, size_t MAX_QRY_LENGTH, size_t MAX_REF_LENGTH>
196  std::vector<string> ReconstructTracebackProfile(std::vector<string> querys, std::vector<string> references,
197  int query_start_idx, int reference_start_idx,
198  T (&tb_streams)[MAX_REF_LENGTH + MAX_QRY_LENGTH])
199  {
200  std::vector<string> alignments_query;
201  std::vector<string> alignments_reference;
202  // print size of query
203  int num_queries = querys.size();
204  int num_references = references.size();
205  // initialize alignments
206  for (int i = 0; i < num_queries; i++)
207  {
208  alignments_query.push_back("");
209  }
210  for (int i = 0; i < num_references; i++)
211  {
212  alignments_reference.push_back("");
213  }
214  std::cout << "Number of queries: " << num_queries << endl;
215  std::cout << "Number of references: " << num_references << endl;
216  // If we also want to match the portion for the alignment exceeds the start index, use this
217  // string alignment_query = query.substr(query_start_idx + 1, query.length());
218  // string alignment_reference = reference.substr(reference_start_idx + 1, reference.length());
219 
220  std::vector<stack<char>> query_stack;
221  std::vector<stack<char>> reference_stack;
222 
223  // Initialize vectors for querys
224  for (int i = 0; i < querys.size(); i++)
225  {
226  stack<char> q;
227  for (int j = 0; j < query_start_idx; j++)
228  {
229  q.push(querys[i][j]);
230  }
231  query_stack.push_back(q);
232  }
233  // Initialize vectors for references
234  for (int i = 0; i < references.size(); i++)
235  {
236  stack<char> r;
237  for (int j = 0; j < reference_start_idx; j++)
238  {
239  r.push(references[i][j]);
240  }
241  reference_stack.push_back(r);
242  }
243 
244  // print traceback stream
245  // printf("Traceback stream: ");
246  // for (int i = 0; i < MAX_REFERENCE_LENGTH + MAX_QUERY_LENGTH; i++) {
247  // printf("%d ", tb_stream[i].to_int());
248  // }
249 
250  T *curr_ptr = &tb_streams[0];
251  // Insert the characters from the stack to the alignment strings to their beginning.
252  // Iterating in order the tb_steram
253  int cnt = 0;
254  while (*curr_ptr != (T)AL_END_H)
255  {
256  // printf("curr_ptr: %d\n", curr_ptr->to_int());
257  if (*curr_ptr == (T)AL_MMI_H)
258  {
259  for (int i = 0; i < querys.size(); i++)
260  {
261  alignments_query[i].insert(0, 1, query_stack[i].top());
262  query_stack[i].pop();
263  }
264  for (int i = 0; i < reference_stack.size(); i++)
265  {
266  alignments_reference[i].insert(0, 1, reference_stack[i].top());
267  reference_stack[i].pop();
268  }
269  }
270  else if (*curr_ptr == (T)AL_INS_H)
271  {
272  for (int i = 0; i < query_stack.size(); i++)
273  {
274  alignments_query[i].insert(0, 1, '_');
275  }
276  for (int i = 0; i < reference_stack.size(); i++)
277  {
278  alignments_reference[i].insert(0, 1, reference_stack[i].top());
279  reference_stack[i].pop();
280  }
281  }
282  else if (*curr_ptr == (T)AL_DEL_H)
283  {
284  for (int i = 0; i < query_stack.size(); i++)
285  {
286  alignments_query[i].insert(0, 1, query_stack[i].top());
287  query_stack[i].pop();
288  }
289  for (int i = 0; i < reference_stack.size(); i++)
290  {
291  alignments_reference[i].insert(0, 1, '_');
292  }
293  }
294  else if (*curr_ptr == (T)AL_NULL_H)
295  {
296  // Do nothing, AL_NULL Doesn't change the position
297  }
298  else
299  {
300  printf("Alignment Output Iteartion End\n");
301  }
302  curr_ptr++;
303  cnt++;
304  }
305 
306  // Finishing up concatenating the rest of the characters in the stack
307 
308  for (int i = 0; i < query_stack.size(); i++)
309  {
310  while (!query_stack[i].empty())
311  {
312  alignments_query[i].insert(0, 1, query_stack[i].top());
313  query_stack[i].pop();
314  }
315  }
316 
317  for (int i = 0; i < reference_stack.size(); i++)
318  {
319  while (!reference_stack[i].empty())
320  {
321  alignments_reference[i].insert(0, 1, reference_stack[i].top());
322  reference_stack[i].pop();
323  }
324  }
325 
326  // pad the head for query
327  for (int i = 0; i < query_stack.size(); i++)
328  {
329  while (alignments_query[i].length() < alignments_reference[0].length())
330  {
331 
332  alignments_query[i].insert(0, 1, '_');
333  }
334  }
335  // pad the head for reference
336  for (int i = 0; i < reference_stack.size(); i++)
337  {
338  while (alignments_reference[i].length() < alignments_query[0].length())
339  {
340 
341  alignments_reference[i].insert(0, 1, '_');
342  }
343  }
344 
345  // Merge alignments query and alignments reference into one data structure
346  std::vector<string> alignments;
347  for (int i = 0; i < querys.size(); i++)
348  {
349  alignments.push_back(alignments_query[i]);
350  }
351  for (int i = 0; i < references.size(); i++)
352  {
353  alignments.push_back(alignments_reference[i]);
354  }
355 
356  return alignments;
357  }
358 
366  std::vector<std::array<int, 5>> MultipleSequencesToProfileAlign(std::vector<string> seq, int len);
367 
375  template <typename T, size_t MAX_QRY_LENGTH, size_t MAX_REF_LENGTH>
376  std::map<string, string> ReconstructTraceback(string query, string reference,
377  int query_start_idx, int reference_start_idx,
378  T (&tb_streams)[MAX_REF_LENGTH + MAX_QRY_LENGTH])
379  {
380  // If we also want to match the portion for the alignment exceeds the start index, use this
381  // string alignment_query = query.substr(query_start_idx + 1, query.length());
382  // string alignment_reference = reference.substr(reference_start_idx + 1, reference.length());
383  string alignment_query = "";
384  string alignment_reference = "";
385 
386  stack<char> query_stack;
387  stack<char> reference_stack;
388 
389  // insert characters of query and reference into the stack, in sequence
390  for (int i = 0; i < query_start_idx + 1; i++)
391  {
392  query_stack.push(query[i]);
393  }
394  for (int i = 0; i < reference_start_idx + 1; i++)
395  {
396  reference_stack.push(reference[i]);
397  }
398 
399  // print traceback stream
400  // printf("Traceback stream: ");
401  // for (int i = 0; i < MAX_REFERENCE_LENGTH + MAX_QUERY_LENGTH; i++) {
402  // printf("%d ", tb_stream[i].to_int());
403  // }
404 
405  T *curr_ptr = &tb_streams[0];
406  // Insert the characters from the stack to the alignment strings to their beginning.
407  // Iterating in order the tb_steram
408  while (*curr_ptr != (T)AL_END_H)
409  {
410  // printf("curr_ptr: %d\n", curr_ptr->to_int());
411  if (*curr_ptr == (T)AL_MMI_H)
412  {
413  alignment_query = alignment_query.insert(0, 1, query_stack.top());
414  alignment_reference = alignment_reference.insert(0, 1, reference_stack.top());
415  query_stack.pop();
416  reference_stack.pop();
417  }
418  else if (*curr_ptr == (T)AL_INS_H)
419  {
420  alignment_query = alignment_query.insert(0, 1, '_');
421  alignment_reference = alignment_reference.insert(0, 1, reference_stack.top());
422  reference_stack.pop();
423  }
424  else if (*curr_ptr == (T)AL_DEL_H)
425  {
426  alignment_query = alignment_query.insert(0, 1, query_stack.top());
427  alignment_reference = alignment_reference.insert(0, 1, '_');
428  query_stack.pop();
429  }
430  else if (*curr_ptr == (T)AL_NULL_H)
431  {
432  // Do nothing, AL_NULL Doesn't change the position
433  }
434  else
435  {
436  printf("Alignment Output Iteartion End\n");
437  }
438  curr_ptr++;
439  }
440 
441  // Finishing up concatenating the rest of the characters in the stack
442  while (!query_stack.empty())
443  {
444  alignment_query = alignment_query.insert(0, 1, query_stack.top());
445  query_stack.pop();
446  }
447  while (!reference_stack.empty())
448  {
449  alignment_reference = alignment_reference.insert(0, 1, reference_stack.top());
450  reference_stack.pop();
451  }
452 
453  // pad the head for query
454  while (alignment_query.length() < alignment_reference.length())
455  {
456  alignment_query = alignment_query.insert(0, 1, '_');
457  }
458  // pad the head for reference
459  while (alignment_reference.length() < alignment_query.length())
460  {
461  alignment_reference = alignment_reference.insert(0, 1, '_');
462  }
463 
464  // return a dictionary (map) of aligned query and aligned reference
465  map<string, string> alignments;
466  alignments["query"] = alignment_query;
467  alignments["reference"] = alignment_reference;
468  return alignments;
469  }
470 
471  template <typename T, size_t MAX_QRY_LENGTH, size_t MAX_REF_LENGTH>
472  std::map<string, string> ReconstructTracebackSemiglobal(string query, string reference,
473  int query_start_idx, int reference_start_idx,
474  T (&tb_streams)[MAX_REF_LENGTH + MAX_QRY_LENGTH])
475  {
476  string alignment_reference = "";
477  string alignment_query = "";
478  string read_tb = "";
479  T *curr_ptr = &tb_streams[0];
480  if (query_start_idx == query.length() - 1)
481  { // short-long
482  char *qry_ptr = &query[query.length() - 1];
483  char *ref_ptr = &reference[reference.length() - 1];
484 
485  for (int i = 0; i < reference.size() - reference_start_idx; i++)
486  {
487  alignment_query = alignment_query.insert(0, 1, '_');
488  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
489  }
490 
491  // cout << alignment_query << endl;
492  // cout << alignment_reference << endl;
493  // cout << endl;
494 
495  while (*curr_ptr != (T)AL_END_H)
496  {
497  // check if ref_ptr or qry_ptr points to the first character of the string, break the loop if they do
498  if (*qry_ptr == '\0' || '\0' == *ref_ptr)
499  {
500  break;
501  }
502 
503  // printf("curr_ptr: %d\n", curr_ptr->to_int());
504  if (*curr_ptr == (T)AL_MMI_H)
505  {
506  alignment_query = alignment_query.insert(0, 1, *qry_ptr--);
507  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
508  }
509  else if (*curr_ptr == (T)AL_INS_H)
510  {
511  alignment_query = alignment_query.insert(0, 1, '_');
512  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
513  }
514  else if (*curr_ptr == (T)AL_DEL_H)
515  {
516  alignment_query = alignment_query.insert(0, 1, *qry_ptr--);
517  alignment_reference = alignment_reference.insert(0, 1, '_');
518  }
519  else if (*curr_ptr == (T)AL_NULL_H)
520  {
521  // Do nothing, AL_NULL Doesn't change the position
522  }
523  else
524  {
525  printf("Alignment Output Iteartion End\n");
526  }
527  read_tb.append(nav_to_string(*curr_ptr));
528  curr_ptr++;
529 
530  // cout << alignment_query << endl;
531  // cout << alignment_reference << endl;
532  // cout << read_tb << endl;
533  // cout << endl;
534  }
535 
536  // finish the alignment
537  while (*qry_ptr != '\0')
538  {
539  alignment_query = alignment_query.insert(0, 1, *qry_ptr--);
540  }
541  while (*qry_ptr != '\0'){
542  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
543  }
544 
545  while (*ref_ptr != '\0'){
546  alignment_query = alignment_query.insert(0, 1, '_');
547  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
548  }
549 
550  }
551  else if (reference_start_idx == reference.length() - 1)
552  { // long-short
553  }
554  else
555  {
556  std::runtime_error("Alignment is not actually semiglobal, please check traceback start index");
557  }
558  cout << "Reconstructed" << endl;
559 
560  map<string, string> alignments;
561  alignments["query"] = alignment_query;
562  alignments["reference"] = alignment_reference;
563  return alignments;
564  }
565 
566  template <typename T, size_t MAX_QRY_LENGTH, size_t MAX_REF_LENGTH>
567  std::map<string, string> ReconstructTracebackOverlapSuffixPrefix(string query, string reference,
568  int query_start_idx, int reference_start_idx,
569  T (&tb_streams)[MAX_REF_LENGTH + MAX_QRY_LENGTH])
570  {
571  string alignment_reference = "";
572  string alignment_query = "";
573  string read_tb = "";
574  T *curr_ptr = &tb_streams[0];
575 
576  char *qry_ptr = &query[query.length() - 1];
577  char *ref_ptr = &reference[reference.length() - 1];
578 
579  for (int i = 0; i < query.size() - query_start_idx; i++)
580  {
581  alignment_query = alignment_query.insert(0, 1, *qry_ptr--);
582  alignment_reference = alignment_reference.insert(0, 1, '_');
583  }
584 
585 
586 
587 
588 
589  // cout << alignment_query << endl;
590  // cout << alignment_reference << endl;
591  // cout << endl;
592 
593  while (*curr_ptr != (T)AL_END_H)
594  {
595  // check if ref_ptr or qry_ptr points to the first character of the string, break the loop if they do
596  if (*qry_ptr == '\0' || '\0' == *ref_ptr)
597  {
598  break;
599  }
600 
601  // printf("curr_ptr: %d\n", curr_ptr->to_int());
602  if (*curr_ptr == (T)AL_MMI_H)
603  {
604  alignment_query = alignment_query.insert(0, 1, *qry_ptr--);
605  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
606  }
607  else if (*curr_ptr == (T)AL_INS_H)
608  {
609  alignment_query = alignment_query.insert(0, 1, '_');
610  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
611  }
612  else if (*curr_ptr == (T)AL_DEL_H)
613  {
614  alignment_query = alignment_query.insert(0, 1, *qry_ptr--);
615  alignment_reference = alignment_reference.insert(0, 1, '_');
616  }
617  else if (*curr_ptr == (T)AL_NULL_H)
618  {
619  // Do nothing, AL_NULL Doesn't change the position
620  }
621  else
622  {
623  printf("Alignment Output Iteartion End\n");
624  }
625  read_tb.append(nav_to_string(*curr_ptr));
626  curr_ptr++;
627 
628  // cout << alignment_query << endl;
629  // cout << alignment_reference << endl;
630  // cout << read_tb << endl;
631  // cout << endl;
632  }
633 
634  while (*ref_ptr != '\0'){
635  alignment_query = alignment_query.insert(0, 1, '_');
636  alignment_reference = alignment_reference.insert(0, 1, *ref_ptr--);
637  }
638 
639  cout << "Reconstructed" << endl;
640 
641  map<string, string> alignments;
642  alignments["query"] = alignment_query;
643  alignments["reference"] = alignment_reference;
644  return alignments;
645  }
646 
647  template <typename T, int LEN>
648  string NavigationToString(T nav[LEN])
649  {
650  string str = "";
651  for (int i = 0; i < LEN; i++)
652  {
653  str.append(HostUtils::Sequence::nav_to_string(nav[i]));
654  }
655  return str;
656  }
657 
665  template <typename T, int NB, int MAX_QRY_LENGTH, int MAX_REF_LENGTH>
666  array<map<string, string>, NB> ReconstructTracebackBlocks(string query[NB], string reference[NB],
667  int query_start_idx[NB], int reference_start_idx[NB],
668  T (&tb_streams)[NB][MAX_REF_LENGTH + MAX_QRY_LENGTH])
669  {
670  // declare the result data structure
671  array<map<string, string>, NB> alignments;
672 
673  for (int i = 0; i < NB; i++)
674  {
675  alignments[i] = HostUtils::Sequence::ReconstructTraceback<T, MAX_QRY_LENGTH, MAX_REF_LENGTH>(query[i], reference[i],
676  query_start_idx[i], reference_start_idx[i], tb_streams[i]);
677  }
678 
679  return alignments;
680  }
681 
682  template <typename T, int NB, int MAX_QRY_LENGTH, int MAX_REF_LENGTH>
683  array<map<string, string>, NB> ReconstructTracebackSemiglobalBlocks(string query[NB], string reference[NB],
684  int query_start_idx[NB], int reference_start_idx[NB],
685  T (&tb_streams)[NB][MAX_REF_LENGTH + MAX_QRY_LENGTH])
686  {
687 
688  // declare the result data structure
689  array<map<string, string>, NB> alignments;
690 
691  for (int i = 0; i < NB; i++)
692  {
693  alignments[i] = HostUtils::Sequence::ReconstructTracebackSemiglobal<T, MAX_QRY_LENGTH, MAX_REF_LENGTH>(query[i], reference[i],
694  query_start_idx[i], reference_start_idx[i], tb_streams[i]);
695  }
696 
697  return alignments;
698  }
699 
700 
701  template <typename T, int NB, int MAX_QRY_LENGTH, int MAX_REF_LENGTH>
702  array<map<string, string>, NB> ReconstructTracebackOverlapSuffixPrefixBlocks(string query[NB], string reference[NB],
703  int query_start_idx[NB], int reference_start_idx[NB],
704  T (&tb_streams)[NB][MAX_REF_LENGTH + MAX_QRY_LENGTH])
705  {
706 
707  // declare the result data structure
708  array<map<string, string>, NB> alignments;
709 
710  for (int i = 0; i < NB; i++)
711  {
712  alignments[i] = HostUtils::Sequence::ReconstructTracebackOverlapSuffixPrefix<T, MAX_QRY_LENGTH, MAX_REF_LENGTH>(query[i], reference[i],
713  query_start_idx[i], reference_start_idx[i], tb_streams[i]);
714  }
715 
716  return alignments;
717  }
718 
719  }
720 
721  // template <typename T, int N_BLOCKS, typename CHAR_T, typename IDX_T, typename TBR_T>
722  // std::vector<std::vector<T>>align_all_sequences(void (*seq_align_multiple_static)(const std::string&, const std::string&),
723  // std::vector<string> querys, std::vector<string> references){
724  // const size_t num_pairs;
725 
726  // if (querys.size() != references.size()){
727  // // raise some runtime exception
728  // throw std::runtime_error("Different number of query and reference seqences. ");
729  // } else {
730  // num_pairs = querys.size();
731  // }
732 
733  // for (int i = 0; i < num_pairs; i += N_BLOCKS){
734  // for (int j = 0; j < N_BLOCKS; j++){
735  // // align kernel once
736 
737  // }
738  // }
739  // }
740 
741  // Need ot determine the type of the character so that the traceback can be reconstructed
742  // void align_all_sequences(std::vector<string> querys, std::vector<string> references, file){
743 
744  // }
745 }
746 
747 /*
748 DLDDLLDDDDDUDDUUDDDDUDUDUDDUUDDDDDDDDDDDDDD******?????**?*????***?????**?????***?????*********?*????**?????**
749 DLDDLLDDDDDUDDUUDDDDUDUDUDDUUDDDDDDDDDDDDD
750 
751 DDDLDDLDDLLLDDDDDLDLDDDUDDDLDDDDDDLDLDLDDLDDDUDDDDDD
752 DDDLDDLDDLLLDDDDDLDLDDDUDDDLDDDDDDLDLDLDDLDDDUDDDDDD*?**?*???****???**????****???**?******?*???**????**
753 */
754 
755 #endif // !HOST_H
#define AL_INS_H
Definition: host_utils.h:27
void SwitchDimension(T(&src)[M][N], T(&dst)[N][M])
Definition: host_utils.h:119
#define AL_MMI_H
Definition: host_utils.h:28
array< map< string, string >, NB > ReconstructTracebackOverlapSuffixPrefixBlocks(string query[NB], string reference[NB], int query_start_idx[NB], int reference_start_idx[NB], T(&tb_streams)[NB][MAX_REF_LENGTH+MAX_QRY_LENGTH])
Definition: host_utils.h:702
std::vector< std::array< int, 5 > > MultipleSequencesToProfileAlign(std::vector< string > seq, int len)
Given a array of sequences, convert them to the format of the input of profile alignment.
string NavigationToString(T nav[LEN])
Definition: host_utils.h:648
std::map< string, string > ReconstructTracebackOverlapSuffixPrefix(string query, string reference, int query_start_idx, int reference_start_idx, T(&tb_streams)[MAX_REF_LENGTH+MAX_QRY_LENGTH])
Definition: host_utils.h:567
std::map< string, string > ReconstructTraceback(string query, string reference, int query_start_idx, int reference_start_idx, T(&tb_streams)[MAX_REF_LENGTH+MAX_QRY_LENGTH])
Fucntion to reconstruct the alignment result from the an array of traceback navigations.
Definition: host_utils.h:376
std::vector< std::string > readFasta(const std::string &filePath)
#define AL_END_H
Definition: host_utils.h:26
int aa_to_num(char aa)
array< map< string, string >, NB > ReconstructTracebackBlocks(string query[NB], string reference[NB], int query_start_idx[NB], int reference_start_idx[NB], T(&tb_streams)[NB][MAX_REF_LENGTH+MAX_QRY_LENGTH])
Function to reconstruct the alignment result from the array of the traceback navigations for all bloc...
Definition: host_utils.h:666
string Sequence(char alphabet[N], int length)
Definition: host_utils.h:37
std::vector< T > SequenceComplex(int length)
Definition: host_utils.h:56
int base_to_num(char base)
Map a single base to a number. A: 0, C: 1, G: 2, T: 3, _: 4.
char num_to_aa(int num)
#define AL_DEL_H
Definition: host_utils.h:29
#define AL_NULL_H
Definition: host_utils.h:30
std::map< string, string > ReconstructTracebackSemiglobal(string query, string reference, int query_start_idx, int reference_start_idx, T(&tb_streams)[MAX_REF_LENGTH+MAX_QRY_LENGTH])
Definition: host_utils.h:472
array< map< string, string >, NB > ReconstructTracebackSemiglobalBlocks(string query[NB], string reference[NB], int query_start_idx[NB], int reference_start_idx[NB], T(&tb_streams)[NB][MAX_REF_LENGTH+MAX_QRY_LENGTH])
Definition: host_utils.h:683
string nav_to_string(T nav)
Definition: host_utils.h:157
std::vector< string > ReconstructTracebackProfile(std::vector< string > querys, std::vector< string > references, int query_start_idx, int reference_start_idx, T(&tb_streams)[MAX_REF_LENGTH+MAX_QRY_LENGTH])
Reconstruct the traceback for profile alignmetnt from the array of traceback navigations.
Definition: host_utils.h:196
std::vector< std::array< int, 5 > > SequenceProfileAlignment(int len)
A function that generates a random sequence in the format of the input of profile alignment...
Definition: host_utils.h:83
char num_to_base(int num)
map< string, std::vector< string > > read_sequences_from_json(string file_path)
Read form a json file storing the sequences in the format of &quot;specie_name&quot;: &quot;dna string&quot;.