46 #include <wx/msgdlg.h>
53 IMPLEMENT_DYNAMIC_CLASS(
CBulkCDS, wxDialog )
55 BEGIN_EVENT_TABLE(
CBulkCDS, wxDialog )
70 wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize&
size,
long style )
85 wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize&
size,
long style )
86 : m_FeatHandles(feat_handles)
94 bool CBulkCDS::Create( wxWindow* parent, wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize&
size,
long style )
96 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
97 SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
98 wxDialog::Create( parent,
id, caption, pos,
size, style );
103 GetSizer()->SetSizeHints(
this);
129 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
130 itemDialog1->SetSizer(itemBoxSizer2);
132 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
133 itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
135 wxArrayString itemChoiceStrings, itemChoiceStringsWritable;
139 wxMessageBox(
wxT(
"No CDS records found"),
wxT(
"Error"), wxOK | wxICON_ERROR);
144 if (values_table->GetNum_rows() < 1)
146 wxMessageBox(
wxT(
"No CDS records found"),
wxT(
"Error"), wxOK | wxICON_ERROR);
152 itemBoxSizer3->Add(
m_GridPanel, 0, wxALIGN_TOP|wxALL, 5);
155 m_Grid->SetTable(gridAdapter,
true);
156 m_Grid->AutoSizeColumns();
157 int l_height =
m_Grid->GetColLabelSize();
158 m_Grid->SetColLabelSize( 2 * l_height );
165 if ((*it)->IsSetHeader() && (*it)->GetHeader().IsSetTitle() )
167 string title = (*it)->GetHeader().GetTitle();
170 itemChoiceStrings.Add(wxString(title));
172 itemChoiceStringsWritable.Add(wxString(title));
181 if (glyph_col >= 0 && glyph_col+1 <
m_Grid->GetNumberCols())
187 wxBoxSizer* itemBoxSizer4 =
new wxBoxSizer(wxHORIZONTAL);
188 itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
193 wxBoxSizer* itemBoxSizer5 =
new wxBoxSizer(wxHORIZONTAL);
194 itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
203 wxBoxSizer* itemBoxSizer13 =
new wxBoxSizer(wxHORIZONTAL);
204 itemBoxSizer2->Add(itemBoxSizer13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
206 wxButton* itemButton14 =
new wxButton( itemDialog1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
207 itemBoxSizer13->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
209 wxButton* itemButton15 =
new wxButton( itemDialog1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
210 itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
217 id_col->SetHeader().SetField_id(objects::CSeqTable_column_info::eField_id_location_id);
221 expand_col->SetHeader().SetTitle(
"");
222 expand_col->SetHeader().SetField_name(
"expand");
223 expand_col->SetData().SetString();
226 name_col->SetHeader().SetTitle(
"protein name");
227 name_col->SetHeader().SetField_name(
"protein_name");
228 name_col->SetData().SetString();
231 desc_col->SetHeader().SetTitle(
"protein description");
232 desc_col->SetHeader().SetField_name(
"protein_description");
233 desc_col->SetData().SetString();
236 loc_col->SetHeader().SetTitle(
"location");
237 loc_col->SetHeader().SetField_name(
"location");
238 loc_col->SetData().SetString();
241 comment_col->SetHeader().SetTitle(
"comment");
242 comment_col->SetHeader().SetField_name(
"comment");
243 comment_col->SetData().SetString();
246 ec_number_col->SetHeader().SetTitle(
"ec number");
247 ec_number_col->SetHeader().SetField_name(
"ec_number");
248 ec_number_col->SetData().SetString();
251 activity_col->SetHeader().SetTitle(
"activity");
252 activity_col->SetHeader().SetField_name(
"activity");
253 activity_col->SetData().SetString();
257 bogus_col->SetHeader().SetTitle(
"");
258 bogus_col->SetHeader().SetField_name(
"");
259 bogus_col->SetData().SetString();
262 table->SetColumns().push_back(id_col);
263 table->SetColumns().push_back(expand_col);
264 table->SetColumns().push_back(name_col);
265 table->SetColumns().push_back(desc_col);
266 table->SetColumns().push_back(loc_col);
276 table->SetColumns().push_back(comment_col);
277 table->SetColumns().push_back(ec_number_col);
278 table->SetColumns().push_back(activity_col);
279 table->SetColumns().push_back(bogus_col);
292 if (!
fi->IsSetProduct())
continue;
295 if (!prot_bsh || !prot_bsh.
IsProtein())
continue;
300 string name,desc,loc,comment;
303 CFeat_CI prot_feat_ci(prot_bsh, sel);
308 if (
prot.IsSetName())
309 name =
prot.GetName().front();
310 if (
prot.IsSetDesc())
311 desc =
prot.GetDesc();
317 if (
fi->GetOriginalSeq_feat()->IsSetLocation() )
318 fi->GetOriginalSeq_feat()->GetLocation().GetLabel(&loc);
320 if (
fi->GetOriginalSeq_feat()->IsSetComment())
321 comment =
fi->GetOriginalSeq_feat()->GetComment();
323 seh =
fi->GetScope().GetBioseqHandle(
fi->GetLocation()).GetSeq_entry_Handle();
326 const vector<string>& ec_values = ec_feat_action->
GetValues();
327 string ec_number =
NStr::Join(ec_values,
"|");
331 const vector<string>& act_values = act_feat_action->
GetValues();
332 string activity =
NStr::Join(act_values,
"|");
334 id_col->SetData().SetId().push_back(
id);
335 expand_col->SetData().SetString().push_back(
"");
336 name_col->SetData().SetString().push_back(name);
337 desc_col->SetData().SetString().push_back(desc);
338 loc_col->SetData().SetString().push_back(loc);
341 comment_col->SetData().SetString().push_back(comment);
342 ec_number_col->SetData().SetString().push_back(ec_number);
343 activity_col->SetData().SetString().push_back(activity);
344 bogus_col->SetData().SetString().push_back(
"");
370 bool not_asked =
true;
373 if (!
fi->IsSetProduct())
continue;
376 if (!prot_bsh || !prot_bsh.
IsProtein())
continue;
379 new_cds->
Assign(*
fi->GetOriginalSeq_feat());
381 string name,desc,loc;
382 string save_old_name;
385 CFeat_CI prot_feat_ci(prot_bsh, sel);
392 bool modified =
false;
394 if (
prot.IsSetName())
395 name =
prot.GetName().front();
396 if (
prot.IsSetDesc())
397 desc =
prot.GetDesc();
404 if (row < values_table->GetColumn(
"protein_name").GetData().GetString().
size())
408 if (new_name != name)
410 if (new_name.empty())
411 new_feat->
SetData().SetProt().ResetName();
414 if (new_feat->
SetData().SetProt().SetName().empty())
415 new_feat->
SetData().SetProt().SetName().push_back(new_name);
417 new_feat->
SetData().SetProt().SetName().front() = new_name;
423 save_old_name = name;
430 if (row < values_table->GetColumn(
"protein_description").GetData().GetString().
size())
434 if (new_desc != desc)
436 if (new_desc.empty())
437 new_feat->
SetData().SetProt().ResetDesc();
439 new_feat->
SetData().SetProt().SetDesc() = new_desc;
443 seh =
fi->GetScope().GetBioseqHandle(
fi->GetLocation()).GetSeq_entry_Handle();
446 const vector<string>& ec_values = ec_feat_action->
GetValues();
447 string old_ec_number =
NStr::Join(ec_values,
"|");
448 string new_ec_number;
451 if (row < values_table->GetColumn(
"ec_number").GetData().GetString().
size())
454 if (new_ec_number != old_ec_number)
462 new_feat->
SetData().SetProt().ResetEc();
463 vector<string> new_values;
465 for (
const auto&
val : new_values)
469 new_feat->
SetData().SetProt().SetEc().push_back(
val);
477 const vector<string>& act_values = act_feat_action->
GetValues();
478 string old_activity =
NStr::Join(act_values,
"|");
482 if (row < values_table->GetColumn(
"activity").GetData().GetString().
size())
485 if (new_activity != old_activity)
488 new_feat->
SetData().SetProt().ResetActivity();
489 vector<string> new_values;
491 for (
const auto&
val : new_values)
495 new_feat->
SetData().SetProt().SetActivity().push_back(
val);
507 if (
fi->GetOriginalSeq_feat()->IsSetLocation() )
508 fi->GetOriginalSeq_feat()->GetLocation().GetLabel(&loc);
510 bool changed_feat =
false;
519 if (row < values_table->GetColumn(
"comment").GetData().GetString().
size())
523 if (!save_old_name.empty())
525 if (new_comment.empty())
526 new_comment = save_old_name;
531 string msg =
"Do you want to overwrite existing comment values?";
532 int answer = wxMessageBox(
ToWxString(msg),
wxT(
"Existing Text"), wxYES_NO | wxCANCEL | wxICON_QUESTION,
this);
533 if (answer == wxCANCEL)
537 else if (answer == wxYES)
545 if (dlg.ShowModal() == wxID_OK) {
558 if (new_comment != comment)
560 if (new_comment.empty())
568 string partial_start_val = partial_start_feat_col->
GetFromFeat(*
fi->GetOriginalSeq_feat());
569 string new_partial_start_val;
576 if (new_partial_start_val != partial_start_val)
578 if (new_partial_start_val.empty())
585 string partial_stop_val = partial_stop_feat_col->
GetFromFeat(*
fi->GetOriginalSeq_feat());
586 string new_partial_stop_val;
589 if (row < values_table->GetColumn(
kPartialStop).GetData().GetString().
size())
593 if (new_partial_stop_val != partial_stop_val)
595 if (new_partial_stop_val.empty())
627 new_mrna->
Assign(*orig_mrna);
629 new_mrna->
SetData().SetRna().SetRnaProductName(prot_name, remainder);
647 return "Invalid operation in Bulk CDS Edit";
707 wxMessageDialog dlg(
this,
_(
"Discard modifications?"),
_(
"Attention"),wxOK|wxCANCEL|wxCENTRE);
708 if (dlg.ShowModal() == wxID_OK)
USING_SCOPE(ncbi::objects)
vector< CSeq_feat_Handle > m_FeatHandles
static bool ShowToolTips()
Should we show tooltips?
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("CDS Editing"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void CreateControls()
Creates the controls and sizers.
CRef< CCmdComposite > GetCommandFromValuesTable(CRef< objects::CSeq_table >)
void OnClickCancel(wxCommandEvent &event)
CSeqTableGridPanel * m_GridPanel
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void GetUpdateMRNAProductNameCmd(CRef< CSeq_feat > cds, CScope &scope, const string &prot_name, CRef< CCmdComposite > composite)
void Init()
Initialises member variables.
wxCheckBox * m_CopyProtNameToComment
virtual const CObject * RowToScopedObjects(int row, TConstScopedObjects &objects, CBioseq_Handle &bsh)
CRef< objects::CSeq_table > GetChoices(CRef< objects::CSeq_table > values_table)
CRef< CCmdComposite > GetCommand()
CApplyEditconvertPanel * m_AecrPanel
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CRef< objects::CSeq_table > GetValuesTableFromSeqEntry()
CStringConstraintSelect * m_StringConstraintPanel
void OnClickOk(wxCommandEvent &event)
bool IsReadOnlyColumn(string column_name)
void AddCommand(IEditCommand &command)
objects::edit::EExistingText GetExistingTextHandler()
void AllowAdditionalQual(bool val)
static CRef< CFeatureSeqTableColumnBase > Create(const string &sTitle, objects::CSeqFeatData::ESubtype subtype=objects::CSeqFeatData::eSubtype_any)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
CConstRef< objects::CSeq_submit > m_SeqSubmit
Seq-loc and seq-align mapper exceptions.
void MakeColumnReadOnly(int pos, bool val=true)
void InitColumnCollapse(int col)
CRef< objects::CSeq_table > GetValuesTable()
namespace ncbi::objects::
const CProt_ref * GetProtXref(void) const
get protein (if present) from Seq-feat.xref list
void RemoveQualifier(const string &qual_name)
Remove all qualifiers with the given name; do nothing if no such qualifier exists.
void SetProtXref(CProt_ref &value)
const CSeqTable_column & GetColumn(CTempString column_name) const
virtual void SetFeat(CSeq_feat_Handle fh)
void SetTopSeqEntry(CSeq_entry_Handle seh)
const vector< string > & GetValues(void)
IWorkbench is the central interface in the application framework.
CIRef< IEditingAction > CreateAction(CSeq_entry_Handle seh, const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class=kEmptyStr, CConstRef< objects::CSeq_submit > submit=CConstRef< objects::CSeq_submit >(NULL))
const string kPartialStart
const string kPartialStop
const char * kSequenceIdColLabel
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
vector< SConstScopedObject > TConstScopedObjects
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
CConstRef< CSeq_feat > GetmRNAforCDS(const CSeq_feat &cds, CScope &scope)
GetmRNAforCDS A function to find a CSeq_feat representing the appropriate mRNA for a given CDS.
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
bool IsProtein(void) const
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CScope & GetScope(void) const
Get scope this handle belongs to.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
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 string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
void SetHeader(THeader &value)
Assign a value to Header data member.
vector< CRef< CSeqTable_column > > TColumns
const TString & GetString(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
void SetComment(const TComment &value)
Assign a value to Comment data member.
const TData & GetData(void) const
Get the Data member data.
void SetData(TData &value)
Assign a value to Data data member.
void ResetComment(void)
Reset Comment data member.
const TComment & GetComment(void) const
Get the Comment member data.
const TProt & GetProt(void) const
Get the variant data.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
const struct ncbi::grid::netcache::search::fields::SIZE size
CRef< CSeqTable_column > AddStringColumnToTable(CRef< CSeq_table > table, string label)
void AddValueToColumn(CRef< CSeqTable_column > column, string value, size_t row, edit::EExistingText existing_text=edit::eExistingText_replace_old)
#define row(bind, expected)
@ eExistingText_replace_old
bool AddValueToString(string &str, const string &value, EExistingText existing_text)
Add text to an existing string, using the "existing_text" directive to combine new text with existing...
wxString ToWxString(const string &s)