is_intersecting =
50 r1.first.IntersectingWith(
r2.first);
56<<
": is_intersecting = " 57<< (is_intersecting ?
"true":
"false")
61 returnis_intersecting;
65 constpair<TSeqRange, TSeqRange>&
r2)
67 boolis_intersecting =
68 r1.second.IntersectingWith(
r2.second);
74<<
": is_intersecting = " 75<< (is_intersecting ?
"true":
"false")
79 returnis_intersecting;
83 constpair<TSeqRange, TSeqRange>&
r2,
86 boolis_consistent =
false;
88is_consistent = (
r1.first <=
r2.first &&
r1.second <=
r2.second) ||
89(
r2.first <=
r1.first &&
r2.second <=
r1.second);
92is_consistent = (
r1.first <=
r2.first &&
r2.second <=
r1.second) ||
93(
r2.first <=
r1.first &&
r1.second <=
r2.second);
107<<
": is_consistent = " 108<< (is_consistent ?
"true":
"false")
109<<
" r1.first <= r2.first: " 110<< (
r1.first <=
r2.first ?
"true":
"false")
111<<
" r1.second <= r2.second: " 112<< (
r1.second <=
r2.second ?
"true":
"false")
116 returnis_consistent;
121 constpair<TSeqRange, TSeqRange>&
r2,
126 if(
r1.first.GetTo() <
r2.first.GetFrom()) {
127diff +=
r2.first.GetFrom() -
r1.first.GetTo();
129 else if(
r2.first.GetTo() <
r1.first.GetFrom()) {
130diff +=
r1.first.GetFrom() -
r2.first.GetTo();
133 if(
r1.second.GetTo() <
r2.second.GetFrom()) {
134diff +=
r2.second.GetFrom() -
r1.second.GetTo();
136 else if(
r2.second.GetTo() <
r1.second.GetFrom()) {
137diff +=
r1.second.GetFrom() -
r2.second.GetTo();
161 #ifdef _VERBOSE_DEBUG 168<<
": diff = "<< diff
176 typedefpair<TSeqRange, TSeqRange>
TRange;
186 if(
r1.first.first !=
r2.first.first) {
187 return(
r1.first.first <
r2.first.first);
189 if(
r1.first.second !=
r2.first.second) {
190 return(
r1.first.second <
r2.first.second);
208 r1.first.second.GetLength());
210 r2.first.second.GetLength());
227 return r1.second->GetSeqRange(1) <
r2.second->GetSeqRange(1);
236 intscores[2] = {0, 0};
240 if(scores[0] > scores[1]) {
243 if(scores[1] > scores[0]) {
256 return r1.second->GetSeqRange(1) <
r2.second->GetSeqRange(1);
265 doublescores[2] = {0.0, 0.0};
268 if(scores[0] == scores[1]) {
270 r1.first.second.GetLength());
272 r2.first.second.GetLength());
276 if(scores[0] > scores[1]) {
279 if(scores[1] > scores[0]) {
292 return r1.second->GetSeqRange(1) <
r2.second->GetSeqRange(1);
303 if(al1_len > al2_len) {
306 if(al2_len > al1_len) {
328 intscores[2] = {0, 0};
331 returnscores[0] > scores[1];
340 doublescores[2] = {0.0, 0.0};
343 if(scores[0] == scores[1]) {
346 returnscores[0] > scores[1];
355 return&*it1 < &*it2;
388 floatdiff_len_filter)
393 typedefpair<CSeq_id_Handle, ENa_strand> TIdStrand;
394 typedefpair<TIdStrand, TIdStrand> TIdPair;
396TAlignments alignments;
442TIdPair p(TIdStrand(qid, q_strand), TIdStrand(sid, s_strand));
443alignments[p].push_back(*it);
446 typedefpair<SCompartScore, CRef<CSeq_align_set> > TCompartScore;
447vector<TCompartScore> scored_compartments;
452 constTIdPair& id_pair = align_it->first;
456vector< CRef<CSeq_align> >& aligns = align_it->second;
467 #ifdef _VERBOSE_DEBUG 469cerr <<
"ids: "<< id_pair.first.first <<
" x " 470<< id_pair.second.first << endl;
472cerr <<
" sort by score"<< endl;
475cerr <<
" sort by percent identity"<< endl;
478cerr <<
" sort by size"<< endl;
483<< (*it)->GetSeqRange(0) <<
", " 486<< (*it)->GetSeqRange(1) <<
", " 498vector<TAlignRange> align_ranges;
501 TSeqRangeq_range = (*iter)->GetSeqRange(0);
502 TSeqRanges_range = (*iter)->GetSeqRange(1);
507 #ifdef _VERBOSE_DEBUG 510<< id_pair.first.first <<
"/"<< q_strand
512<< id_pair.second.first <<
"/"<< s_strand
514vector<TAlignRange>::const_iterator prev_it = align_ranges.end();
515 ITERATE(vector<TAlignRange>, it, align_ranges) {
517<< it->first.first <<
", " 518<< it->first.second <<
")" 519<<
" ["<< it->first.first.GetLength()
520<<
", "<< it->first.second.GetLength() <<
"]";
521 if(prev_it != align_ranges.end()) {
522cerr <<
" consistent=" 524q_strand, s_strand) ?
"true":
"false");
541 std::sort(align_ranges.begin(), align_ranges.end(),
545 std::sort(align_ranges.begin(), align_ranges.end(),
549 std::sort(align_ranges.begin(), align_ranges.end(),
553list< TAlignRangeMultiSet > compartments;
562list<TAlignRangeMultiSet>::iterator best_compart =
567compart_it, compartments) {
570compart_it->lower_bound(*it);
573 boolis_consistent =
false;
574 boolis_intersecting_query =
false;
575 boolis_intersecting_subject =
false;
576 if(place == compart_it->end()) {
580is_intersecting_query =
582is_intersecting_subject =
592 if(place == compart_it->begin()) {
595is_intersecting_query =
597is_intersecting_subject =
609is_intersecting_query =
611is_intersecting_subject =
622is_intersecting_query |=
624is_intersecting_subject |=
633q_strand, s_strand));
637 #ifdef _VERBOSE_DEBUG 638 floatdiff_len_ratio = double(diff) / it->second->GetAlignLength(
false);
639cerr <<
" comp_id="<< comp_id
640<<
" is_consistent="<< (is_consistent ?
"true":
"false")
641<<
" is_intersecting_query="<< (is_intersecting_query ?
"true":
"false")
642<<
" is_intersecting_subject="<< (is_intersecting_subject ?
"true":
"false")
643<<
" allow intersect_query=" 645<<
" allow intersect_subject=" 647<<
" allow intersect_both=" 650<<
" best_diff="<< best_diff
651<<
" align_len="<< it->second->GetAlignLength(
false)
652<<
" diff_len_ratio="<< diff_len_ratio
653<<
" filter="<< (diff_len_ratio <= diff_len_filter ?
"pass":
"fail")
657 if( ((is_consistent && !is_intersecting_query && !is_intersecting_subject) ||
660is_intersecting_query ) ||
662is_intersecting_subject ) ||
664is_intersecting_query && is_intersecting_subject )))) &&
666best_compart = compart_it;
672 if( !found || best_compart == compartments.end() ) {
674compartments.back().insert(*it);
677best_compart->insert(*it);
680 #ifdef _VERBOSE_DEBUG 682cerr <<
"compartments: found "<< compartments.size() << endl;
684 ITERATE(list<TAlignRangeMultiSet>, it, compartments) {
686cerr <<
" compartment "<<
count<< endl;
689<<
i->first.first <<
", " 690<<
i->first.second <<
")" 691<<
" ["<<
i->first.first.GetLength()
692<<
", "<<
i->first.second.GetLength() <<
"]" 693<<
" (0x"<<
std::hex<< ((
intptr_t)
i->second.GetPointer()) << std::dec <<
")" 701 #ifdef DEBUG_VERBOSE_OUTPUT 703cerr <<
"found "<< compartments.size() << endl;
705 ITERATE(list<TAlignRangeMultiSet>, it, compartments) {
707cerr <<
" compartment "<<
count<< endl;
710<<
i->first.first <<
", " 711<<
i->first.second <<
")" 712<<
" ["<<
i->first.first.GetLength()
713<<
", "<<
i->first.second.GetLength() <<
"]" 721 #ifdef DEBUG_VERBOSE_OUTPUT 722 size_tcompart_count = 0;
724 ITERATE(list<TAlignRangeMultiSet>, it, compartments) {
725 #ifdef DEBUG_VERBOSE_OUTPUT 742 for(; second_subject_range != it->end()
743&& second_subject_range->first.second
744== it->begin()->first.second; ++second_subject_range);
745 boolreverse_subject = second_subject_range != it->end() &&
746second_subject_range->first.second
747< it->begin()->first.second;
748 TSeqPossubject_end = (reverse_subject
750: it->rbegin()->first) . second.GetTo();
752forward_breaks, backward_breaks;
755 #ifdef _VERBOSE_DEBUG 760 #ifdef _VERBOSE_DEBUG 762<<
i->first.first <<
", " 763<<
i->first.second <<
")" 764<<
" ["<<
i->first.first.GetLength()
765<<
", "<<
i->first.second.GetLength() <<
"]" 769(reverse_subject ? subject_end -
i->first.second.GetTo()
770:
i->first.second.GetFrom());
772(reverse_subject ? subject_end -
i->first.second.GetFrom()
773:
i->first.second.GetTo());
774 #ifdef _VERBOSE_DEBUG 775 if(
i!= it->begin()) {
776cerr <<
"At "<< ++
count<<
" Gap "<<
int(start_point - current_end_point) <<
" on length "<< (current_potential_break - current_end_point) << endl;
779 if(
i!= it->begin() &&
780start_point > current_potential_break)
785 #ifdef _VERBOSE_DEBUG 786cerr <<
"Break! "<< (
count- last_break) <<
" members start_point "<< start_point <<
" current break "<< current_potential_break << endl;
790current_end_point =
max(current_potential_break, end_point);
791current_potential_break = current_end_point +
792diff_len_filter *
i->second->GetAlignLength(
false);
794current_potential_break = current_end_point = INT_MAX;
795 #ifdef _VERBOSE_DEBUG 801 #ifdef _VERBOSE_DEBUG 803<<
i->first.first <<
", " 804<<
i->first.second <<
")" 805<<
" ["<<
i->first.first.GetLength()
806<<
", "<<
i->first.second.GetLength() <<
"]" 810(reverse_subject ? subject_end -
i->first.second.GetTo()
811:
i->first.second.GetFrom());
813(reverse_subject ? subject_end -
i->first.second.GetFrom()
814:
i->first.second.GetTo());
815 #ifdef _VERBOSE_DEBUG 816 if(
i!= it->rbegin()) {
817cerr <<
"At "<< ++
count<<
" Gap "<<
int(current_end_point - end_point) <<
" on length "<< (current_end_point - current_potential_break) << endl;
820 if(
i!= it->rbegin() &&
821end_point < current_potential_break)
826backward_breaks.
insert(breakpoint);
827 #ifdef _VERBOSE_DEBUG 828 if(forward_breaks.count(breakpoint)) {
829cerr <<
"Double after "<< (
count- last_double_break) <<
' ';
830last_double_break =
count;
832cerr <<
"Break! "<< (
count- last_break) <<
" members end_point "<< end_point <<
" current break "<< current_potential_break << endl;
836current_end_point =
min(current_potential_break, start_point);
837current_potential_break = current_end_point -
838diff_len_filter *
i->second->GetAlignLength(
false);
840set_intersection(forward_breaks.
begin(), forward_breaks.
end(),
841backward_breaks.
begin(), backward_breaks.
end(),
842inserter(break_positions, break_positions.
end()),
846 if(break_positions.count(
i)) {
847 #ifdef DEBUG_VERBOSE_OUTPUT 848cerr <<
"compartment "<< compart_count <<
" break at "<<
i->first.first.GetFrom() <<
".."<<
i->first.first.GetTo() << endl;
850TCompartScore sc(score, sas);
851scored_compartments.push_back(sc);
855sas->
Set().push_back(
i->second);
861TCompartScore sc(score, sas);
862scored_compartments.push_back(sc);
869 std::sort(scored_compartments.begin(), scored_compartments.end());
870 ITERATE(vector<TCompartScore>, it, scored_compartments) {
871align_sets.push_back(it->second);
881 typedef constlist <CRef<CSeq_align> > TConstSeqAlignList;
882TConstSeqAlignList& alignments = compartment->
Get();
884 ITERATE(TConstSeqAlignList, al_it, alignments) {
885 len+= (*al_it)->GetAlignLength(
false);
888 ITERATE(TConstSeqAlignList, al_it, alignments) {
889TConstSeqAlignList::const_iterator al_it_next = al_it;
892disc_align_set->
Set().push_back(*al_it);
893 if(al_it_next == alignments.end() ||
894(*al_it)->GetSeqStop(0) + max_gap_len < (*al_it_next)->GetSeqStart(0) ||
895(*al_it)->GetSeqStop(1) + max_gap_len < (*al_it_next)->GetSeqStart(1))
900comp_align->
SetSegs().SetDisc(*disc_align_set);
901aligns.push_back(comp_align);
902disc_align_set.
Reset(0);
bool SameOrientation(ENa_strand a, ENa_strand b)
@ eScore_PercentIdentity_Ungapped
CRange< TSeqPos > GetSeqRange(TDim row) const
GetSeqRange NB: On a Spliced-seg, in case the product-type is protein, these only return the amin par...
bool GetNamedScore(const string &id, int &score) const
Get score.
TSeqPos GetAlignLength(bool include_gaps=true) const
Get the length of this alignment.
parent_type::iterator iterator
parent_type::const_iterator const_iterator
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator end() const
Include a standard set of the NCBI C++ Toolkit most basic headers.
pair< TSeqRange, TSeqRange > TRange
bool IsConsistent(const pair< TSeqRange, TSeqRange > &r1, const pair< TSeqRange, TSeqRange > &r2, ENa_strand s1, ENa_strand s2)
void JoinCompartment(const CRef< CSeq_align_set > &compartment, float gap_ratio, list< CRef< CSeq_align > > &aligns)
bool IsIntersectingQuery(const pair< TSeqRange, TSeqRange > &r1, const pair< TSeqRange, TSeqRange > &r2)
multiset< TAlignRange, SRangesByStart > TAlignRangeMultiSet
pair< TRange, CRef< CSeq_align > > TAlignRange
TSeqPos Difference(const pair< TSeqRange, TSeqRange > &r1, const pair< TSeqRange, TSeqRange > &r2, ENa_strand s1, ENa_strand s2)
void FindCompartments(const list< CRef< CSeq_align > > &aligns, list< CRef< CSeq_align_set > > &align_sets, TCompartOptions options, float diff_len_filter)
bool IsIntersectingSubject(const pair< TSeqRange, TSeqRange > &r1, const pair< TSeqRange, TSeqRange > &r2)
@ fCompart_AllowIntersectionsSubject
@ fCompart_SortByPctIdent
@ fCompart_FilterByDiffLen
@ fCompart_AllowIntersectionsBoth
@ fCompart_AllowIntersectionsQuery
@ fCompart_AllowInconsistentIntersection
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.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
#define REVERSE_ITERATE(Type, Var, Cont)
ITERATE macro to reverse sequence through container elements.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
Tdata & Set(void)
Assign a value to data member.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
void SetType(TType value)
Assign a value to Type data member.
const Tdata & Get(void) const
Get the member data.
@ eType_disc
discontinuous alignment
ENa_strand
strand of nucleic acid
unsigned int
A callback function used to compare two keys in a database.
static void hex(unsigned char c)
constexpr auto sort(_Init &&init)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const sljit_gpr r1
static const sljit_gpr r2
bool operator<(const SCompartScore &o) const
bool operator()(TAlignRangeMultiSet::const_iterator it1, TAlignRangeMultiSet::const_iterator it2) const
bool operator()(const TAlignRange &r1, const TAlignRange &r2) const
bool operator()(const TAlignRange &r1, const TAlignRange &r2) const
bool operator()(const TAlignRange &r1, const TAlignRange &r2) const
bool operator()(const TAlignRange &r1, const TAlignRange &r2) const
bool operator()(const CRef< CSeq_align > &al_ref1, const CRef< CSeq_align > &al_ref2) const
bool operator()(const CRef< CSeq_align > &al_ref1, const CRef< CSeq_align > &al_ref2) const
bool operator()(const CRef< CSeq_align > &al_ref1, const CRef< CSeq_align > &al_ref2) const
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