modified: myjupyterlab.sh
[GalaxyCodeBases.git] / c_cpp / readscorr / chrseq.h
blob980ddb6c10692e8692bc336e663755b501664825
1 #ifndef _G_CHRSEQ_H
2 #define _G_CHRSEQ_H
4 #include "gtypendef.h"
5 #include <stdint.h> // int_fast8_t
6 #include <stdlib.h> // malloc
8 FORCE_INLINE void NormalizeChrSeq(char *seq){
9 while(*seq){
10 switch (*seq) {
11 case 'a': case 'A':
12 *seq = 'A';
13 break;
14 case 't': case 'T':
15 *seq = 'T';
16 break;
17 case 'c': case 'C':
18 *seq = 'C';
19 break;
20 case 'g': case 'G':
21 *seq = 'G';
22 break;
23 default:
24 *seq = 'N';
25 break;
26 } // Whether a looking-up array[64] can be faster ?
27 ++seq;
31 // *seq must have been Normalized to /[ATCGN]*/
32 FORCE_INLINE char *ChrSeqRevComp(char const * seq, size_t len){
33 char *revcomseq=malloc(len+1);
34 const char *tmpseqin=seq+len-1; // if len is shorter than real length, trim it.
35 char *tmpseqrc=revcomseq;
36 while(tmpseqin>=seq){
37 switch (*tmpseqin) {
38 case 'A':
39 *tmpseqrc++ = 'T';
40 break;
41 case 'T':
42 *tmpseqrc++ = 'A';
43 break;
44 case 'C':
45 *tmpseqrc++ = 'G';
46 break;
47 case 'G':
48 *tmpseqrc++ = 'C';
49 break;
50 default:
51 *tmpseqrc++ = 'N';
52 break;
53 } // Whether a looking-up array[32] can be faster ?
54 --tmpseqin;
56 *tmpseqrc++ = '\0';
57 return revcomseq;
60 #endif // chrseq.h