33 #include "wx/wxprec.h"
126 Create(parent,
id, caption, pos,
size, style);
137 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
138 wxDialog::Create( parent,
id, caption, pos,
size, style );
143 GetSizer()->SetSizeHints(
this);
187 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
188 itemDialog1->SetSizer(itemBoxSizer2);
190 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
191 itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxLEFT, 40);
193 wxStaticText* itemStaticText4 =
new wxStaticText( itemDialog1, wxID_STATIC,
_(
"Start"), wxDefaultPosition, wxDefaultSize, 0 );
194 itemBoxSizer3->Add(itemStaticText4, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
196 wxStaticText* itemStaticText5 =
new wxStaticText( itemDialog1, wxID_STATIC,
_(
"Type"), wxDefaultPosition, wxDefaultSize, 0 );
197 itemBoxSizer3->Add(itemStaticText5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
199 wxStaticText* itemStaticText6 =
new wxStaticText( itemDialog1, wxID_STATIC,
_(
"Length"), wxDefaultPosition, wxDefaultSize, 0 );
200 itemBoxSizer3->Add(itemStaticText6, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
202 wxStaticText* itemStaticText7 =
new wxStaticText( itemDialog1, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
203 itemBoxSizer3->Add(itemStaticText7, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
205 wxScrolledWindow* itemScrolledWindow8 =
new wxScrolledWindow(itemDialog1,
ID_CRAWTODELTA_SCROLLEDWINDOW, wxDefaultPosition, wxSize(-1, 120), wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL);
206 itemBoxSizer2->Add(itemScrolledWindow8, 0, wxGROW|wxALL, 5);
207 itemScrolledWindow8->SetScrollbars(0, 1, 0, 30);
211 wxArrayString itemChoice12Strings;
212 itemChoice12Strings.Add(
_(
"Unknown length"));
213 itemChoice12Strings.Add(
_(
"Known length"));
214 wxArrayString itemChoice14Strings;
215 itemChoice14Strings.Add(
_(
"Insert"));
216 itemChoice14Strings.Add(
_(
"Replace"));
217 for (
size_t i = 0;
i < 4;
i++)
219 wxBoxSizer* itemBoxSizer10 =
new wxBoxSizer(wxHORIZONTAL);
220 m_ScrollSizer->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5);
222 m_LastStart =
new wxTextCtrl( itemScrolledWindow8,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
223 itemBoxSizer10->Add(
m_LastStart, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
224 m_LastStart->SetValidator( wxTextValidator( wxFILTER_NUMERIC ) );
226 wxChoice* itemChoice12 =
new wxChoice( itemScrolledWindow8,
wxID_ANY, wxDefaultPosition, wxDefaultSize, itemChoice12Strings, 0 );
227 itemChoice12->SetStringSelection(
_(
"Unknown length"));
228 itemBoxSizer10->Add(itemChoice12, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
230 m_LastLength =
new wxTextCtrl( itemScrolledWindow8,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
231 itemBoxSizer10->Add(
m_LastLength, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
232 m_LastLength->SetValidator( wxTextValidator( wxFILTER_NUMERIC ) );
234 wxChoice* itemChoice14 =
new wxChoice( itemScrolledWindow8,
wxID_ANY, wxDefaultPosition, wxDefaultSize, itemChoice14Strings, 0 );
235 itemChoice14->SetStringSelection(
_(
"Insert"));
236 itemBoxSizer10->Add(itemChoice14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
240 itemScrolledWindow8->FitInside();
242 wxStaticBox* itemStaticBoxSizer30Static =
new wxStaticBox(itemDialog1,
wxID_ANY,
_(
"Coordinates"));
243 wxStaticBoxSizer* itemStaticBoxSizer30 =
new wxStaticBoxSizer(itemStaticBoxSizer30Static, wxHORIZONTAL);
244 itemBoxSizer2->Add(itemStaticBoxSizer30, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
248 itemStaticBoxSizer30->Add(
m_CoordSeq, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
250 wxRadioButton* itemRadioButton32 =
new wxRadioButton(itemStaticBoxSizer30->GetStaticBox(),
ID_CRAWTODELTA_RADIOBUTTON1,
_(
"Alignment"), wxDefaultPosition, wxDefaultSize, 0);
251 itemRadioButton32->SetValue(
false);
252 itemStaticBoxSizer30->Add(itemRadioButton32, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
254 objects::CAlign_CI align_ci(
m_TopSeqEntry, objects::CSeq_annot::C_Data::e_Align);
258 itemRadioButton32->Enable();
263 itemRadioButton32->Disable();
268 itemBoxSizer2->Add(
m_AdjustCDS, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
270 wxBoxSizer* itemBoxSizer34 =
new wxBoxSizer(wxHORIZONTAL);
271 itemBoxSizer2->Add(itemBoxSizer34, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
273 wxButton* itemButton35 =
new wxButton( itemDialog1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
274 itemBoxSizer34->Add(itemButton35, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
276 wxButton* itemButton36 =
new wxButton( itemDialog1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
277 itemBoxSizer34->Add(itemButton36, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
287 wxArrayString itemChoice12Strings;
288 itemChoice12Strings.Add(
_(
"Unknown length"));
289 itemChoice12Strings.Add(
_(
"Known length"));
290 wxArrayString itemChoice14Strings;
291 itemChoice14Strings.Add(
_(
"Insert"));
292 itemChoice14Strings.Add(
_(
"Replace"));
296 wxBoxSizer* itemBoxSizer10 =
new wxBoxSizer(wxHORIZONTAL);
297 m_ScrollSizer->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5);
299 m_LastStart =
new wxTextCtrl( parent,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
300 itemBoxSizer10->Add(
m_LastStart, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
301 m_LastStart->SetValidator( wxTextValidator( wxFILTER_NUMERIC ) );
303 wxChoice* itemChoice12 =
new wxChoice( parent,
wxID_ANY, wxDefaultPosition, wxDefaultSize, itemChoice12Strings, 0 );
304 itemChoice12->SetStringSelection(
_(
"Unknown length"));
305 itemBoxSizer10->Add(itemChoice12, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
307 m_LastLength =
new wxTextCtrl( parent,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
308 itemBoxSizer10->Add(
m_LastLength, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
309 m_LastLength->SetValidator( wxTextValidator( wxFILTER_NUMERIC ) );
311 wxChoice* itemChoice14 =
new wxChoice( parent,
wxID_ANY, wxDefaultPosition, wxDefaultSize, itemChoice14Strings, 0 );
312 itemChoice14->SetStringSelection(
_(
"Insert"));
313 itemBoxSizer10->Add(itemChoice14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
359 bool create_xref_map =
true;
360 apply_impl(title, old_to_new, create_xref_map);
361 create_xref_map =
false;
362 return apply_impl(title, old_to_new, create_xref_map);
367 vector<NRawToDeltaSeq::SGap> orig_gaps;
368 wxSizerItemList::iterator node =
m_ScrollSizer->GetChildren().begin();
371 if ((*node)->IsSizer())
373 wxTextCtrl *start_ctrl =
dynamic_cast<wxTextCtrl*
>((*node)->GetSizer()->GetItem((
size_t)0)->GetWindow());
374 wxChoice *unknown_known_ctrl =
dynamic_cast<wxChoice*
>((*node)->GetSizer()->GetItem((
size_t)1)->GetWindow());
375 wxTextCtrl *length_ctrl =
dynamic_cast<wxTextCtrl*
>((*node)->GetSizer()->GetItem((
size_t)2)->GetWindow());
376 wxChoice *insert_replace_ctrl =
dynamic_cast<wxChoice*
>((*node)->GetSizer()->GetItem((
size_t)3)->GetWindow());
377 if (start_ctrl && unknown_known_ctrl && length_ctrl && insert_replace_ctrl && !start_ctrl->GetValue().IsEmpty() && !length_ctrl->GetValue().IsEmpty())
379 NRawToDeltaSeq::SGap gap;
380 gap.start = wxAtoi(start_ctrl->GetValue()) - 1;
381 gap.length = wxAtoi(length_ctrl->GetValue());
382 gap.is_known =
false;
383 if (unknown_known_ctrl->GetSelection() != wxNOT_FOUND)
384 gap.is_known = (unknown_known_ctrl->GetString(unknown_known_ctrl->GetSelection()) ==
_(
"Known length"));
385 gap.is_replace =
false;
386 if (insert_replace_ctrl->GetSelection() != wxNOT_FOUND)
387 gap.is_replace = (insert_replace_ctrl->GetString(insert_replace_ctrl->GetSelection()) ==
_(
"Replace"));
389 orig_gaps.push_back(gap);
394 sort(orig_gaps.begin(), orig_gaps.end());
402 bool alignment_affected =
false;
404 for( objects::CBioseq_CI bi(
m_TopSeqEntry, objects::CSeq_inst::eMol_na); bi; ++bi)
406 objects::CBioseq_Handle bsh = *bi;
407 vector<NRawToDeltaSeq::SGap> gaps(orig_gaps);
414 map_gaps[bsh] = gaps;
416 bseq->Assign(*bsh.GetCompleteBioseq());
417 objects::CSeq_inst& inst = bseq->SetInst();
419 if (!inst.IsSetRepr() || inst.GetRepr() != objects::CSeq_inst::eRepr_raw
420 || !inst.IsSetSeq_data()) {
425 switch(inst.GetSeq_data().Which()) {
426 case objects::CSeq_data::e_Iupacna:
427 iupacna = inst.GetSeq_data().GetIupacna();
429 case objects::CSeq_data::e_Ncbi2na:
433 case objects::CSeq_data::e_Ncbi4na:
437 case objects::CSeq_data::e_Ncbi8na:
445 int literal_start = 0;
446 inst.ResetSeq_data();
447 inst.SetRepr(objects::CSeq_inst::eRepr_delta);
449 if (inst.IsSetLength())
450 total_length = inst.GetLength();
451 for (
size_t i = 0;
i < gaps.size();
i++)
453 int literal_length = gaps[
i].start - literal_start;
454 if (literal_length < 0 || gaps[
i].start > iupacna.size())
456 wxMessageBox(
_(
"Inconsistent gap intervals"),
_(
"Error in gap interval specification"), wxOK|wxICON_ERROR);
459 if (literal_length > 0)
461 string literal = iupacna.
substr(literal_start, literal_length);
463 ds->SetLiteral().SetSeq_data().SetIupacna().Set(
literal);
465 inst.SetExt().SetDelta().Set().push_back(ds);
469 if (!gaps[
i].is_known)
471 gap->SetLiteral().SetFuzz().SetLim(objects::CInt_fuzz::eLim_unk);
473 gap->SetLiteral().SetLength(gaps[
i].length);
474 inst.SetExt().SetDelta().Set().push_back(gap);
475 literal_start = gaps[
i].start;
476 if (gaps[
i].is_replace)
477 literal_start += gaps[
i].length;
479 total_length += gaps[
i].length;
481 if (literal_start < iupacna.size())
485 ds->SetLiteral().SetSeq_data().SetIupacna().Set(
literal);
487 inst.SetExt().SetDelta().Set().push_back(ds);
489 inst.SetLength(total_length);
494 auto local_cmd = composite;
497 local_cmd->Unexecute();
505 for (
size_t i = 0;
i < gaps.size();
i++)
507 int start = gaps[
i].start;
508 int stop = gaps[
i].start + gaps[
i].length - 1;
512 if (real_start >= 0 && real_stop >= 0)
514 gaps[
i].start = real_start;
515 gaps[
i].length = real_stop - real_start + 1;
522 objects::CAlign_CI align_ci(bsh);
525 const objects::CSeq_align& align = *align_ci;
533 while (real_before < 0 && before < bsh.GetBioseqLength())
543 while (real_after < 0 && after >= 0)
556 for (objects::CAlign_CI align_ci(tse); align_ci; ++ align_ci)
558 const objects::CSeq_align& align = *align_ci;
559 int num_rows = align.CheckNumRows();
562 if (!align.IsSetSegs() || !align.GetSegs().IsDenseg() ||
563 !align.GetSegs().GetDenseg().IsSetStarts() || !align.GetSegs().GetDenseg().IsSetLens())
566 vector< TSignedSeqPos > starts(align.GetSegs().GetDenseg().GetStarts());
567 vector< TSeqPos > lens(align.GetSegs().GetDenseg().GetLens());
569 vector< ENa_strand > strands;
570 vector<vector<vector< ENa_strand > > > all_new_strands;
571 if (align.GetSegs().GetDenseg().IsSetStrands())
572 strands = align.GetSegs().GetDenseg().GetStrands();
574 vector< CRef< CScore > > scores;
575 vector< vector< CRef< CScore > > > all_new_scores;
576 if (align.GetSegs().GetDenseg().IsSetScores())
577 scores = align.GetSegs().GetDenseg().GetScores();
579 vector< vector< vector<TSignedSeqPos> > > all_new_starts;
580 vector< vector<TSeqPos> > all_new_lens;
582 x_UpdateRows(num_rows, gaps, starts, lens, strands, scores, all_new_starts, all_new_lens, all_new_strands, all_new_scores, use_align_coords, align);
586 if (all_new_lens.empty())
597 for (
size_t block = 1; block < all_new_lens.size(); block++)
609 const vector< ENa_strand > &strands,
const vector<
CRef< CScore > > &scores,
610 vector < vector< vector<TSignedSeqPos> > > &all_new_starts, vector < vector<TSeqPos> > &all_new_lens,
611 vector< vector< vector< ENa_strand > > > &all_new_strands, vector< vector<
CRef< CScore > > > &all_new_scores,
612 const bool use_align_coords,
const objects::CSeq_align& align)
614 vector< vector<TSignedSeqPos> > new_starts(num_rows);
615 vector<TSeqPos> new_lens;
616 vector< vector< ENa_strand > > new_strands(num_rows);
617 vector< CRef< CScore > > new_scores;
619 vector< TSignedSeqPos > starts(orig_starts);
620 vector< TSignedSeqPos > stops(orig_starts);
621 size_t num_segs = lens.size();
622 for (
size_t s = 0; s < num_segs; s++)
623 for (
size_t row = 0; row < num_rows; row++)
624 if (starts[num_rows * s + row] != -1)
625 stops[num_rows * s + row] += lens[s] - 1;
627 vector<TSeqPos>
offset(num_rows, 0);
630 vector<bool> next_segment(num_rows,
false);
631 vector<bool> next_gap(num_rows,
false);
638 while ( j < num_segs )
640 for (
size_t row = 0; row < num_rows; row++)
642 if (next_segment[row] || next_gap[row])
649 next_segment[row] =
true;
657 gap_start = gaps[
i].start;
658 if (use_align_coords)
661 for (
size_t s = 0; s < lens.size(); s++)
662 total_len += lens[s];
667 while (real_before < 0 && gap_start < total_len)
673 gap_start = real_before;
677 if (
i >= gaps.size() || seg_stop < gap_start)
679 next_segment[row] =
true;
681 else if (!gaps[
i].is_replace && gap_start <= seg_start)
683 if (gaps[
i].is_known)
687 next_gap[row] =
true;
689 else if (gaps[
i].is_replace && gaps[
i].is_known && gap_start + gaps[
i].length <= seg_start)
691 next_gap[row] =
true;
693 else if (gaps[
i].is_replace && !gaps[
i].is_known && gap_start + 100 <= seg_start)
695 offset[row] += 100 - gaps[
i].length;
696 next_gap[row] =
true;
698 else if (!gaps[
i].is_replace && gaps[
i].is_known && gap_start > seg_start && gap_start <= seg_stop)
702 breaks[gap_start - orig_seg_start].push_back(pair<TSeqPos, size_t>(new_stop + 1, row));
703 lengths[gap_start - orig_seg_start] = gaps[
i].length;
705 starts[num_rows*j+row] = gap_start;
707 next_gap[row] =
true;
709 else if (!gaps[
i].is_replace && !gaps[
i].is_known && gap_start > seg_start && gap_start <= seg_stop)
713 breaks[gap_start - orig_seg_start].push_back(pair<TSeqPos, size_t>(new_stop + 1, row) );
714 lengths[gap_start - orig_seg_start] = 100;
716 starts[num_rows*j+row] = gap_start;
718 next_gap[row] =
true;
719 break_aligns.
insert(gap_start - orig_seg_start);
721 else if (gaps[
i].is_replace && gaps[
i].is_known && gap_start >= seg_start && gap_start + gaps[
i].length - 1 <= seg_stop)
723 next_gap[row] =
true;
725 else if (gaps[
i].is_replace && !gaps[
i].is_known && gap_start <= seg_start && gap_start + gaps[
i].length - 1 < seg_stop)
727 offset[row] += 100 - gaps[
i].length;
729 starts[num_rows*j+row] = gap_start + gaps[
i].length;
730 next_gap[row] =
true;
733 break_aligns_before.
insert(gap_start + gaps[
i].length - orig_seg_start);
736 else if (gaps[
i].is_replace && !gaps[
i].is_known && gap_start <= seg_start && gap_start + gaps[
i].length - 1 >= seg_stop)
738 next_segment[row] =
true;
739 break_aligns_before.
insert(gap_start - orig_seg_start);
741 else if (gaps[
i].is_replace && !gaps[
i].is_known && gap_start > seg_start && gap_start <= seg_stop && gap_start + gaps[
i].length - 1 > seg_stop)
743 offset[row] += 100 - gaps[
i].length;
745 if (j != num_segs - 1 )
747 break_aligns_before.
insert(gap_start - orig_seg_start);
749 next_segment[row] =
true;
751 else if (gaps[
i].is_replace && !gaps[
i].is_known && gap_start > seg_start && gap_start <= seg_stop && gap_start + gaps[
i].length - 1 <= seg_stop)
753 offset[row] += 100 - gaps[
i].length;
755 starts[num_rows*j+row] = gap_start + gaps[
i].length;
756 next_gap[row] =
true;
757 break_aligns_before.
insert(gap_start - orig_seg_start);
760 next_gap[row] =
true;
763 bool all_next_segment =
true;
764 bool all_next_gap =
true;
765 for (
size_t row = 0; row < num_rows; row++)
767 all_next_segment &= next_segment[row];
768 all_next_gap &= next_gap[row];
771 if (all_next_segment)
773 vector< TSignedSeqPos > current_starts(orig_starts);
775 for (
map<
TSeqPos, vector<pair<TSeqPos, size_t> > >::const_iterator
b = breaks.
begin();
b != breaks.
end(); ++
b)
778 for (
size_t row = 0; row < num_rows; row++)
781 new_starts[row].push_back(seg_start);
782 current_starts[num_rows*j+row] += start - prev_break;
783 new_starts[row].push_back(-1);
784 if (!strands.empty())
786 new_strands[row].push_back(strands[num_rows*j+row]);
787 new_strands[row].push_back(strands[num_rows*j+row]);
790 new_lens.push_back(start - prev_break);
795 score->Assign(*scores[j]);
796 new_scores.push_back(score);
799 if (break_aligns.
find(start) != break_aligns.
end())
800 delete_segs.
insert(new_lens.size());
801 if (bai != break_aligns_before.
end() && start > *bai)
803 before_segs.
insert(new_lens.size());
806 for (
size_t r = 0;
r <
b->second.size();
r++)
808 size_t row =
b->second[
r].second;
809 new_starts[row].back() =
b->second[
r].first;
810 current_starts[num_rows*j+row] += lengths[start];
812 new_lens.push_back(lengths[start]);
816 score->Assign(*scores[j]);
817 new_scores.push_back(score);
826 for (
size_t row = 0; row < num_rows; row++)
829 new_starts[row].push_back(seg_start);
830 if (!strands.empty())
831 new_strands[row].push_back(strands[num_rows*j+row]);
833 if (bai != break_aligns_before.
end() && prev_break < *bai)
835 before_segs.
insert(new_lens.size());
837 new_lens.push_back(
len);
841 score->Assign(*scores[j]);
842 new_scores.push_back(score);
848 break_aligns.
clear();
849 break_aligns_before.
clear();
850 if (all_next_segment)
852 for (
size_t row = 0; row < num_rows; row++)
853 next_segment[row] =
false;
860 for (
size_t row = 0; row < num_rows; row++)
861 next_gap[row] =
false;
866 vector< vector<TSignedSeqPos> > block_starts(num_rows);
867 vector<TSeqPos> block_lens;
868 vector< vector< ENa_strand > > block_strands(num_rows);
869 vector< CRef< CScore > > block_scores;
870 for (
size_t seg = 0; seg < new_lens.size(); seg++)
872 if (delete_segs.
find(seg) != delete_segs.
end() || before_segs.
find(seg) != before_segs.
end())
874 all_new_starts.push_back(block_starts);
875 all_new_lens.push_back(block_lens);
876 all_new_strands.push_back(block_strands);
877 all_new_scores.push_back(block_scores);
878 block_starts.clear();
879 block_starts.resize(num_rows);
881 block_strands.clear();
882 block_strands.resize(num_rows);
883 block_scores.clear();
885 if (delete_segs.
find(seg) != delete_segs.
end())
887 for (
size_t row = 0; row < num_rows; row++)
889 block_starts[row].push_back(new_starts[row][seg]);
890 if (!strands.empty())
891 block_strands[row].push_back(new_strands[row][seg]);
893 block_lens.push_back(new_lens[seg]);
895 block_scores.push_back(new_scores[seg]);
897 if (!block_lens.empty())
899 all_new_starts.push_back(block_starts);
900 all_new_lens.push_back(block_lens);
901 all_new_strands.push_back(block_strands);
902 all_new_scores.push_back(block_scores);
907 const vector < vector< vector<TSignedSeqPos> > > &all_new_starts,
const vector < vector<TSeqPos> > &all_new_lens,
908 const vector< vector< vector< ENa_strand > > > &all_new_strands,
const vector< vector<
CRef< CScore > > > &all_new_scores)
910 vector< TSignedSeqPos > starts_vec(num_rows * all_new_lens[block].
size());
911 for (
size_t i = 0;
i < all_new_lens[block].size();
i++)
912 for (
size_t row = 0; row < num_rows; ++row)
913 starts_vec[
i * num_rows + row] = all_new_starts[block][row][
i];
917 new_align->
SetSegs().SetDenseg().SetStarts() = starts_vec;
918 new_align->
SetSegs().SetDenseg().SetLens() = all_new_lens[block];
920 if (!all_new_strands.empty() && all_new_strands[block].size() == num_rows && !all_new_strands[block].front().empty())
922 vector< ENa_strand > strands_vec(num_rows * all_new_lens[block].
size());
923 for (
size_t i = 0;
i < all_new_lens[block].size();
i++)
924 for (
size_t row = 0; row < num_rows; ++row)
925 strands_vec[
i * num_rows + row] = all_new_strands[block][row][
i];
926 new_align->
SetSegs().SetDenseg().SetStrands() = strands_vec;
929 new_align->
SetSegs().SetDenseg().ResetStrands();
931 if (!all_new_scores[block].
empty())
932 new_align->
SetSegs().SetDenseg().SetScores() = all_new_scores[block];
934 new_align->
SetSegs().SetDenseg().ResetScores();
936 new_align->
SetSegs().SetDenseg().TrimEndGaps();
937 new_align->
SetSegs().SetDenseg().RemovePureGapSegs();
938 new_align->
SetSegs().SetDenseg().Compact();
945 bool create_xref_map =
true;
947 create_xref_map =
false;
956 objects::CScope &scope = seh.GetScope();
960 bool alignment_affected =
false;
961 vector<NRawToDeltaSeq::SGap> all_gaps;
963 for( objects::CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na); bi; ++bi)
965 objects::CBioseq_Handle bsh = *bi;
967 vector<NRawToDeltaSeq::SGap> gaps;
970 const CSeq_loc& feat_loc = feat_it->GetLocation();
974 NRawToDeltaSeq::SGap gap;
975 gap.start = feat_range.
GetFrom() - seq_start;
976 gap.length = feat_range.
GetTo() - seq_start - gap.start + 1;
978 if (feat_it->GetNamedQual(
"estimated_length") ==
"unknown")
979 gap.is_known =
false;
980 gap.gap_type = objects::CSeq_gap::eType_unknown;
981 string gap_type_str = feat_it->GetNamedQual(
"gap_type");
982 if (!gap_type_str.empty())
988 const objects::CSeq_gap::SGapTypeInfo *gap_type_info = objects::CSeq_gap::NameToGapTypeInfo(gap_type_str);
990 gap.gap_type = gap_type_info->m_eType;
993 gap.linkage = objects::CSeq_gap::eLinkage_unlinked;
994 gap.linkage_evidence = -1;
995 string linkage_evidence_str = feat_it->GetNamedQual(
"linkage_evidence");
996 if ( gap.gap_type == objects::CSeq_gap::eType_repeat || gap.gap_type == objects::CSeq_gap::eType_scaffold || gap.gap_type == objects::CSeq_gap::eType_contamination)
998 gap.linkage = objects::CSeq_gap::eLinkage_linked;
1002 gap.is_replace =
true;
1003 gaps.push_back(gap);
1004 all_gaps.push_back(gap);
1009 sort(gaps.begin(), gaps.end());
1010 map_gaps[bsh] = gaps;
1012 bseq->Assign(*bsh.GetCompleteBioseq());
1013 objects::CSeq_inst& inst = bseq->SetInst();
1015 if (!inst.IsSetRepr() || inst.GetRepr() != objects::CSeq_inst::eRepr_raw
1016 || !inst.IsSetSeq_data()) {
1021 switch(inst.GetSeq_data().Which()) {
1022 case objects::CSeq_data::e_Iupacna:
1023 iupacna = inst.GetSeq_data().GetIupacna();
1025 case objects::CSeq_data::e_Ncbi2na:
1029 case objects::CSeq_data::e_Ncbi4na:
1033 case objects::CSeq_data::e_Ncbi8na:
1041 int literal_start = 0;
1042 inst.ResetSeq_data();
1043 inst.SetRepr(objects::CSeq_inst::eRepr_delta);
1045 if (inst.IsSetLength())
1046 total_length = inst.GetLength();
1047 for (
size_t i = 0;
i < gaps.size();
i++)
1049 int literal_length = gaps[
i].start - literal_start;
1050 if (literal_length < 0 || gaps[
i].start > iupacna.size())
1052 if (create_xref_map)
1053 wxMessageBox(
_(
"Inconsistent gap intervals"),
_(
"Error in gap interval specification"), wxOK|wxICON_ERROR);
1056 if (literal_length > 0)
1058 string literal = iupacna.
substr(literal_start, literal_length);
1060 ds->SetLiteral().SetSeq_data().SetIupacna().Set(
literal);
1062 inst.SetExt().SetDelta().Set().push_back(ds);
1066 if (!gaps[
i].is_known)
1068 gap->SetLiteral().SetFuzz().SetLim(objects::CInt_fuzz::eLim_unk);
1070 gap->SetLiteral().SetLength(gaps[
i].length);
1071 gap->SetLiteral().SetSeq_data().SetGap().SetType(gaps[
i].gap_type);
1072 gap->SetLiteral().SetSeq_data().SetGap().SetLinkage(gaps[
i].linkage);
1073 if (gaps[
i].linkage_evidence >= 0)
1076 link_ev->SetType(gaps[
i].linkage_evidence);
1077 gap->SetLiteral().SetSeq_data().SetGap().SetLinkage_evidence().push_back(link_ev);
1080 inst.SetExt().SetDelta().Set().push_back(gap);
1081 literal_start = gaps[
i].start;
1082 if (gaps[
i].is_replace)
1083 literal_start += gaps[
i].length;
1085 total_length += gaps[
i].length;
1087 if (literal_start < iupacna.size())
1091 ds->SetLiteral().SetSeq_data().SetIupacna().Set(
literal);
1093 inst.SetExt().SetDelta().Set().push_back(ds);
1095 inst.SetLength(total_length);
1105 auto local_cmd = composite;
1108 local_cmd->Unexecute();
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
void AddCommand(IEditCommand &command)
virtual void Execute()
Do the editing action.
static int FindRow(const CBioseq_Handle &bsh, const CSeq_align &align)
static int FindPosition(const CSeq_align &align, int row, int after)
static TId s_FindHighestFeatureId(const objects::CSeq_entry_Handle &entry)
CRef< CCmdComposite > apply_impl(string title, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
void ComputeAlignCoords(objects::CBioseq_Handle bsh, int before, int after, int &real_before, int &real_after)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnNewText(wxCommandEvent &event)
wxRadioButton * m_CoordSeq
void Init()
Initialises member variables.
static void x_UpdateRows(size_t num_rows, const vector< NRawToDeltaSeq::SGap > &gaps, const vector< TSignedSeqPos > &orig_starts, const vector< TSeqPos > &lens, const vector< objects::ENa_strand > &strands, const vector< CRef< objects::CScore > > &scores, vector< vector< vector< TSignedSeqPos > > > &all_new_starts, vector< vector< TSeqPos > > &all_new_lens, vector< vector< vector< objects::ENa_strand > > > &all_new_strands, vector< vector< CRef< objects::CScore > > > &all_new_scores, const bool use_align_coords, const objects::CSeq_align &align)
void CreateControls()
Creates the controls and sizers.
CRawSeqToDeltaSeqByLoc()
Constructors.
static bool ShowToolTips()
Should we show tooltips?
wxBoxSizer * m_ScrollSizer
objects::CSeq_entry_Handle m_TopSeqEntry
static CRef< objects::CSeq_align > x_GetNewAlign(const size_t block, const objects::CSeq_align &align, const size_t num_rows, const vector< vector< vector< TSignedSeqPos > > > &all_new_starts, const vector< vector< TSeqPos > > &all_new_lens, const vector< vector< vector< objects::ENa_strand > > > &all_new_strands, const vector< vector< CRef< objects::CScore > > > &all_new_scores)
CRef< CCmdComposite > apply(string title)
void UseAlignCoords(objects::CBioseq_Handle bsh, vector< NRawToDeltaSeq::SGap > &gaps)
static CRef< CCmdComposite > ByAssemblyGapFeatures_impl(objects::CSeq_entry_Handle seh, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
static void UpdateDensegAlignment(const objects::CSeq_entry_Handle &tse, CRef< CCmdComposite > composite, const vector< NRawToDeltaSeq::SGap > &gaps, const bool use_align_coords)
static CRef< CCmdComposite > ByAssemblyGapFeatures(objects::CSeq_entry_Handle seh)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool Create(wxWindow *parent, wxWindowID id=10000, const wxString &caption=_("Convert Raw Sequence to Delta Sequence"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
~CRawSeqToDeltaSeqByLoc()
Destructor.
wxTextCtrl * m_LastLength
static SIZE_TYPE Convert(const CTempString &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst, TCoding dst_coding)
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
const_iterator begin() const
const_iterator end() const
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator find(const key_type &key) const
const_iterator end() const
void AdjustFeatureLocations(const map< objects::CBioseq_Handle, vector< SGap >> &map_gaps, CRef< CCmdComposite > composite, bool split_gene_locations, bool break_features, bool keep_gap_length, bool create_general_only, objects::CObject_id::TId &max_feat_id, map< objects::CObject_id::TId, objects::CObject_id::TId > &old_to_new, bool create_xref_map)
unsigned int TSeqPos
Type for sequence locations and lengths.
int TSignedSeqPos
Type for signed sequence position.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define ENUM_METHOD_NAME(EnumName)
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to the seq-annot.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CTempString literal(const char(&str)[Size])
Templatized initialization from a string literal.
size_type length(void) const
Return the length of the represented array.
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
constexpr auto sort(_Init &&init)
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define ID_CRAWTODELTA_RADIOBUTTON1
#define ID_CRAWTODELTA_CHECKBOX
#define ID_CRAWTODELTA_RADIOBUTTON
#define ID_CRAWTODELTA_SCROLLEDWINDOW
TLocAdjustmentVector NormalizeUnknownLengthGaps(CSeq_inst &inst, TSeqPos unknown_length=100)
NormalizeUnknownLengthGaps A function to adjust the length of unknown-length gaps to a specific lengt...