NCBI C++ ToolKit
vectortrimpanel.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: vectortrimpanel.cpp 38143 2017-04-03 16:11:47Z filippov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Yoon Choi
27  */
28 
29 
30 #include <ncbi_pch.hpp>
32 
33 ////@begin includes
34 ////@end includes
35 
36 #include <wx/panel.h>
37 #include <wx/sizer.h>
38 #include <wx/button.h>
39 #include <wx/textctrl.h>
40 #include <wx/msgdlg.h>
41 #include <wx/log.h>
42 #include <wx/stattext.h>
43 #include <wx/radiobox.h>
44 
64 #include <objects/seq/Seq_inst.hpp>
65 #include <objects/seq/Seq_ext.hpp>
67 #include <objects/seq/Pubdesc.hpp>
68 #include <objects/pub/Pub.hpp>
70 #include <objmgr/feat_ci.hpp>
71 #include <objmgr/align_ci.hpp>
72 #include <objmgr/graph_ci.hpp>
73 #include <objmgr/seqdesc_ci.hpp>
75 #include <objmgr/util/sequence.hpp>
77 
78 #include <sstream>
79 
80 ////@begin XPM images
81 ////@end XPM images
82 
85 
86 void ShowDebugMessage(const wxString& message)
87 {
88  wxMessageDialog msgdlg( NULL, message, _("Debug") );
89  msgdlg.ShowModal();
90 }
91 
92 // Ids do not need to be globally unique as long as they are
93 // unique within the local context (e.g., unique per dialog)
94 enum
95 {
96  MYID_BUTTON_RUN_VECSCREEN = wxID_HIGHEST + 1,
112 };
113 
114 /*!
115  * CVectorTrimPanel type definition
116  */
117 
118 IMPLEMENT_DYNAMIC_CLASS( CVectorTrimPanel, wxPanel )
119 
120 
121 /*!
122  * CVectorTrimPanel event table definition
123  */
124 
125 BEGIN_EVENT_TABLE( CVectorTrimPanel, wxPanel )
126 
127 ////@begin CVectorTrimPanel event table entries
128 
129 ////@end CVectorTrimPanel event table entries
130  EVT_BUTTON(MYID_BUTTON_RUN_VECSCREEN, CVectorTrimPanel::OnRunVecscreen)
131  EVT_RADIOBOX(MYID_RADIOBOX_SORT, CVectorTrimPanel::OnSort)
132  EVT_BUTTON(MYID_BUTTON_SELECT_ALL, CVectorTrimPanel::OnSelectAll)
133  EVT_BUTTON(MYID_BUTTON_SELECT_STRONG_MODERATE, CVectorTrimPanel::OnSelectStrongModerate)
134  EVT_BUTTON(MYID_BUTTON_UNSELECT_ALL, CVectorTrimPanel::OnUnselectAll)
135  EVT_BUTTON(MYID_BUTTON_UNSELECT_INTERNAL, CVectorTrimPanel::OnUnselectInternal)
136  //EVT_CHECKBOX(MYID_CHECKBOX_VIEWGRAPHIC, CVectorTrimPanel::OnViewAlignmentGraphic)
137  EVT_BUTTON(MYID_BUTTON_MAKE_REPORT, CVectorTrimPanel::OnMakeReport)
138  EVT_BUTTON(MYID_BUTTON_TRIM_SELECTED, CVectorTrimPanel::OnTrimSelected)
139  EVT_BUTTON(MYID_BUTTON_FIND_FORWARD, CVectorTrimPanel::OnFindForward)
140  EVT_BUTTON(MYID_BUTTON_FIND_REVERSE, CVectorTrimPanel::OnFindReverse)
141  EVT_BUTTON(MYID_BUTTON_DISMISS, CVectorTrimPanel::OnDismiss)
142 
144 
145 
146 /*!
147  * CVectorTrimPanel constructors
148  */
149 
150 CVectorTrimPanel::CVectorTrimPanel()
151 {
152  m_pParentWindow = NULL;
153  Init();
154 }
155 
157  objects::CSeq_entry_Handle seh,
158  ICommandProccessor* cmdProcessor,
159  wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
160  : m_TopSeqEntry(seh),
161  m_CmdProcessor(cmdProcessor),
162  m_pParentWindow(parent)
163 {
164  Init();
165  Create(parent, id, pos, size, style);
166 }
167 
168 
169 /*!
170  * CVectorTrimPanel creator
171  */
172 
173 bool CVectorTrimPanel::Create( wxWindow* parent,
174  wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
175 {
176 ////@begin CVectorTrimPanel creation
177  wxPanel::Create( parent, id, pos, size, style );
178  m_pParentWindow = parent;
179 
180  CreateControls();
181  if (GetSizer())
182  {
183  GetSizer()->SetSizeHints(this);
184  }
185  Centre();
186 ////@end CVectorTrimPanel creation
187  return true;
188 }
189 
190 
191 /*!
192  * CVectorTrimPanel destructor
193  */
194 
196 {
197 ////@begin CVectorTrimPanel destruction
198 ////@end CVectorTrimPanel destruction
199 }
200 
201 
202 /*!
203  * Member initialisation
204  */
205 
207 {
208 ////@begin CVectorTrimPanel member initialisation
209 ////@end CVectorTrimPanel member initialisation
210 }
211 
212 
213 /*!
214  * Control creation for CVectorTrimPanel
215  */
216 
218 {
219 ////@begin CVectorTrimPanel content construction
220  CVectorTrimPanel* itemPanel1 = this;
221 
222  // Top level sizer
223  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
224  itemPanel1->SetSizer(itemBoxSizer2);
225 
226 ////@end CVectorTrimPanel content construction
227 
228  // Row 0 - heading labels
229  wxBoxSizer* sizerLabels = new wxBoxSizer(wxHORIZONTAL);
230  wxStaticText* matches =
231  new wxStaticText( this, wxID_ANY, _( "Sequences with Vector Match" ),
232  wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_VERTICAL );
233  wxStaticText* locations =
234  new wxStaticText( this, wxID_ANY, _( "Location of Vector Match" ),
235  wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_VERTICAL );
236  sizerLabels->Add(matches, 1, wxEXPAND|wxALL, 5);
237  sizerLabels->Add(locations, 1, wxEXPAND|wxALL, 5);
238  itemBoxSizer2->Add(sizerLabels, 0, wxEXPAND|wxALL, 5);
239 
240  // Row 1 - display results
241  m_sizerVectorResults = new wxBoxSizer(wxHORIZONTAL);
242  m_listMatches = new CMatchesListCtrl( this, MYID_LISTCTRL_MATCHES, wxDefaultPosition, wxDefaultSize,
243  wxLC_REPORT | wxLC_SINGLE_SEL );
244 
245  // Workaround for Windows only!
246  // Highlight the entire row not just the first column in the row.
247 #ifdef __WXMSW__
248  DWORD dwStyle = ::SendMessage((HWND)m_listMatches->GetHandle(), LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
249  dwStyle |= LVS_EX_FULLROWSELECT;
250  ::SendMessage((HWND)m_listMatches->GetHandle(), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
251 #endif
252 
253 
254  // This sizer contains 2 elements in the same location.
255  // A toggle will show/hide the appropriate element.
256  m_sizerVectorResults->Add(m_listMatches, 1, wxEXPAND|wxALL, 5);
257 
258  m_viewAlignGraphic = new wxHtmlWindow( this, MYID_WEBVIEW_GRAPHIC );
259  m_sizerVectorResults->Add(m_viewAlignGraphic, 1, wxEXPAND|wxALL, 5);
261 
262  m_listLocations = new CLocationsListCtrl( this, MYID_LISTCTRL_LOCATIONS, wxDefaultPosition, wxDefaultSize,
263  wxLC_REPORT | wxLC_SINGLE_SEL );
264  m_sizerVectorResults->Add(m_listLocations, 1, wxEXPAND|wxALL, 5);
266 
267  // By default show m_listLocations, hide m_viewAlignGraphic
269  m_sizerVectorResults->Layout();
270 
271 
272  itemBoxSizer2->Add(m_sizerVectorResults, 1, wxEXPAND|wxALL, 5);
273 
274  // Row 2 - run blast vecscreen against UniVec db
275  wxBoxSizer* sizerSearchVector = new wxBoxSizer(wxHORIZONTAL);
276  m_buttonRunVecscreen = new wxButton( this, MYID_BUTTON_RUN_VECSCREEN, _("Search UniVec_Core") );
277  sizerSearchVector->Add(m_buttonRunVecscreen, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
279  m_gaugeProgressBar = new wxGauge( this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_SMOOTH );
280  sizerSearchVector->Add(m_gaugeProgressBar, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
281  itemBoxSizer2->Add(sizerSearchVector, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
282 
283  // Row 3 - Find text
284  wxBoxSizer* sizerFindText = new wxBoxSizer(wxHORIZONTAL);
285  wxStaticText* findtext =
286  new wxStaticText( this, wxID_ANY, _( "Find Text" ), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL );
287  sizerFindText->Add(findtext, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
288  m_textFind = new wxTextCtrl( this, wxID_ANY );
289  sizerFindText->Add(m_textFind, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
290  m_buttonFindReverse = new wxButton( this, MYID_BUTTON_FIND_REVERSE, _("<<") );
291  sizerFindText->Add(m_buttonFindReverse, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
292  m_buttonFindForward = new wxButton( this, MYID_BUTTON_FIND_FORWARD, _(">>") );
293  sizerFindText->Add(m_buttonFindForward, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
294  itemBoxSizer2->Add(sizerFindText, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
295 
296  // Row 4 - Sort results
297  wxArrayString buttons;
298  buttons.Add(_("Internal, 5', 3'"));
299  buttons.Add(_("Strength"));
300  buttons.Add(_("Marked"));
301  buttons.Add(_("Accession"));
302  m_radioBoxSort = new wxRadioBox( this, MYID_RADIOBOX_SORT, _("Order By"), wxDefaultPosition, wxDefaultSize,
303  buttons, 0, wxRA_SPECIFY_COLS );
304  itemBoxSizer2->Add(m_radioBoxSort, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
305 
306  // Row 5 - Internal Trim Options
307  wxArrayString buttons2;
308  buttons2.Add(_("Trim to closest end"));
309  buttons2.Add(_("Trim to 5' end"));
310  buttons2.Add(_("Trim to 3' end"));
312  _("Internal Trim Options"),
313  wxDefaultPosition, wxDefaultSize,
314  buttons2, 0, wxRA_SPECIFY_COLS );
315  itemBoxSizer2->Add(m_radioBoxInternalTrimOptions, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
316 
317  // Row 6 - select results
318  wxBoxSizer* sizerSelectResults = new wxBoxSizer(wxHORIZONTAL);
319  m_buttonSelectAll = new wxButton( this, MYID_BUTTON_SELECT_ALL, _("Select All") );
320  sizerSelectResults->Add(m_buttonSelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
321  m_buttonUnselectAll = new wxButton( this, MYID_BUTTON_UNSELECT_ALL, _("Unselect All") );
322  sizerSelectResults->Add(m_buttonUnselectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
323  m_buttonUnselectInternal = new wxButton( this, MYID_BUTTON_UNSELECT_INTERNAL, _("Unselect Internal") );
324  sizerSelectResults->Add(m_buttonUnselectInternal, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
325  m_buttonSelectStrongModerate = new wxButton( this, MYID_BUTTON_SELECT_STRONG_MODERATE, _("Select Only Strong and Moderate") );
326  sizerSelectResults->Add(m_buttonSelectStrongModerate, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
327  //m_checkboxViewGraphic = new wxCheckBox( this, MYID_CHECKBOX_VIEWGRAPHIC, _("View Alignment Graphic") );
328  //sizerSelectResults->Add(m_checkboxViewGraphic, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
329  itemBoxSizer2->Add(sizerSelectResults, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
330 
331  m_CitSub = new wxCheckBox( this, wxID_ANY, _("Add CitSub Update to trimmed sequences"), wxDefaultPosition, wxDefaultSize, 0 );
332  m_CitSub->SetValue(false);
333  itemBoxSizer2->Add(m_CitSub, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
334 
335  // Row 7 - Trim selected sequences
336  wxBoxSizer* sizerTrimSelected = new wxBoxSizer(wxHORIZONTAL);
337  m_buttonMakeReport = new wxButton( this, MYID_BUTTON_MAKE_REPORT, _("Make Report") );
338  sizerTrimSelected->Add(m_buttonMakeReport, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
339  m_buttonTrimSelected = new wxButton( this, MYID_BUTTON_TRIM_SELECTED, _("Trim Selected Sequences") );
340  sizerTrimSelected->Add(m_buttonTrimSelected, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
341  m_buttonTrimSelected->Disable();
342  m_buttonDismiss = new wxButton( this, MYID_BUTTON_DISMISS, _("Dismiss") );
343  sizerTrimSelected->Add(m_buttonDismiss, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
344  itemBoxSizer2->Add(sizerTrimSelected, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
345 }
346 
347 
349 {
350  if (!wxPanel::TransferDataToWindow())
351  return false;
352 
353 
354  return true;
355 }
356 
357 
359 {
360  if (!wxPanel::TransferDataFromWindow())
361  return false;
362 
363 
364  return true;
365 }
366 
367 
368 /*!
369  * Should we show tooltips?
370  */
371 
373 {
374  return true;
375 }
376 
377 /*!
378  * Get bitmap resources
379  */
380 
381 wxBitmap CVectorTrimPanel::GetBitmapResource( const wxString& name )
382 {
383  // Bitmap retrieval
384 ////@begin CVectorTrimPanel bitmap retrieval
385  wxUnusedVar(name);
386  return wxNullBitmap;
387 ////@end CVectorTrimPanel bitmap retrieval
388 }
389 
390 /*!
391  * Get icon resources
392  */
393 
394 wxIcon CVectorTrimPanel::GetIconResource( const wxString& name )
395 {
396  // Icon retrieval
397 ////@begin CVectorTrimPanel icon retrieval
398  wxUnusedVar(name);
399  return wxNullIcon;
400 ////@end CVectorTrimPanel icon retrieval
401 }
402 
403 
404 void CVectorTrimPanel::OnRunVecscreen(wxCommandEvent &event)
405 {
408  m_buttonTrimSelected->Enable();
409 }
410 
411 
412 void CVectorTrimPanel::OnSort(wxCommandEvent &event)
413 {
414  // selection value is 0-based
415  int selection = m_radioBoxSort->GetSelection();
416 
417  CMatchesListCtrl::ESortOption eSortOption;
418  switch (selection) {
419  case 0:
421  break;
422  case 1:
423  eSortOption = CMatchesListCtrl::eSortStrength;
424  break;
425  case 2:
426  eSortOption = CMatchesListCtrl::eSortMarked;
427  break;
428  case 3:
429  eSortOption = CMatchesListCtrl::eSortAccession;
430  break;
431  default:
433  break;
434  }
435 
436  m_listMatches->Sort(eSortOption, true);
437 }
438 
439 
440 void CVectorTrimPanel::OnSelectAll(wxCommandEvent &event)
441 {
443 }
444 
445 
446 void CVectorTrimPanel::OnSelectStrongModerate(wxCommandEvent &event)
447 {
449 }
450 
451 
452 void CVectorTrimPanel::OnUnselectAll(wxCommandEvent &event)
453 {
455 }
456 
457 
458 void CVectorTrimPanel::OnUnselectInternal(wxCommandEvent &event)
459 {
461 }
462 
463 
464 
465 void CVectorTrimPanel::OnMakeReport(wxCommandEvent &event)
466 {
467  CVecscreenReport* vecscreenReport = new CVecscreenReport(this);
468  wxString report;
469  m_listMatches->GetReport(report);
470  vecscreenReport->SetReport(report);
471  vecscreenReport->Show();
472 }
473 
474 
475 void CVectorTrimPanel::OnTrimSelected(wxCommandEvent &event)
476 {
477  // Did the user trim or cancel?
478  bool bTrimmed = x_TrimSelected();
479  m_buttonTrimSelected->Disable();
480  // Was ALL contamination selected?
481  bool bAllSelected = m_listMatches->AllSelected();
482 
483  // If the user trimmed all contamination, then close the window,
484  // otherwise update the window with the remaining contamination.
485  if (m_pParentWindow && bTrimmed && bAllSelected) {
486  m_pParentWindow->Close();
487  }
488 }
489 
490 
491 void CVectorTrimPanel::OnDismiss(wxCommandEvent &event)
492 {
493  if (m_pParentWindow) {
494  m_pParentWindow->Close();
495  }
496 }
497 
498 
499 void CVectorTrimPanel::OnFindForward(wxCommandEvent &event)
500 {
501  m_listMatches->FindForward(m_textFind->GetValue());
502 }
503 
504 
505 void CVectorTrimPanel::OnFindReverse(wxCommandEvent &event)
506 {
507  m_listMatches->FindReverse(m_textFind->GetValue());
508 }
509 
510 
511 class CRangeCmp : public binary_function<SRangeMatch, SRangeMatch, bool>
512 {
513 public:
515  {
518  };
519 
520  explicit CRangeCmp(ESortOrder sortorder = eAscending)
521  : m_sortorder(sortorder)
522  {
523  };
524 
525  bool operator()(const SRangeMatch& a1, const SRangeMatch& a2)
526  {
527  if (m_sortorder == eAscending)
528  {
529  // Tiebreaker
530  if (a1.m_range.GetTo() == a2.m_range.GetTo()) {
531  return a1.m_range.GetFrom() < a2.m_range.GetFrom();
532  }
533  return a1.m_range.GetTo() < a2.m_range.GetTo();
534  }
535  else
536  {
537  // Tiebreaker
538  if (a1.m_range.GetTo() == a2.m_range.GetTo()) {
539  return a1.m_range.GetFrom() > a2.m_range.GetFrom();
540  }
541  return a1.m_range.GetTo() > a2.m_range.GetTo();
542  }
543  };
544 
545 private:
547 };
548 
549 
552  const TCuts& sorted_cuts)
553 {
554  // Should be a nuc!
555  if (!bsh.IsNucleotide()) {
556  return;
557  }
558 
559  // Add the complete bioseq to scope
560  CRef<CBioseq> bseq(new CBioseq);
561  bseq->Assign(*bsh.GetCompleteBioseq());
562  CScope& scope = bsh.GetTopLevelEntry().GetScope();
563  CBioseq_Handle complete_bsh = scope.AddBioseq(*bseq);
564 
565  // Determine the "good" range sequence coordinates
566  TSeqPos left_pos = 0;
567  TSeqPos right_pos = inst->GetLength() - 1;
568  for (const auto& cut : sorted_cuts) {
569  if (cut.m_range.GetTo() == right_pos) {
570  right_pos = cut.m_range.GetFrom() - 1;
571  }
572 
573  if (cut.m_range.GetFrom() == left_pos) {
574  left_pos = cut.m_range.GetTo() + 1;
575  }
576  }
577 
578  // Create a new Delta-ext
579  CAutoInitRef<CDelta_ext> pDeltaExt;
580  CSeqMap_CI seqmap_ci = complete_bsh.GetSeqMap().ResolvedRangeIterator(&complete_bsh.GetScope(),
581  left_pos,
582  1 + (right_pos - left_pos));
583  for (; seqmap_ci; ++seqmap_ci) {
584  switch (seqmap_ci.GetType()) {
585  case CSeqMap::eSeqGap:
586  {
587  // Sequence gaps
588  const TSeqPos uGapLength = seqmap_ci.GetLength();
589  const bool bIsLengthKnown = !seqmap_ci.IsUnknownLength();
590  CConstRef<CSeq_literal> pOriginalGapSeqLiteral =
591  seqmap_ci.GetRefGapLiteral();
592  CAutoInitRef<CDelta_seq> pDeltaSeq;
593  CAutoInitRef<CSeq_literal> pNewGapLiteral;
594  if (pOriginalGapSeqLiteral) {
595  pNewGapLiteral->Assign(*pOriginalGapSeqLiteral);
596  }
597  if (!bIsLengthKnown) {
598  pNewGapLiteral->SetFuzz().SetLim(CInt_fuzz::eLim_unk);
599  }
600  pNewGapLiteral->SetLength(uGapLength);
601  pDeltaSeq->SetLiteral(*pNewGapLiteral);
602  pDeltaExt->Set().push_back(ncbi::Ref(&*pDeltaSeq));
603  }
604  break;
605  case CSeqMap::eSeqData:
606  {
607  // Sequence data
608  string new_data;
609  CSeqVector seqvec(complete_bsh, CBioseq_Handle::eCoding_Iupac);
610  seqvec.GetSeqData(seqmap_ci.GetPosition(), seqmap_ci.GetEndPosition(),
611  new_data);
612  CRef<CSeq_data> pSeqData(new CSeq_data());
613  pSeqData->SetIupacna(*new CIUPACna(new_data));
614  CSeqportUtil::Pack(pSeqData);
615  CAutoInitRef<CDelta_seq> pDeltaSeq;
616  pDeltaSeq->SetLiteral().SetLength(seqmap_ci.GetLength());
617  pDeltaSeq->SetLiteral().SetSeq_data(*pSeqData);
618  pDeltaExt->Set().push_back(ncbi::Ref(&*pDeltaSeq));
619  }
620  break;
621  }
622  }
623 
624  scope.RemoveBioseq(complete_bsh);
625 
626  // Update sequence repr, length and data
627  inst->ResetExt();
628  inst->ResetSeq_data();
629  inst->SetLength(1 + (right_pos - left_pos));
630  if (pDeltaExt->Set().size() == 1) {
631  // Repr raw
632  inst->SetRepr(CSeq_inst::eRepr_raw);
633  CRef<CDelta_seq> pDeltaSeq = *pDeltaExt->Set().begin();
634  CSeq_data & seq_data = pDeltaSeq->SetLiteral().SetSeq_data();
635  inst->SetSeq_data(seq_data);
636  }
637  else {
638  // Repr delta
639  inst->SetExt().SetDelta(*pDeltaExt);
640  }
641 }
642 
643 
645  TSeqPos cut_from, TSeqPos cut_to,
646  const CSeq_id* seqid,
647  bool& bCompleteCut,
648  bool& bTrimmed)
649 {
650  // These are required fields
651  if ( !(interval->CanGetFrom() && interval->CanGetTo()) )
652  {
653  return;
654  }
655 
656  // Feature location
657  TSeqPos feat_from = interval->GetFrom();
658  TSeqPos feat_to = interval->GetTo();
659 
660  // Size of the cut
661  TSeqPos cut_size = cut_to - cut_from + 1;
662 
663  // Case 1: feature is located completely before the cut
664  if (feat_to < cut_from)
665  {
666  // Nothing needs to be done - cut does not affect feature
667  return;
668  }
669 
670  // Case 2: feature is completely within the cut
671  if (feat_from >= cut_from && feat_to <= cut_to)
672  {
673  // Feature should be deleted
674  bCompleteCut = true;
675  return;
676  }
677 
678  // Case 3: feature is completely past the cut
679  if (feat_from > cut_to)
680  {
681  // Shift the feature by the cut_size
682  feat_from -= cut_size;
683  feat_to -= cut_size;
684  interval->SetFrom(feat_from);
685  interval->SetTo(feat_to);
686  bTrimmed = true;
687  return;
688  }
689 
690  /***************************************************************************
691  * Cases below are partial overlapping cases
692  ***************************************************************************/
693  // Case 4: Cut is completely inside the feature
694  // OR
695  // Cut is to the "left" side of the feature (i.e., feat_from is
696  // inside the cut)
697  // OR
698  // Cut is to the "right" side of the feature (i.e., feat_to is
699  // inside the cut)
700  if (feat_to > cut_to) {
701  // Left side cut or cut is completely inside feature
702  feat_to -= cut_size;
703  }
704  else {
705  // Right side cut
706  feat_to = cut_from - 1;
707  }
708 
709  // Take care of the feat_from from the left side cut case
710  if (feat_from >= cut_from) {
711  feat_from = cut_to + 1;
712  feat_from -= cut_size;
713  }
714 
715  interval->SetFrom(feat_from);
716  interval->SetTo(feat_to);
717  bTrimmed = true;
718 }
719 
720 
722  TSeqPos from, TSeqPos to,
723  const CSeq_id* seqid,
724  bool& bCompleteCut,
725  bool& bTrimmed)
726 {
727  // Given a seqloc and a range, cut the seqloc
728 
729  switch(loc->Which())
730  {
731  // Single interval
732  case CSeq_loc::e_Int:
733  {
734  CRef<CSeq_interval> interval(new CSeq_interval);
735  interval->Assign(loc->GetInt());
736  x_SeqIntervalDelete(interval, from, to, seqid,
737  bCompleteCut, bTrimmed);
738  loc->SetInt(*interval);
739  }
740  break;
741 
742  // Multiple intervals
744  {
746  intervals->Assign(loc->GetPacked_int());
747  if (intervals->CanGet()) {
748  // Process each interval in the list
749  CPacked_seqint::Tdata::iterator it;
750  for (it = intervals->Set().begin();
751  it != intervals->Set().end(); )
752  {
753  // Initial value: assume that all intervals
754  // will be deleted resulting in bCompleteCut = true.
755  // Later on if any interval is not deleted, then set
756  // bCompleteCut = false
757  if (it == intervals->Set().begin()) {
758  bCompleteCut = true;
759  }
760 
761  bool bDeleted = false;
762  x_SeqIntervalDelete(*it, from, to, seqid,
763  bDeleted, bTrimmed);
764 
765  // Should interval be deleted from list?
766  if (bDeleted) {
767  it = intervals->Set().erase(it);
768  }
769  else {
770  ++it;
771  bCompleteCut = false;
772  }
773  }
774 
775  // Update the original list
776  loc->SetPacked_int(*intervals);
777  }
778  }
779  break;
780 
781  // Multiple seqlocs
782  case CSeq_loc::e_Mix:
783  {
785  mix->Assign(loc->GetMix());
786  if (mix->CanGet()) {
787  // Process each seqloc in the list
788  CSeq_loc_mix::Tdata::iterator it;
789  for (it = mix->Set().begin();
790  it != mix->Set().end(); )
791  {
792  // Initial value: assume that all seqlocs
793  // will be deleted resulting in bCompleteCut = true.
794  // Later on if any seqloc is not deleted, then set
795  // bCompleteCut = false
796  if (it == mix->Set().begin()) {
797  bCompleteCut = true;
798  }
799 
800  bool bDeleted = false;
801  x_SeqLocDelete(*it, from, to, seqid, bDeleted, bTrimmed);
802 
803  // Should seqloc be deleted from list?
804  if (bDeleted) {
805  it = mix->Set().erase(it);
806  }
807  else {
808  ++it;
809  bCompleteCut = false;
810  }
811  }
812 
813  // Update the original list
814  loc->SetMix(*mix);
815  }
816  }
817  break;
818 
819  // Other choices not supported yet
820  default:
821  {
822  }
823  break;
824  }
825 }
826 
827 
829  const TCuts& sorted_cuts,
830  const CSeq_id* seqid,
831  bool& bFeatureDeleted,
832  bool& bFeatureTrimmed,
833  bool& bProdDeleted,
834  bool& bProdTrimmed)
835 {
836  for (int ii = 0; ii < sorted_cuts.size(); ++ii)
837  {
838  const SRangeMatch& cut = sorted_cuts[ii];
839  TSeqPos from = cut.m_range.GetFrom();
840  TSeqPos to = cut.m_range.GetTo();
841 
842  // Update Seqloc "feature made from"
843  if (feat->CanGetLocation())
844  {
846  new_location->Assign(feat->GetLocation());
847  x_SeqLocDelete(new_location, from, to, seqid,
848  bFeatureDeleted, bFeatureTrimmed);
849  feat->SetLocation(*new_location);
850 
851  // No need to cut anymore nor update. Feature will be completely
852  // deleted.
853  if (bFeatureDeleted) {
854  return;
855  }
856  }
857 
858  // Update Seqloc "product of process"
859  if (feat->CanGetProduct())
860  {
862  new_product->Assign(feat->GetProduct());
863  x_SeqLocDelete(new_product, from, to, seqid, bProdDeleted, bProdTrimmed);
864  feat->SetProduct(*new_product);
865  }
866  }
867 }
868 
869 
871  CRef<CSeq_feat> feat,
872  const TCuts& sorted_cuts,
873  const CSeq_id* seqid,
874  bool bFeatureTrimmed,
875  bool bProdTrimmed)
876 {
877  CBioseq_Handle bsh = scope.GetBioseqHandle(*seqid);
878 
879  // Get partialness and strand of location before cutting
880  bool bIsPartialStart = false;
881  ENa_strand eStrand = eNa_strand_unknown;
882  if (feat->CanGetLocation())
883  {
884  bIsPartialStart = feat->GetLocation().IsPartialStart(eExtreme_Biological);
885  eStrand = feat->GetLocation().GetStrand();
886  }
887 
888  for (int ii = 0; ii < sorted_cuts.size(); ++ii)
889  {
890  const SRangeMatch& cut = sorted_cuts[ii];
891  TSeqPos from = cut.m_range.GetFrom();
892  TSeqPos to = cut.m_range.GetTo();
893 
894  // Adjust Seq-feat.data.cdregion frame
895  if (feat->CanGetData() &&
897  feat->GetData().IsCdregion() &&
898  (bFeatureTrimmed || bProdTrimmed))
899  {
900  // Make a copy
901  CRef<CCdregion> new_cdregion(new CCdregion);
902  new_cdregion->Assign(feat->GetData().GetCdregion());
903 
904  // Edit the copy
905  if ( (eStrand == eNa_strand_minus &&
906  to == bsh.GetInst().GetLength() - 1 &&
907  bIsPartialStart)
908  ||
909  (eStrand != eNa_strand_minus &&
910  from == 0 &&
911  bIsPartialStart) )
912  {
913  TSeqPos old_frame = new_cdregion->GetFrame();
914  if (old_frame == 0)
915  {
916  old_frame = 1;
917  }
918 
919  TSignedSeqPos new_frame = old_frame - ((to - from + 1) % 3);
920  if (new_frame < 1)
921  {
922  new_frame += 3;
923  }
924  new_cdregion->SetFrame((CCdregion::EFrame)new_frame);
925  }
926 
927  // Update the original
928  feat->SetData().SetCdregion(*new_cdregion);
929  }
930  }
931 }
932 
933 
935  TSeqPos seq_length)
936 {
937  EInternalTrimType eInternalTrimType =
938  static_cast<EInternalTrimType>(m_radioBoxInternalTrimOptions->GetSelection());
939 
940  for (int ii = 0; ii < cuts.size(); ++ii)
941  {
942  SRangeMatch& cut = cuts[ii];
943  TSeqPos from = cut.m_range.GetFrom();
944  TSeqPos to = cut.m_range.GetTo();
945 
946  // Is it an internal cut?
947  if (from != 0 && to != seq_length-1) {
948  if (eInternalTrimType == eTrimToClosestEnd) {
949  // Extend the cut to the closest end
950  if (from - 0 < seq_length-1 - to) {
951  cut.m_range.SetFrom(0);
952  }
953  else {
954  cut.m_range.SetTo(seq_length-1);
955  }
956  }
957  else
958  if (eInternalTrimType == eTrimTo5PrimeEnd) {
959  // Extend the cut to 5' end
960  cut.m_range.SetFrom(0);
961  }
962  else {
963  // Extend the cut to 3' end
964  cut.m_range.SetTo(seq_length-1);
965  }
966  }
967  }
968 }
969 
970 
972 {
973  // Assume cuts are sorted in Ascending order.
974 
975  // Merge abutting and overlapping cuts
976  TCuts::iterator it;
977  for (it = sorted_cuts.begin(); it != sorted_cuts.end(); )
978  {
979  SRangeMatch& cut = *it;
980  TSeqPos from = cut.m_range.GetFrom();
981  TSeqPos to = cut.m_range.GetTo();
982 
983  // Does next cut exist?
984  if ( it+1 != sorted_cuts.end() ) {
985  SRangeMatch& next_cut = *(it+1);
986  TSeqPos next_from = next_cut.m_range.GetFrom();
987  TSeqPos next_to = next_cut.m_range.GetTo();
988 
989  if ( next_from <= (to + 1) ) {
990  // Current and next cuts abut or overlap
991  // So adjust current cut and delete next cut
992  cut.m_range.SetTo(next_to);
993  sorted_cuts.erase(it+1);
994 
995  // Post condition after erase:
996  // Since "it" is before the erase, "it" stays valid
997  // and still refers to current cut
998  }
999  else {
1000  ++it;
1001  }
1002  }
1003  else {
1004  // I'm done
1005  break;
1006  }
1007  }
1008 }
1009 
1010 
1013  CRef<CSeq_feat> cds)
1014 {
1015  // Assumption: cds has been verified to be Cdregion with Product
1016 
1017  // Use Cdregion.Product to get handle to protein bioseq
1018  CBioseq_Handle prot_bsh = scope.GetBioseqHandle(cds->GetProduct());
1019 
1020  // Should be a protein!
1021  if (!prot_bsh.IsProtein())
1022  {
1023  return;
1024  }
1025 
1026  // Make a copy of existing CSeq_inst
1027  CRef<objects::CSeq_inst> new_inst(new objects::CSeq_inst());
1028  new_inst->Assign(prot_bsh.GetInst());
1029 
1030  // Make edits to the CSeq_inst copy
1031  CRef<CBioseq> new_protein_bioseq;
1032  if (new_inst->IsSetSeq_data())
1033  {
1034  // Generate new protein sequence data and length
1035  new_protein_bioseq = CSeqTranslator::TranslateToProtein(*cds, scope);
1036  if (new_protein_bioseq->GetInst().GetSeq_data().IsIupacaa())
1037  {
1038  new_inst->SetSeq_data().SetIupacaa().Set(
1039  new_protein_bioseq->GetInst().GetSeq_data().GetIupacaa().Get());
1040  new_inst->SetLength( new_protein_bioseq->GetInst().GetLength() );
1041  }
1042  else if (new_protein_bioseq->GetInst().GetSeq_data().IsNcbieaa())
1043  {
1044  new_inst->SetSeq_data().SetNcbieaa().Set(
1045  new_protein_bioseq->GetInst().GetSeq_data().GetNcbieaa().Get());
1046  new_inst->SetLength( new_protein_bioseq->GetInst().GetLength() );
1047  }
1048  }
1049 
1050  if ( !new_protein_bioseq ) {
1051  return;
1052  }
1053 
1054  // Update protein sequence data and length
1055  CRef<CCmdChangeBioseqInst> chgInst (new CCmdChangeBioseqInst(prot_bsh,
1056  *new_inst));
1057  command->AddCommand(*chgInst);
1058 
1059  // If protein feature exists, update it
1061  CFeat_CI prot_feat_ci(prot_bsh, sel);
1062  for ( ; prot_feat_ci; ++prot_feat_ci ) {
1063  CRef<CSeq_feat> new_feat(new CSeq_feat());
1064  new_feat->Assign(prot_feat_ci->GetOriginalFeature());
1065 
1066  if ( new_feat->CanGetLocation() &&
1067  new_feat->GetLocation().IsInt() &&
1068  new_feat->GetLocation().GetInt().CanGetTo() )
1069  {
1070  new_feat->SetLocation().SetInt().SetTo(
1071  new_protein_bioseq->GetLength() - 1);
1072 
1073  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(*prot_feat_ci,
1074  *new_feat));
1075  command->AddCommand(*chgFeat);
1076  }
1077  }
1078 }
1079 
1080 
1082  CDense_seg::TDim row,
1083  TSeqPos pos,
1084  CDense_seg::TNumseg& seg,
1085  TSeqPos& seg_start) const
1086 {
1087  for (seg = 0; seg < denseg.GetNumseg(); ++seg) {
1088  TSignedSeqPos start = denseg.GetStarts()[seg * denseg.GetDim() + row];
1089  TSignedSeqPos len = denseg.GetLens()[seg];
1090  if (start != -1) {
1091  if (pos >= start && pos < start + len) {
1092  seg_start = start;
1093  return true;
1094  }
1095  }
1096  }
1097  return false;
1098 }
1099 
1100 
1102  CDense_seg::TDim row,
1103  TSeqPos pos)
1104 {
1105  // Find the segment where pos occurs for the sequence (identified by
1106  // row).
1107  // If pos is not the start of the segment, cut the segment in two, with
1108  // one of the segments using pos as the new start.
1109 
1110 
1111  // Find the segment where pos lies
1112  const CDense_seg& denseg = align->GetSegs().GetDenseg();
1113  CDense_seg::TNumseg foundseg;
1114  TSeqPos seg_start;
1115  if ( !x_FindSegment(denseg, row, pos, foundseg, seg_start) ) {
1116  return;
1117  }
1118 
1119  // Found our segment seg
1120  // If pos falls on segment boundary, do nothing
1121  if (pos == seg_start) {
1122  return;
1123  }
1124 
1125 
1126  // Cut the segment :
1127  // 1) Allocate a new denseg with numseg size = original size + 1
1128  // 2) Copy elements before the cut
1129  // 3) Split segment at pos
1130  // 4) Copy elements after the cut
1131  // 5) Replace old denseg with new denseg
1132 
1133  // Allocate a new denseg with numseg size = original size + 1
1134  CRef<CDense_seg> new_denseg(new CDense_seg);
1135  new_denseg->SetDim( denseg.GetDim() );
1136  new_denseg->SetNumseg( denseg.GetNumseg() + 1 );
1137  ITERATE( CDense_seg::TIds, idI, denseg.GetIds() ) {
1138  CSeq_id *si = new CSeq_id;
1139  si->Assign(**idI);
1140  new_denseg->SetIds().push_back( CRef<CSeq_id>(si) );
1141  }
1142 
1143  // Copy elements (starts, lens, strands) before the cut (up to and including
1144  // foundseg-1 in original denseg)
1145  for (CDense_seg::TNumseg curseg = 0; curseg < foundseg; ++curseg) {
1146  // Copy starts
1147  for (CDense_seg::TDim curdim = 0; curdim < denseg.GetDim(); ++curdim) {
1148  TSeqPos index = curseg * denseg.GetDim() + curdim;
1149  new_denseg->SetStarts().push_back( denseg.GetStarts()[index] );
1150  }
1151 
1152  // Copy lens
1153  new_denseg->SetLens().push_back( denseg.GetLens()[curseg] );
1154 
1155  // Copy strands
1156  if ( denseg.IsSetStrands() ) {
1157  for (CDense_seg::TDim curdim = 0; curdim < denseg.GetDim();
1158  ++curdim)
1159  {
1160  TSeqPos index = curseg * denseg.GetDim() + curdim;
1161  new_denseg->SetStrands().push_back(denseg.GetStrands()[index]);
1162  }
1163  }
1164  }
1165 
1166  // Split segment at pos
1167  // First find the lengths of the split segments, first_len and second_len
1168  TSeqPos first_len, second_len;
1169  TSeqPos index = foundseg * denseg.GetDim() + row;
1170  if ( !denseg.IsSetStrands() || denseg.GetStrands()[index] != eNa_strand_minus )
1171  {
1172  first_len = pos - seg_start;
1173  second_len = denseg.GetLens()[foundseg] - first_len;
1174  }
1175  else {
1176  second_len = pos - seg_start;
1177  first_len = denseg.GetLens()[foundseg] - second_len;
1178  }
1179 
1180  // Set starts, strands, and lens for the split segments (foundseg and foundseg+1)
1181  // Populate foundseg in new denseg
1182  for (CDense_seg::TDim curdim = 0; curdim < denseg.GetDim(); ++curdim) {
1183  TSeqPos index = foundseg * denseg.GetDim() + curdim;
1184  if (denseg.GetStarts()[index] == -1) {
1185  new_denseg->SetStarts().push_back(-1);
1186  }
1187  else if (!denseg.IsSetStrands() || denseg.GetStrands()[index] != eNa_strand_minus) {
1188  new_denseg->SetStarts().push_back(denseg.GetStarts()[index]);
1189  }
1190  else {
1191  new_denseg->SetStarts().push_back(denseg.GetStarts()[index] + second_len);
1192  }
1193 
1194  if (denseg.IsSetStrands()) {
1195  new_denseg->SetStrands().push_back(denseg.GetStrands()[index]);
1196  }
1197  }
1198  new_denseg->SetLens().push_back(first_len);
1199  // Populate foundseg+1 in new denseg
1200  for (CDense_seg::TDim curdim = 0; curdim < denseg.GetDim(); ++curdim) {
1201  TSeqPos index = foundseg * denseg.GetDim() + curdim;
1202  if (denseg.GetStarts()[index] == -1) {
1203  new_denseg->SetStarts().push_back(-1);
1204  }
1205  else if (!denseg.IsSetStrands() || denseg.GetStrands()[index] != eNa_strand_minus) {
1206  new_denseg->SetStarts().push_back(denseg.GetStarts()[index] + first_len);
1207  }
1208  else {
1209  new_denseg->SetStarts().push_back(denseg.GetStarts()[index]);
1210  }
1211 
1212  if (denseg.IsSetStrands()) {
1213  new_denseg->SetStrands().push_back(denseg.GetStrands()[index]);
1214  }
1215  }
1216  new_denseg->SetLens().push_back(second_len);
1217 
1218  // Copy elements (starts, lens, strands) after the cut (starting from foundseg+1 in
1219  // original denseg)
1220  for (CDense_seg::TNumseg curseg = foundseg+1; curseg < denseg.GetNumseg(); ++curseg) {
1221  // Copy starts
1222  for (CDense_seg::TDim curdim = 0; curdim < denseg.GetDim(); ++curdim) {
1223  TSeqPos index = curseg * denseg.GetDim() + curdim;
1224  new_denseg->SetStarts().push_back( denseg.GetStarts()[index] );
1225  }
1226 
1227  // Copy lens
1228  new_denseg->SetLens().push_back( denseg.GetLens()[curseg] );
1229 
1230  // Copy strands
1231  if ( denseg.IsSetStrands() ) {
1232  for (CDense_seg::TDim curdim = 0; curdim < denseg.GetDim();
1233  ++curdim)
1234  {
1235  TSeqPos index = curseg * denseg.GetDim() + curdim;
1236  new_denseg->SetStrands().push_back(denseg.GetStrands()[index]);
1237  }
1238  }
1239  }
1240 
1241  // Update
1242  align->SetSegs().SetDenseg(*new_denseg);
1243 }
1244 
1245 
1247  CDense_seg::TDim row,
1248  const TCuts& sorted_cuts)
1249 {
1250  for (int ii = 0; ii < sorted_cuts.size(); ++ii)
1251  {
1252  const SRangeMatch& cut = sorted_cuts[ii];
1253  TSeqPos cut_from = cut.m_range.GetFrom();
1254  TSeqPos cut_to = cut.m_range.GetTo();
1255 
1256  TSeqPos cut_len = cut_to - cut_from + 1;
1257  if (cut_to < cut_from) {
1258  cut_len = cut_from - cut_to + 1;
1259  cut_from = cut_to;
1260  }
1261 
1262  // Note: row is 0-based
1263 
1264  // May need to cut the segment at both start and stop positions
1265  // if they do not fall on segment boundaries
1266  x_CutDensegSegment(align, row, cut_from);
1267  x_CutDensegSegment(align, row, cut_from + cut_len);
1268 
1269  // Update segment start values for the trimmed sequence row
1270  const CDense_seg& denseg = align->GetSegs().GetDenseg();
1271  for (CDense_seg::TNumseg curseg = 0; curseg < denseg.GetNumseg(); ++curseg) {
1272  TSeqPos index = curseg * denseg.GetDim() + row;
1273  TSeqPos seg_start = denseg.GetStarts()[index];
1274  if (seg_start < 0) {
1275  // This indicates a gap, no change needed
1276  }
1277  else if (seg_start < cut_from) {
1278  // This is before the cut, no change needed
1279  }
1280  else if (seg_start >= cut_from &&
1281  seg_start + denseg.GetLens()[curseg] <= cut_from + cut_len) {
1282  // This is in the gap, indicate it with a -1
1283  align->SetSegs().SetDenseg().SetStarts()[index] = -1;
1284  }
1285  else {
1286  // This is after the cut - subtract the cut_len
1287  align->SetSegs().SetDenseg().SetStarts()[index] -= cut_len;
1288  }
1289  }
1290  }
1291 }
1292 
1293 
1295  const CSeq_id* seqid,
1296  const SVecscreenResult& vecres)
1297 {
1298  CScope& scope = m_TopSeqEntry.GetScope();
1299  CBioseq_Handle bsh = scope.GetBioseqHandle(*seqid);
1300 
1301  // Should be a nuc!
1302  if (!bsh.IsNucleotide())
1303  {
1304  return;
1305  }
1306 
1307 
1308  TCuts sorted_cuts(vecres.m_arrRangeMatch);
1309  x_GetSortedCuts(sorted_cuts, seqid);
1310 
1311 
1312  /***************************************************************************
1313  * Trim nuc sequence
1314  ***************************************************************************/
1315  // Make a copy of existing CSeq_inst
1316  CRef<objects::CSeq_inst> new_inst(new objects::CSeq_inst());
1317  new_inst->Assign(bsh.GetInst());
1318 
1319  // Make edits to the CSeq_inst copy
1320  x_SetSeqData(bsh, new_inst, sorted_cuts);
1321 
1322  // Swap in the edited CSeq_inst copy against the original
1323  CRef<CCmdChangeBioseqInst> chgInst (new CCmdChangeBioseqInst(bsh, *new_inst));
1324  command->AddCommand(*chgInst);
1325 
1326 
1327  /***************************************************************************
1328  * Trim all annotation that reference the nuc
1329  ***************************************************************************/
1330  // Trim features
1332  CRef<CSeq_id> copy_id(new CSeq_id());
1333  copy_id->Assign(*seqid);
1334  CRef<CSeq_loc> search_loc( new CSeq_loc );
1335  search_loc->SetWhole(*copy_id);
1336  CFeat_CI feat_ci(scope, *search_loc, feat_sel);
1337  for (; feat_ci; ++feat_ci)
1338  {
1339  // Make a copy of the feature
1340  CRef<CSeq_feat> new_feat(new CSeq_feat());
1341  new_feat->Assign(feat_ci->GetOriginalFeature());
1342 
1343  // Detect complete deletions of feature
1344  bool bFeatureDeleted = false;
1345 
1346  // Detect case where feature was not deleted but merely trimmed
1347  bool bFeatureTrimmed = false;
1348 
1349  bool bProdDeleted = false;
1350  bool bProdTrimmed = false;
1351 
1352  // Make edits to the copy
1353  x_TrimFeatureLocations(new_feat, sorted_cuts, seqid,
1354  bFeatureDeleted, bFeatureTrimmed,
1355  bProdDeleted, bProdTrimmed);
1356 
1357  if (bFeatureDeleted) {
1358  // Delete original feature
1359  CIRef<IEditCommand> delFeat(new CCmdDelSeq_feat(*feat_ci));
1360  command->AddCommand(*delFeat);
1361 
1362  // If this feat is a Cdregion, then delete the protein sequence
1363  if ( feat_ci->IsSetData() &&
1364  feat_ci->GetData().Which() == CSeqFeatData::e_Cdregion &&
1365  feat_ci->IsSetProduct() )
1366  {
1367  // Use Cdregion feat.product seqloc to get protein bioseq handle
1368  CBioseq_Handle prot_h =
1369  scope.GetBioseqHandle(feat_ci->GetProduct());
1370 
1371  // Should be a protein!
1372  if ( prot_h.IsProtein() ) {
1373  // NOTE:
1374  // CCmdDelBioseqInst implementation already takes care of
1375  // renormalizing the nuc-prot set if necessary.
1377  delProt(new CCmdDelBioseqInst(prot_h));
1378  command->AddCommand(*delProt);
1379  }
1380  }
1381  }
1382  else {
1383  if (bFeatureTrimmed) {
1384  // If this feat is a Cdregion, then RETRANSLATE the protein
1385  // sequence AND adjust any protein feature
1386  if ( new_feat->IsSetData() &&
1387  new_feat->GetData().Which() == CSeqFeatData::e_Cdregion &&
1388  new_feat->IsSetProduct() )
1389  {
1390  x_AdjustCdregionFrame(scope,
1391  new_feat,
1392  sorted_cuts,
1393  seqid,
1394  bFeatureTrimmed,
1395  bProdTrimmed);
1396 
1397  // In order to retranslate correctly, we need to create a
1398  // new scope with the trimmed sequence data.
1399 
1400  // Keep track of original seqinst
1401  CRef<objects::CSeq_inst> orig_inst(new objects::CSeq_inst());
1402  orig_inst->Assign(bsh.GetInst());
1403 
1404  // Update the seqinst to the trimmed version, set the scope
1405  // and retranslate
1406  CBioseq_EditHandle bseh = bsh.GetEditHandle();
1407  bseh.SetInst(*new_inst);
1408  CScope& new_scope = bseh.GetScope();
1409  x_RetranslateCDS(new_scope, command, new_feat);
1410 
1411  // Restore the original seqinst
1412  bseh.SetInst(*orig_inst);
1413  }
1414 
1415  // Swap edited copy with original feature
1416  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(*feat_ci,
1417  *new_feat));
1418  command->AddCommand(*chgFeat);
1419  }
1420  }
1421  }
1422 
1423  if (m_CitSub->GetValue()) // add cit-sub update
1424  {
1425  for (objects::CSeqdesc_CI desc_ci( bsh, objects::CSeqdesc::e_Pub); desc_ci; ++desc_ci)
1426  {
1427  if (!desc_ci->GetPub().IsSetPub())
1428  continue;
1429  CRef<objects::CSeqdesc> new_desc( new objects::CSeqdesc );
1430  new_desc->Assign(*desc_ci);
1431 
1432  NON_CONST_ITERATE (CPub_equiv::Tdata, pub_it, new_desc->SetPub().SetPub().Set())
1433  {
1434  if ((*pub_it)->IsSub())
1435  {
1436  (*pub_it)->SetSub().SetDescr("Sequence update by database staff to remove vector contamination");
1437  CRef<CDate> today(new CDate);
1439  (*pub_it)->SetSub().SetDate(*today);
1440  if (desc_ci.GetSeq_entry_Handle() == bsh.GetParentEntry())
1441  {
1443  CObject* actual = (CObject*) &(*desc_ci);
1444  ecmd->Add(actual, CConstRef<CObject>(new_desc));
1445  }
1446  else
1447  {
1448  command->AddCommand( *CRef<CCmdCreateDesc>(new CCmdCreateDesc(bsh.GetParentEntry(), *new_desc)) );
1449  }
1450  break;
1451  }
1452  }
1453  }
1454  }
1455 }
1456 
1457 
1459  const CSeq_id* seqid)
1460 {
1461  CScope& scope = m_TopSeqEntry.GetScope();
1462  CBioseq_Handle bsh = scope.GetBioseqHandle(*seqid);
1463 
1464  /***************************************************************************
1465  * Adjust internal cuts to 3' end
1466  * Merge abutting and overlapping cuts
1467  ***************************************************************************/
1469  sort(sorted_cuts.begin(), sorted_cuts.end(), asc);
1470 
1471  // Adjust internal cuts
1472  x_AdjustInternalCutLocations(sorted_cuts, bsh.GetBioseqLength());
1473 
1474  // Merge abutting and overlapping cuts
1475  x_MergeCuts(sorted_cuts);
1476 
1477  /***************************************************************************
1478  * Sort the cuts in descending order
1479  ***************************************************************************/
1480  // Sort the ranges from greatest to least so that sequence
1481  // data and metadata will be deleted from greatest loc to smallest loc.
1482  // That way we don't have to adjust coordinate values after
1483  // each delete.
1485  sort(sorted_cuts.begin(), sorted_cuts.end(), descend);
1486 }
1487 
1488 
1490  const TVecscreenSummaryBySeqid& trimOnly)
1491 {
1492  // Adjust alignments
1494  CAlign_CI align_ci(m_TopSeqEntry, align_sel);
1495  for (; align_ci; ++align_ci)
1496  {
1497  // So far, handle DENSEG type only
1498  const CSeq_align& align = *align_ci;
1499  if ( align.CanGetSegs() &&
1501  {
1502  // Make sure mandatory fields are present in the denseg
1503  const CDense_seg& denseg = align.GetSegs().GetDenseg();
1504  if (! (denseg.CanGetDim() && denseg.CanGetNumseg() &&
1505  denseg.CanGetIds() && denseg.CanGetStarts() &&
1506  denseg.CanGetLens()) )
1507  {
1508  continue;
1509  }
1510 
1511  // Make a copy of the alignment
1512  CRef<CSeq_align> new_align(new CSeq_align());
1513  new_align->Assign(align_ci.GetOriginalSeq_align());
1514 
1515  // Make edits to the copy
1517  for (cit = trimOnly.begin(); cit != trimOnly.end(); ++cit)
1518  {
1519  const CSeq_id* seqid = cit->first;
1520  const SVecscreenResult& result = cit->second;
1521 
1522  // On which "row" does the seqid lie?
1523  const CDense_seg::TIds& ids = denseg.GetIds();
1524  CDense_seg::TDim row = -1;
1525  for (int ii = 0; ii < ids.size(); ++ii) {
1526  if ( ids[ii]->Match(*seqid) ) {
1527  row = ii;
1528  break;
1529  }
1530  }
1531  if ( row < 0 || !denseg.CanGetDim() || row >= denseg.GetDim() ) {
1532  continue;
1533  }
1534 
1535  TCuts sorted_cuts(result.m_arrRangeMatch);
1536  x_GetSortedCuts(sorted_cuts, seqid);
1537  x_AdjustDensegAlignment(new_align, row, sorted_cuts);
1538  }
1539 
1540  // Swap edited copy with the original alignment
1541  CIRef<IEditCommand> chgAlign(
1542  new CCmdChangeAlign( align_ci.GetSeq_align_Handle(),
1543  *new_align ));
1544  command->AddCommand(*chgAlign);
1545  }
1546  else {
1547  // For other alignment types, delete them. This is what
1548  // C Toolkit does (see AdjustAlignmentsInAnnot)
1549  CIRef<IEditCommand> delAlign(
1550  new CCmdDelSeq_align( align_ci.GetSeq_align_Handle() ));
1551  command->AddCommand(*delAlign);
1552  }
1553  }
1554 }
1555 
1556 
1558  const TCuts& sorted_cuts,
1559  const CSeq_id* seqid)
1560 {
1561  for (int ii = 0; ii < sorted_cuts.size(); ++ii)
1562  {
1563  const SRangeMatch& cut = sorted_cuts[ii];
1564  TSeqPos from = cut.m_range.GetFrom();
1565  TSeqPos to = cut.m_range.GetTo();
1566 
1567  if (new_graph->CanGetLoc())
1568  {
1570  new_loc->Assign(new_graph->GetLoc());
1571  bool bDeleted = false;
1572  bool bTrimmed = false;
1573  x_SeqLocDelete(new_loc, from, to, seqid, bDeleted, bTrimmed);
1574  new_graph->SetLoc(*new_loc);
1575  }
1576  }
1577 }
1578 
1579 
1581  const CSeq_id* seqid,
1582  TSeqPos& trim_start,
1583  TSeqPos& trim_stop)
1584 {
1585  CScope& scope = m_TopSeqEntry.GetScope();
1586  CBioseq_Handle bsh = scope.GetBioseqHandle(*seqid);
1587 
1588  // Set defaults
1589  trim_start = 0;
1590  trim_stop = bsh.GetInst().GetLength() - 1;
1591 
1592  // Assumptions :
1593  // All cuts have been sorted. Internal cuts were converted to terminal.
1594  for (int ii = 0; ii < sorted_cuts.size(); ++ii)
1595  {
1596  const SRangeMatch& cut = sorted_cuts[ii];
1597  TSeqPos from = cut.m_range.GetFrom();
1598  TSeqPos to = cut.m_range.GetTo();
1599 
1600  // Left-side terminal cut. Update trim_start if necessary.
1601  if ( from == 0 ) {
1602  if ( trim_start <= to ) {
1603  trim_start = to + 1;
1604  }
1605  }
1606 
1607  // Right-side terminal cut. Update trim_stop if necessary.
1608  if ( to == bsh.GetInst().GetLength() - 1 ) {
1609  if ( trim_stop >= from ) {
1610  trim_stop = from - 1;
1611  }
1612  }
1613  }
1614 }
1615 
1616 
1618  const CMappedGraph& orig_graph,
1619  const TCuts& sorted_cuts,
1620  const CSeq_id* seqid)
1621 {
1622  // Get range that original seqgraph data covers
1623  TSeqPos graph_start = new_graph->GetLoc().GetStart(eExtreme_Positional);
1624  TSeqPos graph_stop = new_graph->GetLoc().GetStop(eExtreme_Positional);
1625 
1626  // Get range of trimmed sequence
1627  TSeqPos trim_start;
1628  TSeqPos trim_stop;
1629  x_GetTrimCoordinates(sorted_cuts, seqid, trim_start, trim_stop);
1630 
1631  // Determine range over which to copy seqgraph data from old to new
1632  TSeqPos copy_start = graph_start;
1633  if (trim_start > graph_start) {
1634  copy_start = trim_start;
1635  }
1636  TSeqPos copy_stop = graph_stop;
1637  if (trim_stop < graph_stop) {
1638  copy_stop = trim_stop;
1639  }
1640 
1641  // Copy over seqgraph data values. Handle BYTE type only (see
1642  // C Toolkit's GetGraphsProc function in api/sqnutil2.c)
1643  CSeq_graph::TGraph& dst_data = new_graph->SetGraph();
1644  dst_data.Reset();
1645  const CSeq_graph::TGraph& src_data = orig_graph.GetGraph();
1646  switch ( src_data.Which() ) {
1648  // Keep original min, max, axis
1649  dst_data.SetByte().SetMin(src_data.GetByte().GetMin());
1650  dst_data.SetByte().SetMax(src_data.GetByte().GetMax());
1651  dst_data.SetByte().SetAxis(src_data.GetByte().GetAxis());
1652 
1653  // Copy start/stop values are relative to bioseq coordinate system.
1654  // Change them so that they are relative to graph location.
1655  copy_start -= graph_start;
1656  copy_stop -= graph_start;
1657 
1658  // Update data values
1659  dst_data.SetByte().SetValues();
1660  dst_data.SetByte().SetValues().insert(
1661  dst_data.SetByte().SetValues().end(),
1662  src_data.GetByte().GetValues().begin() + copy_start,
1663  src_data.GetByte().GetValues().begin() + copy_stop + 1);
1664 
1665  // Update numvals
1666  new_graph->SetNumval(copy_stop - copy_start + 1);
1667 
1668  // Update seqloc
1669  x_UpdateSeqGraphLoc(new_graph, sorted_cuts, seqid);
1670  break;
1671  }
1672 }
1673 
1674 
1676  const TVecscreenSummaryBySeqid& trimOnly)
1677 {
1679  CGraph_CI graph_ci(m_TopSeqEntry, graph_sel);
1680  for (; graph_ci; ++graph_ci)
1681  {
1682  // Only certain types of graphs are supported.
1683  // See C Toolkit function GetGraphsProc in api/sqnutil2.c
1684  const CMappedGraph& graph = *graph_ci;
1685  if ( graph.IsSetTitle() &&
1686  (NStr::CompareNocase( graph.GetTitle(), "Phrap Quality" ) == 0 ||
1687  NStr::CompareNocase( graph.GetTitle(), "Phred Quality" ) == 0 ||
1688  NStr::CompareNocase( graph.GetTitle(), "Gap4" ) == 0) )
1689  {
1690  // Make a copy of the graph
1691  CRef<CSeq_graph> new_graph(new CSeq_graph());
1692  new_graph->Assign(graph.GetOriginalGraph());
1693 
1694  // Make edits to the copy
1696  for (cit = trimOnly.begin(); cit != trimOnly.end(); ++cit)
1697  {
1698  const CSeq_id* seqid = cit->first;
1699  const SVecscreenResult& result = cit->second;
1700 
1701  // Find matching seqid referred to by the graph
1702  if ( graph.GetLoc().GetId()->Match(*seqid) ) {
1703  TCuts sorted_cuts(result.m_arrRangeMatch);
1704  x_GetSortedCuts(sorted_cuts, seqid);
1705 
1706  x_TrimSeqGraphData(new_graph, graph, sorted_cuts, seqid);
1707 
1708  // Swap edited copy with the original graph
1709  CIRef<IEditCommand> chgGraph(
1710  new CCmdChangeGraph( graph.GetSeq_graph_Handle(),
1711  *new_graph ));
1712  command->AddCommand(*chgGraph);
1713  break;
1714  }
1715  }
1716  }
1717  }
1718 }
1719 
1720 
1721 bool CVectorTrimPanel::x_IsCompleteCut(const TCuts& sorted_cuts,
1722  TSeqPos seq_length)
1723 {
1724  // Assume cuts are sorted in Ascending order.
1725 
1726 
1727  // Special case: no cuts
1728  if (sorted_cuts.empty()) {
1729  return false;
1730  }
1731 
1732 
1733  // Special case: only one cut
1734  if (sorted_cuts.size() == 1) {
1735  const SRangeMatch& cut = sorted_cuts[0];
1736  TSeqPos from = cut.m_range.GetFrom();
1737  TSeqPos to = cut.m_range.GetTo();
1738  if (from == 0 && to == seq_length - 1) {
1739  return true;
1740  }
1741  else {
1742  return false;
1743  }
1744  }
1745 
1746 
1747  // 2 or more cuts exist
1748  TSeqPos min_from = -1;
1749  TSeqPos max_to = -1;
1750  for (int ii = 0; ii < sorted_cuts.size(); ++ii)
1751  {
1752  const SRangeMatch& cut = sorted_cuts[ii];
1753  TSeqPos from = cut.m_range.GetFrom();
1754  TSeqPos to = cut.m_range.GetTo();
1755 
1756  if (ii == 0) {
1757  min_from = from;
1758  max_to = to;
1759  }
1760  else {
1761  // If the current cut is discontiguous with previous cut(s)
1762  // then we do NOT have a complete cut
1763  if (from > max_to + 1) {
1764  // Gap exists, so this is a discontiguous cut
1765  return false;
1766  }
1767 
1768  min_from = min(min_from, from);
1769  max_to = max(max_to, to);
1770  }
1771  }
1772 
1773  if (min_from == 0 && max_to == seq_length - 1) {
1774  return true;
1775  }
1776 
1777  return false;
1778 }
1779 
1780 
1782  TVecscreenSummaryBySeqid& completeDeletions,
1783  TVecscreenSummaryBySeqid& trimOnly)
1784 {
1785  // Put complete deletions into completeDeletions container
1786  // Put partial cuts into trimOnly container
1787 
1788  CScope& scope = m_TopSeqEntry.GetScope();
1789 
1791  for (cit = seqidSummary.begin(); cit != seqidSummary.end(); ++cit)
1792  {
1793  const CSeq_id* seqid = cit->first;
1794  const SVecscreenResult& vecres = cit->second;
1795 
1796  // Will the sequence be completely deleted by the trim?
1797  CBioseq_Handle bsh = scope.GetBioseqHandle(*seqid);
1798 
1799  // Should be a nuc!
1800  if ( !bsh.IsNucleotide() ) {
1801  continue;
1802  }
1803 
1804  // Sort ranges in ascending order
1805  TCuts sorted_cuts(vecres.m_arrRangeMatch);
1807  sort(sorted_cuts.begin(), sorted_cuts.end(), asc);
1808 
1809  // Merge abutting and overlapping cuts
1810  x_MergeCuts(sorted_cuts);
1811 
1812  // Adjust internal cuts
1813  TSeqPos nuc_length = bsh.GetBioseqLength();
1814  x_AdjustInternalCutLocations(sorted_cuts, nuc_length);
1815 
1816  // Is it a complete cut of the entire sequence?
1817  if (x_IsCompleteCut(sorted_cuts, nuc_length)) {
1818  completeDeletions.insert(TVecscreenSummaryBySeqid::value_type(seqid,
1819  vecres));
1820  }
1821  else {
1823  vecres));
1824  }
1825  }
1826 }
1827 
1828 
1830  const CSeq_id* seqid)
1831 {
1832  CScope& scope = m_TopSeqEntry.GetScope();
1833  CBioseq_Handle bsh = scope.GetBioseqHandle(*seqid);
1834 
1835  // Should be a nuc!
1836  if (!bsh.IsNucleotide())
1837  {
1838  return;
1839  }
1840 
1841  // Is nuc bioseq part of a nucprot set? If so, delete the nucprot
1842  // set. Otherwise delete just the nuc.
1844  if (bssh && bssh.CanGetClass() &&
1846  {
1847  // Delete the nucprot set
1848  CRef<CCmdDelBioseqSet> delSet(new CCmdDelBioseqSet(bssh));
1849  command->AddCommand(*delSet);
1850  }
1851  else
1852  {
1853  // Delete just the nuc
1854  CRef<CCmdDelBioseqInst> delSeq(new CCmdDelBioseqInst(bsh));
1855  command->AddCommand(*delSeq);
1856  }
1857 }
1858 
1859 
1861 {
1862 
1863  const TVecscreenSummaryBySeqid& seqidSummary =
1865 
1866 
1867  // Detect if some sequences are 100% contamination sequences.
1868  // Warn user that these sequences will be completely removed.
1869  // Give user chance to CANCEL.
1870  TVecscreenSummaryBySeqid completeDeletions;
1871  TVecscreenSummaryBySeqid trimOnly;
1872  x_FindCompleteDeletions(seqidSummary, completeDeletions, trimOnly);
1873  if ( !completeDeletions.empty() ) {
1874  CListReportDlg* listReport = new CListReportDlg(this);
1875 
1876  wxString header;
1877  header << "The following " << completeDeletions.size()
1878  << " sequences are 100% matches to vector and \n"
1879  << "will be deleted from your submission:";
1880  listReport->SetHeader(header);
1881 
1882  wxString list;
1884  for (cit = completeDeletions.begin(); cit != completeDeletions.end(); ++cit)
1885  {
1886  const CSeq_id* seqid = cit->first;
1887  const SVecscreenResult& vecres = cit->second;
1888 
1889  list << seqid->AsFastaString() << "\n";
1890  }
1891  listReport->SetList(list);
1892 
1893  wxString footer;
1894  footer << "Do you want to continue?";
1895  listReport->SetFooter(footer);
1896 
1897  if ( listReport->ShowModal() == wxID_CANCEL ) {
1898  // User canceled
1899  return false;
1900  }
1901  }
1902 
1903 
1904  CRef<CCmdComposite> command( new CCmdComposite( "Trim Vector" ) );
1905 
1906 
1907  // Delete selected sequences
1909  for (cit = completeDeletions.begin(); cit != completeDeletions.end(); ++cit)
1910  {
1911  const CSeq_id* seqid = cit->first;
1912 
1913  x_DeleteSelected(command, seqid);
1914  }
1915 
1916 
1917  // Trim selected sequences
1918  for (cit = trimOnly.begin(); cit != trimOnly.end(); ++cit)
1919  {
1920  const CSeq_id* seqid = cit->first;
1921  const SVecscreenResult& result = cit->second;
1922 
1923  x_TrimSelected(command, seqid, result);
1924  }
1925 
1926  // Trim alignments
1927  x_TrimAlignments(command, trimOnly);
1928 
1929  // Trim seq-graphs
1930  x_TrimSeqGraphs(command, trimOnly);
1931 
1932 
1933  EInternalTrimType eInternalTrimType =
1934  static_cast<EInternalTrimType>(m_radioBoxInternalTrimOptions->GetSelection());
1935  wxString report;
1936  m_listMatches->GetSelectedLocations(report, eInternalTrimType);
1937  if (!report.IsEmpty()) {
1938  // Popup report of locations trimmed.
1939  // Set parent window to NULL and add style wxDIALOG_NO_PARENT, so that the report stays up
1940  // even when the vector trim dialog is closed.
1941  CVecscreenReport* vecscreenReport = new CVecscreenReport(GetGrandParent(),
1942  wxID_ANY,
1943  _("Trimmed Location(s)"),
1944  wxDefaultPosition,
1945  wxDefaultSize,
1946  wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX);
1947  vecscreenReport->SetReport(report);
1948  vecscreenReport->Show();
1949  }
1950 
1951 
1952  // Keep track of ALL commands executed so that later you can
1953  // unexecute them all if the user cancels
1954  m_CmdProcessor->Execute(command);
1955  return true;
1956 }
1957 
1958 
1959 void CVectorTrimPanel::
1961  vecscreen_summary)
1962 {
1963  m_listMatches->UpdateData(vecscreen_summary);
1964 }
1965 
1966 
1967 
1968 IMPLEMENT_DYNAMIC_CLASS( CMatchesListCtrl, wxListCtrl )
1969 
1970 
1971 BEGIN_EVENT_TABLE(CMatchesListCtrl, wxListCtrl)
1972  EVT_LIST_COL_CLICK(MYID_LISTCTRL_MATCHES, CMatchesListCtrl::OnColClick)
1973  EVT_LIST_ITEM_SELECTED(MYID_LISTCTRL_MATCHES, CMatchesListCtrl::OnSelected)
1974  EVT_LIST_ITEM_CHECKED(MYID_LISTCTRL_MATCHES, CMatchesListCtrl::OnChecked)
1976 
1977 
1978 CMatchesListCtrl::CMatchesListCtrl()
1979 {
1980 }
1981 
1982 
1984  const wxWindowID id,
1985  const wxPoint& pos,
1986  const wxSize& size,
1987  long style)
1988 {
1989  Create(parent, id, pos, size, style);
1990 }
1991 
1992 
1994 {
1995 }
1996 
1997 
1998 bool CMatchesListCtrl::Create(wxWindow *parent,
1999  wxWindowID id,
2000  const wxPoint &pos,
2001  const wxSize &size,
2002  long style)
2003 {
2004  wxCheckedListCtrl::Create(parent, id, pos, size, style);
2005 
2006  // Init state variables
2008  m_SortAscending = true;
2009  m_SelectedRow = -1;
2010 
2011  // Set line item graphic properties
2012  m_listItemAttr.SetTextColour(*wxBLUE);
2013  m_listItemAttr.SetBackgroundColour(*wxLIGHT_GREY);
2014  m_listItemAttr.SetFont(wxNullFont);
2015 
2016  // Set up the column properties
2017 
2018  InsertColumn( 0, _("Select"), wxLIST_FORMAT_LEFT);
2019  InsertColumn( 1, _("Location"), wxLIST_FORMAT_LEFT);
2020  InsertColumn( 2, _("Seqid"), wxLIST_FORMAT_LEFT );
2021  InsertColumn( 3, _("Match"), wxLIST_FORMAT_LEFT );
2022 
2023  return true;
2024 }
2025 
2026 
2027 void CMatchesListCtrl::SetAlignGraphicView( wxHtmlWindow* view )
2028 {
2029  m_AlignView = view;
2030 }
2031 
2032 
2034 {
2035  m_RangeView = view;
2036 }
2037 
2038 
2040 {
2041  return hitloc.m_Selected;
2042 }
2043 
2044 
2046 {
2047  switch(hitloc.m_HitLocation) {
2048  case CUVHitLoc::e5Prime:
2049  return _( "5' End" );
2050  case CUVHitLoc::eInternal:
2051  {
2052  if (hitloc.m_matches.size() != 1) {
2053  return _( "Internal" );
2054  }
2055 
2056  TSeqPos start = hitloc.m_matches[0].m_range.GetFrom();
2057  TSeqPos stop = hitloc.m_matches[0].m_range.GetTo();
2058  stringstream ss;
2059  ss << _( "Internal: " ) << start << _( " from 5' end, " )
2060  << hitloc.m_SeqLen - stop << _( " from 3' end" );
2061  return _( ss.str() );
2062  }
2063  case CUVHitLoc::e3Prime:
2064  return _( "3' End" );
2065  default:
2066  return _( "Unknown" );
2067  }
2068 }
2069 
2070 
2072 {
2073  return _( hitloc.m_FastaSeqid );
2074 }
2075 
2076 
2078 {
2079  // Concatenate the match type(s)
2080  stringstream ssMatchType;
2081  for (int ii = 0; ii < hitloc.m_matches.size(); ++ii)
2082  {
2083  if (ii > 0)
2084  {
2085  ssMatchType << "; ";
2086  }
2087  ssMatchType << hitloc.m_matches[ii].m_match_type;
2088  }
2089  return _( ssMatchType.str() );
2090 }
2091 
2092 
2093 // Note :
2094 // TVecscreenSummaryBySeqid is CMatchesListCtrl's interface to the outside.
2095 // Internally CMatchesListCtrl uses TVecscreenSummaryByLocation to display
2096 // data.
2098 {
2099  // Transform internal TVecscreenSummaryByLocation selections to
2100  // TVecscreenSummaryBySeqid data type for callers
2102  return m_seqidSummaryBySeqid;
2103 }
2104 
2105 
2107  vecscreen_summary)
2108 {
2109  // Transform TVecscreenSummaryBySeqid to internal data type
2111 
2112  // Clean slate
2113  DeleteAllItems();
2114  if (m_RangeView) {
2115  m_RangeView->DeleteAllItems();
2116  }
2117 
2118  // Display message if no vector contamination was found
2119  if (m_seqidSummaryByLocation.empty()) {
2120  wxListItem item;
2121  int row = 0;
2122  int col = 0;
2123  item.SetId(row);
2124  InsertItem(item);
2125  SetItem(row, col, _("No vector contamination found")); // TODO
2126 
2127  // Adjust the first column width
2128  wxListItem objcol;
2129  GetColumn(col, objcol);
2130  objcol.SetWidth(450);
2131  SetColumn(col, objcol);
2132 
2133  return true;
2134  }
2135 
2136  // Re-adjust the first column width
2137  int col = 0;
2138  wxListItem objcol;
2139  GetColumn(col, objcol);
2140  objcol.SetWidth(50);
2141  SetColumn(col, objcol);
2142 
2143  x_Redraw();
2144 
2145  return true;
2146 }
2147 
2148 
2150  TVecscreenSummaryBySeqid& seqidSummaryBySeqid) const
2151 {
2152  // Input container: TVecscreenSummaryByLocation
2153  // Output container: TVecscreenSummaryBySeqid
2154 
2155  // Combine matches separated by location into a single container for each seqid
2156 
2157  seqidSummaryBySeqid.clear();
2158  TVecscreenSummaryByLocation::const_iterator cit;
2159  for (cit = seqidSummaryByLocation.begin(); cit != seqidSummaryByLocation.end(); ++cit) {
2160  const CUVHitLoc& loc = *cit;
2161 
2162  if (!loc.m_Selected) {
2163  continue;
2164  }
2165 
2166  // Insert into output container.
2167  SVecscreenResult vecres(loc.m_FastaSeqid, loc.m_matches, loc.m_SeqLen);
2168  pair<TVecscreenSummaryBySeqid::iterator, bool> ins_res =
2169  seqidSummaryBySeqid.insert(TVecscreenSummaryBySeqid::value_type(loc.m_Seqid, vecres));
2170 
2171  // If insert fails, append element to existing key's value
2172  if (!ins_res.second) {
2173  SVecscreenResult& vecres = ins_res.first->second;
2174  vecres.m_arrRangeMatch.insert(vecres.m_arrRangeMatch.end(),
2175  loc.m_matches.begin(),
2176  loc.m_matches.end());
2177  }
2178  }
2179 }
2180 
2181 
2183  const vector<SRangeMatch>& sorted_matches,
2184  const CSeq_id* seqid,
2185  const SVecscreenResult& vecres) const
2186 {
2187  if (sorted_matches.empty()) {
2188  return;
2189  }
2190 
2191 
2192  // Use sorted_matches to determine location: 5' or 3' or Internal
2193  static const TSeqPos kTerminalLenFromEnd = 50;
2195  const TSeqPos loc_start = sorted_matches[0].m_range.GetFrom();
2196  const TSeqPos loc_stop = sorted_matches[sorted_matches.size()-1].m_range.GetTo();
2197  if (loc_start < kTerminalLenFromEnd) {
2198  location = CUVHitLoc::e5Prime;
2199  }
2200  else
2201  if (vecres.m_SeqLen - loc_stop < kTerminalLenFromEnd) {
2202  location = CUVHitLoc::e3Prime;
2203  }
2204  else {
2205  location = CUVHitLoc::eInternal;
2206  }
2207 
2208 
2209  // Use location to determine selected: Internal hits should not be selected by default.
2210  bool selected = true;
2211  if (location == CUVHitLoc::eInternal) {
2212  selected = false;
2213  }
2214 
2215 
2216  CUVHitLoc hits(selected, location, vecres, seqid, sorted_matches);
2217  seqidSummaryByLocation.push_back(hits);
2218 }
2219 
2220 
2222  TVecscreenSummaryByLocation& seqidSummaryByLocation) const
2223 {
2224  // Input container: TVecscreenSummaryBySeqid
2225  // Output container: TVecscreenSummaryByLocation
2226 
2227  // For each seqid, split matches out by location into separate containers.
2228  // Abutting locations are put into the same container.
2229 
2230  seqidSummaryByLocation.clear();
2232  for (cit = vecscreen_summary.begin(); cit != vecscreen_summary.end(); ++cit) {
2233  const CSeq_id* seqid = cit->first;
2234  SVecscreenResult vecres = cit->second;
2235 
2236  // Sort the matches in ascending order
2238  sort(vecres.m_arrRangeMatch.begin(), vecres.m_arrRangeMatch.end(), asc);
2239 
2240  // If location is by itself, put into separate container.
2241  // If location is abutting previous location, put into same container as previous.
2242  int previous_to = -99;
2243  vector<SRangeMatch> previous_matches;
2244  for (int ii = 0; ii < vecres.m_arrRangeMatch.size(); ++ii) {
2245  const SRangeMatch& match = vecres.m_arrRangeMatch[ii];
2246 
2247  if (match.m_range.GetFrom() <= previous_to+1) {
2248  // This location abuts previous location!
2249  // Put into same container as previous.
2250  previous_matches.push_back(match);
2251  }
2252  else {
2253  // Put into new separate container.
2254  vector<SRangeMatch> current_matches;
2255  current_matches.push_back(match);
2256 
2257  // And insert any previous_matches into Output container TVecscreenSummaryByLocation
2258  x_InsertMatches(seqidSummaryByLocation, previous_matches, seqid, vecres);
2259 
2260  // Update previous_matches container
2261  previous_matches.swap(current_matches);
2262  }
2263 
2264  previous_to = match.m_range.GetTo();
2265  }
2266 
2267  // Insert remaining previous_matches into Output container TVecscreenSummaryByLocation
2268  x_InsertMatches(seqidSummaryByLocation, previous_matches, seqid, vecres);
2269  }
2270 }
2271 
2272 
2273 void CMatchesListCtrl::GetReport(wxString& report)
2274 {
2275  if (m_seqidSummaryByLocation.empty()) {
2276  report << _("No vector contamination found");
2277  return;
2278  }
2279 
2280  // Generate report of current state of results
2281  TVecscreenSummaryByLocation::const_iterator cit;
2282  for (cit = m_seqidSummaryByLocation.begin(); cit != m_seqidSummaryByLocation.end(); ++cit)
2283  {
2284  const CUVHitLoc& hitloc = *cit;
2285 
2286  report << x_GetHitLocation(hitloc) << _(";")
2287  << x_GetSeqid(hitloc) << _(";")
2288  << x_GetMatchType(hitloc) << _("\n");
2289  }
2290 }
2291 
2292 
2294 {
2295  // Sort a copy of the seqidSummaryByLocation data structure by
2296  // Accession for reporting purposes.
2297  CUVHitCmp cmp(eSortAccession, true);
2298  TVecscreenSummaryByLocation seqidSummaryByLocation(m_seqidSummaryByLocation);
2299  sort(seqidSummaryByLocation.begin(), seqidSummaryByLocation.end(), cmp);
2300 
2301  TVecscreenSummaryByLocation::const_iterator cit;
2302  for (cit = seqidSummaryByLocation.begin(); cit != seqidSummaryByLocation.end(); ++cit)
2303  {
2304  if (cit->m_Selected && !cit->m_matches.empty()) {
2305  // Seqid
2306  report << cit->m_FastaSeqid << _(":");
2307 
2308  const SRangeMatch& firstrange = cit->m_matches[0];
2309  const SRangeMatch& lastrange = cit->m_matches[cit->m_matches.size()-1];
2310 
2311  // Since abutting hits are kept together in the same container,
2312  // get the "from" of the first element and get the "to" of the last
2313  // element to effectively MERGE abutting hits
2314  TSeqPos from = firstrange.m_range.GetFrom();
2315  TSeqPos to = lastrange.m_range.GetTo();
2316 
2317  // Adjust the cut location reports for any internal cut
2318  // adjustments that were made
2319  TSeqPos seq_length = cit->m_SeqLen;
2320  if (from != 0 && to != seq_length-1) {
2321  // We have an internal hit!
2322  // Internal hits are always adjusted to terminal using an option.
2323 
2324  if (eInternalTrimType == CVectorTrimPanel::eTrimToClosestEnd) {
2325  // Extend the cut to the closest end
2326  if (from - 0 < seq_length-1 - to) {
2327  from = 0;
2328  }
2329  else {
2330  to = seq_length-1;
2331  }
2332  }
2333  else
2334  if (eInternalTrimType == CVectorTrimPanel::eTrimTo5PrimeEnd) {
2335  // Extend the cut to 5' end
2336  from = 0;
2337  }
2338  else {
2339  // Extend the cut to 3' end
2340  to = seq_length-1;
2341  }
2342  }
2343 
2344  // Report the locations that were actually cut
2345  // Units are 1-based for reporting!
2346  report << from + 1 << "-" << to + 1 << _("\n");
2347  }
2348  }
2349 }
2350 
2351 
2352 void CMatchesListCtrl::Sort(ESortOption eSortOption, bool bAscending)
2353 {
2354  m_SortOption = eSortOption;
2355  m_SortAscending = bAscending;
2356 
2357  x_Redraw();
2358 }
2359 
2360 
2361 bool CMatchesListCtrl::x_Find(const CUVHitLoc& hitloc, const wxString& searchstr)
2362 {
2363  if (searchstr.empty()) {
2364  return false;
2365  }
2366 
2367  // Search hit location
2368  wxString s = x_GetHitLocation(hitloc);
2369  if (s.Find(searchstr) != wxNOT_FOUND) {
2370  return true;
2371  }
2372 
2373  // Search Seqid
2374  s = x_GetSeqid(hitloc);
2375  if (s.Find(searchstr) != wxNOT_FOUND) {
2376  return true;
2377  }
2378 
2379  // Search Strength
2380  s = x_GetMatchType(hitloc);
2381  if (s.Find(searchstr) != wxNOT_FOUND) {
2382  return true;
2383  }
2384 
2385  return false;
2386 }
2387 
2388 
2390 {
2391  return row >= 0 && row < m_seqidSummaryByLocation.size();
2392 }
2393 
2394 
2396 {
2397  if (bFound) {
2398  // If found, select that row as if user clicked on it
2399  SetItemState(row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
2400  m_SelectedRow = row;
2401  }
2402  else {
2403  // Popup a Not Found! dialog
2404  wxMessageDialog msg( NULL, _("Text not found!"), _("Info") );
2405  msg.ShowModal();
2406  }
2407 }
2408 
2409 
2410 void CMatchesListCtrl::FindForward(wxString searchstr)
2411 {
2412  bool bFound = false;
2413 
2414  // Start search from next
2415  int row = m_SelectedRow + 1;
2416  if (!x_IsValidRow(row)) {
2417  // If not valid, init search from first row
2418  row = 0;
2419  }
2420 
2421  int initialSearchRow = row;
2422  for (; row < m_seqidSummaryByLocation.size();) {
2423  const CUVHitLoc& hitloc = m_seqidSummaryByLocation[row];
2424  bFound = x_Find(hitloc, searchstr);
2425  if (bFound) {
2426  break;
2427  }
2428 
2429  // If you've reached the end and your initial search row was not the
2430  // beginning, then wrap around to the beginning and search again
2431  if (row == m_seqidSummaryByLocation.size() - 1 && initialSearchRow > 0) {
2432  row = 0;
2433  initialSearchRow = row;
2434  }
2435  else {
2436  ++row;
2437  }
2438  }
2439 
2440  x_DisplaySearchResult(bFound, row);
2441 }
2442 
2443 
2444 void CMatchesListCtrl::FindReverse(wxString searchstr)
2445 {
2446  bool bFound = false;
2447 
2448  // Start search from previous
2449  int row = m_SelectedRow - 1;
2450  if (!x_IsValidRow(row)) {
2451  // If not valid, init search from last row
2452  row = m_seqidSummaryByLocation.size() - 1;
2453  }
2454 
2455  int initialSearchRow = row;
2456  for (; row >= 0;) {
2457  const CUVHitLoc& hitloc = m_seqidSummaryByLocation[row];
2458  bFound = x_Find(hitloc, searchstr);
2459  if (bFound) {
2460  break;
2461  }
2462 
2463  // If you've reached the beginning and your initial search row was not the
2464  // end, then wrap around to the end and search again
2465  if (row == 0 && initialSearchRow < m_seqidSummaryByLocation.size() - 1) {
2466  row = m_seqidSummaryByLocation.size() - 1;
2467  initialSearchRow = row;
2468  }
2469  else {
2470  --row;
2471  }
2472  }
2473 
2474  x_DisplaySearchResult(bFound, row);
2475 }
2476 
2477 
2479 {
2480  TVecscreenSummaryByLocation::const_iterator cit;
2481  for (cit = m_seqidSummaryByLocation.begin(); cit != m_seqidSummaryByLocation.end(); ++cit)
2482  {
2483  if (!cit->m_Selected) {
2484  return false;
2485  }
2486  }
2487  return true;
2488 }
2489 
2490 
2492 {
2493  return m_SortAscending ?
2494  x_Compare(x, y) < 0 :
2495  x_Compare(x, y) > 0;
2496 }
2497 
2498 
2499 void CMatchesListCtrl::CUVHitCmp::x_FindStrongestMatchType(const vector<SRangeMatch>& matches,
2500  SRangeMatch::EMatchType& matchtype) const
2501 {
2502  // Iterate through container and keep track of the strongest matchtype found
2503  for (int ii = 0; ii < matches.size(); ++ii) {
2504  string matchstr = matches[ii].m_match_type;
2505  NStr::ToLower(matchstr);
2506 
2508  if (matchstr == "strong") {
2509  current = SRangeMatch::eStrong;
2510  }
2511  else
2512  if (matchstr == "moderate") {
2513  current = SRangeMatch::eModerate;
2514  }
2515  else
2516  if (matchstr == "weak") {
2517  current = SRangeMatch::eWeak;
2518  }
2519  else
2520  if (matchstr == "suspect") {
2521  current = SRangeMatch::eSuspect;
2522  }
2523 
2524  // Update to the strongest match defined by enum order
2525  if (current < matchtype) {
2526  matchtype = current;
2527  }
2528  }
2529 }
2530 
2531 
2532 int CMatchesListCtrl::CUVHitCmp::x_CompareMatches(const vector<SRangeMatch>& x,
2533  const vector<SRangeMatch>& y) const
2534 {
2536  x_FindStrongestMatchType(x, xMatchType);
2537 
2539  x_FindStrongestMatchType(y, yMatchType);
2540 
2541  return xMatchType - yMatchType;
2542 }
2543 
2544 
2546  const CUVHitLoc& y) const
2547 {
2548  switch (m_SortOption) {
2550  {
2551  int res = x.m_HitLocation - y.m_HitLocation;
2552  if (res != 0) {
2553  return res;
2554  }
2555  //else go to tiebreak
2556  }
2557  break;
2558 
2559  case eSortStrength:
2560  {
2561  int res = x_CompareMatches(x.m_matches, y.m_matches);
2562  if (res != 0) {
2563  return res;
2564  }
2565  //else go to tiebreak
2566  }
2567  break;
2568 
2569  case eSortMarked:
2570  {
2571  // Define ascending to be marked=true before marked=false
2572  if (x.m_Selected && !y.m_Selected) {
2573  return -1;
2574  }
2575  else if (!x.m_Selected && y.m_Selected) {
2576  return 1;
2577  }
2578  //else go to tiebreak
2579  }
2580  break;
2581 
2582  case eSortAccession:
2583  {
2584  return x.m_FastaSeqid.compare(y.m_FastaSeqid);
2585  }
2586  }
2587 
2588  // Tiebreak!
2589  return x.m_FastaSeqid.compare(y.m_FastaSeqid);
2590 }
2591 
2592 
2594 {
2595  // Sort
2597  sort(m_seqidSummaryByLocation.begin(), m_seqidSummaryByLocation.end(), cmp);
2598 
2599  // Clean slate
2600  DeleteAllItems();
2601 
2602  // Set value in each column of each row
2603  TVecscreenSummaryByLocation::const_iterator cit;
2604  int row = 0;
2605  for (cit = m_seqidSummaryByLocation.begin(); cit != m_seqidSummaryByLocation.end(); ++cit)
2606  {
2607  const CUVHitLoc& hitloc = *cit;
2608 
2609  // Insert a row
2610  wxListItem item;
2611  item.SetId(row);
2612  InsertItem(item);
2613 
2614  // Column to indicate selected or not
2615  SetChecked(row, x_GetSelected(hitloc));
2616  SetItem( row, 0, wxEmptyString );
2617 
2618  // 5` or 3` End
2619  SetItem( row, 1, x_GetHitLocation(hitloc) );
2620 
2621  // Seqid
2622  SetItem( row, 2, x_GetSeqid(hitloc) );
2623 
2624  // Match type
2625  SetItem( row, 3, x_GetMatchType(hitloc) );
2626 
2627  ++row;
2628  }
2629  SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
2630  SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
2631  SetColumnWidth(2, wxLIST_AUTOSIZE);
2632  SetColumnWidth(3, wxLIST_AUTOSIZE);
2633 }
2634 
2635 
2637 {
2638  TVecscreenSummaryByLocation::iterator it;
2639  int row = 0;
2640  for (it = m_seqidSummaryByLocation.begin(); it != m_seqidSummaryByLocation.end(); ++it)
2641  {
2642  CUVHitLoc& hitloc = *it;
2643 
2644  hitloc.m_Selected = true;
2645  }
2646 
2647  x_Redraw();
2648 }
2649 
2650 
2652 {
2653  TVecscreenSummaryByLocation::iterator it;
2654  int row = 0;
2655  for (it = m_seqidSummaryByLocation.begin(); it != m_seqidSummaryByLocation.end(); ++it)
2656  {
2657  CUVHitLoc& hitloc = *it;
2658 
2659  hitloc.m_Selected = false;
2660  for (int ii = 0; ii < hitloc.m_matches.size(); ++ii)
2661  {
2662  const SRangeMatch& rangematch = hitloc.m_matches[ii];
2663  if ( NStr::FindNoCase(rangematch.m_match_type, "strong") != NPOS ||
2664  NStr::FindNoCase(rangematch.m_match_type, "moderate") != NPOS )
2665  {
2666  hitloc.m_Selected = true;
2667  break;
2668  }
2669  }
2670  }
2671 
2672  x_Redraw();
2673 }
2674 
2675 
2677 {
2678  TVecscreenSummaryByLocation::iterator it;
2679  int row = 0;
2680  for (it = m_seqidSummaryByLocation.begin(); it != m_seqidSummaryByLocation.end(); ++it)
2681  {
2682  CUVHitLoc& hitloc = *it;
2683 
2684  hitloc.m_Selected = false;
2685  }
2686 
2687  x_Redraw();
2688 }
2689 
2690 
2692 {
2693  TVecscreenSummaryByLocation::iterator it;
2694  int row = 0;
2695  for (it = m_seqidSummaryByLocation.begin(); it != m_seqidSummaryByLocation.end(); ++it)
2696  {
2697  CUVHitLoc& hitloc = *it;
2698 
2699  if (hitloc.m_HitLocation == CUVHitLoc::eInternal) {
2700  hitloc.m_Selected = false;
2701  }
2702  }
2703 
2704  x_Redraw();
2705 }
2706 
2707 
2708 void CMatchesListCtrl::OnColClick(wxListEvent& event)
2709 {
2710  // Use this callback to sort.
2711 
2712  // Column integer value is 0 based.
2713  int col = event.GetColumn();
2714 
2715  ESortOption eSortOption;
2716  switch (col) {
2717  case 0:
2718  eSortOption = eSortMarked;
2719  break;
2720  case 1:
2721  eSortOption = eSortInternal5Prime3Prime;
2722  break;
2723  case 2:
2724  eSortOption = eSortAccession;
2725  break;
2726  case 3:
2727  eSortOption = eSortStrength;
2728  break;
2729  default:
2730  eSortOption = eSortInternal5Prime3Prime;
2731  break;
2732  }
2733 
2734  // If sort option did not change, then toggle sort ascending
2735  if (m_SortOption == eSortOption) {
2736  m_SortAscending = m_SortAscending ? false : true;
2737  }
2738  else {
2739  m_SortOption = eSortOption;
2740  }
2741 
2742  x_Redraw();
2743 }
2744 
2745 
2746 void CMatchesListCtrl::OnSelected(wxListEvent& event)
2747 {
2748  if ( GetWindowStyle() & wxLC_REPORT )
2749  {
2750  int selected_row = event.GetIndex();
2751 
2752  TVecscreenSummaryByLocation::const_iterator cit;
2753  int count = 0;
2754  for (cit = m_seqidSummaryByLocation.begin(); cit != m_seqidSummaryByLocation.end(); ++cit)
2755  {
2756  if (count == selected_row)
2757  {
2758  m_SelectedRow = selected_row;
2759 
2760  if (m_RangeView)
2761  {
2762  m_RangeView->UpdateData(cit->m_FastaSeqid, cit->m_matches);
2763  }
2764  break;
2765  }
2766 
2767  ++count;
2768  }
2769  }
2770 }
2771 
2772 void CMatchesListCtrl::OnChecked(wxListEvent& event)
2773 {
2774  int selected_row = event.GetIndex();
2775  m_seqidSummaryByLocation[selected_row].m_Selected = IsChecked(selected_row);
2776  event.Skip();
2777 }
2778 
2779 
2780 
2781 IMPLEMENT_DYNAMIC_CLASS( CLocationsListCtrl, wxListCtrl )
2782 
2783 
2784 BEGIN_EVENT_TABLE(CLocationsListCtrl, wxListCtrl)
2785  EVT_LIST_ITEM_SELECTED(MYID_LISTCTRL_LOCATIONS, CLocationsListCtrl::OnSelected)
2787 
2788 
2789 CLocationsListCtrl::CLocationsListCtrl()
2790 {
2791 }
2792 
2793 
2795  const wxWindowID id,
2796  const wxPoint& pos,
2797  const wxSize& size,
2798  long style)
2799 {
2800  Create(parent, id, pos, size, style);
2801 }
2802 
2803 
2805 {
2806 }
2807 
2808 
2809 bool CLocationsListCtrl::Create(wxWindow *parent,
2810  wxWindowID id,
2811  const wxPoint &pos,
2812  const wxSize &size,
2813  long style)
2814 {
2815  wxListCtrl::Create(parent, id, pos, size, style);
2816 
2817  // Set line item graphic properties
2818  m_listItemAttr.SetTextColour(*wxBLUE);
2819  m_listItemAttr.SetBackgroundColour(*wxLIGHT_GREY);
2820  m_listItemAttr.SetFont(wxNullFont);
2821 
2822  // Set up the column properties
2823  wxListItem col0;
2824  col0.SetColumn(0);
2825  col0.SetText( _("Seqid") );
2826  col0.SetWidth(200);
2827  InsertColumn( 0, col0 );
2828 
2829  wxListItem col1;
2830  col1.SetColumn(1);
2831  col1.SetText( _("Range") );
2832  col1.SetWidth(220);
2833  InsertColumn( 1, col1 );
2834 
2835  return true;
2836 }
2837 
2838 
2839 bool CLocationsListCtrl::UpdateData(const string& fastaseqid,
2840  const vector<SRangeMatch>& matches)
2841 {
2842  // Clean slate
2843  DeleteAllItems();
2844 
2845  // Set value in each column of each row
2846  for (int ii = 0; ii < matches.size(); ++ii)
2847  {
2848  const SRangeMatch& rangematch = matches[ii];
2849 
2850  // Insert a row
2851  wxListItem row;
2852  row.SetId(ii);
2853  InsertItem(row);
2854 
2855  // Seqid
2856  SetItem( ii, 0, _( fastaseqid ) );
2857 
2858  // Range
2859  stringstream ssRange;
2860  ssRange << rangematch.m_range.GetFrom() + 1
2861  << "-" << rangematch.m_range.GetTo() + 1;
2862  SetItem( ii, 1, _( ssRange.str() ) );
2863  }
2864 
2865  return true;
2866 }
2867 
2868 
2869 void CLocationsListCtrl::OnSelected(wxListEvent& event)
2870 {
2871  if ( GetWindowStyle() & wxLC_REPORT )
2872  {
2873  wxListItem info;
2874  info.m_itemId = event.GetIndex();
2875 
2876  }
2877 }
2878 
2879 
2880 IMPLEMENT_DYNAMIC_CLASS( CListReportDlg, wxDialog )
2881 
2882 
2883 BEGIN_EVENT_TABLE( CListReportDlg, wxDialog )
2885 
2886 
2887 CListReportDlg::CListReportDlg()
2888 {
2889  Init();
2890 }
2891 
2892 CListReportDlg::CListReportDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
2893 {
2894  Init();
2895  Create(parent, id, caption, pos, size, style);
2896 }
2897 
2898 
2899 bool CListReportDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
2900 {
2901  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
2902  wxDialog::Create( parent, id, caption, pos, size, style );
2903 
2904  CreateControls();
2905  if (GetSizer())
2906  {
2907  GetSizer()->SetSizeHints(this);
2908  }
2909  Centre();
2910  return true;
2911 }
2912 
2913 
2915 {
2916 }
2917 
2918 
2920 {
2921 }
2922 
2923 
2925 {
2926  wxBoxSizer* dialogSizer = new wxBoxSizer(wxVERTICAL);
2927  this->SetSizer(dialogSizer);
2928 
2929 
2930  // Display header portion of dialog
2931  m_textHeader = new wxStaticText( this,
2932  wxID_ANY,
2933  _( "" ),
2934  wxDefaultPosition,
2935  wxDefaultSize,
2936  wxALIGN_LEFT );
2937  dialogSizer->Add(m_textHeader, 0, wxEXPAND|wxALL, 5);
2938 
2939 
2940  // Display message list in a scrollable text field
2941  m_textList = new wxTextCtrl( this,
2942  wxID_ANY,
2943  wxEmptyString,
2944  wxDefaultPosition,
2945  wxSize(600, 450),
2946  wxTE_MULTILINE|wxTE_READONLY );
2947  dialogSizer->Add(m_textList, 1, wxEXPAND|wxALL, 5);
2948 
2949 
2950  // Display footer portion of dialog
2951  m_textFooter = new wxStaticText( this,
2952  wxID_ANY,
2953  _( "" ),
2954  wxDefaultPosition,
2955  wxDefaultSize,
2956  wxALIGN_LEFT );
2957  dialogSizer->Add(m_textFooter, 0, wxEXPAND|wxALL, 5);
2958 
2959 
2960  // Display Ok/Cancel buttons
2961  wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
2962  wxButton* okButton = new wxButton( this, wxID_OK, _( "Ok" ), wxDefaultPosition, wxDefaultSize, 0 );
2963  wxButton* cancelButton = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
2964  buttonSizer->Add(okButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2965  buttonSizer->Add(cancelButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
2966  dialogSizer->Add(buttonSizer, 0, wxEXPAND|wxALL, 5);
2967 }
2968 
2969 
2970 void CListReportDlg::SetHeader(const wxString& header)
2971 {
2972  m_textHeader->SetLabel(header);
2973 }
2974 
2975 
2976 void CListReportDlg::SetList(const wxString& list)
2977 {
2978  m_textList->SetValue(list);
2979 }
2980 
2981 
2982 void CListReportDlg::SetFooter(const wxString& footer)
2983 {
2984  m_textFooter->SetLabel(footer);
2985 }
2986 
2987 
2988 IMPLEMENT_DYNAMIC_CLASS( CVecscreenReportPanel, wxPanel )
2989 
2990 
2991 BEGIN_EVENT_TABLE( CVecscreenReportPanel, wxPanel )
2993 
2994 
2995 CVecscreenReportPanel::CVecscreenReportPanel()
2996 {
2997  Init();
2998 }
2999 
3000 CVecscreenReportPanel::CVecscreenReportPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
3001 {
3002  Init();
3003  Create(parent, id, pos, size, style);
3004 }
3005 
3006 
3007 bool CVecscreenReportPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
3008 {
3009  wxPanel::Create( parent, id, pos, size, style );
3010 
3011  CreateControls();
3012  if (GetSizer())
3013  {
3014  GetSizer()->SetSizeHints(this);
3015  }
3016  Centre();
3017  return true;
3018 }
3019 
3020 
3022 {
3023 }
3024 
3025 
3027 {
3028 }
3029 
3030 
3032 {
3033  wxBoxSizer* panelSizer = new wxBoxSizer(wxVERTICAL);
3034  this->SetSizer(panelSizer);
3035 
3036 
3037  // Display message list in a scrollable text field
3038  m_textReport = new wxTextCtrl( this,
3039  wxID_ANY,
3040  wxEmptyString,
3041  wxDefaultPosition,
3042  wxSize(600, 450),
3043  wxTE_MULTILINE );
3044  panelSizer->Add(m_textReport, 1, wxEXPAND|wxALL, 5);
3045 }
3046 
3047 
3048 void CVecscreenReportPanel::SetReport(const wxString& report)
3049 {
3050  m_textReport->SetValue(report);
3051 }
3052 
3053 
3054 IMPLEMENT_DYNAMIC_CLASS( CVecscreenReport, wxDialog )
3055 
3056 
3057 BEGIN_EVENT_TABLE( CVecscreenReport, wxDialog )
3059 
3060 
3061 CVecscreenReport::CVecscreenReport()
3062 {
3063  Init();
3064 }
3065 
3066 CVecscreenReport::CVecscreenReport( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
3067 {
3068  Init();
3069  Create(parent, id, caption, pos, size, style);
3070 }
3071 
3072 
3073 bool CVecscreenReport::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
3074 {
3075  wxDialog::Create( parent, id, caption, pos, size, style );
3076 
3077  CreateControls();
3078  if (GetSizer())
3079  {
3080  GetSizer()->SetSizeHints(this);
3081  }
3082  Centre();
3083  return true;
3084 }
3085 
3086 
3088 {
3089 }
3090 
3091 
3093 {
3094 }
3095 
3096 
3098 {
3099  wxBoxSizer* dialogSizer = new wxBoxSizer(wxVERTICAL);
3100  this->SetSizer(dialogSizer);
3101 
3102  m_panel = new CVecscreenReportPanel(this);
3103  dialogSizer->Add(m_panel, 1, wxEXPAND|wxALL, 5);
3104 }
3105 
3106 
3107 void CVecscreenReport::SetReport(const wxString& report)
3108 {
3109  m_panel->SetReport(report);
3110 }
3111 
3112 
3114 
static static static static wxID_ANY
TSeqPos GetLength(void) const
return length of current segment
Definition: seq_map_ci.hpp:672
Definition: Date.hpp:52
CBioseq_Handle –.
wxHtmlWindow * m_viewAlignGraphic
void SetAlignGraphicView(wxHtmlWindow *view)
void SetPacked_int(TPacked_int &v)
Definition: Seq_loc.hpp:968
wxWindow * m_pParentWindow
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:908
CTime CurrentTime(CTime::ETimeZone tz=CTime::eLocal, CTime::ETimeZonePrecision tzp=CTime::eTZPrecisionDefault)
Definition: ncbitime.hpp:2139
~CVecscreenReport()
Destructor.
ICommandProccessor * m_CmdProcessor
const TVecscreenSummaryBySeqid & GetVecscreenSummaryBySeqid() const
wxGauge * m_gaugeProgressBar
Iterator over CSeqMap.
Definition: seq_map_ci.hpp:251
void x_DisplaySearchResult(bool bFound, int row)
const TSeq_data & GetSeq_data(void) const
Get the Seq_data member data.
Definition: Seq_inst_.hpp:802
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:783
CConstRef –.
Definition: ncbiobj.hpp:1192
size_type size() const
Definition: map.hpp:148
bool IsNucleotide(void) const
void x_ConvertSelectedToBySeqid(const TVecscreenSummaryByLocation &seqidSummaryByLocation, TVecscreenSummaryBySeqid &seqidSummaryBySeqid) const
Set coding to printable coding (Iupacna or Iupacaa)
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:848
void SetNumval(TNumval value)
Assign a value to Numval data member.
const TInst & GetInst(void) const
CSeq_align_Handle GetSeq_align_Handle(void) const
Get original alignment handle.
Definition: align_ci.cpp:223
vector< CRef< CSeq_id > > TIds
Definition: Dense_seg_.hpp:106
void SetTo(TTo value)
Assign a value to To data member.
CScope & GetScope(void) const
Get scope this handle belongs to.
void SetFrom(TFrom value)
Assign a value to From data member.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:1849
static const unsigned char msg[]
Definition: ccm.c:378
TTo GetTo(void) const
Get the To member data.
void x_FindStrongestMatchType(const vector< SRangeMatch > &matches, SRangeMatch::EMatchType &matchtype) const
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:865
void SetInst(TInst &v) const
ESortOption m_SortOption
void Reset(void)
Reset the whole object.
Definition: Seq_graph_.cpp:54
void OnSort(wxCommandEvent &event)
void CreateControls()
Creates the controls and sizers.
bool IsUnknownLength(void) const
return true if current segment is a gap of unknown length
Definition: seq_map_ci.cpp:302
void x_CutDensegSegment(CRef< CSeq_align > align, CDense_seg::TDim row, TSeqPos pos)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxBORDER_SIMPLE)
Creation.
TStrands & SetStrands(void)
Assign a value to Strands data member.
Definition: Dense_seg_.hpp:573
CBioseq_EditHandle –.
const CSeq_loc & GetProduct(void) const
USING_SCOPE(objects)
bool CanGetData(void) const
Check if it is safe to call GetData method.
Definition: Seq_feat_.hpp:891
bool CanGetTo(void) const
Check if it is safe to call GetTo method.
void SetLength(TLength value)
Assign a value to Length data member.
wxCheckBox * m_CitSub
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:836
void x_AdjustInternalCutLocations(TCuts &cuts, TSeqPos seq_length)
void SetList(const wxString &list)
void clear()
Definition: map.hpp:169
const CSeq_loc & GetLoc(void) const
Definition: graph_ci.hpp:103
TSeqPos GetLength(void) const
Definition: Bioseq.cpp:360
void OnUnselectAll(wxCommandEvent &event)
END_EVENT_TABLE()
void SetMax(TMax value)
Assign a value to Max data member.
TSeqPos GetPosition(void) const
return position of current segment in sequence
Definition: seq_map_ci.hpp:665
bool IsSetTitle(void) const
Definition: graph_ci.hpp:85
User-defined methods of the data storage class.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
const TPacked_int & GetPacked_int(void) const
Get the variant data.
Definition: Seq_loc_.cpp:216
TIupacna & SetIupacna(void)
Select the variant.
Definition: Seq_data_.hpp:517
void Run(objects::CSeq_entry_Handle seh, wxGauge &progress)
TFrame GetFrame(void) const
Get the Frame member data.
Definition: Cdregion_.hpp:520
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1061
void x_UpdateSeqGraphLoc(CRef< CSeq_graph > new_graph, const TCuts &sorted_cuts, const CSeq_id *seqid)
bool Create(wxWindow *parent, wxWindowID id=ID_CVECTORTRIMPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Creation.
void OnRunVecscreen(wxCommandEvent &event)
const CSeqMap & GetSeqMap(void) const
Get sequence map.
const TValues & GetValues(void) const
Get the Values member data.
const TStarts & GetStarts(void) const
Get the Starts member data.
Definition: Dense_seg_.hpp:517
bool CanGetProduct(void) const
Check if it is safe to call GetProduct method.
Definition: Seq_feat_.hpp:1055
bool CanGetIds(void) const
Check if it is safe to call GetIds method.
Definition: Dense_seg_.hpp:486
CScope & GetScope(void) const
Get scope this handle belongs to.
void CreateControls()
Creates the controls and sizers.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CSeqMap::ESegmentType GetType(void) const
Definition: seq_map_ci.hpp:651
const TByte & GetByte(void) const
Get the variant data.
Definition: Seq_graph_.cpp:153
string m_match_type
CRangeCmp(ESortOrder sortorder=eAscending)
CBioseq_EditHandle GetEditHandle(void) const
Get 'edit' version of handle.
wxButton * m_buttonMakeReport
void OnSelected(wxListEvent &event)
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2888
bool IsCdregion(void) const
Check if variant Cdregion is selected.
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
Definition: Dense_seg_.hpp:555
wxRadioBox * m_radioBoxSort
wxString x_GetHitLocation(const CUVHitLoc &hitloc)
void RemoveBioseq(const CBioseq_Handle &seq)
Revoke Bioseq previously added using AddBioseq().
Definition: scope.cpp:356
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:298
const NCBI_NS_NCBI::CEnumeratedTypeValues *ENUM_METHOD_NAME() ENa_strand(void)
Access to ENa_strand's attributes (values, names) as defined in spec.
TThisType & SetTo(position_type to)
Definition: range.hpp:180
SAnnotSelector –.
CAlign_CI –.
Definition: align_ci.hpp:62
const CSeq_graph & GetOriginalGraph(void) const
Get original graph with unmapped location/product.
Definition: graph_ci.hpp:64
void OnUnselectInternal(wxCommandEvent &event)
#define NULL
Definition: ncbistd.hpp:225
const TStrands & GetStrands(void) const
Get the Strands member data.
Definition: Dense_seg_.hpp:567
static const unsigned char res[3][32]
Definition: ccm.c:389
CBioseq_Handle AddBioseq(CBioseq &bioseq, TPriority pri=kPriority_Default, EExist action=eExist_Throw)
Add bioseq, return bioseq handle.
Definition: scope.cpp:487
TThisType & SetFrom(position_type from)
Definition: range.hpp:170
static bool ShowToolTips()
Should we show tooltips?
CVecscreenReportPanel()
Constructors.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:966
void OnColClick(wxListEvent &event)
const CSeq_align & GetOriginalSeq_align(void) const
Get original alignment.
Definition: align_ci.cpp:215
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
TMax GetMax(void) const
Get the Max member data.
CChangeUnindexedObjectCommand< objects::CSeqdesc > CChangeSeqDescCommand
static TSeqPos Pack(CSeq_data *in_seq, TSeqPos uLength=ncbi::numeric_limits< TSeqPos >::max())
void OnTrimSelected(wxCommandEvent &event)
const CSeq_graph::C_Graph & GetGraph(void) const
Definition: graph_ci.cpp:192
wxListItemAttr m_listItemAttr
vector< SRangeMatch > m_matches
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:776
#define NPOS
Definition: ncbistr.hpp:130
void SetFrame(TFrame value)
Assign a value to Frame data member.
Definition: Cdregion_.hpp:526
User-defined methods of the data storage class.
const TMix & GetMix(void) const
Get the variant data.
Definition: Seq_loc_.cpp:282
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1082
bool IsSetProduct(void) const
CRange< TSeqPos > m_range
wxString x_GetSeqid(const CUVHitLoc &hitloc)
real sequence data
Definition: seq_map.hpp:98
bool Create(wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxLC_REPORT, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxListCtrlNameStr)
bool CanGetStarts(void) const
Check if it is safe to call GetStarts method.
Definition: Dense_seg_.hpp:511
void x_AdjustDensegAlignment(CRef< CSeq_align > align, CDense_seg::TDim row, const TCuts &sorted_cuts)
void Init()
Initialises member variables.
#define wxCLOSE_BOX
Definition: gui.hpp:50
User-defined methods of the data storage class.
TMin GetMin(void) const
Get the Min member data.
void SetToTime(const CTime &time, EPrecision prec=ePrecision_second)
Definition: Date.cpp:57
bool x_IsCompleteCut(const TCuts &sorted_cuts, TSeqPos seq_length)
TVecscreenSummaryBySeqid m_seqidSummaryBySeqid
wxButton * m_buttonSelectStrongModerate
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
static const char si[8][64]
Definition: des.c:152
static CRef< CBioseq > TranslateToProtein(const CSeq_feat &cds, CScope &scope)
Definition: sequence.cpp:3661
wxHtmlWindow * m_AlignView
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
Definition: seq_vector.cpp:304
ESortOrder m_sortorder
void Init()
Initialises member variables.
const_iterator end() const
Definition: map.hpp:152
CLocationsListCtrl * m_RangeView
list< CRef< CPub > > Tdata
Definition: Pub_equiv_.hpp:90
bool Create(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxLC_ICON)
unsigned int DWORD
Definition: sqltypes.h:98
void SetDim(TDim value)
Assign a value to Dim data member.
Definition: Dense_seg_.hpp:414
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3205
TNumseg GetNumseg(void) const
Get the Numseg member data.
Definition: Dense_seg_.hpp:452
bool operator()(const CUVHitLoc &x, const CUVHitLoc &y) const
bool x_Find(const CUVHitLoc &hitloc, const wxString &searchstr)
CBioseq_set_Handle –.
vector< SRangeMatch > TCuts
TByte & SetByte(void)
Select the variant.
Definition: Seq_graph_.cpp:159
bool x_GetSelected(const CUVHitLoc &hitloc)
wxRadioBox * m_radioBoxInternalTrimOptions
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:898
TLength GetLength(void) const
Get the Length member data.
Definition: Seq_inst_.hpp:644
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_graph_.hpp:696
vector< CUVHitLoc > TVecscreenSummaryByLocation
TValues & SetValues(void)
Assign a value to Values data member.
Tdata & Set(void)
Assign a value to data member.
const TCdregion & GetCdregion(void) const
Get the variant data.
void x_TrimAlignments(CRef< CCmdComposite > command, const TVecscreenSummaryBySeqid &trimOnly)
void CreateControls()
Creates the controls and sizers.
TSeqPos GetEndPosition(void) const
return end position of current segment in sequence (exclusive)
Definition: seq_map_ci.hpp:679
CFeat_CI –.
Definition: feat_ci.hpp:63
bool CanGetLoc(void) const
Check if it is safe to call GetLoc method.
Definition: Seq_graph_.hpp:829
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
~CListReportDlg()
Destructor.
void x_SeqLocDelete(CRef< CSeq_loc > loc, TSeqPos from, TSeqPos to, const CSeq_id *seqid, bool &bCompleteCut, bool &bTrimmed)
bool CanGetClass(void) const
const TLens & GetLens(void) const
Get the Lens member data.
Definition: Dense_seg_.hpp:542
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:946
TFrom GetFrom(void) const
Get the From member data.
static bool IsDbAvailable()
User-defined methods of the data storage class.
const string & GetTitle(void) const
Definition: graph_ci.hpp:89
void SetSeq_data(TSeq_data &value)
Assign a value to Seq_data data member.
void Init()
Initialises member variables.
virtual bool TransferDataFromWindow()
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void x_AdjustCdregionFrame(CScope &scope, CRef< CSeq_feat > feat, const TCuts &sorted_cuts, const CSeq_id *seqid, bool bFeatureTrimmed, bool bProdTrimmed)
int x_Compare(const CUVHitLoc &x, const CUVHitLoc &y) const
bool CanGetDim(void) const
Check if it is safe to call GetDim method.
Definition: Dense_seg_.hpp:389
CSeqVector –.
Definition: seq_vector.hpp:64
TVecscreenSummaryByLocation m_seqidSummaryByLocation
wxTextCtrl * m_textFind
TStarts & SetStarts(void)
Assign a value to Starts data member.
Definition: Dense_seg_.hpp:523
void OnDismiss(wxCommandEvent &event)
Tdata & Set(void)
Assign a value to data member.
static int match(register const unsigned char *eptr, register const uschar *ecode, const unsigned char *mstart, int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, int flags, unsigned int rdepth)
Definition: pcre_exec.c:431
bool IsSetData(void) const
bool IsNcbieaa(void) const
Check if variant Ncbieaa is selected.
Definition: Seq_data_.hpp:644
bool empty() const
Definition: map.hpp:149
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
wxButton * m_buttonFindReverse
void GetReport(wxString &report)
void x_SeqIntervalDelete(CRef< CSeq_interval > interval, TSeqPos cut_from, TSeqPos cut_to, const CSeq_id *seqid, bool &bCompleteCut, bool &bTrimmed)
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Dense_seg_.hpp:492
numerical value
Definition: Na_strand.hpp:63
CLocationsListCtrl * m_listLocations
TClass GetClass(void) const
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
void x_RetranslateCDS(CScope &scope, CRef< CCmdComposite > command, CRef< CSeq_feat > cds)
void OnFindReverse(wxCommandEvent &event)
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
TLens & SetLens(void)
Assign a value to Lens data member.
Definition: Dense_seg_.hpp:548
void x_SetSeqData(const CBioseq_Handle &bsh, CRef< objects::CSeq_inst > inst, const TCuts &sorted_cuts)
wxButton * m_buttonSelectAll
CListReportDlg()
Constructors.
wxButton * m_buttonUnselectInternal
int size
~CVecscreenReportPanel()
Destructor.
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1049
void SetFuzz(TFuzz &value)
Assign a value to Fuzz data member.
void Init()
Initialises member variables.
CVecscreenReport()
Constructors.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:885
void FindReverse(wxString searchstr)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Report Dialog"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxButton * m_buttonUnselectAll
static MDB_envinfo info
Definition: mdb_load.c:37
T max(T x_, T y_)
~CVectorTrimPanel()
Destructor.
User-defined methods of the data storage class.
position_type GetTo(void) const
Definition: range.hpp:142
void x_TrimFeatureLocations(CRef< CSeq_feat > feat, const TCuts &sorted_cuts, const CSeq_id *seqid, bool &bFeatureDeleted, bool &bFeatureTrimmed, bool &bProdDeleted, bool &bProdTrimmed)
void FindForward(wxString searchstr)
bool IsIupacaa(void) const
Check if variant Iupacaa is selected.
Definition: Seq_data_.hpp:524
bool IsChecked(long item) const
void * HWND
Definition: sqltypes.h:73
CIUPACna –.
Definition: IUPACna.hpp:65
void x_ConvertAllToByLocation(const TVecscreenSummaryBySeqid &vecscreen_summary, TVecscreenSummaryByLocation &seqidSummaryByLocation) const
void OnSelectAll(wxCommandEvent &event)
map< string, string > ss
T min(T x_, T y_)
CVectorTrimPanel()
Constructors.
const char * command
Definition: util.cpp:116
objects::CSeq_entry_Handle m_TopSeqEntry
bool x_IsValidRow(int row)
TIds & SetIds(void)
Assign a value to Ids data member.
Definition: Dense_seg_.hpp:498
bool CanGet(void) const
Check if it is safe to call Get method.
wxButton * m_buttonRunVecscreen
TDim GetDim(void) const
Get the Dim member data.
Definition: Dense_seg_.hpp:408
const TLoc & GetLoc(void) const
Get the Loc member data.
Definition: Seq_graph_.hpp:835
void ShowDebugMessage(const wxString &message)
position_type GetFrom(void) const
Definition: range.hpp:134
bool CanGetSegs(void) const
Check if it is safe to call GetSegs method.
Definition: Seq_align_.hpp:902
void SetLoc(TLoc &value)
Assign a value to Loc data member.
Definition: Seq_graph_.cpp:223
void x_TrimSeqGraphData(CRef< CSeq_graph > new_graph, const CMappedGraph &orig_graph, const TCuts &sorted_cuts, const CSeq_id *seqid)
Tdata & Set(void)
Assign a value to data member.
Definition: Delta_ext_.hpp:171
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
TSeqPos GetBioseqLength(void) const
void x_DeleteSelected(CRef< CCmdComposite > command, const CSeq_id *seqid)
void SetMin(TMin value)
Assign a value to Min data member.
wxBoxSizer * m_sizerVectorResults
CScope –.
Definition: scope.hpp:90
void OnChecked(wxListEvent &event)
bool Create(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxLC_ICON)
bool CanGetLens(void) const
Check if it is safe to call GetLens method.
Definition: Dense_seg_.hpp:536
void x_TrimSeqGraphs(CRef< CCmdComposite > command, const TVecscreenSummaryBySeqid &trimOnly)
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
void SetInt(TInt &v)
Definition: Seq_loc.hpp:967
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_graph_Handle GetSeq_graph_Handle(void) const
Get original graph handle.
Definition: graph_ci.cpp:93
static void Init(void)
Definition: cursor6.c:79
CConstRef< CSeq_literal > GetRefGapLiteral(void) const
return CSeq_literal with gap data, or null if either the segment is not a gap, or an unspecified gap ...
Definition: seq_map_ci.cpp:292
const TIupacaa & GetIupacaa(void) const
Get the variant data.
Definition: Seq_data_.hpp:530
const TVecscreenSummaryBySeqid & GetSelectedVecscreenSummaryBySeqid()
int len
void CreateControls()
Creates the controls and sizers.
bool IsProtein(void) const
const string AsFastaString(void) const
Definition: Seq_id.cpp:1638
TAxis GetAxis(void) const
Get the Axis member data.
void SetGraph(TGraph &value)
Assign a value to Graph data member.
Definition: Seq_graph_.cpp:249
bool CanGetFrom(void) const
Check if it is safe to call GetFrom method.
void SetRangeView(CLocationsListCtrl *view)
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
void x_InsertMatches(TVecscreenSummaryByLocation &seqidSummaryByLocation, const vector< SRangeMatch > &sorted_matches, const CSeq_id *seqid, const SVecscreenResult &vecres) const
bool x_FindSegment(const CDense_seg &denseg, CDense_seg::TDim row, TSeqPos pos, CDense_seg::TNumseg &seg, TSeqPos &seg_start) const
bool CanGet(void) const
Check if it is safe to call Get method.
else result
Definition: token2.c:20
CSeqMap_CI ResolvedRangeIterator(CScope *scope, TSeqPos from, TSeqPos length, ENa_strand strand=eNa_strand_plus, size_t maxResolve=size_t(-1), TFlags flags=fDefaultFlags) const
Iterate segments in the range with specified strand coordinates.
Definition: seq_map.cpp:829
wxButton * m_buttonTrimSelected
Helper functor to compare cuts during sorting.
CAutoInitRef<>::
CMappedGraph –.
Definition: graph_ci.hpp:60
wxString x_GetMatchType(const CUVHitLoc &hitloc)
CGraph_CI –.
Definition: graph_ci.hpp:210
wxButton * m_buttonFindForward
bool UpdateData(const string &fastaseqid, const vector< SRangeMatch > &matches)
bool operator()(const SRangeMatch &a1, const SRangeMatch &a2)
void OnSelected(wxListEvent &event)
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
const CSeqFeatData & GetData(void) const
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
Definition: Seq_id.cpp:278
void OnMakeReport(wxCommandEvent &event)
static const char location[]
Definition: config.c:97
void SetSegs(TSegs &value)
Assign a value to Segs data member.
Definition: Seq_align_.cpp:309
continuous sequence
Definition: Seq_inst_.hpp:94
void x_MergeCuts(TCuts &sorted_cuts)
namespace ncbi::objects::
Definition: Seq_feat.hpp:56
Undo/Redo interface for editing operations.
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:326
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:336
virtual bool TransferDataToWindow()
void SetMix(TMix &v)
Definition: Seq_loc.hpp:971
void SetAxis(TAxis value)
Assign a value to Axis data member.
E_Choice Which(void) const
Which variant is currently selected.
void SetReport(const wxString &report)
void SetChecked(long item, bool checked)
void AddCommand(IEditCommand &command)
const_iterator begin() const
Definition: map.hpp:151
CVectorScreen m_vectorscreen
void GetSelectedLocations(wxString &report, CVectorTrimPanel::EInternalTrimType eInternalTrimType)
TLiteral & SetLiteral(void)
Select the variant.
Definition: Delta_seq_.cpp:130
void OnFindForward(wxCommandEvent &event)
int x_CompareMatches(const vector< SRangeMatch > &x, const vector< SRangeMatch > &y) const
void SetHeader(const wxString &header)
static int CompareNocase(const CTempString str, SIZE_TYPE pos, SIZE_TYPE n, const char *pattern)
Case-insensitive compare of a substring with a pattern.
Definition: ncbistr.cpp:170
void OnSelectStrongModerate(wxCommandEvent &event)
void Add(CObject *obj, const CObject *new_obj)
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("VecScreen Report"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
Creation.
void x_GetTrimCoordinates(const TCuts &sorted_cuts, const CSeq_id *seqid, TSeqPos &trim_start, TSeqPos &trim_stop)
void SetProduct(TProduct &value)
Assign a value to Product data member.
Definition: Seq_feat_.cpp:110
bool UpdateData(const TVecscreenSummaryBySeqid &vecscreen_summary)
bool CanGetNumseg(void) const
Check if it is safe to call GetNumseg method.
Definition: Dense_seg_.hpp:439
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
CMatchesListCtrl * m_listMatches
wxButton * m_buttonDismiss
void SetNumseg(TNumseg value)
Assign a value to Numseg data member.
Definition: Dense_seg_.hpp:461
void SetFooter(const wxString &footer)
void Sort(ESortOption eSortOption, bool bAscending)
void x_GetSortedCuts(TCuts &sorted_cuts, const CSeq_id *seqid)
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
static char col1[256]
Definition: compute.c:16
void x_FindCompleteDeletions(const TVecscreenSummaryBySeqid &seqidSummary, TVecscreenSummaryBySeqid &completeDeletions, TVecscreenSummaryBySeqid &trimOnly)
vector< SRangeMatch > m_arrRangeMatch
void DisplaySummaryBySeqid(const TVecscreenSummaryBySeqid &vecscreen_summary)
const TPrim & Get(void) const
Definition: serialbase.hpp:346
void SetReport(const wxString &report)
CCdregion –.
Definition: Cdregion.hpp:65
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:678
ESubtype GetSubtype(void) const
const TNcbieaa & GetNcbieaa(void) const
Get the variant data.
Definition: Seq_data_.hpp:650
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:897
bool CanGetLocation(void) const
Check if it is safe to call GetLocation method.
Definition: Seq_feat_.hpp:1076
Modified on Sun Aug 20 16:47:47 2017 by modify_doxy.py rev. 533848