cerr <<
"existing:"<< endl << existing << endl;
62cerr <<
"addition:"<< endl << addition << endl;
63cerr <<
"difference = addition - existing:"<< endl << difference << endl;
66existing.
insert(*rng_it);
78 #ifdef _TRACE_MergeAlnRngColl 79cerr <<
"result = existing + difference:"<< endl << existing << endl;
115(*it)->SortInsertions();
127addition->GetSecondId(),
128addition->GetPolicyFlags()));
133 #ifdef _TRACE_MergeAlnRngColl 135cerr <<
"existing:"<< endl << existing << endl;
136cerr <<
"addition:"<< endl << *addition << endl;
137cerr <<
"truncated = addition - existing:"<< endl << *truncated << endl;
148addition = truncated;
149addition->AddInsertions(gaps_truncated);
152addition = truncated;
187CPairwiseAln::const_iterator it =
a.find_insertion_point(
r);
189 if(it !=
a.begin()) {
193 r.IsDirect() ?
r: left) ) {
197 if(it !=
a.end()) {
201 r.IsDirect() ? right :
r) ) {
210TPairwiseAlnVector::iterator aln_it, aln_end;
212CPairwiseAln::TInsertions::const_iterator gap_it = gaps.begin();
220 if(rng_it->IsDirect()) {
230 while(aln_it != aln_end) {
231 #ifdef _TRACE_MergeAlnRngColl 233cerr << *rng_it << endl;
234cerr << **aln_it << endl;
245 if(aln_it == aln_end) {
254 if(rng_it->IsDirect() &&
259(*aln_it)->insert(*rng_it);
260 #ifdef _TRACE_MergeAlnRngColl 269CPairwiseAln::const_iterator next_rng_it = rng_it;
272 if(next_rng_it != addition.
end()) {
273next_rng_pos = next_rng_it->GetFirstFrom();
277 while(gap_it != gaps.end() &&
278(gap_it->GetFirstFrom() <= next_rng_pos || next_rng_pos < 0)) {
279(*aln_it)->AddInsertion(*gap_it);
295 out<<
"MergedPairwiseAln contains: "<< endl;
312 size_ttotal_number_of_rows = 0;
314total_number_of_rows += (*merged_i)->GetPairwiseAlns().size();
334 sort(anchored_aln_vec.begin(),
335anchored_aln_vec.end(),
344 if( anchor_pw.
empty() )
return;
348aln_len += it->GetLength();
351 booldirect = anchor_pw.
begin()->IsFirstDirect();
362out_anchor_pw.
insert(ar);
376CPairwiseAln::TInsertions::const_iterator gap_it = gaps.begin();
387 if(gap_it != gaps.end()) {
388CPairwiseAln::const_iterator next_it = it;
390 if(next_it != pw.
end()) {
391 while(gap_it != gaps.end() &&
392gap_it->GetFirstFrom() <= next_it->GetFirstFrom()) {
411 while(gap_it != gaps.end()) {
417 if(new_gap_pos == -1) {
422 else if( !direct ) {
445 const CPairwiseAln& anchor_pw = *pairwises[anchor_row];
454 booldirect = (new_anchor_pw->begin()->IsFirstDirect() == anchor_pw.
begin()->IsFirstDirect());
458 if(
row== anchor_row) {
459pairwises[
row].Reset(new_anchor_pw);
468pairwises[
row].Reset(new_pw);
481 boolhave_direct =
false;
482 boolhave_reverse =
false;
488 if( !common_anchor_id ) {
491 else if( !common_anchor_id->GetSeqId().Equals(
498 if( seg->IsFirstDirect() ) {
502have_reverse =
true;
504 if(have_direct && have_reverse) {
508 if(have_direct && have_reverse) {
512 if(have_direct && have_reverse) {
516 if(!have_direct || !have_reverse) {
529out_alns->push_back(anchored_copy);
541pw_copy->insert(seg_copy);
570 if(anchored_it == adj_alns->begin()) {
580}
else if(!anchor_first) {
591 if( !adj_alns->empty() ) {
596 const CAnchoredAln& first_anchored = *adj_alns->front();
597merged_vec.resize(first_anchored.
GetDim());
602 stringerrstr =
"All input alignments need to have " 603 "the same dimension when using ePreserveRows.";
608 stringerrstr =
"All input alignments need to have " 609 "the same anchor row when using ePreserveRows.";
614 if(merged.
Empty()) {
633TIdMergedMap id_merged_map;
636 #ifdef _TRACE_MergeAlnRngColl 643merged_vec.push_back(merged_anchor);
652 #ifdef _TRACE_MergeAlnRngColl 654cerr << *merged_anchor << endl;
655cerr <<
"inserting aln "<< aln_idx <<
", anchor row ("<< anchor_row <<
")"<< endl;
659 if(anchored_it == adj_alns->begin()) {
660id_merged_map[anchored_aln.
GetId(anchor_row)].
Reset(merged_anchor);
665 if(
row!= anchor_row) {
667 if(merged.
Empty()) {
672merged_vec.push_back(merged);
674 #ifdef _TRACE_MergeAlnRngColl 675cerr << *merged << endl;
676cerr <<
"inserting aln "<< aln_idx <<
", row "<<
row<< endl;
682 #ifdef _TRACE_MergeAlnRngColl 688merged_vec.push_back(merged_anchor);
691(*ma)->SortInsertions();
699 if( !pseudo_seqid ) {
703pseudo_seqid.
Reset(aln_seq_id);
void MergePairwiseAlns(CPairwiseAln &existing, const CPairwiseAln &addition, const CAlnUserOptions::TMergeFlags &flags)
Merge two pariwise alignments.
void s_TranslateAnchorToAlnCoords(CPairwiseAln &out_anchor_pw, const CPairwiseAln &anchor_pw)
void SortAnchoredAlnVecByScore(TAnchoredAlnVec &anchored_aln_vec)
Sort anchored alignments by score.
void s_TranslatePairwiseToAlnCoords(CPairwiseAln &out_pw, const CPairwiseAln &pw, const CPairwiseAln &tr, bool direct)
vector< CRef< CMergedPairwiseAln > > TMergedVec
void x_AdjustAnchorDirection(TAnchoredAlnVec &in_alns, AutoPtr< TAnchoredAlnVec > &out_alns)
ostream & operator<<(ostream &out, const CMergedPairwiseAln &merged)
void BuildAln(const TMergedVec &merged_vec, CAnchoredAln &out_aln)
void s_TranslateToAlnCoords(CAnchoredAln &anchored_aln, const TAlnSeqIdIRef &pseudo_seqid)
void SubtractAlnRngCollections(const CAlignRangeCollectionList< TAlnRng > &minuend, const CAlignRangeCollectionList< TAlnRng > &subtrahend, CAlignRangeCollectionList< TAlnRng > &difference)
Subtract one range collection from another.
class CAlignRangeCollectionList<TAlignRange> represent a sorted collection of TAlignRange.
int GetPolicyFlags() const
const_iterator begin() const
const_iterator insert(const TAlignRange &r)
@ fAllowOverlap
allow segments with different orientation
@ fAllowAbutting
allow segments overlapping on the first sequence
@ fAllowMixedDir
enforce all policies after any modification
@ fReversed
contains at least one direct range
TSignedSeqPos GetFirstPosBySecondPos(position_type pos, ESearchDirection dir=eNone) const
const TInsertions & GetInsertions() const
Each insertion shows where the 'first' sequence has a gap while the 'second' sequence has the inserti...
vector< TAlignRange > TInsertions
const_iterator end() const
void AddInsertion(const TAlignRange &r)
void AddInsertions(const TInsertions &insertions)
CAlignRange Represents an element of pairwise alignment of two sequences.
Default IAlnSeqId implementation based on CSeq_id_Handle.
Options for different alignment manager operations.
@ eMergeAllSeqs
Merge all sequences (greedy algo).
@ ePreserveRows
Preserve all rows as they were in the input (e.g.
@ eQuerySeqMergeOnly
Only put the query seq on same row (input order is not significant).
@ fUseAnchorAsAlnSeq
Use the anchor sequence as the alignment sequence.
@ fAllowTranslocation
Allow translocations on the same row.
@ fSkipSortByScore
In greedy algos, skip sorting input alignments by score thus allowing for user-defined sort order.
@ fAnchorRowFirst
Store anchor row in the first pairwise alignment (by default it's stored in the last one).
@ fTruncateOverlaps
Truncate overlapping ranges.
@ fIgnoreInsertions
Do not collect and store insertions (gaps on the anchor).
@ fAllowMixedStrand
Allow mixed strands on the same row.
Query-anchored alignment can be 2 or multi-dimentional.
const TPairwiseAlnVector & GetPairwiseAlns(void) const
The vector of pairwise alns.
vector< CRef< CPairwiseAln > > TPairwiseAlnVector
const TAlnSeqIdIRef & GetId(TDim row) const
Seq ids of the rows.
TDim GetDim(void) const
How many rows.
void SetAnchorRow(TDim anchor_row)
Modify anchor row (never do this unless you are creating a new alignment and know what you're doing).
TPairwiseAlnVector & SetPairwiseAlns(void)
Modify pairwise alns.
void SetScore(int score)
Set the total score.
TDim GetAnchorRow(void) const
Which is the anchor row?
int GetScore(void) const
What is the total score?
const TAlnSeqIdIRef & GetAnchorId(void) const
What is the seq id of the anchor?
void SetDim(TDim dim)
Modify the number of rows.
bool x_ValidNeighboursOnSecondDim(const CPairwiseAln::TAlnRng &left, const CPairwiseAln::TAlnRng &right)
const TPairwiseAlnVector & GetPairwiseAlns() const
bool x_CanInsertRng(CPairwiseAln &a, const CPairwiseAln::TAlnRng &r)
void x_TruncateOverlaps(CRef< CPairwiseAln > &addition)
size_t m_NumberOfDirectAlns
bool x_ValidNeighboursOnFirstDim(const CPairwiseAln::TAlnRng &left, const CPairwiseAln::TAlnRng &right)
const CAlnUserOptions::TMergeFlags m_MergeFlags
void SortInsertions(void)
const CAlnUserOptions::TMergeFlags & GetMergedFlags() const
CMergedPairwiseAln(const CAlnUserOptions::TMergeFlags &merge_flags)
void x_AddPairwise(const CPairwiseAln &addition)
void insert(const CRef< CPairwiseAln > &pairwise)
CAnchoredAln::TPairwiseAlnVector TPairwiseAlnVector
TPairwiseAlnVector m_PairwiseAlns
A pairwise aln is a collection of ranges for a pair of rows.
const TAlnSeqIdIRef & GetFirstId(void) const
Get first sequence id.
const TAlnSeqIdIRef & GetSecondId(void) const
Get second sequence id.
std::ofstream out("events_result.xml")
main entry point for tests
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
element_type * get(void) const
Get pointer.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
#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.
bool Empty(void) const THROWS_NONE
Check if CRef is empty â not pointing to any object, which means having a null value.
position_type GetFirstToOpen(void) const
position_type GetFirstTo(void) const
position_type GetSecondFrom(void) const
void SetDirect(bool direct=true)
TThisType & SetFirstFrom(position_type from)
void SetFirstDirect(bool direct=true)
position_type GetFirstFrom(void) const
position_type GetSecondToOpen(void) const
position_type GetLength(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
@ eCurrent
Use current time. See also CCurrentTime.
constexpr auto sort(_Init &&init)
Defines: CTimeFormat - storage class for time format.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
vector< CRef< CAnchoredAln > > TAnchoredAlnVec
Collection of anchored alignments.
#define row(bind, expected)
Compare alignments by score.
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