void SequenceViewer::CreateSequenceWindow(bool showNow) { if (sequenceWindow) { sequenceWindow->Show(showNow); if (showNow) GlobalMessenger()->PostRedrawSequenceViewer(this); } else { SequenceDisplay *display = GetCurrentDisplay(); if (display) { sequenceWindow = new SequenceViewerWindow(this); #ifdef __WXMAC__ // Nudge down a bit to compensate for the menubar at the top of the screen wxPoint p = sequenceWindow->GetPosition(); p.y += 20; sequenceWindow->Move(p); #endif sequenceWindow->NewDisplay(display, true); sequenceWindow->ScrollToColumn(display->GetStartingColumn()); sequenceWindow->Show(showNow); // ScrollTo causes immediate redraw, so don't need a second one GlobalMessenger()->UnPostRedrawSequenceViewer(this); } } }
bool SequenceViewer::ReplaceAlignment(const BlockMultipleAlignment *origAln, BlockMultipleAlignment *newAln) { AlignmentList& alignments = GetCurrentAlignments(); SequenceDisplay *display = GetCurrentDisplay(); // sanity checks if (alignments.size() != 1 || alignments.front() != origAln || !sequenceWindow || !sequenceWindow->EditorIsOn()) { ERRORMSG("SequenceViewer::ReplaceAlignment() - bad parameters"); return false; } // empty out and then recreate the current alignment list and display (but not the undo stacks!) DELETE_ALL_AND_CLEAR(alignments, AlignmentList); alignments.push_back(newAln); display->Empty(); display->AddBlockBoundaryRow(newAln); for (unsigned int row=0; row<newAln->NRows(); ++row) display->AddRowFromAlignment(row, newAln); // set starting scroll to a few residues left of the first aligned block display->SetStartingColumn(newAln->GetFirstAlignedBlockPosition() - 5); Save(); // make this an undoable operation if (sequenceWindow) sequenceWindow->UpdateDisplay(display); return true; }
void SequenceViewer::SaveAlignment(void) { KeepCurrent(); // go back into the original pairwise alignment data and save according to the // current edited BlockMultipleAlignment and display row order vector < unsigned int > rowOrder; const SequenceDisplay *display = GetCurrentDisplay(); for (unsigned int i=0; i<display->rows.size(); ++i) { DisplayRowFromAlignment *alnRow = dynamic_cast<DisplayRowFromAlignment*>(display->rows[i]); if (alnRow) rowOrder.push_back(alnRow->row); } alignmentManager->SavePairwiseFromMultiple(GetCurrentAlignments().back(), rowOrder); }
void GMApp::OpenMailbox ( const JCharacter* filename, const JBoolean beep, const JBoolean iconify ) { if (JDirectoryExists(filename)) { const JCharacter* map[] = { "dir", filename }; const JString msg = JGetString("NameIsDirectoryNotFile::GMApp", map, sizeof(map)); JGetUserNotification()->ReportError(msg); return; } if (MailboxOpen(filename, !iconify)) { return; } JString mailbox(filename); JBoolean locked = FileLocked(mailbox, kJFalse); GMessageTableDir* dir; if (!locked) { if (GLockFile(mailbox) && GMessageTableDir::Create(this, mailbox, &dir, iconify)) { itsTableDirs->Append(dir); GUnlockFile(mailbox); Broadcast(MailboxOpened(mailbox)); if (beep && GGetPrefsMgr()->IsBeepingOnNewMail()) { GetCurrentDisplay()->Beep(); } } } }
void SequenceViewer::ExportAlignment(eExportType type) { // get filename wxString extension, wildcard; if (type == asFASTA) { extension = ".fsa"; wildcard = "FASTA Files (*.fsa)|*.fsa"; } else if (type == asFASTAa2m) { extension = ".a2m"; wildcard = "A2M FASTA (*.a2m)|*.a2m"; } else if (type == asText) { extension = ".txt"; wildcard = "Text Files (*.txt)|*.txt"; } else if (type == asHTML) { extension = ".html"; wildcard = "HTML Files (*.html)|*.html"; } else if (type == asPSSM) { extension = ".pssm"; wildcard = "PSSM Files (*.pssm)|*.pssm"; } wxString outputFolder = wxString(GetUserDir().c_str(), GetUserDir().size() - 1); // remove trailing / wxString baseName, outputFile; wxFileName::SplitPath(GetWorkingFilename().c_str(), NULL, &baseName, NULL); wxFileDialog dialog(sequenceWindow, "Choose a file for alignment export:", outputFolder, #ifdef __WXGTK__ baseName + extension, #else baseName, #endif wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); dialog.SetFilterIndex(0); if (dialog.ShowModal() == wxID_OK) outputFile = dialog.GetPath(); if (outputFile.size() > 0) { // create output stream auto_ptr<CNcbiOfstream> ofs(new CNcbiOfstream(WX_TO_STD(outputFile).c_str(), IOS_BASE::out)); if (!(*ofs)) { ERRORMSG("Unable to open output file " << outputFile.c_str()); return; } // map display row order to rows in BlockMultipleAlignment vector < int > rowOrder; const SequenceDisplay *display = GetCurrentDisplay(); for (unsigned int i=0; i<display->rows.size(); ++i) { DisplayRowFromAlignment *alnRow = dynamic_cast<DisplayRowFromAlignment*>(display->rows[i]); if (alnRow) rowOrder.push_back(alnRow->row); } // actually write the alignment if (type == asFASTA || type == asFASTAa2m) { INFOMSG("exporting" << (type == asFASTAa2m ? " A2M " : " ") << "FASTA to " << outputFile.c_str()); DumpFASTA((type == asFASTAa2m), alignmentManager->GetCurrentMultipleAlignment(), rowOrder, sequenceWindow->GetCurrentJustification(), *ofs); } else if (type == asText || type == asHTML) { INFOMSG("exporting " << (type == asText ? "text" : "HTML") << " to " << outputFile.c_str()); DumpText((type == asHTML), alignmentManager->GetCurrentMultipleAlignment(), rowOrder, sequenceWindow->GetCurrentJustification(), *ofs); } else if (type == asPSSM) { static string prevTitle; if (prevTitle.size() == 0) prevTitle = GetWorkingTitle(); string title = WX_TO_STD(wxGetTextFromUser( "Enter a name for this PSSM (to be used by other applications like PSI-BLAST or RPS-BLAST):", "PSSM Title?", prevTitle.c_str(), *viewerWindow).Strip(wxString::both)); if (title.size() > 0) { INFOMSG("exporting PSSM (" << title << ") to " << outputFile.c_str()); alignmentManager->GetCurrentMultipleAlignment()->GetPSSM().OutputPSSM(*ofs, title); prevTitle = title; } } } }