Task::ReportResult GTest_DNAcompareSequencesNamesInTwoObjects::report() { Document* doc = getContext<Document>(this, docContextName); if (doc == NULL) { stateInfo.setError(QString("document not found %1").arg(docContextName)); return ReportResult_Finished; } Document* doc2 = getContext<Document>(this, secondDocContextName); if (doc2 == NULL) { stateInfo.setError(QString("document not found %1").arg(secondDocContextName)); return ReportResult_Finished; } const QList<GObject*>& objs = doc->getObjects(); const QList<GObject*>& objs2 = doc2->getObjects(); GObject*obj=NULL; GObject*obj2=NULL; U2SequenceObject * mySequence; U2SequenceObject * mySequence2; for(int i=0;(i!=objs.size())&&(i!=objs2.size());i++){ obj = objs.at(i); obj2 = objs2.at(i); if((obj->getGObjectType()== GObjectTypes::SEQUENCE)&&(obj2->getGObjectType() == GObjectTypes::SEQUENCE)){ mySequence = qobject_cast<U2SequenceObject*>(obj); if(mySequence==NULL){ stateInfo.setError(QString("can't cast to sequence from: %1 in position %2").arg(obj->getGObjectName()).arg(i)); return ReportResult_Finished; } mySequence2 = qobject_cast<U2SequenceObject*>(obj2); if(mySequence2==NULL){ stateInfo.setError(QString("can't cast to sequence from: %1 in position %2").arg(obj2->getGObjectName()).arg(i)); return ReportResult_Finished; } if(mySequence->getGObjectName()!=mySequence2->getGObjectName()){ stateInfo.setError(QString("Name of object in position %1 not matched: '%2' vs '%3'").arg(i) .arg(mySequence->getGObjectName()).arg(mySequence2->getGObjectName())); return ReportResult_Finished; } } } if (objs.size() != objs2.size()) { QString error("Number of objects in doc mismatches: [%1=%2] vs [%3=%4]"); error = error.arg(docContextName).arg(objs.size()) .arg(secondDocContextName).arg(objs2.size()); if (obj) { error += QString("\nLast good object: %1").arg(obj->getGObjectName()); } stateInfo.setError(error); } return ReportResult_Finished; }
void DotPlotDialog::sl_loadTaskStateChanged(Task* t){ DotPlotLoadDocumentsTask *loadTask = qobject_cast<DotPlotLoadDocumentsTask*>(t); if (!loadTask || !loadTask->isFinished()) { if(t->isFinished()){ if(curURL == ""){ return; } GUrl URL(curURL); Project *project = AppContext::getProject(); SAFE_POINT(project, "project is NULL", ); Document *doc = project->findDocumentByURL(URL); if (!doc || !doc->isLoaded()) { return; } QList<GObject*> docObjects = doc->getObjects(); foreach (GObject* obj, docObjects) { U2SequenceObject* seqObj = qobject_cast<U2SequenceObject*>(obj); if (seqObj != NULL){ QString name = seqObj->getGObjectName(); xAxisCombo->addItem(name); yAxisCombo->addItem(name); sequences << seqObj; } } curURL = ""; } return; }
QString AssemblyBrowser::tryAddObject(GObject * obj) { Document * objDoc = obj->getDocument(); SAFE_POINT(NULL != objDoc, "", tr("Internal error: only object with document can be added to browser")); if (GObjectTypes::SEQUENCE == obj->getGObjectType()) { U2SequenceObject * seqObj = qobject_cast<U2SequenceObject*>(obj); CHECK(NULL != seqObj, tr("Internal error: broken sequence object")); SAFE_POINT(NULL != objDoc->getDocumentFormat(), "", tr("Internal error: empty document format")); U2OpStatus2Log os; qint64 seqLen = seqObj->getSequenceLength(); QStringList errs; qint64 modelLen = model->getModelLength(os); if (seqLen != modelLen) { errs << tr("The lengths of the sequence and assembly are different."); } if (seqObj->getGObjectName() != gobject->getGObjectName()) { errs << tr("The sequence and assembly names are different."); } // commented: waiting for fix //QByteArray refMd5 = model->getReferenceMd5(); //if(!refMd5.isEmpty()) { // //QByteArray data = QString(seqObj->getSequence()).remove("-").toUpper().toUtf8(); // QByteArray data = QString(seqObj->getSequence()).toUpper().toUtf8(); // QByteArray seqObjMd5 = QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex(); // if(seqObjMd5 != refMd5) { // errs << tr("- Reference MD5 not match with MD5 written in assembly"); // } //} bool setRef = !isAssemblyObjectLocked(true) && !model->isLoadingReference(); setRef &= model->checkPermissions(QFile::WriteUser, setRef); if(!errs.isEmpty() && setRef) { const NotificationStack *notificationStack = AppContext::getMainWindow()->getNotificationStack(); const QString message = tr("It seems that sequence \"%1\", set as reference to assembly \"%2\", does not match it.").arg(seqObj->getGObjectName()).arg(gobject->getGObjectName()) + "\n- " + errs.join("\n- "); notificationStack->addNotification(message, Warning_Not); } if(setRef) { model->setReference(seqObj); U2Assembly assembly = model->getAssembly(); U2DataId refId; QString folder; const QStringList folders = model->getDbiConnection().dbi->getObjectDbi()->getObjectFolders(assembly.id, os); if (folders.isEmpty() || os.isCoR()) { folder = U2ObjectDbi::ROOT_FOLDER; } else { folder = folders.first(); } if (seqObj->getEntityRef().dbiRef == model->getDbiConnection().dbi->getDbiRef()) { refId = seqObj->getEntityRef().entityId; } else { U2CrossDatabaseReferenceDbi * crossDbi = model->getDbiConnection().dbi->getCrossDatabaseReferenceDbi(); U2CrossDatabaseReference crossDbRef; // Cannot simply use seqObj->getSequenceRef(), since it points to a temporary dbi // TODO: make similar method seqObj->getPersistentSequenctRef() crossDbRef.dataRef.dbiRef.dbiId = objDoc->getURLString(); crossDbRef.dataRef.dbiRef.dbiFactoryId = "document"; crossDbRef.dataRef.entityId = seqObj->getGObjectName().toUtf8(); crossDbRef.visualName = "cross_database_reference: " + seqObj->getGObjectName(); crossDbRef.dataRef.version = 1; crossDbi->createCrossReference(crossDbRef, folder, os); LOG_OP(os); refId = crossDbRef.id; addObjectToView(obj); } model->associateWithReference(refId); } } else if (GObjectTypes::VARIANT_TRACK == obj->getGObjectType()) { VariantTrackObject *trackObj = qobject_cast<VariantTrackObject*>(obj); CHECK(NULL != trackObj, tr("Internal error: broken variant track object")); model->addTrackObject(trackObj); addObjectToView(obj); connect(model.data(), SIGNAL(si_trackRemoved(VariantTrackObject *)), SLOT(sl_trackRemoved(VariantTrackObject *))); } else {