void MafftAddToAlignmentTask::prepare() { algoLog.info(tr("Align sequences to an existing alignment by MAFFT started")); MSAUtils::removeColumnsWithGaps(inputMsa, inputMsa->getNumRows()); tmpDirUrl = ExternalToolSupportUtils::createTmpDir("add_to_alignment", stateInfo); QString tmpAddedUrl = generateTmpFileUrl(tmpDirUrl + QDir::separator() + "XXXXXXXXXXXXXXXX_add.fa");; DocumentFormatRegistry *dfr = AppContext::getDocumentFormatRegistry(); DocumentFormat *dfd = dfr->getFormatById(BaseDocumentFormats::FASTA); Document* tempDocument = dfd->createNewLoadedDocument(IOAdapterUtils::get(BaseIOAdapters::LOCAL_FILE), GUrl(tmpAddedUrl), stateInfo); QListIterator<QString> namesIterator(settings.addedSequencesNames); int currentRowNumber = inputMsa->getNumRows(); foreach(const U2EntityRef& sequenceRef, settings.addedSequencesRefs) { uniqueIdsToNames[QString::number(currentRowNumber)] = namesIterator.next(); U2SequenceObject seqObject(QString::number(currentRowNumber), sequenceRef); GObject* cloned = seqObject.clone(tempDocument->getDbiRef(), stateInfo); CHECK_OP(stateInfo, ); cloned->setGObjectName(QString::number(currentRowNumber)); tempDocument->addObject(cloned); currentRowNumber++; } saveSequencesDocumentTask = new SaveDocumentTask(tempDocument, tempDocument->getIOAdapterFactory(), tmpAddedUrl, SaveDocFlags(SaveDoc_Roll) | SaveDoc_DestroyAfter | SaveDoc_ReduceLoggingLevel); addSubTask(saveSequencesDocumentTask); QString tmpExistingAlignmentUrl = generateTmpFileUrl(tmpDirUrl + QDir::separator() + "XXXXXXXXXXXXXXXX.fa"); saveAlignmentDocumentTask = new SaveMSA2SequencesTask(inputMsa, tmpExistingAlignmentUrl, false, BaseDocumentFormats::FASTA); addSubTask(saveAlignmentDocumentTask); }
/******************************************* * WorkflowRunFromCMDLineBase *******************************************/ WorkflowRunFromCMDLineBase::WorkflowRunFromCMDLineBase() : Task(tr("Workflow run from cmdline"), TaskFlag_None), schema(NULL), optionsStartAt(-1), loadTask(NULL), workflowRunTask(NULL) { GCOUNTER(cvar,tvar,"workflow_run_from_cmdline"); CMDLineRegistry * cmdLineRegistry = AppContext::getCMDLineRegistry(); // try to process schema without 'task' option (it can only be the first one) QStringList pureValues = CMDLineRegistryUtils::getPureValues(); if( !pureValues.isEmpty() ) { QString schemaName = pureValues.first(); processLoadSchemaTask( schemaName, 1 ); // because after program name } if( loadTask != NULL ) { addSubTask( loadTask ); return; } // process schema with 'task' option int taskOptionIdx = CMDLineRegistryUtils::getParameterIndex( WorkflowDesignerPlugin::RUN_WORKFLOW ); if(taskOptionIdx != -1) { processLoadSchemaTask( cmdLineRegistry->getParameterValue( WorkflowDesignerPlugin::RUN_WORKFLOW, taskOptionIdx ), taskOptionIdx ); } if( loadTask == NULL ) { setError( tr( "no task to run" ) ); return; } addSubTask( loadTask ); }
void TopHatSupportTask::prepare() { settings.outDir = GUrlUtils::createDirectory( settings.outDir + "/" + outSubDirBaseName, "_", stateInfo); CHECK_OP(stateInfo, ); workingDirectory = setupTmpDir(); CHECK_OP(stateInfo, ); if (settings.data.fromFiles) { topHatExtToolTask = runTophat(); addSubTask(topHatExtToolTask); return; } /************************************************************************/ /* Create save tasks */ /************************************************************************/ QString url = workingDirectory + "/tmp_1.fq"; settings.data.urls << url; saveTmpDocTask = createSaveTask(url, tmpDoc, settings.data.seqIds); addSubTask(saveTmpDocTask); if (settings.data.paired) { QString pairedUrl = workingDirectory + "/tmp_2.fq"; settings.data.pairedUrls << pairedUrl; savePairedTmpDocTask = createSaveTask(pairedUrl, tmpDocPaired, settings.data.pairedSeqIds); addSubTask(savePairedTmpDocTask); } }
void HMMCalibrateParallelTask::prepare() { TaskLocalData::createHMMContext(getTaskId(), false); initTask = new HMMCreateWPoolTask(this); addSubTask(initTask); for(int i=0;i < settings.nThreads;i++){ addSubTask(new HMMCalibrateParallelSubTask(this)); } setMaxParallelSubtasks(1); }
void GenomeAlignerFindTask::prepare() { alignerTaskCount = alignContext->openCL ? 1 : AppContext::getAppSettings()->getAppResourcePool()->getIdealThreadCount(); if (alignContext->openCL) { Task *subTask = new ShortReadAlignerOpenCL(0, index, alignContext, writeTask); subTask->setSubtaskProgressWeight(1.0f); addSubTask(subTask); } else { setMaxParallelSubtasks(alignerTaskCount); for (int i = 0; i < alignerTaskCount; i++) { Task *subTask = new ShortReadAlignerCPU(i, index, alignContext, writeTask); subTask->setSubtaskProgressWeight(1.0f / alignerTaskCount); addSubTask(subTask); } } }
void FormatsMsaClipboardTask::prepare(){ CreateSubalignmentSettings settings = defineSettings(names, window, formatId, stateInfo); CHECK_OP(stateInfo, ) createSubalignmentTask = new CreateSubalignmentTask(msaObj, settings); addSubTask(createSubalignmentTask); }
void GTest_CalculateTreeFromAligment::prepare() { GObject *obj = getContext<GObject>(this, objContextName); if(obj==NULL){ stateInfo.setError(QString("wrong value: %1").arg(objContextName)); return; } MultipleSequenceAlignmentObject* maObj = qobject_cast<MultipleSequenceAlignmentObject*>(obj); if(maObj==NULL){ stateInfo.setError(QString("can't cast to multimple alignment object from: %1").arg(obj->getGObjectName())); return; } CreatePhyTreeSettings settings; settings.algorithmId = algName; settings.mb_ngen = 1000; settings.mrBayesSettingsScript = QString("Begin MrBayes;\n" "lset Nst=2 rates=gamma ngammacat=4;\n" "mcmc ngen=1000 samplefreq=100 printfreq=1000 nchains=4 temp=0.4 savebrlens=yes " "startingtree=random seed=10;\n" "sumt burnin=10;\n" "End;\n"); task = new PhyTreeGeneratorLauncherTask(maObj->getMultipleAlignment(), settings); if (task == NULL) { stateInfo.setError(QString("Algorithm %1 not found").arg(algName)); return; } addSubTask(task); }
void FormatDBSupportTask::prepare(){ const QString tempDir = prepareTempDir(); CHECK_OP(stateInfo, ); prepareTask = new PrepareInputFastaFilesTask(settings.inputFilesPath, tempDir); addSubTask(prepareTask); }
AddExportedDocumentAndOpenViewTask::AddExportedDocumentAndOpenViewTask(DocumentProviderTask* t) : Task("Export sequence to document", TaskFlags_NR_FOSCOE), loadTask(NULL) { exportTask = t; addSubTask(exportTask); }
void GTest_PhyML::prepare() { maDoc = getContext<Document>(this, inputDocCtxName); if (maDoc == NULL) { stateInfo.setError( QString("context not found %1").arg(inputDocCtxName) ); return; } QList<GObject*> list = maDoc->findGObjectByType(GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT); if (list.size() == 0) { stateInfo.setError( QString("container of object with type \"%1\" is empty").arg(GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT) ); return; } GObject *obj = list.first(); if(obj == NULL){ stateInfo.setError( QString("object with type \"%1\" not found").arg(GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT) ); return; } assert(obj != NULL); MultipleSequenceAlignmentObject* ma = qobject_cast<MultipleSequenceAlignmentObject*>(obj); if(ma == NULL){ stateInfo.setError( QString("error can't cast to multiple alignment from GObject") ); return; } input = ma; treeDoc = getContext<Document>(this, resultCtxName); if (treeDoc == NULL) { stateInfo.setError( QString("context not found %1").arg(resultCtxName) ); return; } QList<GObject*> list2 = treeDoc->findGObjectByType(GObjectTypes::PHYLOGENETIC_TREE); if (list2.size() == 0) { stateInfo.setError( QString("container of object with type \"%1\" is empty").arg(GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT) ); return; } GObject *obj2 = list2.first(); if(obj2 == NULL){ stateInfo.setError( QString("object with type \"%1\" not found").arg(GObjectTypes::PHYLOGENETIC_TREE) ); return; } treeObjFromDoc = qobject_cast<PhyTreeObject*>(obj2); if(treeObjFromDoc == NULL){ stateInfo.setError( QString("error can't cast to phylogenetic tree from GObject") ); return; } assert( obj != NULL); settings.algorithmId = PhyMLSupport::PhyMlRegistryId; task = new PhyTreeGeneratorLauncherTask(input->getMultipleAlignment(), settings); addSubTask(task); }
void DefaultConvertFileTask::prepare() { loadTask = LoadDocumentTask::getDefaultLoadDocTask(sourceURL); if (NULL == loadTask) { coreLog.info( QString("Cannot load file %1").arg(sourceURL.getURLString()) ); return; } addSubTask(loadTask); }
GTest_uHMMERCalibrate::GTest_uHMMERCalibrateSubtask::GTest_uHMMERCalibrateSubtask(HMMCalibrateToFileTask **calibrateTask, int n) :Task(tr("uhmmer-calibrate-subtask"),TaskFlags_NR_FOSCOE) { assert(calibrateTask!=NULL); for(int i=0;i<n;i++){ assert(calibrateTask[i]!=NULL); addSubTask(calibrateTask[i]); } }
RemoteBLASTTask::RemoteBLASTTask(const RemoteBLASTTaskSettings & cfg_) : Task(tr("RemoteBLASTTask"), TaskFlags_NR_FOSE_COSC), cfg(cfg_), httpBlastTask(NULL), createAnnotTask(NULL) { httpBlastTask = new RemoteBlastHttpRequestTask(cfg); addSubTask(httpBlastTask); }
void GTest_uHMMERBuild::init(XMLTestFormat* tf, const QDomElement& el) { Q_UNUSED(tf); QString inFile = el.attribute(IN_FILE_NAME_ATTR); if (inFile.isEmpty()) { failMissingValue(IN_FILE_NAME_ATTR); return; } outFile = el.attribute(OUT_FILE_NAME_ATTR); if (outFile.isEmpty()) { failMissingValue(OUT_FILE_NAME_ATTR); return; } QString expOpt = el.attribute(EXP_OPT_ATTR); if (expOpt.isEmpty()) { failMissingValue(EXP_OPT_ATTR); return; } QString hmmName = el.attribute(HMM_NAME_ATTR); QString delTempStr = el.attribute(DEL_TEMP_FILE_ATTR); if (delTempStr .isEmpty()) { failMissingValue(DEL_TEMP_FILE_ATTR); return; } if(delTempStr=="yes") deleteTempFile = true; else if(delTempStr=="no") deleteTempFile =false; else { failMissingValue(DEL_TEMP_FILE_ATTR); return; } UHMMBuildSettings s; s.name = hmmName; if(expOpt=="LS") s.strategy = P7_LS_CONFIG; else if(expOpt=="FS") s.strategy = P7_FS_CONFIG; else if(expOpt=="BASE") s.strategy = P7_BASE_CONFIG; else if(expOpt=="SW") s.strategy = P7_SW_CONFIG; else { stateInfo.setError( QString("invalid value %1, available values: LS, FS, BASE, SW").arg(EXP_OPT_ATTR) ); return; } QFileInfo fi(env->getVar("TEMP_DATA_DIR")+"/"+outFile); fi.absoluteDir().mkpath(fi.absoluteDir().absolutePath()); QFile createFile(fi.absoluteFilePath()); createFile.open(QIODevice::WriteOnly); if(!createFile.isOpen()){ stateInfo.setError( QString("File opening error \"%1\", description: ").arg(createFile.fileName())+createFile.errorString() ); return; } else createFile.close(); buildTask = new HMMBuildToFileTask(env->getVar("COMMON_DATA_DIR")+"/"+inFile, createFile.fileName(), s); outFile = createFile.fileName(); addSubTask(buildTask); }
void RFDiagonalAlgorithmWK::prepare(){ RFAlgorithmBase::prepare(); if (hasError()) { return; } int nThreads = getNumParallelSubtasks(); for (int i = 0; i < nThreads; i++) { addSubTask(new RFDiagonalWKSubtask(this, i, nThreads)); } }
void TabixSupportTask::prepare() { algoLog.details(tr("Tabix indexing started")); if ( BgzipTask::checkBgzf( fileUrl )) { algoLog.info(tr("Input file '%1' is already bgzipped").arg(fileUrl.getURLString())); copyTask = new CopyFileTask( fileUrl, bgzfUrl); addSubTask(copyTask); return; } if (bgzfUrl.isEmpty()) { bgzfUrl = GUrl(fileUrl.getURLString() + ".gz"); } algoLog.info(tr("Saving data to file '%1'").arg(bgzfUrl.getURLString())); bgzipTask = new BgzipTask(fileUrl, bgzfUrl); addSubTask(bgzipTask); }
void SatisfyTechRequirement::act() { printDebugInfo("Acting"); printDebugInfo(techType.c_str()); if (util::game::getSelf()->allUnitCount(techType.requiredUnit()) < 1) { CreateUnit* createUnit = new CreateUnit(techType.requiredUnit()); addSubTask(createUnit); } if (util::game::getSelf()->allUnitCount(techType.whatResearches()) < 1) { CreateUnit* createUnit = new CreateUnit(techType.whatResearches()); addSubTask(createUnit); } acting = true; printDebugInfo("Acting End"); }
void GTest_SecStructPredictAlgorithm::prepare() { SecStructPredictAlgRegistry* sspr = AppContext::getSecStructPredictAlgRegistry(); if (!sspr->hadRegistered(algName)) { stateInfo.setError( QString(tr("Algorithm named %1 not found")).arg(algName)); return; } SecStructPredictTaskFactory* factory = sspr->getAlgorithm(algName); task = factory->createTaskInstance(inputSeq.toLatin1()); addSubTask(task); }
void ContactTaskBase::setContact(Kopete::Contact *contact) { d->contact = contact; // Add the children tasks for DeleteContactTask from the rptocol KJob *subTask = d->contact->protocol()->createProtocolTask( taskType() ); if( subTask ) { kDebug(14010) << "Adding protocol subtask for " << taskType(); addSubTask(subTask); } }
void ExportCoverageTask::prepare() { getAssemblyNameTask = new GetAssemblyVisibleNameTask(dbiRef, assemblyId); addSubTask(getAssemblyNameTask); QDir().mkpath(QFileInfo(settings.url).absoluteDir().absolutePath()); if (settings.compress) { IOAdapterFactory *ioAdapterFactory = IOAdapterUtils::get(BaseIOAdapters::GZIPPED_LOCAL_FILE); SAFE_POINT_EXT(NULL != ioAdapterFactory, setError(tr("Can't write the compressed file: IOAdapterFactory is NULL")), ); ioAdapter.reset(ioAdapterFactory->createIOAdapter()); bool isSuccess = ioAdapter->open(settings.url, IOAdapterMode_Write); CHECK_EXT(isSuccess, setError(L10N::errorOpeningFileWrite(settings.url)), ); } else {
void Bowtie2Task::prepare() { if(!justBuildIndex) { setUpIndexBuilding(indexSuffixes); if(!settings.prebuiltIndex) { setUpIndexBuilding(largeIndexSuffixes); } } if (GzipDecompressTask::checkZipped(settings.refSeqUrl)) { temp.open(); //opening creates new temporary file temp.close(); unzipTask = new GzipDecompressTask(settings.refSeqUrl, GUrl(QFileInfo(temp).absoluteFilePath())); settings.refSeqUrl = GUrl(QFileInfo(temp).absoluteFilePath()); } if(!settings.prebuiltIndex) { QString indexFileName = settings.indexFileName; if(indexFileName.isEmpty()) { if(justBuildIndex) { indexFileName = settings.refSeqUrl.dirPath() + "/" + settings.refSeqUrl.baseFileName(); } else { indexFileName = settings.resultFileName.dirPath() + "/" + settings.resultFileName.baseFileName(); } } buildIndexTask = new Bowtie2BuildIndexTask(settings.refSeqUrl.getURLString(), indexFileName); } if(!justBuildIndex) { alignTask = new Bowtie2AlignTask(settings); } if (unzipTask != NULL) { addSubTask(unzipTask); } else if(!settings.prebuiltIndex) { addSubTask(buildIndexTask); } else if(!justBuildIndex) { addSubTask(alignTask); } else { assert(false); } }
void DnaAssemblyMultiTask::prepare() { // perform assembly QString algName = settings.algName; DnaAssemblyAlgorithmEnv* env= AppContext::getDnaAssemblyAlgRegistry()->getAlgorithm(algName); assert(env); if (env == NULL) { setError(QString("Algorithm %1 is not found").arg(algName)); return; } assemblyToRefTask = env->getTaskFactory()->createTaskInstance(settings, justBuildIndex); assemblyToRefTask->addListeners(getListeners()); addSubTask(assemblyToRefTask); }
void SpadesTask::prepare() { const QDir outDir = QFileInfo(settings.outDir.getURLString()).absoluteDir(); if (!outDir.exists()) { stateInfo.setError(tr("Folder does not exist: ") + outDir.absolutePath()); return ; } writeYamlReads(); if(hasError()){ return; } QStringList arguments; if(settings.getCustomValue(SpadesTask::OPTION_DATASET_TYPE, "Multi Cell").toString() == "Single Cell"){ arguments.append("--sc"); } QString runningMode = settings.getCustomValue(SpadesTask::OPTION_RUNNING_MODE, "Error Correction and Assembly").toString(); if(runningMode == "Assembly only"){ arguments.append("--only-assembler"); }else if(runningMode == "Error correction only"){ arguments.append("--only-error-correction"); } arguments.append("--dataset"); arguments.append(settings.outDir.getURLString() + QDir::separator() + SpadesTask::YAML_FILE_NAME); arguments.append("-t"); arguments.append(settings.getCustomValue(SpadesTask::OPTION_THREADS, "16").toString()); arguments.append("-m"); arguments.append(settings.getCustomValue(SpadesTask::OPTION_MEMLIMIT, "250").toString()); QString k = settings.getCustomValue(SpadesTask::OPTION_K_MER, "auto").toString(); if(k != "auto"){ arguments.append("-k"); arguments.append(k); } arguments.append("-o"); arguments.append(settings.outDir.getURLString()); //it uses system call gzip. it might not be installed arguments.append("--disable-gzip-output"); assemblyTask = new ExternalToolRunTask(ET_SPADES, arguments, new SpadesLogParser(), settings.outDir.getURLString()); if (!settings.listeners.isEmpty()) { assemblyTask->addOutputListener(settings.listeners.first()); } addSubTask(assemblyTask); }
DNASequenceGeneratorTask::DNASequenceGeneratorTask(const DNASequenceGeneratorConfig& cfg) : Task(tr("Generate sequence task"), TaskFlag_NoRun), cfg(cfg), loadRefTask(NULL), evalTask(NULL), generateTask(NULL), saveTask(NULL) { GCOUNTER( cvar, tvar, "DNASequenceGeneratorTask" ); if (cfg.useReference()) { // do not load reference file if it is already in project and has loaded state const QString& docUrl = cfg.getReferenceUrl(); Project* prj = AppContext::getProject(); if (prj) { Document* doc = prj->findDocumentByURL(docUrl); if (doc && doc->isLoaded()) { QString err; evalTask = createEvaluationTask(doc, err); if (evalTask) { addSubTask(evalTask); } else { stateInfo.setError(err); } return; } } loadRefTask = LoadDocumentTask::getDefaultLoadDocTask(GUrl(docUrl)); if (loadRefTask) { addSubTask(loadRefTask); } else { stateInfo.setError(tr("Incorrect reference file")); return; } } else { generateTask = new GenerateDNASequenceTask(cfg.getContent(), cfg.getLength(), cfg.window, cfg.getNumberOfSequences(), cfg.seed); addSubTask(generateTask); } }
void BlastDBCmdSupportTask::prepare(){ QStringList arguments; arguments << "-db" << settings.databasePath; arguments << "-dbtype" << (settings.isNuclDatabase ? "nucl" : "prot"); arguments << "-entry" << settings.query; arguments << "-logfile" << settings.outputPath+".BlastDBCmd.log"; arguments << "-out" << settings.outputPath; blastDBCmdTask = new ExternalToolRunTask(toolName, arguments, new ExternalToolLogParser()); blastDBCmdTask->setSubtaskProgressWeight(95); addSubTask(blastDBCmdTask); }
void BamBedConversionTask::prepare(){ QString extension = ".bed"; QString destURL = workingDir + QFileInfo(sourceURL.getURLString()).fileName() + extension; targetUrl = GUrlUtils::rollFileName(destURL, QSet<QString>()); QStringList args; args << "bamtobed"; args << "-i"; args << sourceURL.getURLString(); ExternalToolRunTask* etTask = new ExternalToolRunTask(ET_BEDTOOLS, args, new ExternalToolLogParser(), workingDir); etTask->setStandartOutputFile(targetUrl); addSubTask(etTask); }
void GTest_UHMM3Search::prepare() { assert( !hasError() ); setAndCheckArgs(); if( hasError() ) { return; } switch( algo ) { case GENERAL_SEARCH: searchTaskToCtx = new UHMM3LoadProfileAndSearchTask(settings, hmmFilename, sequence.seq); addSubTask( searchTaskToCtx ); break; case SEQUENCE_WALKER_SEARCH: if( machinePath.isEmpty() ) { /* search task on local machine */ searchTaskToCtx = new UHMM3SWSearchTask( hmmFilename, sequence, settings, swChunk ); addSubTask( searchTaskToCtx ); } else { /* search on remote machine */ addSubTask( LoadDocumentTask::getDefaultLoadDocTask( hmmFilename ) ); } break; default: assert( 0 && "undefined_algorithm_type" ); } }
void FindPatternListTask::prepare() { foreach (const NamePattern &pattern, patterns) { if (pattern.second.isEmpty()) { uiLog.error(tr("Empty pattern")); continue; } FindAlgorithmTaskSettings subTaskSettings = settings; subTaskSettings.pattern = pattern.second.toLocal8Bit().toUpper(); subTaskSettings.maxErr = getMaxError( subTaskSettings.pattern ); subTaskSettings.name = pattern.first; subTaskSettings.countTask = false; FindPatternTask *task = new FindPatternTask(subTaskSettings, removeOverlaps); addSubTask(task); } }
void GTest_LoadRemoteDocumentTask::prepare(){ RemoteDBRegistry& registry = RemoteDBRegistry::getRemoteDBRegistry(); const QList<QString> dataBases = registry.getDBs(); bool checked = false; foreach(const QString& db, dataBases) { if(dbName == db){ checked = true; } } if(!checked){ setError(tr("Given database name %1 not present in database registry").arg(dbName)); return; } t = new LoadRemoteDocumentTask(docId, dbName); addSubTask(t); }
void Bowtie2BuildIndexTask::prepare() { { QFileInfo file(referencePath); if(!file.exists()) { stateInfo.setError(tr("Reference file \"%1\" does not exist").arg(referencePath)); return; } } QStringList arguments; arguments.append(referencePath); arguments.append(indexPath); ExternalToolRunTask *task = new ExternalToolRunTask(ET_BOWTIE2_BUILD, arguments, new ExternalToolLogParser()); addSubTask(task); }