34 #include "wx/wxprec.h"
45 #include <wx/textfile.h>
46 #include <wx/hyperlink.h>
129 Create(parent,
id, caption, pos,
size, style);
140 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
141 wxDialog::Create( parent,
id, caption, pos,
size, style );
146 GetSizer()->SetSizeHints(
this);
198 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
199 itemDialog1->SetSizer(itemBoxSizer2);
201 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
202 itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
205 itemBoxSizer3->Add(
m_Features, 1, wxGROW|wxALL, 5);
209 col0.SetText(
_(
"Feature") );
215 col1.SetText( wxEmptyString );
221 col2.SetText(
_(
"Action"));
227 col3.SetText(
_(
"Location") );
231 m_FeatureCountText =
new wxStaticText( itemDialog1, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
235 itemBoxSizer2->Add(
m_FeatureType, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
237 wxBoxSizer* itemBoxSizer7 =
new wxBoxSizer(wxHORIZONTAL);
238 itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
242 itemBoxSizer7->Add(
m_UnknownGap, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
246 itemBoxSizer7->Add(
m_KnownGap, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
249 m_Ns->SetValue(
false);
250 itemBoxSizer7->Add(
m_Ns, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
252 wxArrayString m_MakeTruncatedPartialStrings;
253 m_MakeTruncatedPartialStrings.Add(
_(
"Always"));
254 m_MakeTruncatedPartialStrings.Add(
_(
"Unless pseudo"));
255 m_MakeTruncatedPartialStrings.Add(
_(
"Never"));
260 wxBoxSizer* itemBoxSizer11 =
new wxBoxSizer(wxHORIZONTAL);
261 itemBoxSizer2->Add(itemBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
265 itemBoxSizer11->Add(
m_TrimEnds, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
269 itemBoxSizer11->Add(
m_RemoveFeats, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
278 itemBoxSizer11->Add(
m_EvenIfIntrons, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
280 wxBoxSizer* itemBoxSizer15 =
new wxBoxSizer(wxHORIZONTAL);
281 itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
283 m_AcceptButton =
new wxButton( itemDialog1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
284 itemBoxSizer15->Add(
m_AcceptButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
287 wxButton* itemButton17 =
new wxButton( itemDialog1, wxID_CANCEL,
_(
"Close"), wxDefaultPosition, wxDefaultSize, 0 );
288 itemBoxSizer15->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
290 wxButton* itemButton18 =
new wxButton( itemDialog1,
ID_CADJUSTFEATURES_BUTTON2,
_(
"Make Report"), wxDefaultPosition, wxDefaultSize, 0 );
291 itemBoxSizer15->Add(itemButton18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
293 wxHyperlinkCtrl* itemHyperlinkCtrl =
new wxHyperlinkCtrl( itemDialog1, wxID_HELP,
_(
"Help"),
wxT(
"https://www.ncbi.nlm.nih.gov/tools/gbench/manual15/#adjust-features"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
294 itemHyperlinkCtrl->SetForegroundColour(wxColour(192, 192, 192));
295 itemBoxSizer15->Add(itemHyperlinkCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
298 itemBoxSizer15->Add(
m_LeaveUp, 0, wxALIGN_LEFT | wxALL, 5);
303 m_FeatureType->InsertColumn(0,
" Feature", wxLIST_FORMAT_LEFT, 237);
316 ITERATE(vector<const objects::CFeatListItem *>, ft_it, feat_list)
318 const objects::CFeatListItem& item = **ft_it;
319 wxString desc = wxString(item.GetDescription());
320 int feat_type = item.GetType();
321 int feat_subtype = item.GetSubtype();
322 if (existing.
find(desc) == existing.
end())
351 item =
m_FeatureType->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
352 if (item == -1)
break;
358 if (
match == subtype) {
368 if ((fgap.HasKnown() &&
m_KnownGap->GetValue()) ||
370 (fgap.HasNs() &&
m_Ns->GetValue())) {
375 if (fgap.Trimmable() &&
m_TrimEnds->GetValue()) {
394 if (((fgap.HasKnown() &&
m_KnownGap->GetValue()) ||
396 (fgap.HasNs() &&
m_Ns->GetValue())) &&
397 ((fgap.Trimmable() &&
m_TrimEnds->GetValue()) ||
406 }
else if (fgap.ShouldRemove() &&
m_RemoveFeats->GetValue()) {
424 size_t internal_gap = 0;
437 long itemIndex =
m_Features->InsertItem(0, wxString(name));
438 m_Features->SetItem(itemIndex, 1, wxString(desc));
439 m_Features->SetItem(itemIndex, 2, wxString(action));
443 size_t num_items =
m_Features->GetItemCount();
444 if (num_items > 0 || internal_gap > 0)
448 feat_count << num_items;
450 feat_count <<
" features will be adjusted";
452 feat_count <<
" feature will be adjusted";
514 bool show_ns =
m_Ns->GetValue();
517 (*it)->CalculateRelevantIntervals(show_unknown, show_known, show_ns);
572 size_t num_adjustable = 0, num_internal = 0;
582 if (num_adjustable == 0 && num_internal == 0) {
583 wxMessageBox(
_(
"No features found"),
wxT(
"Error"), wxOK|wxICON_ERROR);
587 wxFileDialog save_file(
this,
wxT(
"Make report"), wxEmptyString, wxEmptyString,
589 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
591 if (save_file.ShowModal() == wxID_OK)
593 wxString path = save_file.GetPath();
596 string lb(wxString(wxTextFile::GetEOL()).
ToStdString());
599 if (num_adjustable > 0)
601 os << num_adjustable;
602 if (num_adjustable > 1)
603 os <<
" features will be adjusted" << lb;
605 os <<
" feature will be adjusted" << lb;
612 os << name <<
"\t" << desc <<
"\t" <<
location << lb;
615 if (num_internal > 0)
618 if (num_internal > 0)
621 if (num_internal > 1)
622 os <<
" features contain internal gaps" << lb;
624 os <<
" feature contains internal gaps" << lb;
630 os << name <<
"\t" << desc <<
"\t" <<
location << lb;
643 bool make_partial = (always || (unless_pseudo && !(top->GetFeature().IsSetPseudo() && top->GetFeature().GetPseudo())));
644 grp.push_back(
TFeatUpdatePair(top, top->AdjustForRelevantGapIntervals(make_partial, do_trim, do_split, split_intron, create_general_only)));
645 to_edit.erase(to_edit.begin());
646 size_t check_index = 0;
647 while (check_index < grp.size()) {
649 edit::TGappedFeatList::iterator cand = to_edit.begin();
650 while (cand != to_edit.end()) {
651 if (top->IsRelatedByCrossRef(**cand)) {
652 bool make_partial = (always || (unless_pseudo && !((*cand)->GetFeature().IsSetPseudo() && (*cand)->GetFeature().GetPseudo())));
653 grp.push_back(
TFeatUpdatePair(*cand, (*cand)->AdjustForRelevantGapIntervals(make_partial, do_trim, do_split, split_intron, create_general_only)));
654 cand = to_edit.erase(cand);
670 if (it->second.size() > 1) {
675 TFeatUpdatePairVector::iterator it2 = it1;
677 while (it2 != grp.end()) {
681 x_DoOne(*it1, next_id,
cmd, old_to_new, create_xref_map);
690 vector<CRef<CSeq_feat> > updates = p.second;
691 if (updates.empty() || (p.first->ShouldRemove() &&
m_RemoveFeats->GetValue())) {
695 cmd.AddCommand(*cmd_del);
699 const objects::CSeq_annot_Handle& feat_annot_handle = fh.
GetAnnot();
700 objects::CSeq_entry_Handle feat_seh = feat_annot_handle.
GetParentEntry();
701 if (!feat_seh.IsSet()) {
711 cmd.AddCommand(*change_feat);
736 prot_seq->
SetInst().ResetExt();
737 prot_seq->
SetInst().SetRepr(objects::CSeq_inst::eRepr_raw);
738 prot_seq->
SetInst().SetSeq_data().SetIupacaa().Set(
prot);
742 cmd.AddCommand(*chgInst);
743 objects::CFeat_CI prot_feat_ci(prot_bsh, objects::SAnnotSelector(objects::CSeqFeatData::eSubtype_prot));
747 prot_feat->Assign(*(prot_feat_ci->GetSeq_feat()));
748 prot_feat->ResetLocation();
749 prot_feat->SetLocation().SetInt().SetId().Assign(*(prot_seq->
GetId().front()));
750 prot_feat->SetLocation().SetInt().SetFrom(0);
751 prot_feat->SetLocation().SetInt().SetTo(prot_seq->
GetLength() - 1);
754 cmd.AddCommand(*chgFeat);
763 cmd.AddCommand(*delInst);
773 vector<CRef<CSeq_feat> > other_prot_feats;
774 vector<CRef<objects::CSeq_id> > new_prot_id;
777 new_prot_id.push_back(new_id);
781 for (objects::CFeat_CI prot_feat_ci(product); prot_feat_ci; ++prot_feat_ci)
783 if (prot_feat_ci->GetSeq_feat_Handle().GetFeatSubtype() == objects::CSeqFeatData::eSubtype_prot)
785 prot_feat.
Reset(
new objects::CSeq_feat());
786 prot_feat->Assign(*(prot_feat_ci->GetSeq_feat()));
806 cmd.AddCommand(*change_feat);
808 const objects::CSeq_annot_Handle& feat_annot_handle = fh.
GetAnnot();
809 objects::CSeq_entry_Handle feat_seh = feat_annot_handle.
GetParentEntry();
813 cmd.AddCommand(*cmd_add_feat);
822 if ((*it)->GetFeature() == feat) {
841 genes_to_trim.push_back(add);
846 return genes_to_trim;
859 size_t shown_feat_offset = 0;
863 item =
m_Features->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
864 if (item == -1)
break;
865 while (shown_feat_offset < item) {
875 if (item == shown_feat_offset) {
876 rval.push_back(*rit);
885 bool create_xref_map =
true;
887 create_xref_map =
false;
897 if (partial_sel == wxNOT_FOUND)
901 bool unless_pseudo =
false;
902 if (partial_sel_str ==
"Always")
904 else if (partial_sel_str ==
"Unless pseudo")
905 unless_pseudo =
true;
910 bool split_intron =
false;
916 if (
m_Features->GetSelectedItemCount() == 0) {
919 to_do.push_back(*it);
932 bool make_partial = (always || (unless_pseudo && !((*it)->GetFeature().IsSetPseudo() && (*it)->GetFeature().GetPseudo())));
933 grp.push_back(
TFeatUpdatePair(*it, (*it)->AdjustForRelevantGapIntervals(make_partial, do_trim,
false,
false, create_general_only)));
934 x_DoGroup(grp, next_id, *
cmd, old_to_new, create_xref_map);
938 while (!to_do.empty()) {
940 x_DoGroup(grp, next_id, *
cmd, old_to_new, create_xref_map);
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CRef< edit::CFeatGapInfo > s_ListHasFeature(CSeq_feat_Handle feat, const edit::TGappedFeatList &to_do)
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
#define ID_CADJUSTFEATURES_BUTTON2
#define ID_CADJUSTFEATURES_CHECKBOX5
#define ID_CADJUSTFEATURES_CHECKBOX1
#define ID_CADJUSTFEATURES_CHECKBOX3
#define ID_CADJUSTFEATURES_CHECKBOX
#define ID_CADJUSTFEATURES_LISTCTRL
#define ID_CADJUSTFEATURES_CHECKBOX_NS
#define ID_CADJUSTFEATURES_LISTBOX
#define ID_CADJUSTFEATURES_CHECKBOX4
#define ID_CADJUSTFEATURES_RADIOBOX
#define ID_CADJUSTFEATURES_CHECKBOX2
bool AdjustProteinFeaturePartialsToMatchCDS(CSeq_feat &new_prot, const CSeq_feat &cds)
AdjustProteinFeaturePartialsToMatchCDS A function to change an existing MolInfo to match a coding reg...
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
void OnSplitSelected(wxCommandEvent &event)
wxCheckBox * m_RemoveFeats
wxCheckBox * m_EvenIfIntrons
CRef< objects::feature::CFeatTree > m_FeatTree
vector< int > m_feat_subtypes
wxCheckBox * m_SplitForInternal
bool x_Adjustable(objects::edit::CFeatGapInfo &fgap)
objects::CSeq_entry_Handle m_TopSeqEntry
objects::edit::TGappedFeatList x_GetGenesForFeatures(const objects::edit::TGappedFeatList &to_do)
wxListCtrl * m_FeatureType
void OnRemoveSelected(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=10000, const wxString &caption=_("Adjust Features For Gaps"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
static bool ShowToolTips()
Should we show tooltips?
void OnTrimSelected(wxCommandEvent &event)
wxRadioBox * m_MakeTruncatedPartial
objects::edit::TGappedFeatList m_GappedFeatureList
void OnKnownUnknownSelected(wxCommandEvent &event)
TFeatUpdatePairVector x_PullRelatedGroup(objects::edit::TGappedFeatList &to_edit, bool always, bool unless_pseudo, bool do_trim, bool do_split, bool split_intron, bool create_general_only)
void OnMakeReport(wxCommandEvent &event)
wxArrayString m_FeatureTypeStrings
void DisplayGappedFeatures(void)
void x_DoGroup(TFeatUpdatePairVector grp, objects::CObject_id::TId &next_id, CCmdComposite &cmd, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
void GetTextForFeature(objects::CSeq_feat_Handle fh, string &name, string &desc, string &location)
void RecalculateGapIntervals()
~CAdjustFeaturesForGaps()
Destructor.
vector< int > m_feat_types
void EnableDisableAcceptButton(void)
void x_DoOne(TFeatUpdatePair &p, objects::CObject_id::TId &next_id, CCmdComposite &cmd, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
string x_Action(objects::edit::CFeatGapInfo &fgap)
bool x_IsFeatureTypeSelected(objects::CSeqFeatData::ESubtype subtype)
void CreateControls()
Creates the controls and sizers.
void PopulateFeatureList(void)
CRef< CCmdComposite > GetCommand()
CRef< CCmdComposite > GetCommand_impl(map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
pair< CRef< objects::edit::CFeatGapInfo >, vector< CRef< objects::CSeq_feat > > > TFeatUpdatePair
CAdjustFeaturesForGaps()
Constructors.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
objects::CObject_id::TId m_TopFeatureId
void OnFeatTypeChanged(wxListEvent &event)
void Init()
Initialises member variables.
objects::edit::TGappedFeatList x_GetSelectedFeatures()
wxButton * m_AcceptButton
wxCheckBox * m_UnknownGap
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
vector< TFeatUpdatePair > TFeatUpdatePairVector
void GetGappedFeatures(void)
wxStaticText * m_FeatureCountText
TSeqPos GetLength(void) const
static wxString GetDialogFilter(EFileType fileType)
static TId s_FindHighestFeatureId(const objects::CSeq_entry_Handle &entry)
static ESubtype SubtypeNameToValue(CTempString sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum.
SeqVector related exceptions.
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
static const char location[]
void RemapOtherProtFeats(const objects::CSeq_feat &old_cds, objects::CSeq_feat &cds, objects::CBioseq_Handle bh, CRef< CCmdComposite > composite, bool &any_actions)
std::ofstream out("events_result.xml")
main entry point for tests
TGappedFeatList ListGappedFeatures(CFeat_CI &feat_it, CScope &scope)
void FixFeatureIdsForUpdatePair(vector< CRef< CSeq_feat > > &updates1, vector< CRef< CSeq_feat > > &updates2)
void FixFeatureIdsForUpdates(vector< CRef< CSeq_feat > > updates, objects::CObject_id::TId &next_id)
vector< CRef< CFeatGapInfo > > TGappedFeatList
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
vector< const objects::CFeatListItem * > GetSortedFeatList(objects::CSeq_entry_Handle seh, size_t max=numeric_limits< size_t >::max())
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
static void Translate(const string &seq, string &prot, const CGenetic_code *code, bool include_stop=true, bool remove_trailing_X=false, bool *alt_start=NULL, bool is_5prime_complete=true, bool is_3prime_complete=true)
Translate a string using a specified genetic code.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TClass GetClass(void) const
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
const CSeqFeatData & GetData(void) const
virtual const CSeq_loc & GetProduct(void) const
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
bool IsSetProduct(void) const
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
bool IsSetClass(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
void Reset(void)
Reset reference object.
#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 EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
bool IsCdregion(void) const
Check if variant Cdregion is selected.
bool IsGene(void) const
Check if variant Gene is selected.
const TProduct & GetProduct(void) const
Get the Product member data.
const TWhole & GetWhole(void) const
Get the variant data.
@ eClass_nuc_prot
nuc acid and coded proteins
const TId & GetId(void) const
Get the Id member data.
void SetInst(TInst &value)
Assign a value to Inst data member.
const struct ncbi::grid::netcache::search::fields::SIZE size
double f(double x_, const double &y_)
static int match(register const pcre_uchar *eptr, register const pcre_uchar *ecode, const pcre_uchar *mstart, int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
string GetTextObjectDescription(const CSeq_feat &sf, CScope &scope)
string ToStdString(const wxString &s)