10 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
11 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
12 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
13 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
14 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 0, 4,
15 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
16 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 0, 4,
17 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
22 'A', 'C', 'G', 'T', 'N'
27 'T', 'G', 'C', 'A', 'N'
30 uint64_t seq2bit(string
&kseq
)
34 for(int i
=0; i
<kseq
.size(); i
++)
36 kbit
=(kbit
<<2)|alphabet
[kseq
[i
]];
42 string
bit2seq(uint64_t kbit
, int kmerSize
)
46 for(int i
=0; i
<kmerSize
; i
++)
48 kseq
.push_back(bases
[(kbit
>>(kmerSize
-1-i
)*2)&0x3]);
54 bool check_seq(string
&seq
)
57 for (int i
= 0; i
< seq
.size(); i
++)
59 if (alphabet
[seq
[i
]] == 4)
70 void reverse_complement (string
&in_str
, string
&out_str
)
72 for (int64_t i
=in_str
.size()-1; i
>=0; i
--)
74 out_str
.push_back(c_bases
[alphabet
[in_str
[i
]]]);
78 void TrimRight(string
& str
)
80 int pos
= str
.length() - 1;
84 while((c
== '\t') || (c
== '\n') || (c
== ' '))
86 str
= str
.substr(0, pos
);
87 pos
= str
.length() - 1;
97 void TrimLeft(string
& str
)
102 while((c
== '\t') || (c
== '\n') || (c
== ' '))
105 if(str
.length() == 0)
114 vector
<string
> splitString(string str
, string delims
)
118 //const string delims(" \t\n");
119 string::size_type begIdx
, endIdx
;
120 begIdx
= str
.find_first_not_of(delims
);
121 while(begIdx
!= string::npos
)
123 endIdx
= str
.find_first_of(delims
, begIdx
);
124 if(endIdx
== string::npos
)
126 endIdx
== str
.length();
129 vec
.push_back(str
.substr(begIdx
, endIdx
-begIdx
));
130 begIdx
= str
.find_first_not_of(delims
, endIdx
);
135 vector
<int> splitStringToInt(string str
, string delims
)
139 string::size_type begIdx
, endIdx
;
140 begIdx
= str
.find_first_not_of(delims
);
141 while(begIdx
!= string::npos
)
143 endIdx
= str
.find_first_of(delims
, begIdx
);
144 if(endIdx
== string::npos
)
146 endIdx
== str
.length();
148 vec
.push_back(toInt(str
.substr(begIdx
, endIdx
-begIdx
)));
149 begIdx
= str
.find_first_not_of(delims
, endIdx
);
154 int toInt(string str
)
158 //int prec = numeric_limits<int>::digits10;
159 //ss.precision(prec);
165 uint64_t toUint64(string str
)
169 //int prec = numeric_limits<int>::digits10;
170 //ss.precision(prec);
176 char toUpper(const char& ch
)
184 char toLower(const char& ch
)
191 string
ToUpper(string str
)
194 for(int i
=0; i
<str
.length(); ++i
)
196 temp
+= toUpper(str
[i
]);
201 string
ToLower(string str
)
204 //transform (str.begin(),str.end(), temp.begin(), toLower);
205 for(int i
=0; i
<str
.length(); ++i
)
207 temp
+= toUpper(str
[i
]);