SequenceObjectContext::SequenceObjectContext (U2SequenceObject* obj, QObject* parent) : QObject(parent), seqObj(obj), aminoTT(NULL), complTT(NULL), selection(NULL), translations(NULL), visibleFrames(NULL), rowChoosed(false) { selection = new DNASequenceSelection(seqObj, this); clarifyAminoTT = false; const DNAAlphabet* al = getAlphabet(); if (al->isNucleic()) { DNATranslationRegistry* translationRegistry = AppContext::getDNATranslationRegistry(); complTT = GObjectUtils::findComplementTT(seqObj->getAlphabet()); aminoTT = GObjectUtils::findAminoTT(seqObj, true); clarifyAminoTT = aminoTT == NULL; QList<DNATranslation*> aminoTs = translationRegistry->lookupTranslation(al, DNATranslationType_NUCL_2_AMINO); if (!aminoTs.empty()) { aminoTT = aminoTT == NULL ? translationRegistry->getStandardGeneticCodeTranslation(al) : aminoTT; translations = new QActionGroup(this); foreach(DNATranslation* t, aminoTs) { QAction* a = translations->addAction(t->getTranslationName()); a->setObjectName(t->getTranslationName()); a->setCheckable(true); a->setChecked(aminoTT == t); a->setData(QVariant(t->getTranslationId())); connect(a, SIGNAL(triggered()), SLOT(sl_setAminoTranslation())); }
Task::ReportResult GTest_DNATranslation3to1Test::report() { GObject *obj = getContext<GObject>(this, objContextName); if (obj==NULL){ stateInfo.setError(QString("wrong value: %1").arg(OBJ_ATTR)); return ReportResult_Finished; } U2SequenceObject * mySequence = qobject_cast<U2SequenceObject*>(obj); if(mySequence==NULL){ stateInfo.setError(QString("error can't cast to sequence from: %1").arg(obj->getGObjectName())); return ReportResult_Finished; } if(!(mySequence->getAlphabet()->isNucleic())){ stateInfo.setError(QString("error Alphabet is not Nucleic: %1").arg(mySequence->getAlphabet()->getId())); return ReportResult_Finished; } DNATranslation* aminoTransl = 0; DNATranslationRegistry* tr = AppContext::getDNATranslationRegistry(); QList<DNATranslation*> aminoTs = tr->lookupTranslation(mySequence->getAlphabet(), DNATranslationType_NUCL_2_AMINO); if (!aminoTs.empty()) { aminoTransl = tr->getStandardGeneticCodeTranslation(mySequence->getAlphabet()); } int tempValue; if(strTo == -1){ tempValue=-1; } else{ tempValue=(strTo-strFrom+1); } QByteArray myByteArray = mySequence->getSequenceData(U2Region(strFrom,tempValue)); QByteArray rezult(myByteArray.length() / 3, 0); int n = aminoTransl->translate(myByteArray, myByteArray.length(), rezult.data(), rezult.length()); assert(n == rezult.length()); Q_UNUSED(n); if(rezult != stringValue.toLatin1()){ stateInfo.setError(QString("translated sequence not matched: %1, expected %2 ").arg(rezult.data()).arg(stringValue)); return ReportResult_Finished; } return ReportResult_Finished; }