void MainWindow::appendTable(bool v) { setMatches(); int n; if (v) n = 5; else n = 1; ui->tableWidget->clear(); QStringList labels; labels << "Игрок" << "Команда" << "И" << "В" << "Н" << "П" << "MЗ" << "МП" << "Очки"; QStringList lst = trn->getData(n).toStringList(); ui->tableWidget->setRowCount(lst.size()); ui->tableWidget->setHorizontalHeaderLabels(labels); foreach (QString row, lst) { QStringList data = row.split(";"); for (int i = 0; i < data.count(); ++i) { QTableWidgetItem *it = new QTableWidgetItem (0); it->setFlags(Qt::ItemIsEnabled); it->setText(data.at(i)); ui->tableWidget->setItem(lst.indexOf(row), i, it); } }
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; }
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; }
void YoutubeSessionData::queryFinished() { QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender()); if (!m_reply) { qDebug() << "query finished .. but no reply" << sender(); return; } if (reply != m_reply) { reply->deleteLater(); qDebug() << "Late response"; return; } delete m_busyToken; m_busyToken = 0; if (m_context.isValid(this)) { QByteArray data = reply->readAll(); QJsonParseError *error = 0; QJsonDocument doc = QJsonDocument::fromJson(data, error); //qDebug() << "We have our reply!" << reply->url(); //qDebug() << doc.toJson(); if (!error) { QJsonObject obj = doc.object(); QVector<Sprinter::QueryMatch> matches; const QJsonArray entries = obj["items"].toArray(); for (QJsonArray::const_iterator it = entries.begin(); it != entries.end(); ++it) { const QJsonObject entry = (*it).toObject(); if (entry.isEmpty()) { continue; } const QJsonObject media = entry["snippet"].toObject(); const QString title = media["title"].toString(); const QString desc = media["description"].toString(); const QString author = media["channelTitle"].toString(); const QString url = s_baseUrl + entry["id"].toObject()["videoId"].toString(); const QString thumbnailUrl = media["thumbnails"].toObject()["high"].toObject()["url"].toString(); // qDebug() << "================================"; // qDebug() << title << seconds << time << desc << thumbnailUrl; Sprinter::QueryMatch match; match.setTitle(tr("%1 (%2)").arg(title, author)); match.setText(desc); match.setType(Sprinter::QuerySession::VideoType); match.setSource(Sprinter::QuerySession::FromNetworkService); match.setPrecision(Sprinter::QuerySession::CloseMatch); match.setUserData(url); match.setData(url); match.setImage(m_icon.pixmap(m_context.imageSize()).toImage()); matches << match; if (!thumbnailUrl.isEmpty()) { //TODO: requesting the thumbnail EVERY SINGLE TIME is not very cool // find a way to re-use existing thumbnails QNetworkRequest thumbRequest(thumbnailUrl); QNetworkReply *thumbReply = m_network->get(thumbRequest); connect(thumbReply, SIGNAL(finished()), this, SLOT(thumbRecv())); m_thumbJobs.insert(thumbReply->url(), match); } } // qDebug() <<" **********" << matches.count(); setMatches(matches, m_context); setCanFetchMoreMatches(true, m_context); } } reply->deleteLater(); m_reply = 0; }