#include<string>
#include<algorithm>
#include<sstream>
+#include<iostream>
+#include<vector>
#include "utils.h"
+#include "my_assert.h"
#include "Orientation.h"
#include "LenDist.h"
#include "RSPD.h"
int fpos = (dir == 0 ? pos : totLen - pos - insertLen); // the aligned position reported in SAM file, should be a coordinate in forward strand
int effL = std::min(fullLen, totLen - insertLen + 1);
- assert(fpos >= 0 && fpos + insertLen <= totLen && insertLen <= totLen);
+ general_assert(fpos >= 0, "The alignment of fragment " + read.getName() + " to transcript " + itos(sid) + " starts at " + itos(fpos) + \
+ " from the forward direction, which should be a non-negative number! " + \
+ "It is possible that the aligner you use gave different read lengths for a same read in SAM file.");
+ general_assert(fpos + insertLen <= totLen,"Fragment " + read.getName() + " is hung over the end of transcript " + itos(sid) + "! " \
+ + "It is possible that the aligner you use gave different read lengths for a same read in SAM file.");
+ general_assert(insertLen <= totLen, "Fragment " + read.getName() + " has length " + itos(insertLen) + ", but it is aligned to transcript " \
+ + itos(sid) + ", whose length (" + itos(totLen) + ") is shorter than the fragment's length!");
+
if (fpos >= fullLen || ref.getMask(fpos)) return 0.0; // For paired-end model, fpos is the seedPos
prob = ori->getProb(dir) * gld->getAdjustedProb(insertLen, totLen) *
const LenDist& getGLD() { return *gld; }
- void startSimulation(simul*, double*);
- bool simulate(int, PairedEndReadQ&, int&);
+ void startSimulation(simul*, const std::vector<double>&);
+ bool simulate(READ_INT_TYPE, PairedEndReadQ&, int&);
void finishSimulation();
//Use it after function 'read' or 'estimateFromReads'
- double* getMW() {
+ const double* getMW() {
assert(mw != NULL);
return mw;
}
static const int read_type = 3;
int M;
- int N[3];
+ READ_INT_TYPE N[3];
Refs *refs;
int seedLen;
genReadFileNames(readFN, i, read_type, s, readFs);
ReadReader<PairedEndReadQ> reader(s, readFs, refs->hasPolyA(), seedLen); // allow calculation of calc_lq() function
- int cnt = 0;
+ READ_INT_TYPE cnt = 0;
while (reader.next(read)) {
SingleReadQ mate1 = read.getMate1();
SingleReadQ mate2 = read.getMate2();
}
}
else if (verbose && (mate1.getReadLength() < seedLen || mate2.getReadLength() < seedLen)) {
- printf("Warning: Read %s is ignored due to at least one of the mates' length < seed length %d!\n", read.getName().c_str(), seedLen);
+ std::cout<< "Warning: Read "<< read.getName()<< " is ignored due to at least one of the mates' length < seed length "<< seedLen<< "!"<< std::endl;
}
++cnt;
- if (verbose && cnt % 1000000 == 0) { printf("%d READS PROCESSED\n", cnt); }
+ if (verbose && cnt % 1000000 == 0) { std::cout<< cnt<< " READS PROCESSED"<< std::endl; }
}
- if (verbose) { printf("estimateFromReads, N%d finished.\n", i); }
+ if (verbose) { std::cout<<"estimateFromReads, N"<< i<<" finished."<< std::endl; }
}
mld->finish();
fclose(fo);
}
-void PairedEndQModel::startSimulation(simul* sampler, double* theta) {
+void PairedEndQModel::startSimulation(simul* sampler, const std::vector<double>& theta) {
this->sampler = sampler;
theta_cdf = new double[M + 1];
nqpro->startSimulation();
}
-bool PairedEndQModel::simulate(int rid, PairedEndReadQ& read, int& sid) {
+bool PairedEndQModel::simulate(READ_INT_TYPE rid, PairedEndReadQ& read, int& sid) {
int dir, pos;
int insertL, mateL1, mateL2;
std::string name;