예제 #1
0
void SequenceInfo::updateCommonStatisticsLayout() {
    ADVSequenceWidget *wgt = annotatedDnaView->getSequenceWidgetInFocus();
    CHECK(wgt != NULL, );
    ADVSequenceObjectContext *ctx = wgt->getActiveSequenceContext();
    SAFE_POINT(ctx != NULL, tr("Sequence context is NULL"), );
    SAFE_POINT(ctx->getAlphabet() != NULL, tr("Sequence alphbet is NULL"), );

    int availableSpace = getAvailableSpace(ctx->getAlphabet()->getType());

    QString statsInfo = QString("<table cellspacing=%1>").arg(COMMON_STATISTICS_TABLE_CELLSPACING);
    statsInfo += formTableRow(CAPTION_SEQ_REGION_LENGTH, getFormattedLongNumber(currentCommonStatistics.length), availableSpace);
    if (ctx->getAlphabet()->isNucleic()) {
        statsInfo += formTableRow(CAPTION_SEQ_GC_CONTENT, QString::number(currentCommonStatistics.gcContent, 'f', 2) + "%", availableSpace);
        statsInfo += formTableRow(CAPTION_SEQ_MOLAR_WEIGHT, QString::number(currentCommonStatistics.molarWeight, 'f', 2) + " Da", availableSpace);
        statsInfo += formTableRow(CAPTION_SEQ_MOLAR_EXT_COEF, QString::number(currentCommonStatistics.molarExtCoef) + " I/mol", availableSpace);
        statsInfo += formTableRow(CAPTION_SEQ_MELTING_TM, QString::number(currentCommonStatistics.meltingTm, 'f', 2) + " C", availableSpace);

        statsInfo += formTableRow(CAPTION_SEQ_NMOLE_OD, QString::number(currentCommonStatistics.nmoleOD260, 'f', 2), availableSpace);
        statsInfo += formTableRow(CAPTION_SEQ_MG_OD, QString::number(currentCommonStatistics.mgOD260, 'f', 2), availableSpace);
    } else if (ctx->getAlphabet()->isAmino()) {
        statsInfo += formTableRow(CAPTION_SEQ_MOLECULAR_WEIGHT, QString::number(currentCommonStatistics.molecularWeight, 'f', 2), availableSpace);
        statsInfo += formTableRow(CAPTION_SEQ_ISOELECTIC_POINT, QString::number(currentCommonStatistics.isoelectricPoint, 'f', 2), availableSpace);
    }

    statsInfo += "</table>";

    statisticLabel->setText(statsInfo);
}
예제 #2
0
void SecStructPredictViewAction::sl_execute() {
    QAction *a = dynamic_cast<QAction*>(sender());
    GObjectViewAction *viewAction = dynamic_cast<GObjectViewAction*>(a);
    SAFE_POINT(NULL != viewAction, "NULL action",);

    AnnotatedDNAView *av = qobject_cast<AnnotatedDNAView*>(viewAction->getObjectView());
    SAFE_POINT(NULL != av, "NULL dna view",);

    SecStructPredictAlgRegistry *sspar = AppContext::getSecStructPredictAlgRegistry();
    SAFE_POINT(NULL != sspar, "NULL SecStructPredictAlgRegistry",);

    if (sspar->getAlgNameList().isEmpty()) {
        QMessageBox::information(av->getWidget(),
            tr("Secondary Structure Prediction"),
            tr("No algorithms for secondary structure prediction are available.\nPlease, load the corresponding plugins."));
        return;
    }

    ADVSequenceObjectContext *seqCtx = av->getSequenceInFocus();
    SAFE_POINT(NULL != seqCtx, "NULL sequence context",);
    SAFE_POINT(NULL != seqCtx->getAlphabet(), "NULL alphabet",);
    SAFE_POINT(seqCtx->getAlphabet()->isAmino(), "Wrong alphabet",);

    QObjectScopedPointer<SecStructDialog> secStructDialog = new SecStructDialog(seqCtx, av->getWidget());
    secStructDialog->exec();
}
예제 #3
0
void EnzymesADVContext::sl_search() {
    GObjectViewAction* action = qobject_cast<GObjectViewAction*>(sender());
    assert(action!=NULL);
    AnnotatedDNAView* av = qobject_cast<AnnotatedDNAView*>(action->getObjectView());
    assert(av!=NULL);

    ADVSequenceObjectContext* seqCtx = av->getSequenceInFocus();
    assert(seqCtx->getAlphabet()->isNucleic());
    QObjectScopedPointer<FindEnzymesDialog> d = new FindEnzymesDialog(seqCtx);
    d->exec();
}
예제 #4
0
void SequenceInfo::updateDinuclLayout()
{
    ADVSequenceObjectContext* activeSequenceContext = annotatedDnaView->getSequenceInFocus();
    SAFE_POINT(0 != activeSequenceContext, "A sequence context is NULL!",);

    const DNAAlphabet* activeSequenceAlphabet = activeSequenceContext->getAlphabet();
    SAFE_POINT(0 != activeSequenceAlphabet, "An active sequence alphabet is NULL!",);

    QString alphabetId = activeSequenceAlphabet->getId();

    if ((alphabetId == BaseDNAAlphabetIds::NUCL_DNA_DEFAULT()) ||
        (alphabetId == BaseDNAAlphabetIds::NUCL_RNA_DEFAULT()))
    {
        dinuclWidget->show();
    }
    else
    {
        dinuclWidget->hide();
    }
}
예제 #5
0
void SequenceInfo::updateCharOccurLayout()
{
    ADVSequenceObjectContext* activeSequenceContext = annotatedDnaView->getSequenceInFocus();
    if (0 != activeSequenceContext)
    {
        const DNAAlphabet* activeSequenceAlphabet = activeSequenceContext->getAlphabet();
        SAFE_POINT(0 != activeSequenceAlphabet, "An active sequence alphabet is NULL!",);

        if ((activeSequenceAlphabet->isNucleic()) ||
            (activeSequenceAlphabet->isAmino()))
        {
            charOccurWidget->show();
        }
        else
        {
            // Do not show the characters occurrence for raw alphabet
            charOccurWidget->hide();
        }
    }
}
예제 #6
0
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();
}
예제 #7
0
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();
}
예제 #8
0
void ADVClipboard::copySequenceSelection(bool complement, bool amino) {
    ADVSequenceObjectContext* seqCtx = getSequenceContext();
    if (seqCtx == NULL) {
        QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), "No sequence selected!");
        return;
    }

    QString res;
    QVector<U2Region> regions = seqCtx->getSequenceSelection()->getSelectedRegions();
#ifdef UGENE_X86
    int totalLen = 0;
    foreach (const U2Region& r, regions) {
        totalLen += r.length;
    }
    if (totalLen > MAX_COPY_SIZE_FOR_X86) {
        QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), COPY_FAILED_MESSAGE);
        return;
    }
 #endif

    if (!regions.isEmpty()) {
        U2SequenceObject* seqObj = seqCtx->getSequenceObject();
        DNATranslation* complTT = complement ? seqCtx->getComplementTT() : NULL;
        DNATranslation* aminoTT = amino ? seqCtx->getAminoTT() : NULL;
        U2OpStatus2Log os;
        QList<QByteArray> seqParts = U2SequenceUtils::extractRegions(seqObj->getSequenceRef(), regions, complTT, aminoTT, false, os);
        if (os.hasError()) {
            QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), tr("An error occurred during getting sequence data: %1").arg(os.getError()));
            return;
        }
        if (seqParts.size() == 1) {
            putIntoClipboard(seqParts.first());
            return;
        }
        res = U1SequenceUtils::joinRegions(seqParts);
    }
    putIntoClipboard(res);
}