int main() { FILE *f = openLog("unitTestLog.txt"); cunit_init(); // Initiate CUnit Roots root; Terms terms; // First unit test, should //terms.a = "1", terms.b = "2", terms.c = "1"; terms = validateInput("1", "2", "1"); if (terms.input == 1) { root = eqnControl(terms.a, terms.b, terms.c); //fwrite(assert_neq("x1", root.x1, -2.0), f); assert_neq("x1", root.x1, -2.0); fprintf(f, "x1: %f assert not equal %f\n", (double)root.x1, -2.0); assert_neq("x2", root.x2, -2.0); fprintf(f, "x2: %f assert not equal %f\n", (double)root.x2, -2.0); } printf("-------------------------------\n"); //terms.a = "2"; terms.b = "5"; terms.c = "-3"; terms = validateInput("2", "5", "-3"); if (terms.input == 1) { root = eqnControl(terms.a, terms.b, terms.c); assert_eq("x1", root.x1, 0.5); fprintf(f, "x1: %f assert equal %f\n", (double)root.x1, 0.5); assert_eq("x2", root.x2, -3.0); fprintf(f, "x2: %f assert equal %f\n", (double)root.x2, -3.0); } printf("-------------------------------\n"); //char terms.a, terms.b, terms.c; //terms.a = "a"; terms.b = "b"; terms.c = "c"; terms = validateInput("a", "b", "c"); if (terms.input == 1) { root = eqnControl(terms.a, terms.b, terms.c); assert_eq("x1", root.x1, 0.5); fprintf(f, "x1: %f assert equal %f\n", (double)root.x1, 0.5); assert_eq("x2", root.x2, -3.0); fprintf(f, "x2: %f assert equal %f\n", (double)root.x2, -3.0); } fclose(f); }
/** * Check that this Ebwt, when restored via restore(), matches up with * the given array of reference sequences. For sanity checking. */ void Ebwt::checkOrigs( const EList<SString<char> >& os, bool color, bool mirror) const { SString<char> rest; restore(rest); uint32_t restOff = 0; size_t i = 0, j = 0; if(mirror) { // TODO: FIXME return; } while(i < os.size()) { size_t olen = os[i].length(); int lastorig = -1; for(; j < olen; j++) { size_t joff = j; if(mirror) joff = olen - j - 1; if((int)os[i][joff] == 4) { // Skip over Ns lastorig = -1; if(!mirror) { while(j < olen && (int)os[i][j] == 4) j++; } else { while(j < olen && (int)os[i][olen-j-1] == 4) j++; } j--; continue; } if(lastorig == -1 && color) { lastorig = os[i][joff]; continue; } if(color) { assert_neq(-1, lastorig); assert_eq(dinuc2color[(int)os[i][joff]][lastorig], rest[restOff]); } else { assert_eq(os[i][joff], rest[restOff]); } lastorig = (int)os[i][joff]; restOff++; } if(j == os[i].length()) { // Moved to next sequence i++; j = 0; } else { // Just jumped over a gap } } }
/** * Transform this Ebwt into the original string in linear time by using * the LF mapping to walk backwards starting at the row correpsonding * to the end of the string. The result is written to s. The Ebwt * must be in memory. */ void Ebwt::restore(SString<char>& s) const { assert(isInMemory()); s.resize(this->_eh._len); uint32_t jumps = 0; uint32_t i = this->_eh._len; // should point to final SA elt (starting with '$') SideLocus l(i, this->_eh, this->ebwt()); while(i != _zOff) { assert_lt(jumps, this->_eh._len); //if(_verbose) cout << "restore: i: " << i << endl; // Not a marked row; go back a char in the original string uint32_t newi = mapLF(l ASSERT_ONLY(, false)); assert_neq(newi, i); s[this->_eh._len - jumps - 1] = rowL(l); i = newi; l.initFromRow(i, this->_eh, this->ebwt()); jumps++; } assert_eq(jumps, this->_eh._len); }