void DatasetsListWidget::sl_renameDataset() { GCOUNTER(cvar, tvar, "WD::Dataset::Rename Dataset"); QAction *a = dynamic_cast<QAction*>(sender()); CHECK(NULL != a, ); int idx = a->property("idx").toInt(); CHECK(idx < tabs->count(), ); bool error = false; QString text = tabs->tabText(idx); do { bool ok = false; text = QInputDialog::getText(this, tr("Rename Dataset"), tr("New dataset name:"), QLineEdit::Normal, text, &ok); if (!ok) { return; } U2OpStatusImpl os; ctrl->renameDataset(idx, text, os); if (os.hasError()) { QMessageBox::critical(this, tr("Error"), os.getError()); } error = os.hasError(); } while (error); tabs->setTabText(idx, text); }
void DatasetsListWidget::sl_newDataset() { GCOUNTER(cvar, tvar, "WD::Dataset::New Dataset"); QString error; QString text = getTip(); do { bool ok = false; text = QInputDialog::getText(this, tr("Enter Dataset Name"), tr("New dataset name:"), QLineEdit::Normal, text, &ok); if (!ok) { return; } U2OpStatusImpl os; ctrl->addDataset(text, os); error = os.getError(); if (!error.isEmpty()) { QMessageBox::critical(this, tr("Error"), error); } } while (!error.isEmpty()); // activate the tab after adding tabs->setCurrentIndex(tabs->count() - 1); }
void WizardPageController::applyLayout() { wc->clearControllers(); qDeleteAll(controllers); controllers.clear(); QLayout *old = wPage->layout(); removeLayout(old); U2OpStatusImpl os; page->validate(wc->getCurrentActors(), os); if (os.hasError()) { coreLog.error(os.getError()); setError(wPage); return; } PageContentCreator pcc(wc); page->getContent()->accept(&pcc); if (wc->isBroken()) { setError(wPage); return; } pcc.setPageTitle(page->getTitle()); wPage->setLayout(pcc.getResult()); controllers << pcc.getControllers(); wPage->setFinalPage(page->isFinal()); }
Task* HMM3SearchWorker::tick() { while (hmmPort->hasMessage()) { hmms << hmmPort->get().getData().toMap().value(HMM3Lib::HMM3_SLOT.getId()).value<const P7_HMM*>(); } if (!hmmPort->isEnded()) { // || hmms.isEmpty() || !seqPort->hasMessage() return NULL; } if (seqPort->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(seqPort); if (inputMessage.isEmpty() || hmms.isEmpty()) { output->transit(); return NULL; } SharedDbiDataHandler seqId = inputMessage.getData().toMap().value(BaseSlots::DNA_SEQUENCE_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<U2SequenceObject> seqObj(StorageUtils::getSequenceObject(context->getDataStorage(), seqId)); if (seqObj.isNull()) { return NULL; } U2OpStatusImpl os; DNASequence dnaSequence = seqObj->getWholeSequence(os); CHECK_OP(os, new FailTask(os.getError())); if (dnaSequence.alphabet->getType() != DNAAlphabet_RAW) { QList<Task*> subtasks; UHMM3SearchTaskSettings settings; settings.inner = cfg; foreach(const P7_HMM* hmm, hmms) { subtasks << new UHMM3SWSearchTask (hmm, dnaSequence, settings); }
Task * BaseThroughWorker::processNextInputMessage() { const Message message = getMessageAndSetupScriptValues(input); U2OpStatusImpl os; Task *task = createTask(message, os); if (os.hasError()) { reportError(os.getError()); } return task; }
Task* CDSearchWorker::tick() { if (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); if (inputMessage.isEmpty()) { output->transit(); return NULL; } SharedDbiDataHandler seqId = inputMessage.getData().toMap().value(BaseSlots::DNA_SEQUENCE_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<U2SequenceObject> seqObj(StorageUtils::getSequenceObject(context->getDataStorage(), seqId)); if (seqObj.isNull()) { return NULL; } U2OpStatusImpl os; DNASequence seq = seqObj->getWholeSequence(os); CHECK_OP(os, new FailTask(os.getError())); settings.query = seq.seq; settings.alp = seq.alphabet; if (!settings.alp->isAmino()) { QString err = "Required amino acid input sequence"; return new FailTask(err); } settings.ev = actor->getParameter(EVALUE_ATTR)->getAttributeValue<float>(context); settings.dbName = actor->getParameter(DATABASE_ATTR)->getAttributeValue<QString>(context); bool local = actor->getParameter(LOCAL_ATTR)->getAttributePureValue().toBool(); CDSearchFactory* factory = NULL; if (local) { factory = AppContext::getCDSFactoryRegistry()->getFactory(CDSearchFactoryRegistry::LocalSearch); if (!factory) { QString err = tr("'External tools' plugin has to be loaded."); return new FailTask(err); } settings.localDbFolder = actor->getParameter(DB_PATH_ATTR)->getAttributeValue<QString>(context); } else { // remote factory = AppContext::getCDSFactoryRegistry()->getFactory(CDSearchFactoryRegistry::RemoteSearch); if (!factory) { QString err = tr("'Remote blast' plugin has to be loaded."); return new FailTask(err); } } cds = factory->createCDSearch(settings); Task* t = cds->getTask(); connect(new TaskSignalMapper(t), SIGNAL(si_taskFinished(Task*)), SLOT(sl_taskFinished(Task*))); return t; } else if (input->isEnded()) {
void DNAFlexDialog::accept() { // Verifying and passing the settings // TODO // Preparing the annotations object and other annotations parameters QString err = annotController->validate(); if (!err.isEmpty()) { QMessageBox::warning(this, tr("Error"), err); return; } bool objectPrepared = annotController->prepareAnnotationObject(); if (!objectPrepared){ QMessageBox::warning(this, tr("Error"), tr("Cannot create an annotation object. Please check settings")); return; } const CreateAnnotationModel& annotModel = annotController->getModel(); QString annotName = annotModel.data->name; QString annotGroup = annotModel.groupName; if(ctx != NULL){ ctx->getAnnotatedDNAView()->tryAddObject(annotModel.getAnnotationObject()); } // Creating the task U2OpStatusImpl os; QByteArray seqData = ctx->getSequenceObject()->getWholeSequenceData(os); CHECK_OP_EXT(os, QMessageBox::critical(this, L10N::errorTitle(), os.getError()), ); DNAFlexTask* task = new DNAFlexTask( settings, annotModel.getAnnotationObject(), annotName, annotGroup, annotModel.description, seqData); // Registering the task AppContext::getTaskScheduler()->registerTopLevelTask(task); // Accepting the dialog QDialog::accept(); }
Task* PWMatrixSearchWorker::tick() { while (modelPort->hasMessage()) { models << modelPort->get().getData().toMap().value(PWMatrixWorkerFactory::WMATRIX_SLOT.getId()).value<PWMatrix>(); } if (!modelPort->isEnded()) { return NULL; } if (dataPort->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(dataPort); if (inputMessage.isEmpty() || models.isEmpty()) { output->transit(); return NULL; } QVariantMap map = inputMessage.getData().toMap(); SharedDbiDataHandler seqId = map.value(BaseSlots::DNA_SEQUENCE_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<U2SequenceObject> seqObj(StorageUtils::getSequenceObject(context->getDataStorage(), seqId)); if (seqObj.isNull()) { return NULL; } U2OpStatusImpl os; DNASequence seq = seqObj->getWholeSequence(os); CHECK_OP(os, new FailTask(os.getError())); if (!seq.isNull() && seq.alphabet->getType() == DNAAlphabet_NUCL) { WeightMatrixSearchCfg config(cfg); config.complOnly = (strand < 0); if (strand <= 0) { DNATranslation* compTT = AppContext::getDNATranslationRegistry()-> lookupComplementTranslation(seq.alphabet); if (compTT != NULL) { config.complTT = compTT ; } } QList<Task*> subtasks; foreach(PWMatrix model, models) { subtasks << new WeightMatrixSingleSearchTask(model, seq.seq, config, 0); }
Task* DNAStatWorker::tick() { while (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); if (inputMessage.isEmpty()) { output->transit(); return NULL; } QVariantMap qm = inputMessage.getData().toMap(); SharedDbiDataHandler seqId = qm.value(BaseSlots::DNA_SEQUENCE_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<U2SequenceObject> seqObj(StorageUtils::getSequenceObject(context->getDataStorage(), seqId)); if (NULL == seqObj.data()) { return NULL; } U2OpStatusImpl os; DNASequence dna = seqObj->getWholeSequence(os); CHECK_OP(os, new FailTask(os.getError())); if(!dna.alphabet->isNucleic()) { return new FailTask(tr("Sequence must be nucleotide")); } QList<SharedAnnotationData> res; SharedAnnotationData gcAnn(new AnnotationData); gcAnn->name = "statistics"; gcAnn->location->regions << U2Region( 0, dna.seq.size()); if (actor->getParameter(GCCONTENT)->getAttributeValue<bool>(context)) { float gcContent = calcGCContent(dna.seq); gcAnn->qualifiers.push_back(U2Qualifier("gc-content", QString::number(gcContent*100) + "%")); } if (actor->getParameter(GC1CONTENT)->getAttributeValue<bool>(context)) { float gc1Content = calcGC1Content(dna.seq); gcAnn->qualifiers.push_back(U2Qualifier("gc1-content", QString::number(gc1Content*100) + "%")); } if (actor->getParameter(GC2CONTENT)->getAttributeValue<bool>(context)) { float gc2Content = calcGC2Content(dna.seq); gcAnn->qualifiers.push_back(U2Qualifier("gc2-content", QString::number(gc2Content*100) + "%")); } if (actor->getParameter(GC3CONTENT)->getAttributeValue<bool>(context)) { float gc3Content = calcGC3Content(dna.seq); gcAnn->qualifiers.push_back(U2Qualifier("gc3-content", QString::number(gc3Content*100) + "%")); } if (gcAnn->qualifiers.isEmpty()) { return new FailTask(tr("No statistics was selected")); } res << gcAnn; const SharedDbiDataHandler tableId = context->getDataStorage()->putAnnotationTable(res); const QVariant v = qVariantFromValue<SharedDbiDataHandler>(tableId); output->put(Message(BaseTypes::ANNOTATION_TABLE_TYPE(), v)); } if (input->isEnded()) { setDone(); output->setEnded(); } return NULL; }
Task* RepeatWorker::tick() { if (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); if (inputMessage.isEmpty()) { output->transit(); return NULL; } cfg.algo = RFAlgorithm(actor->getParameter(ALGO_ATTR)->getAttributeValue<int>(context)); cfg.minLen = actor->getParameter(LEN_ATTR)->getAttributeValue<int>(context); if(actor->getParameter(USE_MIN_DISTANCE_ATTR)->getAttributeValue<bool>(context)){ cfg.minDist = actor->getParameter(MIN_DIST_ATTR)->getAttributeValue<int>(context); }else{ cfg.minDist = 0; } if(actor->getParameter(USE_MAX_DISTANCE_ATTR)->getAttributeValue<bool>(context)){ cfg.maxDist = actor->getParameter(MAX_DIST_ATTR)->getAttributeValue<int>(context); }else{ cfg.maxDist = INT_MAX; } int identity = actor->getParameter(IDENTITY_ATTR)->getAttributeValue<int>(context); cfg.setIdentity(identity); cfg.nThreads = actor->getParameter(THREADS_ATTR)->getAttributeValue<int>(context); cfg.inverted = actor->getParameter(INVERT_ATTR)->getAttributeValue<bool>(context); cfg.filter = RepeatsFilterAlgorithm(actor->getParameter(NESTED_ATTR)->getAttributeValue<int>(context)); cfg.excludeTandems = actor->getParameter(TANMEDS_ATTR)->getAttributeValue<bool>(context); resultName = actor->getParameter(NAME_ATTR)->getAttributeValue<QString>(context); if(resultName.isEmpty()){ resultName = "repeat_unit"; algoLog.error(tr("result name is empty, default name used")); } if(identity > 100 || identity < 0){ algoLog.error(tr("Incorrect value: identity value must be between 0 and 100")); return new FailTask(tr("Incorrect value: identity value must be between 0 and 100")); } QVariantMap map = inputMessage.getData().toMap(); SharedDbiDataHandler seqId = map.value(BaseSlots::DNA_SEQUENCE_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<U2SequenceObject> seqObj(StorageUtils::getSequenceObject(context->getDataStorage(), seqId)); if (seqObj.isNull()) { return NULL; } U2OpStatusImpl os; DNASequence seq = seqObj->getWholeSequence(os); CHECK_OP(os, new FailTask(os.getError())); if(cfg.minDist < 0){ algoLog.error(tr("Incorrect value: minimal distance must be greater then zero")); return new FailTask(tr("Incorrect value: minimal distance must be greater then zero")); } if (!seq.alphabet->isNucleic()) { QString err = tr("Sequence alphabet is not nucleic!"); return new FailTask(err); } Task* t = new FindRepeatsToAnnotationsTask(cfg, seq, resultName, QString(), "", GObjectReference()); connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished())); return t; } else if (input->isEnded()) { setDone(); output->setEnded(); } return NULL; }
void HMMADVContext::sl_search() { GObjectViewAction* action = qobject_cast<GObjectViewAction*>(sender()); assert(action!=NULL); AnnotatedDNAView* av = qobject_cast<AnnotatedDNAView*>(action->getObjectView()); assert(av!=NULL); QWidget *p; if (av->getWidget()){ p = av->getWidget(); }else{ p = (QWidget*)AppContext::getMainWindow()->getQMainWindow(); } ADVSequenceObjectContext* seqCtx = av->getSequenceInFocus(); if(seqCtx == NULL) { QMessageBox::critical(p, tr("Error"), tr("No sequences found")); return; } U2OpStatusImpl os; DNASequence sequence = seqCtx->getSequenceObject()->getWholeSequence(os); CHECK_OP_EXT(os, QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), os.getError()), ); QObjectScopedPointer<HMMSearchDialogController> d = new HMMSearchDialogController(sequence, seqCtx->getSequenceObject(), p); d->exec(); }
void uHMMPlugin::sl_search() { //to select a sequence //1. check that annotated DNA view is active //2. if not -> check that DNASequence object is selected in project view U2SequenceObject* obj = NULL; MWMDIWindow* w = AppContext::getMainWindow()->getMDIManager()->getActiveWindow(); if (w!=NULL) { GObjectViewWindow* ow = qobject_cast<GObjectViewWindow*>(w); if (ow!=NULL) { GObjectView* ov = ow->getObjectView(); AnnotatedDNAView* av = qobject_cast<AnnotatedDNAView*>(ov); if (av!=NULL) { ADVSequenceObjectContext* seqCtx = av->getSequenceInFocus(); obj = seqCtx->getSequenceObject(); } } } if (obj == NULL) { ProjectView* pv = AppContext::getProjectView(); if (pv!=NULL) { const GObjectSelection* sel = pv->getGObjectSelection(); GObject* o = sel->getSelectedObjects().size() == 1 ? sel->getSelectedObjects().first() : NULL; obj = qobject_cast<U2SequenceObject*>(o); } } QWidget *p = (QWidget*)AppContext::getMainWindow()->getQMainWindow(); if (obj == NULL) { QMessageBox::critical(p, tr("Error"), tr("Error! Select sequence in Project view or open sequence view.")); return; } U2OpStatusImpl os; DNASequence sequence = obj->getWholeSequence(os); CHECK_OP_EXT(os, QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), os.getError()), ); QObjectScopedPointer<HMMSearchDialogController> d = new HMMSearchDialogController(sequence, obj, p); d->exec(); }