char MaIterator::operator *() { SAFE_POINT(isInRange(position), "Out of boundaries", U2Msa::INVALID_CHAR); const QPoint maPoint = getMaPoint(); SAFE_POINT(0 <= maPoint.x() && maPoint.x() < ma->getLength() && 0 <= maPoint.y() && maPoint.y() < ma->getNumRows(), "Out of boundaries", U2Msa::INVALID_CHAR); return ma->charAt(maPoint.y(), maPoint.x()); }
QWidget * PcrOptionsPanelSavableTab::getPrimerEditWidgetById(const QString &childId) const { const QStringList ids = childId.split(WIDGET_ID_SEPARATOR); SAFE_POINT(2 == ids.size(), "Invalid widget ID", NULL); QWidget *primerGroup = wrappedWidget->findChild<QWidget *>(ids.first()); SAFE_POINT(NULL != primerGroup, "Invalid parent widget", NULL); return primerGroup->findChild<QWidget *>(ids.last()); }
inline bool ReadShortReadsSubTask::add(int &CMAX, int &W, int &q, int &readNum, SearchQuery *query, GenomeAlignerTask *parent) { SAFE_POINT(NULL != dataBunch, "No dataBunch", false); SAFE_POINT(NULL != query, "No query", false); W = query->length(); if (!alignContext.absMismatches) { CMAX = (W * alignContext.ptMismatches) / MAX_PERCENTAGE; } q = W / (CMAX + 1); CHECK_EXT(0 != q,, false); const char* querySeq = query->constData(); SAFE_POINT(NULL != querySeq, "No querySeq", false); int win = query->length() < GenomeAlignerTask::MIN_SHORT_READ_LENGTH ? GenomeAlignerTask::calculateWindowSize(alignContext.absMismatches, alignContext.nMismatches, alignContext.ptMismatches, query->length(), query->length()) : GenomeAlignerTask::calculateWindowSize(alignContext.absMismatches, alignContext.nMismatches, alignContext.ptMismatches, alignContext.minReadLength, alignContext.maxReadLength); for (int i = 0; i < W - q + 1; i+=q) { const char *seq = querySeq + i; BMType bv = parent->index->getBitValue(seq, qMin(GenomeAlignerIndex::charsInMask, W - i)); dataBunch->bitValuesV.append(bv); dataBunch->readNumbersV.append(readNum); dataBunch->positionsAtReadV.append(i); dataBunch->windowSizes.append(win); } readNum++; dataBunch->queries.append(query); return true; }
bool ActorCfgFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const { ActorCfgModel *srcModel = qobject_cast<ActorCfgModel *>(sourceModel()); SAFE_POINT(NULL != srcModel, "Invalid actor configuration model", true); Attribute *attr = srcModel->getAttributeByRow(sourceRow); SAFE_POINT(NULL != attr, "Invalid actor attribute", true); return srcModel->isVisible(attr); }
GUITests GUITestService::postActions() { UGUITestBase* tb = AppContext::getGUITestBase(); SAFE_POINT(NULL != tb,"",GUITests()); GUITests additionalChecks = tb->takeTests(UGUITestBase::PostAdditionalActions); SAFE_POINT(additionalChecks.size()>0,"",GUITests()); return additionalChecks; }
QWidget* RefSeqCommonWidgetFactory::createWidget(GObjectView *objView) { SAFE_POINT(NULL != objView, QString("NULL object view!"), NULL); MSAEditor* msa = qobject_cast<MSAEditor*>(objView); SAFE_POINT(NULL != msa, QString("Not MSAEditor!"), NULL); RefSeqCommonWidget *widget = new RefSeqCommonWidget(msa); return widget; }
bool TestDbiProvider::init(const QString& dbiFileName, bool _useConnectionPool){ if(initialized){ close(); initialized = false; } TestRunnerSettings* trs = AppContext::getAppSettings()->getTestRunnerSettings(); QString originalFile = trs->getVar("COMMON_DATA_DIR") + "/" + dbiFileName; QString tmpFile = QDir::temp().absoluteFilePath(QFileInfo(originalFile).fileName()); if(QFile::exists(tmpFile)) { QFile::remove(tmpFile); } bool _create = false; if (QFile::exists(originalFile)) { SAFE_POINT(QFile::copy(originalFile, tmpFile), "db file not copied", false); }else{ _create = true; } dbUrl = tmpFile; useConnectionPool = _useConnectionPool; U2DbiFactory *factory = AppContext::getDbiRegistry()->getDbiFactoryById(SQLITE_DBI_ID); SAFE_POINT(factory!=NULL, "No dbi factory", false); U2OpStatusImpl opStatus; if(useConnectionPool){ U2DbiRef ref; ref.dbiFactoryId = factory->getId(); ref.dbiId = dbUrl; dbi = AppContext::getDbiRegistry()->getGlobalDbiPool()->openDbi(ref, _create, opStatus); CHECK_OP(opStatus, false); }else{ dbi = factory->createDbi(); SAFE_POINT(NULL != dbi, "dbi not created", false); QHash<QString, QString> properties; if(_create){ properties[U2DbiOptions::U2_DBI_OPTION_CREATE] = U2DbiOptions::U2_DBI_VALUE_ON; } properties["url"] = dbUrl; QVariantMap persistentData; dbi->init(properties, persistentData, opStatus); SAFE_POINT_OP(opStatus, false); } U2ObjectDbi* objDbi = dbi->getObjectDbi(); SAFE_POINT(NULL != objDbi, "object dbi not loaded", false); initialized = true; return true; }
QWidget* AssemblyNavigationWidgetFactory::createWidget(GObjectView* objView) { SAFE_POINT(NULL != objView, QString("Internal error: unable to create widget for group '%1', object view is NULL.").arg(GROUP_ID), NULL); AssemblyBrowser* assemblyBrowser = qobject_cast<AssemblyBrowser*>(objView); SAFE_POINT(NULL != assemblyBrowser, QString("Internal error: unable to cast object view to Assembly Browser for group '%1'.").arg(GROUP_ID), NULL); AssemblyNavigationWidget* widget = new AssemblyNavigationWidget(assemblyBrowser, assemblyBrowser->getMainWidget()); return widget; }
QWidget * MSAExportConsensusFactoryTab::createWidget(GObjectView* objView) { SAFE_POINT(NULL != objView, QString("Internal error: unable to create widget for group '%1', object view is NULL.").arg(GROUP_ID), NULL); MSAEditor* msa = qobject_cast<MSAEditor*>(objView); SAFE_POINT(NULL != msa, QString("Internal error: unable to cast object view to MSAEditor for group '%1'.").arg(GROUP_ID), NULL); MSAExportConsensusTab *widget = new MSAExportConsensusTab(msa); return widget; }
QWidget * SeqStatisticsWidgetFactory::createWidget(GObjectView* objView) { SAFE_POINT(NULL != objView, QString("Internal error: unable to create widget for group '%1', object view is NULL.").arg(GROUP_ID), NULL); MSAEditor* msa = qobject_cast<MSAEditor*>(objView); SAFE_POINT(NULL != msa, QString("Internal error: unable to cast object view to MSAEditor for group '%1'.").arg(GROUP_ID), NULL); SeqStatisticsWidget *SeqStatisticsWidgetWidget = new SeqStatisticsWidget(msa); return SeqStatisticsWidgetWidget; }
QWidget * FindPatternWidgetFactory::createWidget(GObjectView* objView) { SAFE_POINT(NULL != objView, QString("Internal error: unable to create widget for group '%1', object view is NULL.").arg(GROUP_ID), NULL); AnnotatedDNAView* annotatedDnaView = qobject_cast<AnnotatedDNAView*>(objView); SAFE_POINT(NULL != annotatedDnaView, QString("Internal error: unable to cast object view to AnnotatedDNAView for group '%1'.").arg(GROUP_ID), NULL); FindPatternWidget* widget = new FindPatternWidget(annotatedDnaView); widget->setObjectName("FindPatternWidget"); return widget; }
QWidget* MSATreeOptionsWidgetFactory::createWidget(GObjectView* objView) { SAFE_POINT(NULL != objView, QString("Internal error: unable to create widget for group '%1', object view is NULL.").arg(GROUP_ID), NULL); MSAEditor* msa = qobject_cast<MSAEditor*>(objView); SAFE_POINT(NULL != msa, QString("Internal error: unable to cast object view to MSAEditor for group '%1'.").arg(GROUP_ID), NULL); SAFE_POINT(NULL != viewSettings, "Invalid tree view settings", NULL); TreeOptionsWidget *treeOpWidget = new TreeOptionsWidget(msa, *viewSettings); connect(treeOpWidget, SIGNAL(saveViewSettings(const TreeOpWidgetViewSettings&)), SLOT(sl_onWidgetViewSaved(const TreeOpWidgetViewSettings&))); return treeOpWidget; }
GroupOptionsWidget* OptionsPanelWidget::createOptionsWidget(const QString& groupId, const QString& title, const QString& documentationPage, QWidget* _widget, QList<QWidget*> commonWidgets) { SAFE_POINT(NULL != _widget, "NULL main widget!", NULL); QWidget *innerWidgets = new QWidget; QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setMargin(0); foreach (QWidget *commonWidget, commonWidgets) { SAFE_POINT(NULL != commonWidget, "NULL common widget!", NULL); layout->addWidget(commonWidget); }
qint64 MultipleSequenceAlignmentRowData::getCoreLength() const { int coreStart = getCoreStart(); int coreEnd = getCoreEnd(); int length = coreEnd - coreStart; SAFE_POINT(length >= 0, QString("Internal error in MultipleSequenceAlignmentRowData: coreEnd is %1, coreStart is %2!").arg(coreEnd).arg(coreStart), length); return length; }
GObjectType U2ObjectTypeUtils::toGObjectType( const U2DataType &dbType ) { GObjectType result = GObjectTypes::UNKNOWN; if ( U2Type::Sequence == dbType ) { result = GObjectTypes::SEQUENCE; } else if ( U2Type::AnnotationTable == dbType ) { result = GObjectTypes::ANNOTATION_TABLE; } else if ( U2Type::PhyTree == dbType ) { result = GObjectTypes::PHYLOGENETIC_TREE; } else if ( U2Type::Chromatogram == dbType ) { result = GObjectTypes::CHROMATOGRAM; } else if ( U2Type::BioStruct3D == dbType ) { result = GObjectTypes::BIOSTRUCTURE_3D; } else if ( U2Type::Assembly == dbType ) { result = GObjectTypes::ASSEMBLY; } else if ( U2Type::Mca == dbType ) { result = GObjectTypes::MULTIPLE_CHROMATOGRAM_ALIGNMENT; } else if ( U2Type::Msa == dbType ) { result = GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT; } else if ( U2Type::VariantTrack == dbType ) { result = GObjectTypes::VARIANT_TRACK; } else if ( U2Type::Text == dbType ) { result = GObjectTypes::TEXT; } SAFE_POINT( GObjectTypes::UNKNOWN != result, "Unsupported object relation type detected!", result ); return result; }
U2DataType U2ObjectTypeUtils::toDataType( const GObjectType &gType ) { U2DataType result = U2Type::Unknown; if ( GObjectTypes::SEQUENCE == gType ) { result = U2Type::Sequence; } else if ( GObjectTypes::ANNOTATION_TABLE == gType ) { result = U2Type::AnnotationTable; } else if ( GObjectTypes::PHYLOGENETIC_TREE == gType ) { result = U2Type::PhyTree; } else if ( GObjectTypes::CHROMATOGRAM == gType ) { result = U2Type::Chromatogram; } else if ( GObjectTypes::BIOSTRUCTURE_3D == gType ) { result = U2Type::BioStruct3D; } else if ( GObjectTypes::ASSEMBLY == gType ) { result = U2Type::Assembly; } else if ( GObjectTypes::MULTIPLE_CHROMATOGRAM_ALIGNMENT == gType ) { result = U2Type::Mca; } else if ( GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT == gType ) { result = U2Type::Msa; } else if ( GObjectTypes::VARIANT_TRACK == gType ) { result = U2Type::VariantTrack; } else if ( GObjectTypes::TEXT == gType ) { result = U2Type::Text; } SAFE_POINT( U2Type::Unknown != result, "Unsupported object relation type detected!", result ); return result; }
Task * TextReader::processFile(const QString &url) { IOAdapterFactory *iof = AppContext::getIOAdapterRegistry()->getIOAdapterFactoryById(IOAdapterUtils::url2io(url)); io = iof->createIOAdapter(); if(!io->open(url,IOAdapterMode_Read)) { return new FailTask(tr("Can't load file %1").arg(url)); } if(actor->getParameter(BaseAttributes::READ_BY_LINES_ATTRIBUTE().getId())->getAttributeValue<bool>(context) == false) { QByteArray buf; int read = 0; int offs = 0; buf.resize(READ_BLOCK_SIZE); buf.fill(0); do { read = io->readBlock(buf.data() + offs, READ_BLOCK_SIZE); if (read == -1) { return new FailTask(tr("Can't load file %1. %2").arg(url).arg(io->errorString())); } if (read != READ_BLOCK_SIZE) { SAFE_POINT(read < READ_BLOCK_SIZE, "Error while reading file", NULL); buf.resize(buf.size() - READ_BLOCK_SIZE + read); break; } offs += read; buf.resize(offs + READ_BLOCK_SIZE); } while(read == READ_BLOCK_SIZE); sendMessage(buf); io->close(); } else { processNextLine(); } return NULL; }
Document* DatabaseConnectionFormat::loadDocument(IOAdapter* io, const U2DbiRef&, const QVariantMap& hints, U2OpStatus& os) { DatabaseConnectionAdapter* databaseConnectionAdapter = qobject_cast<DatabaseConnectionAdapter*>(io); SAFE_POINT(NULL != databaseConnectionAdapter, QString("Can't use current IOAdapter: %1").arg(io->getAdapterName()), NULL); U2Dbi* dbi = databaseConnectionAdapter->getConnection().dbi; SAFE_POINT(NULL != dbi, "NULL dbi", NULL); QList<GObject*> objects = getObjects(dbi, os); CHECK_OP_EXT(os, qDeleteAll(objects), NULL); const QString modLockDesc = dbi->getFeatures().contains(U2DbiFeature_GlobalReadOnly) ? DocumentFormat::tr("You have no permissions to modify the content of this database") : QString(); Document* resultDocument = new Document(this, io->getFactory(), io->getURL(), dbi->getDbiRef(), objects, hints, modLockDesc); resultDocument->setDocumentOwnsDbiResources(false); return resultDocument; }
QWidget * InSilicoPcrOPWidgetFactory::createWidget(GObjectView *objView) { AnnotatedDNAView *annotatedDnaView = qobject_cast<AnnotatedDNAView*>(objView); SAFE_POINT(NULL != annotatedDnaView, L10N::nullPointerError("AnnotatedDNAView"), NULL); InSilicoPcrOptionPanelWidget *opWidget = new InSilicoPcrOptionPanelWidget(annotatedDnaView); opWidget->setObjectName("InSilicoPcrOptionPanelWidget"); return opWidget; }
Task* PFMatrixBuildWorker::tick() { if (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); if (inputMessage.isEmpty()) { output->transit(); return NULL; } mtype = PFMatrixWorkerFactory::FREQUENCY_MATRIX_MODEL_TYPE(); QVariantMap data = inputMessage.getData().toMap(); cfg.type = actor->getParameter(TYPE_ATTR)->getAttributeValue<bool>(context) ? PM_DINUCLEOTIDE : PM_MONONUCLEOTIDE; QVariantMap qm = inputMessage.getData().toMap(); SharedDbiDataHandler msaId = qm.value(BaseSlots::MULTIPLE_ALIGNMENT_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<MAlignmentObject> msaObj(StorageUtils::getMsaObject(context->getDataStorage(), msaId)); SAFE_POINT(!msaObj.isNull(), "NULL MSA Object!", NULL); const MAlignment &msa = msaObj->getMAlignment(); Task* t = new PFMatrixBuildTask(cfg, msa); connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished())); return t; } else if (input->isEnded()) { setDone(); output->setEnded(); } return NULL; }
FSItem * FSItem::child(int pos) const { SAFE_POINT(isDir(), "Files can not have children", NULL); if (pos >= items.size() || pos < 0) { return NULL; } return items[pos]; }
Task * CufflinksWorker::tick() { if (false == settingsAreCorrect) { return NULL; } if (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); SAFE_POINT(!inputMessage.isEmpty(), "Internal error: message can't be NULL!", NULL); QVariantMap data = inputMessage.getData().toMap(); if (settings.fromFile) { settings.url = data[BaseSlots::URL_SLOT().getId()].toString(); } else { settings.assemblyId = data[BaseSlots::ASSEMBLY_SLOT().getId()].value<SharedDbiDataHandler>(); } // Create the task CufflinksSupportTask* cufflinksSupportTask = new CufflinksSupportTask(settings); cufflinksSupportTask->addListeners(createLogListeners()); connect(cufflinksSupportTask, SIGNAL(si_stateChanged()), SLOT(sl_cufflinksTaskFinished())); return cufflinksSupportTask; } else if (input->isEnded()) { setDone(); output->setEnded(); } return NULL; }
bool str2DataType(const QString &str, U2DataType &res) { bool conversionOk = false; // hope that "U2DataType" typedef won't change SAFE_POINT(sizeof(U2DataType) == sizeof(qint16), "Unexpected data type detected", false); res = str.toUShort(&conversionOk); return conversionOk; }
QString AnnotHighlightTree::getFirstItemAnnotName() { QTreeWidgetItem* firstItem = topLevelItem(0); SAFE_POINT(0 != firstItem, "There is no first item in the tree!", QString()); QString annotName = firstItem->text(COL_NUM_ANNOT_NAME); return annotName; }
QString SiteconWritePrompter::composeRichDoc() { IntegralBusPort *input = qobject_cast<IntegralBusPort*>(target->getPort(SITECON_IN_PORT_ID)); SAFE_POINT(NULL != input, "NULL input port", ""); QString from = getProducersOrUnset(SITECON_IN_PORT_ID, SiteconWorkerFactory::SITECON_SLOT.getId()); QString url = getScreenedURL(input, BaseAttributes::URL_OUT_ATTRIBUTE().getId(), BaseSlots::URL_SLOT().getId()); url = getHyperlink(BaseAttributes::URL_OUT_ATTRIBUTE().getId(), url); return tr("Save the profile(s) from <u>%1</u> to %2.").arg(from).arg(url); }
U2Msa MAlignmentExporter::getAlignmentObject(const U2DbiRef &dbiRef, const U2DataId &msaId, U2OpStatus &os) const { SAFE_POINT(!con.isOpen(), OPENED_DBI_CONNECTION_ERROR, U2Msa()); con.open(dbiRef, false, os); U2Msa msa = exportAlignmentObject(msaId, os); CHECK_OP(os, U2Msa()); return msa; }
QList<Task*> DNASequenceGeneratorTask::onGenerateTaskFinished( ) { QList<Task *> resultTasks; SAFE_POINT( generateTask->isFinished( ) && !generateTask->getStateInfo( ).isCoR( ), "Invalid task encountered", resultTasks ); IOAdapterFactory *iof = AppContext::getIOAdapterRegistry( )->getIOAdapterFactoryById( IOAdapterUtils::url2io( cfg.getOutUrlString( ) ) ); if (cfg.saveDoc) { DocumentFormat *format = AppContext::getDocumentFormatRegistry()->getFormatById(cfg.getDocumentFormatId()); Document* doc = format->createNewLoadedDocument(iof, cfg.getOutUrlString(), stateInfo); CHECK_OP( stateInfo, resultTasks ); const QSet<QString> &supportedFormats = format->getSupportedObjectTypes( ); const bool isSequenceFormat = supportedFormats.contains( GObjectTypes::SEQUENCE ); if ( isSequenceFormat) { addSequencesToSeqDoc( doc ); } else { // consider alignment format SAFE_POINT( supportedFormats.contains( GObjectTypes::MULTIPLE_SEQUENCE_ALIGNMENT ), "Unexpected format encountered", resultTasks ); addSequencesToMsaDoc( doc ); } saveTask = new SaveDocumentTask(doc, SaveDoc_Overwrite); resultTasks << saveTask; } else { // TODO: avoid high memory consumption here const DNAAlphabet *alp = cfg.getAlphabet( ); SAFE_POINT( NULL != alp, "Generated sequence has invalid alphabet", resultTasks ); const U2DbiRef dbiRef = generateTask->getDbiRef( ); const QString baseSeqName = cfg.getSequenceName( ); QList<U2Sequence> seqs = generateTask->getResults( ); for ( int sequenceNum = 0, totalSeqCount = seqs.size( ); sequenceNum < totalSeqCount; ++sequenceNum ) { const QString seqName = ( 1 < totalSeqCount ) ? ( baseSeqName + " " + QString::number( sequenceNum + 1 ) ) : baseSeqName; DbiConnection con( dbiRef, stateInfo ); CHECK_OP( stateInfo, resultTasks ); const QByteArray seqContent = con.dbi->getSequenceDbi( )->getSequenceData( seqs[sequenceNum].id, U2_REGION_MAX, stateInfo ); results << DNASequence( seqName, seqContent, alp ); } } return resultTasks; }
bool DnaAssemblyAlgorithmMainWidget::requiredToolsAreOk() const { QStringList missedExtTools; ExternalToolRegistry *extToolRegistry = AppContext::getExternalToolRegistry(); SAFE_POINT(NULL != extToolRegistry, L10N::nullPointerError("External tool subsystem"), false); foreach (const QString &toolName, requiredExtToolNames) { ExternalTool *tool = extToolRegistry->getByName(toolName); if (NULL == tool || tool->getPath().isEmpty()) { missedExtTools.append(toolName); } }
bool GTUtilsCv::cvBtn::isChecked(HI::GUITestOpStatus &os, ADVSingleSequenceWidget *seqWidget) { QAbstractButton *cvButton = getCvButton(os, seqWidget, true /* CV button must exist */ ); CHECK_OP_SET_ERR_RESULT(os, "Error getting CV button!", false); SAFE_POINT(NULL != cvButton, "cvButton is NULL!", false); CHECK_SET_ERR_RESULT(cvButton->isCheckable(), "CV button is not checkable!", false); return cvButton->isChecked(); }
bool OPWidgetFactory::passFiltration( OPFactoryFilterVisitorInterface* filter ){ //by default checks type only bool res = false; SAFE_POINT(filter != NULL, "OPWidgetFactory::passFiltration. Filter is null", res); res = filter->typePass(getObjectViewType()); return res; }