54 #include <wx/msw/ole/automtn.h>
57 #include <wx/filename.h>
58 #include <wx/button.h>
59 #include <wx/statbox.h>
60 #include <wx/stattext.h>
61 #include <wx/msgdlg.h>
62 #include <wx/filedlg.h>
85 wxWindowID
id,
const wxString& caption,
const wxPoint& pos,
const wxSize&
size,
long style )
96 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
97 wxDialog::Create( parent,
id, caption, pos,
size, style );
102 GetSizer()->SetSizeHints(
this);
128 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
129 itemDialog1->SetSizer(itemBoxSizer1);
132 itemBoxSizer1->Add(
m_SourceCheck, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
135 wxArrayString source_quals;
142 itemBoxSizer1->Add(
m_SourceChoice, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
144 wxStaticBox* itemStaticBoxSizer2Static =
new wxStaticBox(itemDialog1,
wxID_ANY,
_(
"Other Qualifiers"));
145 wxStaticBoxSizer* itemBoxSizer2 =
new wxStaticBoxSizer(itemStaticBoxSizer2Static, wxVERTICAL);
146 itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
150 itemBoxSizer2->Add(
m_NoneRB, 0, wxALIGN_LEFT|wxALL, 5);
153 itemBoxSizer2->Add(
m_FeatureRB, 0, wxALIGN_LEFT|wxALL, 5);
159 itemBoxSizer2->Add(
m_RnaRB, 0, wxALIGN_LEFT|wxALL, 5);
162 itemBoxSizer2->Add(
m_DeflineRB, 0, wxALIGN_LEFT|wxALL, 5);
165 itemBoxSizer2->Add(
m_PubRB, 0, wxALIGN_LEFT|wxALL, 5);
168 itemBoxSizer2->Add(
m_DbLinkRB, 0, wxALIGN_LEFT|wxALL, 5);
172 itemBoxSizer1->Add(
m_ExcelCheck, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
175 wxBoxSizer* itemBoxSizer11 =
new wxBoxSizer(wxHORIZONTAL);
176 itemBoxSizer1->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
177 wxButton* itemButton1 =
new wxButton( itemDialog1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
178 itemBoxSizer11->Add(itemButton1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
179 wxButton* itemButton2 =
new wxButton( itemDialog1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
180 itemBoxSizer11->Add(itemButton2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
222 if (!
NStr::IsBlank(qual_name) && !objects::COrgMod::IsDiscouraged((*orgmod)->GetSubtype(),
true)) {
240 }
catch(
const CException&) {}
catch (
const exception&) {}
247 if (!
NStr::IsBlank(qual_name) && !objects::CSubSource::IsDiscouraged((*subsource)->GetSubtype())) {
255 }
catch(
const CException&) {}
catch (
const exception&) {}
266 if ((*it)->IsSource()) {
281 GetDesc (*(tse.GetCompleteSeq_entry()));
292 list< map<string, string> >
table;
334 vector<pair<string, CIRef<IEditingAction> > > cds_gene_mrna_actions;
337 vector<string> cds_gene_mrna_fields;
338 cds_gene_mrna_fields.push_back(
"protein name");
339 cds_gene_mrna_fields.push_back(
"protein description");
340 cds_gene_mrna_fields.push_back(
"CDS comment");
341 cds_gene_mrna_fields.push_back(
"gene locus");
342 cds_gene_mrna_fields.push_back(
"gene description");
343 cds_gene_mrna_fields.push_back(
"gene comment");
344 cds_gene_mrna_fields.push_back(
"gene allele");
345 cds_gene_mrna_fields.push_back(
"gene maploc");
346 cds_gene_mrna_fields.push_back(
"gene locus tag");
347 cds_gene_mrna_fields.push_back(
"gene synonym");
348 cds_gene_mrna_fields.push_back(
"mRNA product");
349 cds_gene_mrna_fields.push_back(
"mRNA comment");
350 cds_gene_mrna_fields.push_back(
"protein name");
351 cds_gene_mrna_fields.push_back(
"protein description");
352 cds_gene_mrna_fields.push_back(
"protein EC number");
353 cds_gene_mrna_fields.push_back(
"protein activity");
354 cds_gene_mrna_fields.push_back(
"protein comment");
355 cds_gene_mrna_fields.push_back(
"codon-start");
357 for (
auto field : cds_gene_mrna_fields)
360 if (field ==
"protein name" || field ==
"protein description" || field ==
"protein EC number"
361 || field ==
"protein activity" || field ==
"protein comment")
365 else if (field ==
"CDS comment" || field ==
"CDS inference" || field ==
"codon-start")
369 else if ( field ==
"gene description" || field ==
"gene comment"
370 || field ==
"gene inference" || field ==
"gene allele" || field ==
"gene maploc"
371 || field ==
"gene locus tag" || field ==
"gene synonym" || field ==
"gene old_locus_tag"
372 || field ==
"gene locus")
376 else if (field ==
"mRNA product" || field ==
"mRNA comment")
387 if (cds_gene_mrna_actions.back().second && !cds_gene_mrna_feat_action)
388 cds_gene_mrna_feat_action =
dynamic_cast<IEditingActionFeat*
>(cds_gene_mrna_actions.back().second.GetPointer());
397 if (seen.
find(fh) != seen.
end())
401 if (cds_gene_mrna_feat_action)
439 for (
auto field_action : cds_gene_mrna_actions)
441 string field = field_action.first;
446 bool is_feat_set(
false);
470 const vector<string>& values = feat_action->
GetValues();
472 value = values.front();
486 for (CSeq_loc_CI subloc(fh.
GetLocation(), objects::CSeq_loc_CI::eEmpty_Skip); subloc; ++subloc)
495 row[
"Seq-ID"] = seqid;
496 table.push_back(row);
503 vector<pair<string, CIRef<IEditingAction> > > actions;
505 vector<string> fields;
507 fields.push_back(
"product");
508 fields.push_back(
"comment");
509 fields.push_back(
"ncRNA class");
510 fields.push_back(
"gene locus");
511 fields.push_back(
"gene description");
512 fields.push_back(
"gene maploc");
513 fields.push_back(
"gene locus tag");
514 fields.push_back(
"gene synonym");
515 fields.push_back(
"gene comment");
516 fields.push_back(
"codons recognized");
517 fields.push_back(
"anticodon");
518 fields.push_back(
"tag_peptide");
522 for (
auto field : fields)
525 if ( field ==
"gene description" || field ==
"gene comment" || field ==
"gene maploc"
526 || field ==
"gene locus tag" || field ==
"gene synonym" || field ==
"gene locus")
530 else if (field ==
"ncRNA class")
534 else if (field ==
"codons recognized" || field ==
"anticodon")
538 else if (field ==
"tag_peptide")
544 if (actions.back().second && !rna_feat_action)
545 rna_feat_action =
dynamic_cast<IEditingActionFeat*
>(actions.back().second.GetPointer());
557 for (
auto field_action : actions)
559 string field = field_action.first;
564 bool is_feat_set(
false);
583 const vector<string>& values = feat_action->
GetValues();
585 value = values.front();
599 for (CSeq_loc_CI subloc(
rna.GetLocation(), objects::CSeq_loc_CI::eEmpty_Skip); subloc; ++subloc)
608 row[
"Seq-ID"] = seqid;
609 table.push_back(row);
617 auto table_it =
table.begin();
618 vector<string> fields;
619 wxArrayInt selections;
621 for (
size_t j = 0; j < num; j++)
623 int i = selections[j];
629 fields.push_back(*s);
633 fields.push_back(sel);
635 vector<pair<string, CIRef<IEditingAction> > > actions;
636 for (
auto &field : fields)
647 for (
auto field_action : actions)
649 string field = field_action.first;
655 const vector<string>& values = action->
GetValues();
657 value = values.front();
670 for (
auto field_action : actions)
672 string field = field_action.first;
678 const vector<string>& values = action->
GetValues();
680 value = values.front();
694 while (table_it !=
table.end() && (*table_it)[
"Seq-ID"] == seqid)
698 table_it->insert(row.
begin(), row.
end());
701 if (!found && !row.
empty())
703 row[
"Seq-ID"] = seqid;
704 table_it =
table.insert(table_it, row);
714 CSeq_table::TColumns::iterator col = values_table->
SetColumns().begin();
715 while (col != values_table->
SetColumns().end())
717 bool do_remove =
false;
718 if ((*col)->IsSetData())
720 if ((*col)->GetData().IsString())
722 bool empty_col =
true;
723 for (
size_t row = 0; row < (*col)->GetData().GetString().
size() && empty_col; row++)
725 empty_col = empty_col && (*col)->GetData().GetString()[row].empty();
743 vector<size_t> erase_rows;
744 for (
size_t row = 0; row < num_rows; row++)
746 bool empty_row =
true;
747 for (CSeq_table::TColumns::iterator col = values_table->
SetColumns().begin(); col != values_table->
SetColumns().end(); ++col)
748 if ((*col)->IsSetData() && (*col)->GetData().IsString() && row < (*col)->GetData().GetString().size())
749 empty_row = empty_row && (*col)->GetData().GetString()[row].empty();
752 erase_rows.push_back(row);
756 for (
long i = erase_rows.size()-1;
i >= 0;
i--)
758 for (CSeq_table::TColumns::iterator col = values_table->
SetColumns().begin(); col != values_table->
SetColumns().end(); ++col)
759 if ((*col)->IsSetData() && (*col)->GetData().IsString() && erase_rows[
i] < (*col)->GetData().GetString().size())
761 (*col)->SetData().SetString().erase((*col)->SetData().SetString().begin()+erase_rows[
i]);
763 else if ((*col)->IsSetData() && (*col)->GetData().IsId() && erase_rows[
i] < (*col)->GetData().GetId().size())
765 (*col)->SetData().SetId().erase((*col)->SetData().SetId().begin()+erase_rows[
i]);
774 string field(
"Definition Line");
794 row[
"Seq-ID"] = seqid;
795 table.push_back(row);
809 if ((*qual)->IsSetQual() && (*qual)->IsSetVal() && !(*qual)->GetQual().empty() && !(*qual)->GetVal().empty())
811 string field = feat_name +
" " + (*qual)->GetQual();
812 string value = (*qual)->GetVal();
820 for (CSeq_loc_CI subloc(feat->GetLocation(), objects::CSeq_loc_CI::eEmpty_Skip); subloc; ++subloc)
829 row[
"Seq-ID"] = seqid;
830 table.push_back(row);
837 vector<pair<string, CIRef<IEditingAction> > > actions;
839 for (
auto &field : pubs)
850 for (
auto field_action : actions)
852 string field = field_action.first;
858 const vector<string>& values = action->
GetValues();
860 value = values.front();
873 row[
"Seq-ID"] = seqid;
874 table.push_back(row);
883 vector<pair<string, CIRef<IEditingAction> > > actions;
884 for (
auto &field : dbs)
893 if (desc_ci->GetUser().IsSetType() && desc_ci->GetUser().GetType().IsStr()
898 for (
auto field_action : actions)
900 string field = field_action.first;
906 const vector<string>& values = action->
GetValues();
908 value = values.front();
921 row[
"Seq-ID"] = seqid;
922 table.push_back(row);
934 wxMessageBox(
wxT(
"Empty table"),
wxT(
"Error"),
935 wxOK | wxICON_ERROR, parent);
938 wxFileDialog table_save_file(parent,
wxT(
"Select a file"), save_file_dir, save_file_name,
939 _(
"TAB files(*.tab) | *.tab | All files(*.*) | *.*"),
940 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
942 if (table_save_file.ShowModal() == wxID_OK)
944 wxString path = table_save_file.GetPath();
945 wxString name = table_save_file.GetFilename();
952 wxMessageBox(
wxT(
"Please, select file name"),
wxT(
"Error"),
953 wxOK | wxICON_ERROR, parent);
961 wxMessageBox(
wxT(
"Cannot open file ")+name,
wxT(
"Error"),
962 wxOK | wxICON_ERROR, parent);
967 exporter.
Field(
string(
"Seq-ID"));
968 for (
auto col : columns)
971 for (
auto row :
table)
973 string seqid = row[
"Seq-ID"];
975 exporter.
Field(seqid);
976 for (
auto col : columns)
978 exporter.
Field(row[col]);
983 save_file_dir = table_save_file.GetDirectory();
984 save_file_name = table_save_file.GetFilename();
991 wxAutomationObject ExcelObject;
992 if (ExcelObject.GetInstance(
wxT(
"Excel.Application")))
994 ExcelObject.CallMethod(
"Workbooks.Open", FileName);
995 ExcelObject.PutProperty(
"Visible",
true);
User-defined methods of the data storage class.
static string GetSubtypeName(const CSubSource &qual)
const string & GetTaxname(void) const
bool IsSetTaxname(void) const
void Field(const string &value)
static vector< string > GetFieldNames()
void CreateControls()
Creates the controls and sizers.
void SaveTableFile(wxWindow *parent, wxString &save_file_dir, wxString &save_file_name, const list< map< string, string > > &table, const set< string > &columns)
set< string > m_source_choices
void Init()
Initialises member variables.
bool Create(wxWindow *parent, wxWindowID id=ID_EXPORT_TABLE_DLG, const wxString &caption=_("Export Table"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxListBox * m_SourceChoice
void AddRnaToTable(list< map< string, string > > &table, set< string > &columns)
static bool ShowToolTips()
Should we show tooltips?
wxRadioButton * m_CdsGeneProtRB
void GetDesc(const CSeq_entry &se)
void AddSourceToTable(list< map< string, string > > &table, set< string > &columns)
void FindBioSource(objects::CSeq_entry_Handle tse)
wxRadioButton * m_FeatureRB
objects::CSeq_entry_Handle m_TopSeqEntry
CExportTableDlg()
Constructors.
void AddFeaturesToTable(list< map< string, string > > &table, set< string > &columns)
void AddDeflinesToTable(list< map< string, string > > &table, set< string > &columns)
void RunExcel(wxString FileName)
wxCheckBox * m_SourceCheck
void AddPubsToTable(list< map< string, string > > &table, set< string > &columns)
void AddBioSource(const CBioSource &biosource)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void SaveTable(const wxString &workDir=wxEmptyString)
wxRadioButton * m_DbLinkRB
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxCheckBox * m_ExcelCheck
~CExportTableDlg()
Destructor.
wxRadioButton * m_DeflineRB
void AddDblinkToTable(list< map< string, string > > &table, set< string > &columns)
static void RemoveEmptyColsAndRows(CRef< CSeq_table > values_table)
void AddCdsGeneMrnaTable(list< map< string, string > > &table, set< string > &columns)
static vector< string > GetFieldNames(bool extended=false)
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
void SetFeat(CSeq_feat_Handle fh)
void SetDesc(const CSeqdesc *desc)
void SetDesc(const CSeqdesc *desc)
CSeq_feat_Handle x_FindGeneForFeature(const CSeq_loc &loc, CScope &scope, CSeqFeatData::ESubtype subtype)
virtual void SetFeat(CSeq_feat_Handle fh)
CSeqFeatData::ESubtype GetActionFeatSubtype()
const vector< string > & GetValues(void)
const_iterator begin() const
const_iterator end() const
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator find(const key_type &key) const
const_iterator end() const
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))
std::ofstream out("events_result.xml")
main entry point for tests
const char * kSubSourceNote
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
@ eContent
Untagged human-readable accession or the like.
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
const CSeqFeatData & GetData(void) const
virtual const CSeq_loc & GetProduct(void) const
bool IsSetProduct(void) const
virtual const CSeq_loc & GetLocation(void) const
CSeqFeatData::ESubtype GetFeatSubtype(void) const
const CSeq_feat_Handle & GetSeq_feat_Handle(void) const
Get original feature handle.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
@ eSubtype_specimen_voucher
@ eSubtype_culture_collection
void SetNum_rows(TNum_rows value)
Assign a value to Num_rows data member.
TNum_rows GetNum_rows(void) const
Get the Num_rows member data.
TColumns & SetColumns(void)
Assign a value to Columns data member.
const TBiosrc & GetBiosrc(void) const
Get the variant data.
const TSet & GetSet(void) const
Get the variant data.
bool IsSet(void) const
Check if variant Set is selected.
const TTitle & GetTitle(void) const
Get the variant data.
@ e_User
user defined object
@ e_Pub
a reference to the publication
@ e_Title
a title for this sequence
@ e_Source
source of materials, includes Org-ref
<!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
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define FOR_EACH_ORGMOD_ON_BIOSOURCE(Itr, Var)
FOR_EACH_ORGMOD_ON_BIOSOURCE EDIT_EACH_ORGMOD_ON_BIOSOURCE.
#define FOR_EACH_GBQUAL_ON_SEQFEAT(Itr, Var)
FOR_EACH_GBQUAL_ON_SEQFEAT EDIT_EACH_GBQUAL_ON_SEQFEAT.
#define FOR_EACH_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
FOR_EACH_SUBSOURCE_ON_BIOSOURCE EDIT_EACH_SUBSOURCE_ON_BIOSOURCE.
Utility macros and typedefs for exploring NCBI objects from seqset.asn.
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
#define FOR_EACH_SEQDESC_ON_SEQENTRY(Itr, Var)
FOR_EACH_SEQDESC_ON_SEQENTRY EDIT_EACH_SEQDESC_ON_SEQENTRY.
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)