42 #include <wx/button.h>
43 #include <wx/statbox.h>
121 wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize&
size,
long style )
125 Create(parent,
id, caption, pos,
size, style);
136 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
137 wxDialog::Create( parent,
id, caption, pos,
size, style );
142 GetSizer()->SetSizeHints(
this);
147 SetSize(wxSize(280, 750));
185 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
186 itemDialog1->SetSizer(itemBoxSizer2);
188 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
189 itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
192 itemBoxSizer3->Add(
m_ListCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
194 m_ListCtrl->InsertColumn(0,
" Sequence",wxLIST_FORMAT_LEFT,220);
209 wxStaticBox* itemStaticBoxSizer4Static =
new wxStaticBox(itemDialog1,
wxID_ANY,
_(
"Move selected sequences"));
210 wxStaticBoxSizer* itemStaticBoxSizer4 =
new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxHORIZONTAL);
211 itemBoxSizer2->Add(itemStaticBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
213 wxButton* itemButton1 =
new wxButton( itemDialog1,
ID_BUTTON_UP,
_(
"Up"), wxDefaultPosition, wxDefaultSize, 0 );
214 itemStaticBoxSizer4->Add(itemButton1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 15);
216 wxButton* itemButton2 =
new wxButton( itemDialog1,
ID_BUTTON_DOWN,
_(
"Down"), wxDefaultPosition, wxDefaultSize, 0 );
217 itemStaticBoxSizer4->Add(itemButton2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 15);
219 wxBoxSizer* itemBoxSizer5 =
new wxBoxSizer(wxHORIZONTAL);
220 itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
227 itemBoxSizer5->Add(
m_SortButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
230 wxBoxSizer* itemBoxSizer12 =
new wxBoxSizer(wxHORIZONTAL);
231 itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
233 wxButton* itemButton13 =
new wxButton( itemDialog1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
234 itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
236 wxButton* itemButton14 =
new wxButton( itemDialog1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
237 itemBoxSizer12->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
260 setseq.push_back(pair<CBioseq_set_Handle,CSeq_entry_Handle>(bssh,bsh.
GetSeq_entry_Handle()));
301 vector < pair<CBioseq_set_Handle,CSeq_entry_Handle> > setseq;
304 for (
unsigned int i=0;
i<setseq.size(); ++
i)
316 vector<int> list_index;
320 cmd->AddCommand(*set_cmd);
333 item =
m_ListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
334 if ( item == -1 )
break;
335 int i =
static_cast<int>(
m_ListCtrl->GetItemData(item));
336 list_index.push_back(
i);
347 for (
size_t j = 0; j < list_index.size(); j++)
349 int i = list_index[j];
350 if (set_seq[
i].
first == bssh)
353 if (set_seq[
i].second.HasParentEntry() && set_seq[
i].second.GetParentEntry().IsSet() &&
356 se->
Assign(*set_seq[
i].second.GetParentEntry().GetCompleteSeq_entry());
358 se->
Assign(*set_seq[
i].second.GetCompleteSeq_entry());
361 CBioseq_set::TSeq_set::iterator it = old_seq_set.begin();
362 while (it != old_seq_set.end())
365 if ((*it)->IsSeq() && (*it)->GetSeq().CanGetId())
366 for (CBioseq::TId::const_iterator
b = (*it)->GetSeq().GetId().begin();
b != (*it)->GetSeq().GetId().end(); ++
b)
367 if ((*b)->Match(*set_seq[
i].second.GetSeq().GetSeqId()))
match =
true;
370 (*it)->GetSet().GetNucFromNucProtSet().CanGetId())
371 for (CBioseq::TId::const_iterator
b = (*it)->GetSet().GetNucFromNucProtSet().GetId().begin();
b != (*it)->GetSet().GetNucFromNucProtSet().GetId().end(); ++
b)
372 if ((*b)->Match(*set_seq[
i].second.GetSeq().GetSeqId()))
match =
true;
375 it = old_seq_set.erase(it);
382 for (CBioseq_set::TSeq_set::iterator it = old_seq_set.begin(); it != old_seq_set.end(); ++it)
394 item =
m_ListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
395 if ( item == -1 )
break;
396 if ( item == 0 )
break;
397 int i =
static_cast<int>(
m_ListCtrl->GetItemData(item));
398 wxString name_i =
m_ListCtrl->GetItemText(item);
399 int state_i =
m_ListCtrl->GetItemState(item,wxLIST_STATE_SELECTED);
400 int j =
static_cast<int>(
m_ListCtrl->GetItemData(item-1));
401 wxString name_j =
m_ListCtrl->GetItemText(item-1);
402 int state_j =
m_ListCtrl->GetItemState(item-1,wxLIST_STATE_SELECTED);
405 m_ListCtrl->SetItemState(item-1,state_i,wxLIST_STATE_SELECTED);
408 m_ListCtrl->SetItemState(item,state_j,wxLIST_STATE_SELECTED);
420 item =
m_ListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
421 if ( item == -1 )
break;
422 index.push_back(item);
424 if ( !index.empty() && index.back() !=
m_ListCtrl->GetItemCount()-1 )
425 for (vector<long>::reverse_iterator rit = index.rbegin(); rit != index.rend(); ++rit)
428 int i =
static_cast<int>(
m_ListCtrl->GetItemData(item));
429 wxString name_i =
m_ListCtrl->GetItemText(item);
430 int state_i =
m_ListCtrl->GetItemState(item,wxLIST_STATE_SELECTED);
431 int j =
static_cast<int>(
m_ListCtrl->GetItemData(item+1));
432 wxString name_j =
m_ListCtrl->GetItemText(item+1);
433 int state_j =
m_ListCtrl->GetItemState(item+1,wxLIST_STATE_SELECTED);
436 m_ListCtrl->SetItemState(item+1,state_i,wxLIST_STATE_SELECTED);
439 m_ListCtrl->SetItemState(item,state_j,wxLIST_STATE_SELECTED);
447 typedef vector < pair<CBioseq_set_Handle,CSeq_entry_Handle> > vptr;
448 vptr * setseq = (vptr *)(
data);
456 return (
a.compare(
b));
487 static bool cmp_labels(
const pair<
unsigned int, pair<bool, string> >&
a,
const pair<
unsigned int, pair<bool,string> > &
b)
489 bool numeric1 =
a.second.first;
490 bool numeric2 =
b.second.first;
491 string str1 =
a.second.second;
492 string str2 =
b.second.second;
493 if (numeric1 && numeric2)
497 if (
i != 0 && j != 0)
500 return (str1 < str2);
505 string genebank, general_str, general_int,
local;
507 for (CBioseq_Handle::TId::const_iterator it = bsh.
GetId().begin(); it != bsh.
GetId().end(); ++it)
509 const CSeq_id &
id = *(it->GetSeqId());
510 if (
id.IsGenbank() &&
id.GetGenbank().IsSetAccession())
511 genebank =
id.GetGenbank().GetAccession();
512 if (
id.IsGeneral() &&
id.GetGeneral().IsSetTag() &&
id.GetGeneral().GetTag().IsStr())
513 general_str =
id.GetGeneral().GetTag().GetStr();
514 if (
id.IsGeneral() &&
id.GetGeneral().IsSetTag() &&
id.GetGeneral().GetTag().IsId())
516 if (
id.IsLocal() &&
id.GetLocal().IsStr())
517 local =
id.GetLocal().GetStr();
519 if (!genebank.empty())
524 if (!general_int.empty())
529 if (!general_str.empty())
541 vector < pair<CBioseq_set_Handle,CSeq_entry_Handle> > set_seq;
542 vector<pair<unsigned int, pair<bool, string> > > list_seq;
543 ReadBioseq(*(seh.GetCompleteSeq_entry()),set_seq, seh);
544 for (
unsigned int i=0;
i<set_seq.size(); ++
i)
548 list_seq.push_back(pair<
unsigned int, pair<bool, string> >(
i, pair<bool, string>(numeric,
label)));
551 for (
unsigned int i=0;
i<set_seq.size(); ++
i)
558 vector<int> list_index;
559 for (
size_t j = 0; j < list_seq.size(); j++)
561 list_index.push_back(list_seq[j].
first);
573 cmd->AddCommand(*set_cmd);
const CSeq_id * GetFirstId() const
objects::CSeq_entry_Handle m_TopSeqEntry
void PrepareList(vector< int > &list_index)
static bool ShowToolTips()
Should we show tooltips?
static string GetIdLabel(CBioseq_Handle bsh, bool &numeric)
static void ReadBioseq(const CSeq_entry &se, vector< pair< CBioseq_set_Handle, CSeq_entry_Handle > > &setseq, CSeq_entry_Handle seh)
~CReorderSequencesDlg()
Destructor.
vector< pair< CBioseq_set_Handle, CSeq_entry_Handle > > m_SetSeq
void OnButtonDown(wxCommandEvent &event)
void OnButtonSort(wxCommandEvent &event)
void CreateControls()
Creates the controls and sizers.
static CRef< CCmdComposite > ReorderById(objects::CSeq_entry_Handle seh)
void OnButtonUp(wxCommandEvent &event)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
static void PopulateSet(CBioseq_set_Handle bssh, CBioseq_set &new_set, const vector< int > &list_index, const vector< pair< CBioseq_set_Handle, CSeq_entry_Handle > > &set_seq)
void Init()
Initialises member variables.
bool Create(wxWindow *parent, wxWindowID id=11100, const wxString &caption=_("Reorder Sequences Dialog"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
CRef< CCmdComposite > GetCommand()
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CReorderSequencesDlg()
Constructors.
iterator_bool insert(const value_type &val)
const_iterator begin() const
parent_type::iterator iterator
const_iterator end() const
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
@ eContent
Untagged human-readable accession or the like.
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
bool CanGetClass(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CConstRef< CBioseq_set > GetCompleteBioseq_set(void) const
Return the complete bioseq-set object.
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id) const
Get Bioseq handle from the TSE of this Seq-entry.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
const TId & GetId(void) const
CConstRef< CBioseq_set > GetBioseq_setCore(void) const
Return core data for the bioseq-set.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ fAllowLeadingSymbols
Ignore leading non-numeric characters.
@ fAllowTrailingSymbols
Ignore trailing non-numerics characters.
static const char label[]
const TSeq & GetSeq(void) const
Get the variant data.
bool CanGetSeq_set(void) const
Check if it is safe to call GetSeq_set method.
TClass GetClass(void) const
Get the Class member data.
const TSet & GetSet(void) const
Get the variant data.
bool IsSeq(void) const
Check if variant Seq is selected.
void ResetSeq_set(void)
Reset Seq_set data member.
bool CanGetClass(void) const
Check if it is safe to call GetClass method.
bool IsSet(void) const
Check if variant Set is selected.
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
list< CRef< CSeq_entry > > TSeq_set
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
@ eClass_nuc_prot
nuc acid and coded proteins
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)
static const char * down_xpm[]
int wxCALLBACK ReverseCompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr data)
int wxCALLBACK DirectCompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr data)
static const char * up_xpm[]
static bool cmp_labels(const pair< unsigned int, pair< bool, string > > &a, const pair< unsigned int, pair< bool, string > > &b)
#define ID_LISTCTRL_REORDER
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
wxString ToWxString(const string &s)