IMPLEMENT_TEST(MsaImporterExporterUnitTests, importExportAlignment) { const U2DbiRef& dbiRef = MsaImporterExporterTestData::getDbiRef(); U2OpStatusImpl os; // Init an alignment QString alignmentName = "Test alignment"; DNAAlphabetRegistry* alphabetRegistry = AppContext::getDNAAlphabetRegistry(); const DNAAlphabet* alphabet = alphabetRegistry->findById(BaseDNAAlphabetIds::NUCL_DNA_DEFAULT()); QByteArray firstSequence("---AG-T"); QByteArray secondSequence("AG-CT-TAA"); MultipleSequenceAlignment al(alignmentName, alphabet); al->addRow("First row", firstSequence); al->addRow("Second row", secondSequence); // Import the alignment QScopedPointer<MultipleSequenceAlignmentObject> msaObj(MultipleSequenceAlignmentImporter::createAlignment(dbiRef, al, os)); CHECK_NO_ERROR(os); // Export the alignment MultipleSequenceAlignmentExporter alExporter; MultipleSequenceAlignment alActual = alExporter.getAlignment(dbiRef, msaObj->getEntityRef().entityId, os); CHECK_NO_ERROR(os); bool alsEqual = (*al == *alActual); CHECK_TRUE(alsEqual, "Actual alignment doesn't equal to the original!"); CHECK_EQUAL(alignmentName, alActual->getName(), "alignment name"); }
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; }
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; }