Exemple #1
0
void convertMSA2MAlignment(MSA& msa, const DNAAlphabet* al, MultipleSequenceAlignment& res) {
    assert(res->isEmpty());
    MuscleContext *ctx = getMuscleContext();
    res->setAlphabet(al);
    ctx->output_uIds.clear();

    for(int i=0, n = msa.GetSeqCount(); i < n; i++) {
        QString name = msa.GetSeqName(i);
        QByteArray seq;
        seq.reserve(msa.GetColCount());
        for (int j = 0, m = msa.GetColCount(); j < m ; j++) {
            char c = msa.GetChar(i, j);
            seq.append(c);
        }
        ctx->output_uIds.append(ctx->tmp_uIds[msa.GetSeqId(i)]);
        res->addRow(name, seq);
    }
}
Exemple #2
0
Task* ClustalOWorker::tick() {
    if (input->hasMessage()) {
        Message inputMessage = getMessageAndSetupScriptValues(input);
        if (inputMessage.isEmpty()) {
            output->transit();
            return NULL;
        }
        cfg.numIterations=actor->getParameter(NUM_ITERATIONS)->getAttributeValue<int>(context);
        cfg.maxGuidetreeIterations=actor->getParameter(MAX_GT_ITERATIONS)->getAttributeValue<int>(context);
        cfg.maxHMMIterations=actor->getParameter(MAX_HMM_ITERATIONS)->getAttributeValue<int>(context);
        cfg.setAutoOptions=actor->getParameter(SET_AUTO)->getAttributeValue<bool>(context);
        cfg.numberOfProcessors=AppContext::getAppSettings()->getAppResourcePool()->getIdealThreadCount();

        QString path=actor->getParameter(EXT_TOOL_PATH)->getAttributeValue<QString>(context);
        if(QString::compare(path, "default", Qt::CaseInsensitive) != 0){
            AppContext::getExternalToolRegistry()->getByName(ET_CLUSTALO)->setPath(path);
        }
        path=actor->getParameter(TMP_DIR_PATH)->getAttributeValue<QString>(context);
        if(QString::compare(path, "default", Qt::CaseInsensitive) != 0){
            AppContext::getAppSettings()->getUserAppsSettings()->setUserTemporaryDirPath(path);
        }
        QVariantMap qm = inputMessage.getData().toMap();
        SharedDbiDataHandler msaId = qm.value(BaseSlots::MULTIPLE_ALIGNMENT_SLOT().getId()).value<SharedDbiDataHandler>();
        QScopedPointer<MultipleSequenceAlignmentObject> msaObj(StorageUtils::getMsaObject(context->getDataStorage(), msaId));
        SAFE_POINT(!msaObj.isNull(), "NULL MSA Object!", NULL);
        const MultipleSequenceAlignment msa = msaObj->getMultipleAlignment();

        if (msa->isEmpty()) {
            algoLog.error(tr("An empty MSA '%1' has been supplied to ClustalO.").arg(msa->getName()));
            return NULL;
        }
        ClustalOSupportTask* supportTask = new ClustalOSupportTask(msa, GObjectReference(), cfg);
        supportTask->addListeners(createLogListeners());
        Task *t = new NoFailTaskWrapper(supportTask);
        connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished()));
        return t;
    } else if (input->isEnded()) {
        setDone();
        output->setEnded();
    }
    return NULL;
}
Exemple #3
0
Task* ClustalWWorker::tick() {
    if (input->hasMessage()) {
        Message inputMessage = getMessageAndSetupScriptValues(input);
        if (inputMessage.isEmpty()) {
            output->transit();
            return NULL;
        }
        cfg.gapOpenPenalty=actor->getParameter(GAP_OPEN_PENALTY)->getAttributeValue<float>(context);
        cfg.gapExtenstionPenalty=actor->getParameter(GAP_EXT_PENALTY)->getAttributeValue<float>(context);
        cfg.gapDist=actor->getParameter(GAP_DIST)->getAttributeValue<float>(context);
        cfg.endGaps=actor->getParameter(END_GAPS)->getAttributeValue<bool>(context);
        cfg.noHGaps=actor->getParameter(NO_HGAPS)->getAttributeValue<bool>(context);
        cfg.noPGaps=actor->getParameter(NO_PGAPS)->getAttributeValue<bool>(context);
        if(actor->getParameter(ITERATION)->getAttributeValue<int>(context) != 0){
            if(actor->getParameter(ITERATION)->getAttributeValue<int>(context) == 1){
                cfg.iterationType="TREE";
            }else if(actor->getParameter(ITERATION)->getAttributeValue<int>(context) == 2){
                cfg.iterationType="ALIGNMENT";
            }
            if(actor->getParameter(NUM_ITERATIONS)->getAttributeValue<int>(context) != 3){
                cfg.numIterations=actor->getParameter(NUM_ITERATIONS)->getAttributeValue<int>(context);
            }
        }
        if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == -1){
            if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == 0){
                cfg.matrix="IUB";
            }else if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == 1){
                cfg.matrix="CLUSTALW";
            }else if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == 2){
                cfg.matrix="BLOSUM";
            }else if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == 3){
                cfg.matrix="PAM";
            }else if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == 4){
                cfg.matrix="GONNET";
            }else if(actor->getParameter(MATRIX)->getAttributeValue<int>(context) == 5){
                cfg.matrix="ID";
            }
        }

        QString path=actor->getParameter(EXT_TOOL_PATH)->getAttributeValue<QString>(context);
        if(QString::compare(path, "default", Qt::CaseInsensitive) != 0){
            AppContext::getExternalToolRegistry()->getByName(ET_CLUSTAL)->setPath(path);
        }
        path=actor->getParameter(TMP_DIR_PATH)->getAttributeValue<QString>(context);
        if(QString::compare(path, "default", Qt::CaseInsensitive) != 0){
            AppContext::getAppSettings()->getUserAppsSettings()->setUserTemporaryDirPath(path);
        }

        QVariantMap qm = inputMessage.getData().toMap();
        SharedDbiDataHandler msaId = qm.value(BaseSlots::MULTIPLE_ALIGNMENT_SLOT().getId()).value<SharedDbiDataHandler>();
        QScopedPointer<MultipleSequenceAlignmentObject> msaObj(StorageUtils::getMsaObject(context->getDataStorage(), msaId));
        SAFE_POINT(!msaObj.isNull(), "NULL MSA Object!", NULL);
        const MultipleSequenceAlignment msa = msaObj->getMultipleAlignment();

        if (msa->isEmpty()) {
            algoLog.error(tr("An empty MSA '%1' has been supplied to ClustalW.").arg(msa->getName()));
            return NULL;
        }
        ClustalWSupportTask* supportTask = new ClustalWSupportTask(msa, GObjectReference(), cfg);
        supportTask->addListeners(createLogListeners());
        Task *t = new NoFailTaskWrapper(supportTask);
        connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished()));
        return t;
    } else if (input->isEnded()) {
        setDone();
        output->setEnded();
    }
    return NULL;
}