예제 #1
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();
}
예제 #2
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();
}
예제 #3
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);
}