: m_DsCnt(aln_mix_matches->m_DsCnt),
51m_AlnMixMatches(aln_mix_matches),
52m_Matches(aln_mix_matches->m_Matches),
53m_AlnMixSequences(aln_mix_matches->m_AlnMixSequences),
54m_Seqs(aln_mix_matches->m_Seqs),
55m_Rows(m_AlnMixSequences->m_Rows),
56m_ExtraRows(m_AlnMixSequences->m_ExtraRows),
58m_SingleRefseq(
false),
59x_CalculateScore(calc_score)
78(*seq_i)->SetStarts().clear();
79(*seq_i)->m_ExtraRow = 0;
89 "CAlnMixMerger::Merge(): " 90 "No alignments were added for merging.");
103 boolfirst_refseq =
true;
112ds_cnt = (*it)->m_DsCnt;
118 if( !first_refseq ) {
125first_refseq =
false;
133(*seq_i)->m_SeqIdx = seq_idx++;
143(*seq_i)->m_Width = (*seq_i)->m_IsAA ? 1 : 3;
149 CAlnMixSeq* refseq = 0, * seq1 = 0, * seq2 = 0;
150 TSeqPosstart, start1, start2,
len, curr_len;
151 intwidth1 = 0, width2 = 0;
153CAlnMixSeq::TMatchList::iterator match_list_iter1, match_list_iter2;
154CAlnMixSeq::TMatchList::iterator match_list_i;
157refseq = *(
m_Seqs.begin());
158TMatches::iterator match_i =
m_Matches.begin();
164first_refseq =
true;
187 if( !((*it)->m_MatchList.empty()) &&
188(*it)->m_RefBy == refseq) {
191 "CAlnMixMerger::x_Merge(): " 192 "Infinitue loop detected " 193 "while searching for a connected candidate.");
203 if( !((*it)->m_MatchList.empty()) ) {
206 "CAlnMixMerger::x_Merge(): " 207 "Infinitue loop detected " 208 "while searching for a new candidate.");
219first_refseq =
false;
229 match= *match_list_i;
231 if(refseq ==
match->m_AlnSeq2 && refseq ==
match->m_AlnSeq1) {
244 if(
match->m_AlnSeq1 == refseq) {
245seq1 =
match->m_AlnSeq1;
246start1 =
match->m_Start1;
248match_list_iter1 =
match->m_MatchIter1;
249seq2 =
match->m_AlnSeq2;
250start2 =
match->m_Start2;
252match_list_iter2 =
match->m_MatchIter2;
253}
else if(
match->m_AlnSeq2 == refseq) {
254seq1 =
match->m_AlnSeq2;
255start1 =
match->m_Start2;
257match_list_iter1 =
match->m_MatchIter2;
258seq2 =
match->m_AlnSeq1;
259start2 =
match->m_Start1;
261match_list_iter2 =
match->m_MatchIter1;
263seq1 =
match->m_AlnSeq1;
264seq2 =
match->m_AlnSeq2;
268 match->m_MatchIter1 =
269seq1->m_MatchList.insert(seq1->m_MatchList.end(),
match);
271 match->m_MatchIter2 =
272seq2->m_MatchList.insert(seq2->m_MatchList.end(),
match);
285 if( !first_refseq ) {
286 if( !seq1->m_MatchList.empty() ) {
287seq1->m_MatchList.erase(match_list_iter1);
288match_list_iter1 = seq1->m_MatchList.end();
293 match->m_AlnSeq1 = seq1;
294 match->m_Start1 = start1;
295 match->m_AlnSeq2 = seq2;
296 match->m_Start2 = start2;
297 match->m_MatchIter1 = match_list_iter1;
299 match->m_MatchIter2 = match_list_iter2;
305!
match->m_StrandsDiffer);
307substrahend.
insert(rng);
310 if((plane_it =
m_Planes.
find(make_pair(seq1, seq2))) !=
312plane = &(plane_it->second);
315 match->m_AlnSeq2->m_Width);
316plane = &(
m_Planes[make_pair(seq1, seq2)] = new_plane);
318plane->
Diff(substrahend, diff);
320 if(diff.
empty()) {
323rng = *diff.
begin();
333width1 = seq1->m_Width;
335width2 = seq2->m_Width;
344seq1 =
match->m_AlnSeq1;
345start1 =
match->m_Start1;
346match_list_iter1 =
match->m_MatchIter1;
347seq2 =
match->m_AlnSeq2;
348start2 =
match->m_Start2;
350match_list_iter2 =
match->m_MatchIter2;
357 boolproper_row_found =
false;
359 if(seq1->m_DsIdx ==
match->m_DsIdx) {
360proper_row_found =
true;
363 if(seq1->m_ExtraRow) {
364seq1 =
match->m_AlnSeq1 = seq1->m_ExtraRow;
370 if( !proper_row_found &&
373 "CAlnMixMerger::x_Merge(): " 374 "Proper row not found for the match. " 375 "Cannot use fQuerySeqMergeOnly?");
382seq2->m_RefBy = refseq;
385 if( !first_refseq ) {
386 if( !seq2->m_MatchList.empty() ) {
388match_list_iter2 = seq2->m_MatchList.end();
389 match->m_MatchIter2 = match_list_iter2;
394start_i = starts.
end();
395lo_start_i = starts.
end();
396hi_start_i = starts.
end();
422seq1 =
match->m_AlnSeq1;
423start1 =
match->m_Start1;
424match_list_iter1 =
match->m_MatchIter1;
425seq2 =
match->m_AlnSeq2;
426start2 =
match->m_Start2;
428match_list_iter2 =
match->m_MatchIter2;
432 if(!seq2->m_ExtraRow) {
435 row->m_BioseqHandle = seq2->m_BioseqHandle;
436 row->m_SeqId = seq2->m_SeqId;
437 row->m_Width = seq2->m_Width;
438 row->m_Frame = start2 % 3;
439 row->m_SeqIdx = seq2->m_SeqIdx;
440 row->m_ChildIdx = seq2->m_ChildIdx + 1;
445 row->m_ExtraRowIdx = seq2->m_ExtraRowIdx + 1;
446seq2 =
match->m_AlnSeq2 = seq2->m_ExtraRow =
row;
449seq2 =
match->m_AlnSeq2 = seq2->m_ExtraRow;
455seq1 =
match->m_AlnSeq1;
456start1 =
match->m_Start1;
457match_list_iter1 =
match->m_MatchIter1;
458seq2 =
match->m_AlnSeq2;
459start2 =
match->m_Start2;
461match_list_iter2 =
match->m_MatchIter2;
468 if(!starts.
size()) {
476 if( !((*it)->m_MatchList.empty()) ) {
477(*it)->m_MatchList.clear();
486seq1->m_PositiveStrand = (seq1->m_StrandScore >= 0);
495starts[start1] = seg;
497(seq1, lo_start_i = hi_start_i = starts.
begin());
500seq2->m_DsIdx =
match->m_DsIdx;
507 if((lo_start_i = start_i = starts.
lower_bound(start1))
509start1 < start_i->
first) {
511 if(lo_start_i != starts.
begin()) {
517 if(hi_start_i == starts.
end() && start_i != lo_start_i) {
519 if(lo_start_i->first + prev_seg->
m_Len* width1 >
524 TSeqPoslen1 = (start1 - lo_start_i->first) / width1;
531starts[start1] = seg;
537tmp_start_i = it->second;
539seq1->m_PositiveStrand) {
541[tmp_start_i->first + len1 * seq->
m_Width]
547 "CAlnMixMerger::x_Merge(): " 548 "Internal error: tmp_start_i == seq->GetStarts().end()");
552[tmp_start_i->first + len2 * seq->
m_Width]
554seq->
SetStarts()[tmp_start_i->first] = seg;
560 "CAlnMixMerger::x_Merge(): " 561 "Internal error: tmp_start_i == seq->GetStarts().end()");
567prev_seg->
m_Len= len1;
569 if(start_i != starts.
begin()) {
573 if(lo_start_i != starts.
end()) {
581 while(hi_start_i == starts.
end()) {
582 if(start_i != starts.
end() && start_i->first == start) {
584 if(prev_seg->
m_Len> curr_len) {
592start += curr_len * width1;
595prev_seg->
m_Len= curr_len;
601tmp_start_i = it->second;
603seq1->m_PositiveStrand) {
611 "CAlnMixMerger::x_Merge(): " 612 "Internal error: tmp_start_i == seq->GetStarts().end()");
618seq->
SetStarts()[tmp_start_i->first] = seg;
624 "CAlnMixMerger::x_Merge(): " 625 "Internal error: tmp_start_i == seq->GetStarts().end()");
629 #if _DEBUG && _ALNMGR_DEBUG 639hi_start_i = start_i;
640}
else if(curr_len == prev_seg->
m_Len) {
643hi_start_i = start_i;
647start += prev_seg->
m_Len* width1;
648curr_len -= prev_seg->
m_Len;
649 if(start_i != starts.
end()) {
656tmp_start_i = start_i;
657 if(tmp_start_i != starts.
begin()) {
661 if(start_i != starts.
end() &&
662start + curr_len * width1 > start_i->first) {
665seg->
m_Len= (start_i->first - start) / width1;
670seg->
m_Len= curr_len;
672hi_start_i = start_i;
673 if(hi_start_i != starts.
begin()) {
677start += seg->
m_Len* width1;
678curr_len -= seg->
m_Len;
679 if(lo_start_i == start_i) {
680 if(lo_start_i != starts.
begin()) {
692 if(!seq2->m_ExtraRow) {
695 row->m_BioseqHandle = seq2->m_BioseqHandle;
696 row->m_SeqId = seq2->m_SeqId;
697 row->m_Width = seq2->m_Width;
698 row->m_Frame = start2 % 3;
699 row->m_SeqIdx = seq2->m_SeqIdx;
700 row->m_ChildIdx = seq2->m_ChildIdx + 1;
705 row->m_ExtraRowIdx = seq2->m_ExtraRowIdx + 1;
706seq2 =
match->m_AlnSeq2 = seq2->m_ExtraRow =
row;
709seq2 =
match->m_AlnSeq2 = seq2->m_ExtraRow;
715seq1 =
match->m_AlnSeq1;
716start1 =
match->m_Start1;
717match_list_iter1 =
match->m_MatchIter1;
718seq2 =
match->m_AlnSeq2;
719start2 =
match->m_Start2;
721match_list_iter2 =
match->m_MatchIter2;
732start1 =
match->m_Start1;
733start2 =
match->m_Start2;
738 if(seq2->GetStarts().empty()) {
739seq2->m_PositiveStrand =
740(seq1->m_PositiveStrand ?
741!
match->m_StrandsDiffer :
742 match->m_StrandsDiffer);
750start_i =
match->m_StrandsDiffer ? hi_start_i : lo_start_i;
752 while(start < start2 +
len* width2) {
753 if(start2_i != starts2.
end() &&
754start2_i->first == start) {
757 if(start2_i->second != start_i->second) {
768tmp_start_i = it->second;
769tmp_start_i->second = start_i->second;
770start_i->second->SetStartIterator(tmp_seq, tmp_start_i);
772 #if _DEBUG && _ALNMGR_DEBUG 773start_i->second->StartItsConsistencyCheck(*seq2,
780seq2->
SetStarts()[start] = start_i->second;
787 if(start_i->second->m_StartIts.find(seq2) !=
788start_i->second->m_StartIts.end()) {
791 "CAlnMixMerger::x_Merge(): " 793 "Start iterator already exists for seq2.");
795start_i->second->SetStartIterator(seq2, start2_i);
796 #if _DEBUG && _ALNMGR_DEBUG 797start_i->second->StartItsConsistencyCheck(*seq2,
804start += start_i->second->m_Len * width2;
805 if(start2_i != starts2.
end()) {
808 if(
match->m_StrandsDiffer) {
809 if(start_i != starts.
begin()) {
813 if(start_i != starts.
end()) {
842 const int& width1 = seq1->
m_Width;
843 const int& width2 = seq2->
m_Width;
872!
match->m_StrandsDiffer :
873 match->m_StrandsDiffer)) {
885 if(seq2->
m_Width== 3 && seq2->
m_Frame!= (
int)(start2 % 3)) {
898starts2_i->second->m_StartIts.find(seq1);
899 if(seq1_start_it_i != starts2_i->second->m_StartIts.end()) {
900 const TSeqPos& existing_start1 = seq1_start_it_i->second->first;
901 if(
match->m_StrandsDiffer) {
902 delta= start1 +
len* width1 - existing_start1;
912start2 +=
delta* width2;
920 delta= (existing_start1 +
921starts2_i->second->m_Len - start1) /
925start1 +=
delta* width1;
940 delta= existing_start1
941+ starts2_i->second->m_Len * width1
952start1 +=
delta* width1;
953start2 +=
delta* width2;
961 delta= (existing_start1 - start1) / width1;
981 delta= starts2_i->first + starts2_i->second->m_Len * width2
992start2 +=
delta* width2;
993 if( !
match->m_StrandsDiffer ) {
994start1 +=
delta* width1;
1010starts2_i->first < start2 +
len* width2) {
1013starts2_i->second->m_StartIts.find(seq1);
1014 if(seq1_start_it_i != starts2_i->second->m_StartIts.end()) {
1015 const TSeqPos& existing_start1 = seq1_start_it_i->second->first;
1016 if(
match->m_StrandsDiffer) {
1019delta1 = (start1 - existing_start1) / width1 +
1020 len- starts2_i->second->m_Len;
1024delta1 = (existing_start1 - start1) / width1;
1026delta2 = (starts2_i->first - start2) / width2;
1027 if(delta1 != delta2) {
1029 delta= (delta1 < delta2 ? delta1 : delta2);
1031 if(
match->m_StrandsDiffer) {
1032start1 += (
len-
delta) * width1;
1053starts2_i->second->m_StartIts.find(seq1);
1054 if(seq1_start_it_i != starts2_i->second->m_StartIts.end()) {
1055 const TSeqPos& existing_start1 = seq1_start_it_i->second->first;
1056 if(
match->m_StrandsDiffer) {
1057 delta= existing_start1 +
1058starts2_i->second->m_Len * width1 - start1;
1080 delta= start1 +
len* width1 - existing_start1;
1108starts1_i->first != start1) {
1116 match->m_StrandsDiffer ? start2 +
len* width2 : start2;
1118starts1_i->first < start1 +
len* width1) {
1121starts1_i->second->m_StartIts;
1123 if(
match->m_StrandsDiffer) {
1124tmp_start -= starts1_i->second->m_Len * width2;
1127 if((seq2_start_it_i = seg_start_its.
find(seq2)) !=
1128seg_start_its.
end()) {
1129 if(seq2_start_it_i->second->first != tmp_start) {
1135 if( !
match->m_StrandsDiffer ) {
1136tmp_start += starts1_i->second->m_Len * width2;
1162 intnum = numrows * numsegs;
1181ids.resize(numrows);
1182lens.resize(numsegs);
1183starts.resize(num, -1);
1186vector<bool> row_empty(numrows,
true);
1191ids[numrow++] = (*row_i)->m_SeqId;
1202lens[numseg] = (*seg_i)->m_Len;
1206(*seg_i)->m_StartIts) {
1207starts[
offset+ start_its_i->first->m_RowIdx] =
1208start_its_i->second->first;
1211row_empty[start_its_i->first->m_RowIdx] =
false;
1218 if((*row_i)->m_PositiveStrand) {
1225numseg++;
offset+= numrows;
1235widths->resize(numrows);
1238(*widths)[numrow++] = (*row_i)->m_Width;
1243 for(
int row= numrows-1;
row>=0; --
row) {
1244 if(row_empty[
row]) {
1245ids.erase(ids.begin()+
row);
1247widths->erase(widths->begin()+
row);
1249 for(
int i= (numsegs-1)*numrows +
row;
i> 0;
i-= numrows) {
1250starts.erase(starts.begin()+
i);
1251strands.erase(strands.begin()+
i);
1272 if(seq ==
match->m_AlnSeq1) {
1273frame =
match->m_Start1 % 3;
1275frame =
match->m_Start2 % 3;
1280 while((
unsigned)seq->
m_Frame!= frame) {
class CAlignRangeCollection<TAlignRange> represent a sorted collection of TAlignRange.
const_iterator insert(const TAlignRange &r)
const_iterator begin() const
CAlignRange Represents an element of pairwise alignment of two sequences.
void x_CreateDenseg(void)
TSecondRowFits x_SecondRowFits(CAlnMixMatch *match) const
void Merge(TMergeFlags flags=0)
@ eSecondRowInconsistency
CRef< CAlnMixMatches > m_AlnMixMatches
CRef< CAlnMixSegments > m_AlnMixSegments
CAlnMixMerger(CRef< CAlnMixMatches > &aln_mix_matches, TCalcScoreMethod calc_score=0)
list< CRef< CAlnMixSeq > > & m_ExtraRows
void x_SetSeqFrame(CAlnMixMatch *match, CAlnMixSeq *&seq)
vector< CRef< CAlnMixSeq > > TSeqs
CAlnMixMatches::TCalcScoreMethod TCalcScoreMethod
CRef< CAlnMixSequences > m_AlnMixSequences
vector< CRef< CAlnMixSeq > > & m_Rows
void StartItsConsistencyCheck(const CAlnMixSeq &seq, const TSeqPos &start, size_t match_idx) const
void SetStartIterator(CAlnMixSeq *seq, CAlnMixStarts::iterator iter)
TStartIterators m_StartIts
void Build(bool gap_join=false, bool min_gap=false, bool remove_leading_and_trailing_gaps=false)
list< CAlnMixSegment * > TSegments
void FillUnalignedRegions(void)
CAlnMixStarts & SetStarts()
const CAlnMixStarts & GetStarts() const
const CBioseq_Handle * m_BioseqHandle
TWidths & SetWidths(void)
void Validate(bool full_test=false) const
void Diff(const TAlnRngColl &substrahend, TAlnRngColl &difference)
Calculate a difference.
void x_SetTaskCompleted(int completed)
void x_SetTaskName(const string &name)
Methods for reporting task progress.
void x_SetTaskTotal(int total)
bool x_InterruptTask()
Check if the task should be interrupted.
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator lower_bound(const key_type &key) const
const_iterator find(const key_type &key) const
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
int TSignedSeqPos
Type for signed sequence position.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Reset(void)
Reset reference object.
position_type GetSecondFrom(void) const
position_type GetFirstFrom(void) const
position_type GetLength(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
TLens & SetLens(void)
Assign a value to Lens data member.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
vector< ENa_strand > TStrands
void SetDim(TDim value)
Assign a value to Dim data member.
vector< TSignedSeqPos > TStarts
void SetDim(TDim value)
Assign a value to Dim data member.
void SetType(TType value)
Assign a value to Type data member.
vector< CRef< CSeq_id > > TIds
TStarts & SetStarts(void)
Assign a value to Starts data member.
TStrands & SetStrands(void)
Assign a value to Strands data member.
void SetNumseg(TNumseg value)
Assign a value to Numseg data member.
TIds & SetIds(void)
Assign a value to Ids data member.
unsigned int
A callback function used to compare two keys in a database.
Int4 delta(size_t dimension_, const Int4 *score_)
static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)
#define row(bind, expected)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4