void RunQSNP::run() { Configuration* pConfig = Configuration::getConfig(); Logger* pLogger = Logger::getLogger(); pLogger->log(QSNP_ALWAYS, "QualitySNP started with settings: " + pConfig->toString()); ContigProvider contigProvider; if (!contigProvider.init()) { emit reportError("Could read contig file"); return; } vector<string> readGroups; if(pConfig->getBool("outputReadGroups")) { readGroups = contigProvider.getReadGroups(); } CSVWriter csvWriter(readGroups); if (!csvWriter.init()) { emit reportError("Could not write results"); emit done(); return; } pConfig->writeFile("config.cfg", pConfig->getString("outputDirectory")); QString message; if(pConfig->getBool("collectStatistics")) { message = QString("Processing a total of %1 contigs with %2 reads").arg(contigProvider.getContigCount()).arg(contigProvider.getReadCount()); emit printMessage(message); } QMutex mutex; Contig* pContig = contigProvider.nextContig(); while (pContig != NULL && !_bCancelled) { message = "Processing: " + QString::fromStdString(pContig->getName()); emit printMessage(message); QSNPRunTask *runTask = new QSNPRunTask(); runTask->setContig(pContig); runTask->setWriter(&csvWriter); runTask->setShowContigsWithoutSNP(pConfig->getBool("showContigsWithoutSNP")); runTask->setMutex(&mutex); while(!QThreadPool::globalInstance()->tryStart(runTask)) { I::msleep(1); // sleep for 1 millisecond before trying again } message = "Done"; emit printMessage(message); pContig = contigProvider.nextContig(); } QThreadPool::globalInstance()->waitForDone(); emit done(); }
int KEduVocDocument::saveAs( const KUrl & url, FileType ft, const QString & generator ) { KUrl tmp( url ); if ( ft == Automatic ) { if ( tmp.path().right( strlen( "." KVTML_EXT ) ) == "." KVTML_EXT ) ft = Kvtml; else if ( tmp.path().right( strlen( "." CSV_EXT ) ) == "." CSV_EXT ) ft = Csv; else { return FileTypeUnknown; } } QFile f( tmp.path() ); if ( !f.open( QIODevice::WriteOnly ) ) { kError() << i18n( "Cannot write to file %1", tmp.path() ); return FileCannotWrite; } KUrl oldUrl = d->m_url; bool saved = false; d->m_url = tmp; switch ( ft ) { case Kvtml: { // write version 2 file KEduVocKvtml2Writer kvtmlWriter( &f ); saved = kvtmlWriter.writeDoc( this, generator ); } break; ///@todo port me // case Kvtml1: { // // write old version 1 file // KEduVocKvtmlWriter kvtmlWriter( &f ); // saved = kvtmlWriter.writeDoc( this, generator ); // } // break; case Csv: { KEduVocCsvWriter csvWriter( &f ); saved = csvWriter.writeDoc( this, generator ); } break; default: { kError() << "kvcotrainDoc::saveAs(): unknown filetype" << endl; } break; } // switch f.close(); if ( !saved ) { kError() << "Error Saving File" << tmp.path(); d->m_url = oldUrl; return FileWriterFailed; } setModified( false ); return 0; }