Пример #1
0
QList<Task*> WorkflowRunFromCMDLineBase::onSubTaskFinished( Task* subTask ) {
    assert( subTask != NULL );
    QList<Task*> res;

    propagateSubtaskError();
    if( hasError() || isCanceled() ) {
        return res;
    }
    assert( !hasError() ); // if error, we won't be here

    if( loadTask == subTask ) {
        Schema * schema = loadTask->getSchema();
        assert( schema != NULL );
        remapping = loadTask->getRemapping();

        setSchemaCMDLineOptions( schema, optionsStartAt );
        if( schema->getDomain().isEmpty() ) {
            QList<QString> domainsId = WorkflowEnv::getDomainRegistry()->getAllIds();
            assert(!domainsId.isEmpty());
            if(!domainsId.isEmpty()) { schema->setDomain(domainsId.first()); }
        }

        QStringList l;
        bool good = WorkflowUtils::validate(*schema, l);
        if(!good) {
            QString schemaHelpStr = QString("\n\nsee 'ugene --help=%1' for details").arg(schemaName);
            setError("\n\n" + l.join("\n\n") + schemaHelpStr);
            return res;
        }

        workflowRunTask = getWorkflowRunTask();
        res << workflowRunTask;
    }
    return res;
}
Пример #2
0
Task::ReportResult GTest_uHMMERBuild::report() {
    propagateSubtaskError();
    if(buildTask->hasError())  {
        stateInfo.setError(  buildTask->getError() );
    }
    return ReportResult_Finished;
}
Task::ReportResult PairwiseAlignmentHirschbergTask::report() {
    propagateSubtaskError();
    CHECK_OP(stateInfo, ReportResult_Finished);

    assert(kalignSubTask->inputMA.getNumRows() == kalignSubTask->resultMA.getNumRows());

    return ReportResult_Finished;
}
Пример #4
0
QList<Task*> BAMImporterTask::onSubTaskFinished(Task* subTask) {
    QList<Task*> res;

    if (subTask->hasError()) {
        propagateSubtaskError();
        return res;
    }

    if (loadInfoTask == subTask) {
        initPrepareToImportTask();
        CHECK(NULL != prepareToImportTask, res);
        res << prepareToImportTask;
    }

    else if (prepareToImportTask == subTask && prepareToImportTask->isNewURL()) {
        initLoadBamInfoTask();
        CHECK(NULL != loadBamInfoTask, res);
        res << loadBamInfoTask;
    }

    else if (loadBamInfoTask == subTask || prepareToImportTask == subTask) {
        initConvertToSqliteTask();
        CHECK(NULL != convertTask, res);
        res << convertTask;
    }

    else if (isSqliteDbTransit && convertTask == subTask) {
        initCloneObjectTasks();
        CHECK(!cloneTasks.isEmpty(), res);
        res << cloneTasks;
    }

    else if (!isSqliteDbTransit && convertTask == subTask) {
        initLoadDocumentTask();
        CHECK(NULL != loadDocTask, res);
        res << loadDocTask;
    }

    else if ((isSqliteDbTransit && cloneTasks.contains(subTask))) {
        cloneTasks.removeOne(subTask);
        CloneObjectTask *cloneTask = qobject_cast<CloneObjectTask *>(subTask);
        SAFE_POINT_EXT(NULL != cloneTask, setError("Unexpected task type: CloneObjectTask expected"), res);
        delete cloneTask->getSourceObject();

        if (cloneTasks.isEmpty()) {
            initLoadDocumentTask();
            CHECK(NULL != loadDocTask, res);
            res << loadDocTask;
        }
    }

    else if (subTask == loadDocTask) {
        resultDocument = loadDocTask->takeDocument();
    }

    return res;
}
Пример #5
0
QList<Task*> DNASequenceGeneratorTask::onSubTaskFinished(Task* subTask) {
    QList<Task*> tasks;
    if (hasError() || isCanceled() || subTask->isCanceled()) {
        return tasks;
    }
    propagateSubtaskError();

    if (subTask == loadRefTask) {
        tasks << onLoadRefTaskFinished( );
    } else if (subTask == evalTask) {
        tasks << onEvalTaskFinished( );
    } else if ( subTask == generateTask ) {
        tasks << onGenerateTaskFinished( );
    } else if (saveTask == subTask) {
        tasks << onSaveTaskFinished( );
    }
    return tasks;
}
Пример #6
0
Task::ReportResult GTest_uHMMERCalibrate::report() {
    propagateSubtaskError();
    if (isCanceled() || hasError()) {
        return ReportResult_Finished;
    }
    for(int i=0; i < nCalibrates; i++){
        float new_mu = ((::plan7_s*)calibrateTask[i]->getHMM())->mu;
        if (qAbs(new_mu - mu) > 0.1) {
            stateInfo.setError(  QString("mu value %1, expected %2").arg(new_mu).arg(mu) );
            break;
        }
        float new_lambda = ((::plan7_s*)calibrateTask[i]->getHMM())->lambda;
        if (qAbs(new_lambda - lambda) > 0.1){
            stateInfo.setError(  QString("lambda value %1, expected %2").arg(new_lambda).arg(lambda) );
            break;
        }
    }
    return ReportResult_Finished;
}
Пример #7
0
QList<Task *> SpideyAlignmentTask::onSubTaskFinished(Task *subTask) {
    QList<Task *> res;

    propagateSubtaskError();

    if (hasError() || isCanceled()) {
        return res;
    }

    if (subTask == prepareDataForSpideyTask) {
        SAFE_POINT(!prepareDataForSpideyTask->getResultPath().isEmpty(), "Invalid result path!",
            res);

        tmpOutputUrl = prepareDataForSpideyTask->getResultPath();
        const QStringList &arguments = prepareDataForSpideyTask->getArgumentsList();

        spideyTask = new ExternalToolRunTask(ET_SPIDEY, arguments, new SpideyLogParser());
        spideyTask->setSubtaskProgressWeight(95);
        res.append(spideyTask);
    } else if (subTask == spideyTask) {
        if (!QFile::exists(tmpOutputUrl)) {
            if (AppContext::getExternalToolRegistry()->getByName(ET_SPIDEY)->isValid()) {
                stateInfo.setError(tr("Output file not found"));
            } else {
                ExternalTool *spideyTool = AppContext::getExternalToolRegistry()->getByName(ET_SPIDEY);
                SAFE_POINT(NULL != spideyTool, "Invalid Spidey tool!", res);
                stateInfo.setError(
                    tr("Output file not found. May be %1 tool path '%2' not valid?")
                    .arg(spideyTool->getName()).arg(spideyTool->getPath()));
            }
            return res;
        }

        // parse result

        QFile resultFile(tmpOutputUrl);

        if (!resultFile.open(QFile::ReadOnly)) {
            setError(tr("Failed to open result file %1").arg(tmpOutputUrl));
            return res;
        }

        QTextStream inStream(&resultFile);
        bool strandDirect = true;

        U2Location location;
        location->op = U2LocationOperator_Join;

        while (!inStream.atEnd()) {
            QByteArray buf = inStream.readLine().toLatin1();
            if (buf.startsWith("Strand")) {
                strandDirect = buf.contains("plus");
            }
            if (buf.startsWith("Exon")) {
                // TODO: better to use reg exp here
                int startPos = buf.indexOf(":") + 1;
                int endPos = buf.indexOf("(gen)");
                if (startPos == -1 || endPos == -1) {
                    continue;
                }
                QByteArray loc = buf.mid(startPos, endPos - startPos).trimmed();
                QList<QByteArray> loci = loc.split('-');
                if (loci.size() < 2) {
                    continue;
                }
                int start = QString(loci.at(0)).toInt();
                int finish = QString(loci.at(1)).toInt();

                if (start == finish) {
                    continue;
                }

               location->regions.append(U2Region(start - 1, finish - start + 1));
            }
        }

        if (!location->isEmpty()) {
            SharedAnnotationData data(new AnnotationData);
            data->location = location;
            data->setStrand(U2Strand(strandDirect ? U2Strand::Direct : U2Strand::Complementary));
            data->type = U2FeatureTypes::Exon;
            data->name = "exon";
            U1AnnotationUtils::addDescriptionQualifier(data, annDescription);
            resultAnnotations.append(data);
        }
    }

    return res;
}
Пример #8
0
QList<Task*> MafftAddToAlignmentTask::onSubTaskFinished(Task* subTask) {
    QList<Task*> subTasks;

    propagateSubtaskError();
    if(subTask->isCanceled() || isCanceled() || hasError()) {
        return subTasks;
    }

    if((subTask == saveAlignmentDocumentTask || subTask == saveSequencesDocumentTask) && saveAlignmentDocumentTask->isFinished()
        && saveSequencesDocumentTask->isFinished()) {

        resultFilePath = settings.resultFileName.isEmpty() ? tmpDirUrl + QDir::separator() + "result_aln.fa" : settings.resultFileName.getURLString();
        QStringList arguments;
        if(settings.addAsFragments) {
            arguments << "--addfragments";
        } else {
            arguments << "--add";
        }
        arguments << saveSequencesDocumentTask->getURL().getURLString();
        const DNAAlphabet* alphabet = U2AlphabetUtils::getById(settings.alphabet);
        SAFE_POINT_EXT(alphabet != NULL, setError("Albhabet is invalid."), subTasks);
        if(alphabet->isRaw()) {
            arguments << "--anysymbol";
        }
        if(useMemsaveOption()) {
            arguments << "--memsave";
        }
        if(settings.reorderSequences) {
            arguments << "--reorder";
        }
        arguments << saveAlignmentDocumentTask->getDocument()->getURLString();
        QString outputUrl = resultFilePath + ".out.fa";

        logParser = new MAFFTLogParser(inputMsa->getNumRows(), 1, outputUrl);
        mafftTask = new ExternalToolRunTask(ET_MAFFT, arguments, logParser);
        mafftTask->setStandartOutputFile(resultFilePath);
        mafftTask->setSubtaskProgressWeight(65);
        subTasks.append(mafftTask);
    } else if (subTask == mafftTask) {
        SAFE_POINT(logParser != NULL, "logParser is null", subTasks);
        logParser->cleanup();
        if (!QFileInfo(resultFilePath).exists()) {
            if (AppContext::getExternalToolRegistry()->getByName(ET_MAFFT)->isValid()){
                stateInfo.setError(tr("Output file '%1' not found").arg(resultFilePath));
            } else {
                stateInfo.setError(tr("Output file '%3' not found. May be %1 tool path '%2' not valid?")
                    .arg(AppContext::getExternalToolRegistry()->getByName(ET_MAFFT)->getName())
                    .arg(AppContext::getExternalToolRegistry()->getByName(ET_MAFFT)->getPath())
                    .arg(resultFilePath));
            }
            return subTasks;
        }
        ioLog.details(tr("Loading output file '%1'").arg(resultFilePath));
        IOAdapterFactory* iof = AppContext::getIOAdapterRegistry()->getIOAdapterFactoryById(BaseIOAdapters::LOCAL_FILE);
        loadTmpDocumentTask = new LoadDocumentTask(BaseDocumentFormats::FASTA, resultFilePath, iof);
        loadTmpDocumentTask->setSubtaskProgressWeight(5);
        subTasks.append(loadTmpDocumentTask);
    } else if(subTask == loadTmpDocumentTask) {
        modStep = new U2UseCommonUserModStep(settings.msaRef, stateInfo);
    }

    return subTasks;
}