#include<algorithm>
using namespace std;
-typedef unsigned int INTEGER;
-
const int STRLEN = 1005;
-INTEGER M;
+int M;
int k; // k-mer size
vector<string> names;
vector<string> seqs;
-vector<INTEGER> effL;
+vector<int> effL;
// tid starts from 1
struct ReadType {
- INTEGER tid, pos;
+ int tid, pos;
- ReadType(INTEGER tid, INTEGER pos) {
+ ReadType(int tid, int pos) {
this->tid = tid;
this->pos = pos;
}
void loadRef(char* inpF) {
ifstream fin(inpF);
string tag, line, rawseq;
- void *pt;
assert(fin.is_open());
names.clear(); names.push_back("");
seqs.clear(); seqs.push_back("");
- pt = getline(fin, line);
- while (pt != 0 && line[0] == '>') {
+ getline(fin, line);
+ while ((fin) && (line[0] == '>')) {
tag = line.substr(1);
rawseq = "";
- while((pt = getline(fin, line)) && line[0] != '>') {
+ while((getline(fin, line)) && (line[0] != '>')) {
rawseq += line;
}
if (rawseq.size() <= 0) {
cands.clear();
effL.assign(M + 1, 0);
- for (INTEGER i = 1; i <= M; i++) {
- effL[i] = seqs[i].length() - k + 1;
+ for (int i = 1; i <= M; i++) {
+ effL[i] = int(seqs[i].length()) - k + 1;
if (effL[i] <= 0) effL[i] = 0; // effL should be non-negative
- for (INTEGER j = 0; j < effL[i]; j++)
+ for (int j = 0; j < effL[i]; j++)
cands.push_back(ReadType(i, j));
}
printf("All possbile %d mers are generated.\n", k);
p = i;
}
- for (INTEGER i = 1; i <= M; i++)
+ for (int i = 1; i <= M; i++)
if (effL[i] == 0) clusteringInfo[i] = -1.0;
else clusteringInfo[i] /= effL[i];
ofstream fout(argv[3]);
- for (INTEGER i = 1; i <= M; i++) fout<<names[i]<<"\t"<<setprecision(6)<<clusteringInfo[i]<<endl;
+ for (int i = 1; i <= M; i++) fout<<names[i]<<"\t"<<setprecision(6)<<clusteringInfo[i]<<endl;
fout.close();
return 0;