45 #include <wx/button.h>
46 #include <wx/listbox.h>
47 #include <wx/notebook.h>
48 #include <wx/msgdlg.h>
49 #include <wx/filedlg.h>
50 #include <wx/wupdlock.h>
95 : m_UpdMultiSeqInput(0), m_Updated(0), m_Skipped(0)
101 wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize&
size,
long style)
102 : m_UpdMultiSeqInput(&updmultiseq_in), m_UpdateCmd(
cmd), m_Updated(0), m_Skipped(0)
105 Create(parent,
id, caption, pos,
size, style);
111 size_t identNum =
input.GetIdenticalUpdates().size();
116 size_t nonIdentNum =
input.GetNonIdenticalUpdates().size();
119 oss <<
"One sequence out of " << identNum + nonIdentNum <<
" is identical to its update sequence.";
121 else if (identNum > 1) {
122 oss << identNum <<
" sequences out of ";
123 oss << identNum + nonIdentNum <<
" are identical to their update sequences.";
127 for (
auto&& it :
input.GetIdenticalUpdates()) {
140 const wxPoint& pos,
const wxSize&
size,
long style )
143 SetExtraStyle(wxWS_EX_BLOCK_EVENTS | wxWS_EX_VALIDATE_RECURSIVELY);
144 CDialog::Create( parent,
id, caption, pos,
size, style );
149 GetSizer()->SetSizeHints(
this);
197 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
198 itemDialog1->SetSizer(itemBoxSizer2);
200 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
201 itemBoxSizer2->Add(itemBoxSizer3, 1, wxEXPAND | wxALL, 5);
205 wxPanel* itemPanel5 =
new wxPanel(
m_Notebook,
ID_PANEL, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
206 wxBoxSizer* itemBoxSizer6 =
new wxBoxSizer(wxVERTICAL);
207 itemPanel5->SetSizer(itemBoxSizer6);
210 wxStaticText* itemStaticText7 =
new wxStaticText( itemPanel5, wxID_STATIC,
_(
"Nonidentical updates"), wxDefaultPosition, wxDefaultSize, 0 );
211 itemBoxSizer6->Add(itemStaticText7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
213 wxArrayString m_NonIdenticalListStrings;
221 wxStaticText* itemStaticText9 =
new wxStaticText( itemPanel5, wxID_STATIC,
_(
"Identical updates"), wxDefaultPosition, wxDefaultSize, 0 );
222 itemBoxSizer6->Add(itemStaticText9, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
224 wxArrayString m_IdenticalListStrings;
237 wxPanel* itemPanel12 =
new wxPanel(
m_Notebook,
ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
238 wxBoxSizer* itemBoxSizer13 =
new wxBoxSizer(wxVERTICAL);
239 itemPanel12->SetSizer(itemBoxSizer13);
241 wxStaticText* itemStaticText14 =
new wxStaticText( itemPanel12, wxID_STATIC,
_(
"No updates"), wxDefaultPosition, wxDefaultSize, 0 );
242 itemBoxSizer13->Add(itemStaticText14, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
244 wxArrayString m_NoUpdateListStrings;
249 wxStaticText* itemStaticText16 =
new wxStaticText( itemPanel12, wxID_STATIC,
_(
"Unmatched sequences"), wxDefaultPosition, wxDefaultSize, 0 );
250 itemBoxSizer13->Add(itemStaticText16, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
252 wxArrayString m_UnmatchedListStrings;
257 wxBoxSizer* itemBoxSizer18 =
new wxBoxSizer(wxHORIZONTAL);
258 itemBoxSizer13->Add(itemBoxSizer18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
260 itemBoxSizer18->Add(
m_LoadMap, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
263 itemBoxSizer18->Add(
m_MapSelection, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
267 itemBoxSizer3->Add(
m_Notebook, 0, wxGROW|wxALL, 2);
287 wxBoxSizer* itemBoxSizer22 =
new wxBoxSizer(wxHORIZONTAL);
288 itemBoxSizer2->Add(itemBoxSizer22, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
290 wxButton* itemButton23 =
new wxButton( itemDialog1,
ID_UPDMULTSEQ_OKTHIS,
_(
"Update This Sequence"), wxDefaultPosition, wxDefaultSize, 0 );
291 itemBoxSizer22->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
293 wxButton* itemButton24 =
new wxButton( itemDialog1,
ID_UPDMULTSEQ_SKIP,
_(
"Skip This Sequence"), wxDefaultPosition, wxDefaultSize, 0 );
294 itemBoxSizer22->Add(itemButton24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
296 wxButton* itemButton25 =
new wxButton( itemDialog1,
ID_UPDMULTSEQ_OKALL,
_(
"Update All Sequences"), wxDefaultPosition, wxDefaultSize, 0 );
297 itemBoxSizer22->Add(itemButton25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
299 wxButton* itemButton26 =
new wxButton( itemDialog1,
ID_UPDMULTSEQ_STOP,
_(
"Stop Updating"), wxDefaultPosition, wxDefaultSize, 0 );
300 itemBoxSizer22->Add(itemButton26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
302 wxButton* itemButton27 =
new wxButton( itemDialog1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
303 itemBoxSizer22->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
309 itemButton23->Disable();
310 itemButton24->Disable();
311 itemButton25->Disable();
327 for (
auto&& it : updates) {
341 for (
auto&& it : identicals) {
353 for (
auto&& it : noUpdates) {
364 for (
auto&& it : noUpdates) {
393 static tuple<objects::CSeq_id_Handle, CConstRef<objects::CSeq_align> >
s_CreateAlign(
405 bool accept_atleast_one = (
subject.GetBioseqLength() <
query.GetBioseqLength());
409 if (align_vector.size() > 1)
412 if (align_vector.empty())
413 LOG_POST(
Info <<
"Could not form alignment between old and update sequence");
416 size_t best_align = 0;
417 for (
size_t i = 0;
i < align_vector.size(); ++
i) {
418 for (
size_t j =
i + 1; j < align_vector.size(); ++j) {
422 _ASSERT(best_align < align_vector.size());
423 std::get<1>(
result) = align_vector[best_align];
426 }
NCBI_CATCH(
"CUpdateMultiSeq_Dlg::s_CreateAlign()");
441 if (it->IsComplete()) {
449 upd_input->
SetAlignment(std::get<1>(res).GetPointerOrNull());
453 if (!seq_name.empty()) {
487 for (
auto&& it : ident_updates) {
489 if (annot && annot->
IsAlign()) {
498 for (
const auto& it : updates) {
500 [idH = it.first,
subject = it.second->GetOldBioseq(),
query = it.second->GetUpdateBioseq()](
ICanceled& canceled)
502 return s_CreateAlign(idH, subject, query, canceled);
503 },
"Update Sequence Align"));
510 for (
auto&& it : update_pairs) {
520 if (annot && annot->
IsAlign()) {
528 return s_CreateAlign(idH, subject, query, canceled);
529 },
"Update Sequence Align"));
584 int selected = wxNOT_FOUND;
588 if (selected != wxNOT_FOUND) {
593 if (seq_name.empty()) {
596 if (selected != wxNOT_FOUND) {
606 if (seq_name.empty())
611 wxMessageBox(
wxT(
"This sequence could not be updated!"),
wxT(
"Info"), wxOK | wxICON_INFORMATION);
617 wxMessageBox(
wxT(
"This sequence could not be updated!"),
wxT(
"Info"), wxOK | wxICON_INFORMATION);
647 if (selected != wxNOT_FOUND) {
660 if (selected != wxNOT_FOUND) {
676 for (
auto&& it : identicals) {
684 wxString ext =
wxT(
"Text Documents (*.txt)|*.txt|All Files (*.*)|*.*");
685 wxFileDialog open_dlg(
this,
wxT(
"Select a file"), wxEmptyString, wxEmptyString, ext, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
686 if (open_dlg.ShowModal() == wxID_CANCEL) {
690 wxString filename = open_dlg.GetPath();
693 if (line_reader.
Empty()) {
700 auto pos = s.first.
find(
'.');
701 if (string::npos != pos)
702 unmatchedOldSeqs.emplace(s.first.substr(0, pos), s.second);
705 vector<string> ignored_lines;
708 while (!line_reader->
AtEOF()) {
714 for (
auto&& it : ids) {
718 if (ids.size() != 2) {
719 ignored_lines.push_back(line);
724 auto oldidh_it = unmatchedOldSeqs.find(ids[0]);
726 if (oldidh_it == unmatchedOldSeqs.end()) {
728 oldidh_it = unmatchedOldSeqs.find(ids[1]);
734 ignored_lines.push_back(line);
738 if (oldidh_it == unmatchedOldSeqs.end()) {
740 ignored_lines.push_back(line);
744 update_pairs.emplace(oldidh_it->second, updidh_it->second);
752 for (
auto&& it : update_pairs) {
758 if (nonident_updates.
find(old_idh) != nonident_updates.
end()) {
759 m_SeqList.emplace(old_id_label, old_idh);
764 if (identicals.
find(old_idh) != identicals.
end()) {
765 m_SeqList.emplace(old_id_label, old_idh);
784 if (!ignored_lines.empty()) {
785 string msg =
"These lines were ignored:";
786 for (
auto&& it : ignored_lines) {
801 if (noupdate_sel == wxNOT_FOUND || unmatched_sel == wxNOT_FOUND) {
802 NcbiMessageBox(
"Please select one ID from each of the above two lists.");
819 pair.emplace(oldidh_it->second, updidh_it->second);
829 if (nonident_updates.
find(old_idh) != nonident_updates.
end()) {
835 if (identicals.
find(old_idh) != identicals.
end()) {
872 if (selectNonIdent == wxNOT_FOUND && selectIdent == wxNOT_FOUND) {
873 wxMessageBox(
wxT(
"No sequence was selected!"),
wxT(
"Info"), wxOK | wxICON_INFORMATION);
878 if (selectNonIdent != wxNOT_FOUND) {
883 else if (selectIdent != wxNOT_FOUND) {
902 if (seq_name.empty())
907 wxMessageBox(
wxT(
"This sequence could not be updated!"),
wxT(
"Error"), wxOK | wxICON_INFORMATION);
943 if (selectNonIdent == wxNOT_FOUND && selectIdent == wxNOT_FOUND) {
944 wxMessageBox(
wxT(
"No sequence was selected!"),
wxT(
"Info"), wxOK | wxICON_INFORMATION);
948 if (selectNonIdent != wxNOT_FOUND) {
952 else if (selectIdent != wxNOT_FOUND) {
966 string seq_name =
ToStdString(sel_list.GetString(selected));
969 wxMessageBox(
wxT(
"This sequence could not be skipped!"),
wxT(
"Info"), wxOK | wxICON_INFORMATION);
974 sel_list.Delete(selected);
975 if ( ! sel_list.IsEmpty()) {
976 if (selected > sel_list.GetCount() - 1) {
977 selected = sel_list.GetCount() - 1;
979 sel_list.SetSelection(selected);
980 seq_name =
ToStdString(sel_list.GetString(selected));
983 else if (other_list && !other_list->IsEmpty()) {
984 other_list->SetSelection(0);
985 seq_name =
ToStdString(other_list->GetString(selected));
996 for (
unsigned int selected = 0; selected <
m_NonIdenticalList->GetCount(); ++selected) {
1011 for (
unsigned int selected = 0; selected <
m_IdenticalList->GetCount(); ++selected) {
1058 wxMessageBox(
ToWxString(msg),
wxT(
"Info"), wxOK | wxICON_INFORMATION);
1064 int retcode = (
m_Updated > 0) ? wxOK : wxCLOSE;
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
void AddCommand(IEditCommand &command)
virtual void EndModal(int retCode)
virtual void SetRegistryPath(const string &path)
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
class CRegistryReadView provides a nested hierarchical view at a particular key.
CRegistryReadView GetReadView(const string §ion) const
CRegistryWriteView GetWriteView(const string §ion)
Sequence update exception class.
Class responsible for executing the sequence update for one old-update sequence pair.
bool IsReverseComplemented() const
void GetNotImportedFeatsReport(CNcbiOstream &out) const
CRef< CCmdComposite > Update(bool create_general_only)
Main function responsible to update the old sequence with the update sequence.
TNameToIDHandleMap m_UnmatchedUpdSeqs
wxButton * m_MapSelection
wxListBox * m_UnmatchedList
void OnIdle(wxIdleEvent &event)
virtual void x_SaveSettings(CRegistryWriteView view) const
void x_CreatePairwiseAlignments()
void x_FillNoUpdateList()
void x_LaunchJobs(const CUpdateMultipleSeq_Input::TIDToUpdInputMap &updates)
CRef< CCmdComposite > x_UpdateSelected(const string &seq_name, bool create_general_only)
CUpdateMultipleSeq_Input * m_UpdMultiSeqInput
void OnUpdateAllSequenceClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_OKALL
wxListBox * m_NoUpdateList
virtual void x_LoadSettings(const CRegistryReadView &view)
override these functions in derived classes
void x_SkipSelected(wxListBox &sel_list, unsigned int selected, wxListBox *other_list)
void x_CreateAlignmentForIdenticalUpdates()
void OnStopUpdatingClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_STOP
TNameToIDHandleMap m_SeqList
void x_FillNonIdenticalList()
string x_GetCurrentSelection()
static bool ShowToolTips()
Should we show tooltips?
static void s_ReportIdenticalPairs(const CUpdateMultipleSeq_Input &input)
void x_FillIdenticalList()
void OnUpdateThisSequenceClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_OKTHIS
void OnMapSelectionUpdate(wxUpdateUIEvent &event)
void Init()
Initialises member variables.
void OnSkipThisSequenceClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_SKIP
@ ID_UPDMULTSEQ_PNL2_LISTBOX1
@ ID_UPDMULTSEQ_PNL1_LISTBOX2
@ ID_UPDMULTSEQ_PNL2_BTN1
@ ID_UPDMULTSEQ_PNL2_LISTBOX2
@ ID_UPDMULTSEQ_PNL1_LISTBOX1
@ ID_UPDMULTSEQ_PNL2_BTN2
void x_GenerateAlignments(const CUpdateMultipleSeq_Input::TOldToUpdateMap &update_pairs)
void x_FillUnmatchedList()
CUpdateMultiSeq_Dlg()
Constructors.
static string s_GetSeqIDLabel(const objects::CSeq_id_Handle &idh)
void OnIdentSeqSelected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_UPDMULTSEQ_PNL1_LISTBOX2
set< objects::CSeq_id_Handle > m_Running
void OnLoadMapClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_PNL2_BTN1
list< job_future< TAlignResult > > m_Futures
~CUpdateMultiSeq_Dlg()
Destructor.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnCloseWindow(wxCloseEvent &event)
wxEVT_CLOSE_WINDOW event handler for ID_CUPDATEMULTISEQ_DLG
wxListBox * m_IdenticalList
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnMapSelectionClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_PNL2_BTN2
void OnCancelClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
wxButton * m_IdenticalUpdBtn
void x_UpdateAlignmentPanel(const string &seq_name)
wxListBox * m_NonIdenticalList
void OnNonIdentSeqSelected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_UPDMULTSEQ_PNL1_LISTBOX1
void OnRemoveIdenticalsClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_UPDMULTSEQ_PNL1_BTN
CUpdateSeqPanel * m_UpdSeqPanel
void OnRemoveIdenticalUpdate(wxUpdateUIEvent &event)
TNameToIDHandleMap m_UnmatchedOldSeqs
CRef< CCmdComposite > m_UpdateCmd
bool Create(wxWindow *parent, wxWindowID id=ID_CUPDATEMULTISEQ_DLG, const wxString &caption=_("Multiple Sequence Update"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void CreateControls()
Creates the controls and sizers.
void x_UpdateNotebookAfterMapping(void)
SUpdateSeqParams GetData()
void LoadSettings(const CRegistryReadView &view)
void SaveSettings(CRegistryWriteView view) const
void UpdatePanel(bool running, const CUpdateSeq_Input *updseq_in=nullptr)
Function updates the panel with new (old, update) sequence pair.
void SetData(const SUpdateSeqParams ¶ms)
Interface for testing cancellation request in a long lasting operation.
Stores parameters regarding the type of sequence update, on how to handle existing features and on ho...
@ eSeqUpdateReplace
do not change the old sequence
const_iterator end() const
const_iterator find(const key_type &key) const
static bool CompareAlignments(const objects::CSeq_align &align_first, const objects::CSeq_align &align_sec)
Returns true if the first alignment is 'better' than the second one Compares the Blast scores and in ...
static vector< CConstRef< objects::CSeq_align > > RunBlast2Seq(const objects::CBioseq_Handle &subject, const objects::CBioseq_Handle &query, bool accept_atleast_one, ICanceled *canceled=nullptr)
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
const string & GetMsg(void) const
Get message string.
void Info(CExceptionArgs_Base &args)
EDialogReturnValue NcbiInfoBox(const string &message, const string &title="Info")
specialized Message Box function for reporting general information messages
EDialogReturnValue NcbiMessageBox(const string &message, TDialogType type=eDialog_Ok, EDialogIcon icon=eIcon_Exclamation, const string &title="Error", EDialogTextMode text_mode=eRaw)
CTempString GetCurrentLine(void) const
static CRef< ILineReader > New(const string &filename)
Return a new ILineReader object corresponding to the given filename, taking "-" (but not "....
virtual bool AtEOF(void) const =0
Indicates (negatively) whether there is any more input.
CConstRef< CSeq_id > GetSeqId(void) const
@ eContent
Untagged human-readable accession or the like.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
virtual bool IsCanceled(void) const =0
bool IsOssEmpty(CNcbiOstrstream &oss)
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
double Restart(void)
Return time elapsed since first Start() or last Restart() call (in seconds).
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
static const char label[]
const TAlign & GetAlign(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
job_function_traits< _Fty >::future job_async(const _Fty &_Fnarg, const string &descr)
Lightweight interface for getting lines of data with minimal memory copying.
void ReportUsage(const wxString &dialog_name)
Report opening & accepting events in the editing package.
const struct ncbi::grid::netcache::search::fields::SIZE size
static tuple< objects::CSeq_id_Handle, CConstRef< objects::CSeq_align > > s_CreateAlign(CSeq_id_Handle idH, CBioseq_Handle subject, CBioseq_Handle query, ICanceled &canceled)
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)