int main(void) { halInit(); chSysInit(); initLed(); setLeds( 7 ); initRead(); initWrite(); initI2c(); initUsb(); /*IWDGConfig cfg; cfg.div = IWDG_DIV_256; cfg.counter = (40000 / 256 / 2 ); iwdgInit(); iwdgStart( &IWDGD, &cfg ); iwdgReset( &IWDGD );*/ while (TRUE) { //iwdgReset( &IWDGD ); processShell(); chThdSleepMilliseconds( 250 ); } return 0; }
void kmismatch(void *space, Suffixarray *s, fasta_t *reads, Uint k, Uint* counter, Uint rep_type, unsigned char silent, FILE *dev) { Uint i, curlen; char *buffer, *curseq; branch_t *V; Gmap map; Uint noofmatches=0; gread_t read; Container C; pthread_mutex_t *mtx=NULL; if (counter == NULL) { initProgressBarVT(); } else { mtx = &mutex2; } initGmap(&map, s->seq, 1); for (i=0; i < reads->noofseqs; i++) { noofmatches = 0; initRead(&read, reads->seqs[i]); setReads(&map, &read, 1); if (!silent) { if (mtx == NULL) { progressBarVT("reads matched.", reads->noofseqs, i, 25); } else { (*counter)++; } } curseq = reads->seqs[i]->sequence; curlen = reads->seqs[i]->length; V=kmis(space, s, curseq, curlen, k, &noofmatches); if(noofmatches) { bl_containerInit(&C, 100, sizeof(gmatch_t)); branch2match(s, &C, V, noofmatches); setMatches(&read, (gmatch_t*)C.contspace, bl_containerSize(&C), PLUSSTRAND); reportMatch(dev, &map, rep_type, 0, mtx, curlen, curlen); bl_containerDestruct(&C, NULL); FREEMEMORY(space, V); } initRead(&read, reads->seqs[i]); setReads(&map, &read, 1); buffer = charDNAcomplement(space, curseq, curlen); V=kmis(space, s, buffer, curlen, k, &noofmatches); if(noofmatches) { bl_containerInit(&C, 100, sizeof(gmatch_t)); branch2match(s, &C, V, noofmatches); setMatches(&read, (gmatch_t*)C.contspace, bl_containerSize(&C), MINUSSTRAND); reportMatch(dev, &map, rep_type, 0, mtx, curlen, curlen); bl_containerDestruct(&C, NULL); FREEMEMORY(space, V); } FREEMEMORY(space, buffer); } return; }
// This function rebuilds a page into the FTL BUF. If one of the chunks is in the log buffer, returns 1, otherwise returns 0. // If there's at least a chunk in log buffer, the page cannot be copied to data block, otherwise the lpn remains in the log buffer and will be reinserted when the log is flushed to flash. void rebuildPageToFtlBuf(const UINT32 dataLpn, const UINT32 sectOffset, const UINT32 nSects, const UINT8 mode) { uart_print("rebuild page to FTL BUF lpn="); uart_print_int(dataLpn); uart_print("\r\n"); initRead(dataLpn, sectOffset, nSects, mode); for (chunkIdx_ = sectOffset_ / SECTORS_PER_CHUNK; chunkIdx_<lastChunk_; chunkIdx_++) { uart_print("c "); uart_print_int(chunkIdx_); uart_print("\r\n"); if (chunksDone_[chunkIdx_] == 0) { chunksDone_[chunkIdx_] = 1; //oldChunkAddr_ = getChunkAddr(node_, chunkIdx_); if (ChunksMapTable(dataLpn, chunkIdx_) > DRAM_BASE + DRAM_SIZE) { uart_print_level_1("ERROR in rebuildPageToFtlBuf 1: reading above DRAM address space\r\n"); } oldChunkAddr_ = read_dram_32(ChunksMapTable(dataLpn, chunkIdx_)); uart_print("oldChunkAddr is "); uart_print_int(oldChunkAddr_); uart_print("\r\n"); switch (findChunkLocation(oldChunkAddr_)) { case Invalid: { uart_print(" not valid\r\n"); chunkInvalid(); continue; break; } case FlashWLog: { uart_print(" in flash w log\r\n"); chunkInFlashLog(FALSE); continue; break; } case DRAMWLog: { uart_print(" in dram w log\r\n"); chunkInWDramBuf(); continue; break; } #if Overwrite case DRAMOwLog: { uart_print(" in dram ow log\r\n"); oldChunkAddr_ = oldChunkAddr_ & 0x7FFFFFFF; chunkInOWDramBuf(); break; } case FlashOwLog: { uart_print(" in flash ow log\r\n"); oldChunkAddr_ = oldChunkAddr_ & 0x7FFFFFFF; chunkInFlashLog(TRUE); break; } #endif } } else { uart_print(" already done\r\n"); } } }
void matchkdseed( void *space, Suffixarray *s, fasta_t *reads, Uint minsize, char *outfile, Uint *counter, unsigned char silent, Uint s_ext, Uint p_mis, Uint Xoff, Uint k_p, Uint rep_type, Uint hitstrategy, Uint bedist, unsigned char showalignment, double maxevalue, int acc, Uint M, unsigned char matchingstat, FILE *dev, FILE *nomatchdev) { double H, K, lambda; char *buffer, *curseq; Uint k, curlen, dim, wordno; bitvector *D, *Mv; Gmap map; gread_t read; gmatch_t *mmatches=NULL, *pmatches=NULL; matchstem_t *V; int plusdiff, minusdiff, noofmatches=0; pthread_mutex_t *mtx=NULL; pthread_mutex_t *mtx2=NULL; Uint *enctab, i,j, nmmatch, npmatch; int bmscr, bpscr; unsigned char uninformative = 0, beststrand = 0, best = 0; if (hitstrategy == 2) { beststrand = 1; best = 1; } else if (hitstrategy == 1) { beststrand = 1; } /*build alignment matrix*/ enctab = encodetab(s->seq->map, s->seq->mapsize); dim = reads->maxlen + 2*((reads->maxlen-ceil((acc*reads->maxlen)/100))+4); wordno = reads->maxlen/BITVECTOR_WORDSIZE; // wordno += ((reads->maxlen & (BITVECTOR_WORDSIZE-1)) > 0) ? 1 : 0; wordno++; D = ALLOCMEMORY(space, NULL, bitvector, 2*(dim+1)); Mv = &D[dim+1]; for(i=0; i <= dim; i++) { D[i] = initbitvector(space, wordno*BITVECTOR_WORDSIZE); Mv[i] = initbitvector(space, wordno*BITVECTOR_WORDSIZE); } if (counter == NULL) { initProgressBarVT(); } else { mtx = &mutex1; mtx2 = &mutex2; } karlinunitcostpp(space, &lambda, &H, &K); for (k=0; k < reads->noofseqs; k++) { plusdiff = 0; minusdiff = 0; noofmatches = 0; if (!silent) { if (counter == NULL) { progressBarVT("reads matched.", reads->noofseqs, k, 25); } else { (*counter)++; } } curseq = reads->seqs[k]->sequence; curlen = reads->seqs[k]->length; npmatch = 0; nmmatch = 0; if(curlen >= minsize) { initGmap(&map, s->seq, 1); initRead(&read, reads->seqs[k]); bpscr = 0; bmscr = 0; V=kdseeds(space, s, curseq, curlen, s_ext, p_mis, Xoff, k_p); #ifdef KDUNINFORMATIVE if(V[0].branches[0].r > V[0].branches[0].l && V[0].branches[0].r-V[0].branches[0].l > M) { uninformative = 1; plusdiff = V[0].branches[0].r - V[0].branches[0].l; } else #endif if(!matchingstat) { uninformative = 0; pmatches = alignkdmatches(space, s, V, reads->seqs[k], curseq, curlen, M, enctab, beststrand, bedist, lambda, H, K, maxevalue, acc, D, dim, &npmatch, &bpscr); if(npmatch > 0) { setMatches(&read, pmatches, npmatch, PLUSSTRAND); } } else { printf("#%d %s\n",curlen, reads->seqs[k]->description); dumpkdseeds(s, V, curlen, '+', M); } for(j=0; j < curlen; j++) { if (V[j].noofbranches > 0) { FREEMEMORY(space, V[j].branches); } } FREEMEMORY(space, V); /*search the complement*/ buffer = charDNAcomplement(space, curseq, curlen); V=kdseeds(space, s, buffer, curlen, s_ext, p_mis, Xoff, k_p); #ifdef KDUNINFORMATIVE if(uninformative && V[0].branches[0].r > V[0].branches[0].l && V[0].branches[0].r-V[0].branches[0].l > M) { minusdiff = V[0].branches[0].r - V[0].branches[0].l; uninformative = 1; } else #endif if(!matchingstat) { uninformative = 0; mmatches = alignkdmatches(space, s, V, reads->seqs[k], buffer, curlen, M, enctab, beststrand, bedist, lambda, H, K, maxevalue, acc, D, dim, &nmmatch, &bmscr); if(nmmatch > 0) { setMatches(&read, mmatches, nmmatch, MINUSSTRAND); } if (best) { bpscr = MIN(bmscr, bpscr); bmscr = bpscr; } else if (!beststrand) { bpscr = bmscr = curlen-ceil((acc*curlen)/100); } setReads(&map, &read, 1); reportMatch(dev, &map, rep_type, showalignment, mtx, bpscr, bmscr); FREEMEMORY(space, pmatches); FREEMEMORY(space, mmatches); pmatches = NULL; mmatches = NULL; } else { dumpkdseeds(s, V, curlen, '-', M); } for(j=0; j < curlen; j++) { if (V[j].noofbranches > 0) { FREEMEMORY(space, V[j].branches); } } FREEMEMORY(space, V); FREEMEMORY(space, buffer); } if(nomatchdev && nmmatch == 0 && npmatch == 0) { if (mtx2 != NULL) pthread_mutex_lock(mtx2); fprintf(nomatchdev, "%s\n%s\n", reads->seqs[k]->description, reads->seqs[k]->sequence); fflush(nomatchdev); if (mtx2 != NULL) pthread_mutex_unlock(mtx2); } } wrapBitmatrix(space, D, 2*(dim+1)); FREEMEMORY(space, D); FREEMEMORY(space, enctab); return; }
DataReader_::DataReader_(boolean saveHeader) { initRead(saveHeader); }