1 #ifndef ALGO_ALIGN_UTIL_COMPARTMENT_FINDER__HPP
2 #define ALGO_ALIGN_UTIL_COMPARTMENT_FINDER__HPP
145 for(
size_t i = 0;
i <
m_gaps->size(); ++
i) {
146 TCoord gfrom = (*m_gaps)[
i].first;
147 TCoord gto = (*m_gaps)[
i].second;
148 if( gfrom < to && from < gto ) {
160 const vector<pair<TCoord, TCoord> > *
m_gaps;
184 typename THitRefs::const_iterator finish,
268 size_t Run(
bool cross_filter =
false);
401 typename THitRefs::iterator ihr,
402 typename THitRefs::iterator ihr_e,
404 size_t min_compartment_hit_len);
438 bool cross_filter =
false);
459 typename THitRefs::iterator finish,
463 bool cross_filter =
false,
CScope *scope =
NULL,
464 const vector<pair<TCoord, TCoord> > *gaps =
NULL);
474 void Run(
typename THitRefs::iterator start,
475 typename THitRefs::iterator finish,
CScope *scope =
NULL,
476 const vector<pair<TCoord, TCoord> > *gaps =
NULL);
520 size_t valid_count (0);
525 pair<size_t, size_t> rv (
m_pending.size(), valid_count);
565 TCoord min_singleton_matches,
bool cross_filter);
608 if(m_members.size()) {
609 return m_members.front()->GetSubjStrand();
614 "Strand requested on an empty compartment" );
621 typename THitRefs::const_iterator start,
622 typename THitRefs::const_iterator finish,
651 qmax (ph->GetQueryMax());
653 return acm + ph->GetIdentity() * ((
m_Finish = qmax) - qmin + 1);
657 return acm + ph->GetIdentity() * ((
m_Finish = qmax) - finish0);
678 THitComparator sorter (THitComparator::eQueryMin);
679 stable_sort(hitrefs.begin(), hitrefs.end(), sorter);
681 const double rv (accumulate(hitrefs.begin(), hitrefs.end(), 0.0,
690 const double kMinusInf (-1e12);
692 m_compartments.clear();
693 const int dimhits = m_hitrefs.size();
703 stable_sort(m_hitrefs.begin(), m_hitrefs.end(),
704 THitComparator(THitComparator::eSubjMaxQueryMax));
712 typedef vector<SHitStatus> THitData;
713 THitData hitstatus (dimhits);
715 const TCoord subj_min_global (m_hitrefs.front()->GetSubjMin());
718 for(
int i (0);
i < dimhits; ++
i) {
721 const double identity (h->GetIdentity());
723 h->GetQueryMin(), h->GetQueryMax(),
724 h->GetSubjMin(), h->GetSubjMax()
729 cerr << endl << *h << endl;
732 double best_ext_score (kMinusInf);
735 double best_open_score (identity*(hbox[1] - hbox[0] + 1) - m_penalty);
736 int i_best_open (-1);
738 if(hbox[2] + m_max_overlap > m_hitrefs[i_bestsofar]->GetSubjMax()) {
740 const double score_open (identity*(hbox[1] - hbox[0] + 1)
741 + hitstatus[i_bestsofar].m_score
744 if(score_open > best_open_score) {
745 best_open_score = score_open;
746 i_best_open = i_bestsofar;
751 for(
int j (
i - 1); j >= 0; --j) {
753 const double score_open (identity * (hbox[1] - hbox[0] + 1)
754 + hitstatus[j].m_score
757 if(score_open > best_open_score
758 && hbox[2] + m_max_overlap > m_hitrefs[j]->GetSubjMax())
760 best_open_score = score_open;
766 for(
int j =
i; j >= 0; --j) {
773 phcbox[0] = phc->GetQueryMin();
774 phcbox[1] = phc->GetQueryMax();
775 phcbox[2] = phc->GetSubjMin();
776 phcbox[3] = phc->GetSubjMax();
779 cerr <<
'\t' << *phc << endl;
784 cerr <<
"\t[Dummy]" << endl;
797 if( ( phcbox[1] < hbox[1] && phcbox[0] < hbox[0] )
798 && phcbox[2] <= hbox[2]
801 if(hbox[0] <= phcbox[1] &&
802 hbox[2] + phcbox[1] - hbox[0] >= phcbox[3]) {
805 s0 = hbox[2] + phcbox[1] - hbox[0];
807 else if(phcbox[3] >= hbox[2]) {
810 q0 = hbox[1] - (hbox[3] - s0);
817 subj_space = s0 - phcbox[3] - 1;
824 good = (subj_space <=
int(m_intron_max))
825 && (s0 < hbox[3] && q0 < hbox[1]);
829 if( phcbox[3] <= hbox[2] ) {
830 if( ( m_prec_gap_info && m_prec_gap_info->IntersectsNonBridgeableGap(phcbox[3], hbox[2]) ) ||
831 ( m_gap_info && m_gap_info->IntersectsNonBridgeableGap(phcbox[3], hbox[2]) ) ) {
838 intron_start = phcbox[3];
845 const double jscore (hitstatus[j].m_score);
846 const double intron_penalty ((subj_space > 0)?
850 const double ext_score (jscore +
851 identity * (hbox[1] - q0 + 1) + intron_penalty);
853 if(ext_score > best_ext_score) {
854 best_ext_score = ext_score;
858 cerr <<
"\tGood for extension with score = " << ext_score << endl;
867 if(best_ext_score > best_open_score) {
869 hit_type = SHitStatus::eExtension;
870 prev_hit = i_best_ext;
871 best_score = best_ext_score;
875 hit_type = SHitStatus::eOpening;
876 prev_hit = i_best_open;
877 best_score = best_open_score;
880 hitstatus[
i].m_type = hit_type;
881 hitstatus[
i].m_prev = prev_hit;
882 hitstatus[
i].m_score = best_score;
884 if(best_score > hitstatus[i_bestsofar].m_score) {
889 cerr <<
"Status = " << ((hit_type == SHitStatus::eOpening)?
"Open":
"Extend")
890 <<
'\t' << best_score << endl;
892 cerr <<
"[Dummy]" << endl;
895 cerr << *(m_hitrefs[prev_hit]) << endl;
901 cerr <<
"\n\n--- BACKTRACE ---\n";
906 const double score_best (hitstatus[i_bestsofar].m_score);
907 const double min_matches (m_MinSingletonMatches < m_MinMatches?
908 m_MinSingletonMatches: m_MinMatches);
910 vector<bool> comp_status;
911 if(score_best + m_penalty >= min_matches) {
914 bool new_compartment (
true);
918 if(new_compartment) {
920 const double mp (GetTotalMatches<THit>(hitrefs));
924 m_compartments.back().SetMembers() = hitrefs;
925 comp_status.push_back(mp >= m_MinMatches);
929 new_compartment =
false;
931 hitrefs.push_back(m_hitrefs[
i]);
934 cerr << *(m_hitrefs[
i]) << endl;
937 if(hitstatus[
i].m_type == SHitStatus::eOpening) {
938 new_compartment =
true;
940 i = hitstatus[
i].m_prev;
943 const double mp (GetTotalMatches<THit>(hitrefs));
945 bool status ( ( m_compartments.size() == 0 && mp >= m_MinSingletonMatches )
946 || mp >= m_MinMatches );
948 m_compartments.back().SetMembers() = hitrefs;
949 comp_status.push_back(status);
953 if(cross_filter && m_compartments.size()) {
955 const TCoord kMinCompartmentHitLength (8);
958 for(
size_t icn (m_compartments.size()), ic (0); ic < icn; ++ic) {
962 size_t nullified (0);
963 for(
int in (hitrefs.size()),
i (
in - 1);
i > 0; --
i) {
966 while(j1 <
in && hitrefs[j1].IsNull()) ++j1;
967 if(j1 ==
in)
continue;
974 const TCoord * box1o (h1->GetBox());
975 TCoord box1 [4] = {box1o[0], box1o[1], box1o[2], box1o[3]};
976 const TCoord * box2o (h2->GetBox());
977 TCoord box2 [4] = {box2o[0], box2o[1], box2o[2], box2o[3]};
979 const int qd (box1[1] - box2[0] + 1);
980 const int sd (box1[3] - box2[2] + 1);
981 if(qd > sd && qd > 0) {
983 if(box2[0] <= box1[0] + kMinCompartmentHitLength) {
985 #ifdef ALGOALIGNUTIL_COMPARTMENT_FINDER_KEEP_TERMINII
987 TCoord new_coord (box1[0] + (box1[1] - box1[0])/2);
988 if(box1[0] + 1 <= new_coord) {
994 h1->Modify(1, new_coord);
1004 h1->Modify(1, box2[0] - 1);
1007 if(box2[1] <= box1[1] + kMinCompartmentHitLength) {
1009 #ifdef ALGOALIGNUTIL_COMPARTMENT_FINDER_KEEP_TERMINII
1011 TCoord new_coord (box2[0] + (box2[1] - box2[0])/2);
1012 if(box2[1] >= new_coord + 1) {
1016 new_coord = box2[1];
1018 h2->Modify(0, new_coord);
1028 h2->Modify(0, box1[1] + 1);
1033 if(box2[2] <= box1[2] + kMinCompartmentHitLength) {
1036 TCoord new_coord (box1[2] + (box1[3] - box1[2])/2);
1037 if(box1[2] + 1 <= new_coord) {
1041 new_coord = box1[2];
1043 h1->Modify(3, new_coord);
1051 h1->Modify(3, box2[2] - 1);
1054 if(box2[3] <= box1[3] + kMinCompartmentHitLength) {
1057 TCoord new_coord (box2[2] + (box2[3] - box2[2])/2);
1058 if(box2[3] >= new_coord + 1) {
1062 new_coord = box2[3];
1065 h2->Modify(2, new_coord);
1073 h2->Modify(2, box1[3] + 1);
1079 hitrefs.erase(
remove_if(hitrefs.begin(), hitrefs.end(),
1085 #define ALGO_ALIGN_COMPARTMENT_FINDER_USE_FULL_XFILTERING
1086 #ifdef ALGO_ALIGN_COMPARTMENT_FINDER_USE_FULL_XFILTERING
1088 typename THitRefs::iterator ihr_b (m_hitrefs.begin()),
1089 ihr_e(m_hitrefs.end()), ihr (ihr_b);
1091 stable_sort(ihr_b, ihr_e, THitComparator(THitComparator::eSubjMinSubjMax));
1094 for(
int icn (m_compartments.size()), ic (icn - 1); ic >= 0; --ic) {
1099 if(hitrefs.size() < 3) {
1104 (*ii)->SetScore(- (*ii)->GetScore());
1106 hitrefs.front()->SetEValue(-1);
1107 hitrefs.back()->SetEValue(-1);
1110 const TCoord comp_subj_min (hitrefs.back()->GetSubjStart());
1111 const TCoord comp_subj_max (hitrefs.front()->GetSubjStop());
1112 while(ihr != ihr_e && ((*ihr)->GetSubjStart() < comp_subj_min
1113 || (*ihr)->GetScore() < 0))
1118 if(ihr == ihr_e)
break;
1119 if((*ihr)->GetSubjStart() > comp_subj_max)
continue;
1120 typename THitRefs::iterator ihrc_b (ihr);
1122 typename THitRefs::iterator ihrc_e (ihr);
1123 while(ihrc_e != ihr_e && ((*ihrc_e)->GetSubjStart() < comp_subj_max
1124 || (*ihrc_e)->GetScore() < 0))
1129 size_t nullified (sx_XFilter(hitrefs, ihrc_b, ihrc_e, 1,
1130 kMinCompartmentHitLength));
1131 stable_sort(ihrc_b, ihrc_e, THitComparator (THitComparator::eQueryMinQueryMax));
1133 nullified += sx_XFilter(hitrefs, ihrc_b, ihrc_e, 0,
1134 kMinCompartmentHitLength);
1139 hitrefs.erase(
remove_if(hitrefs.begin(), hitrefs.end(),
1145 for(
int icn (m_compartments.size()), ic (icn - 1); ic >= 0; --ic) {
1150 const double score ((*ii)->GetScore());
1152 (*ii)->SetScore(-score);
1154 const double eval ((*ii)->GetEValue());
1156 (*ii)->SetEValue(0);
1164 for(
size_t i (0),
in (m_compartments.size());
i <
in; ++
i) {
1165 if(comp_status[
i] ==
false) {
1167 THitRefs & hitrefs (m_compartments[
i].SetMembers());
1170 hr->SetScore(-hr->GetScore());
1175 return m_compartments.size();
1179 template<
class THit>
1182 typename THitRefs::iterator ihr,
1183 typename THitRefs::iterator ihr_e,
1185 size_t min_compartment_hit_len)
1187 size_t nullified (0);
1188 for(
int in (hitrefs.size()),
i (
in - 2);
i > 0 && ihr != ihr_e; --
i) {
1191 if(h1.
IsNull())
continue;
1193 const TCoord * box1o (h1->GetBox());
1194 TCoord box1 [4] = {box1o[0], box1o[1], box1o[2], box1o[3]};
1197 for(; ihr != ihr_e; ++ihr) {
1200 if(hr.
IsNull())
continue;
1201 if(hr->GetScore() > 0 && hr->GetStop(w) >= box1[2*w]) {
1211 TCoord ls0 (box1[2*w+1] + 1), cursegmax (0);
1212 TCoord segmax_start(box1[2*w]), segmax_stop(box1[2*w+1]);
1214 if(box1[2*w] < (*ihr)->GetStart(w)) {
1216 segmax_start = ls0 = box1[2*w];
1217 segmax_stop = (*ihr)->GetStart(w) - 1;
1218 cursegmax = segmax_stop - segmax_start + 1;
1222 TCoord shrsmax ((*ihr)->GetStop(w));
1223 for(++ihr; ihr != ihr_e; ++ihr) {
1226 if(hr.
IsNull() || hr->GetScore() < 0) {
1230 const TCoord hrs0 (hr->GetStart(w));
1231 if(hrs0 > box1[2*w+1]) {
1232 segmax_stop = box1[2*w+1];
1236 if(hrs0 > shrsmax) {
1237 segmax_stop = hrs0 - 1;
1241 const TCoord hrs1 (hr->GetStop(w));
1242 if(hrs1 > shrsmax) {
1247 if(shrsmax < box1[2*w+1]) {
1248 segmax_start = ls0 = shrsmax + 1;
1249 cursegmax = segmax_stop - segmax_start + 1;
1253 if(ls0 > box1[2*w+1]) {
1260 for(; ihr != ihr_e; ++ihr) {
1263 if(hr.
IsNull() || hr->GetScore() < 0) {
1267 const TCoord hrs0 (hr->GetStart(w));
1268 if(hrs0 > box1[2*w+1]) {
1269 if(ls0 <= box1[2*w+1] && box1[2*w+1] + 1 - ls0 > cursegmax) {
1271 segmax_stop = box1[2*w+1];
1272 cursegmax = segmax_stop - segmax_start + 1;
1278 if(hrs0 - ls0 > cursegmax) {
1280 segmax_stop = hrs0 - 1;
1281 cursegmax = segmax_stop - segmax_start + 1;
1284 ls0 = hr->GetStop(w) + 1;
1286 else if(hr->GetStop(w) + 1 > ls0) {
1287 ls0 = hr->GetStop(w) + 1;
1291 if(box1[2*w+1] > ls0 + cursegmax) {
1293 segmax_stop = box1[2*w+1];
1294 cursegmax = segmax_stop - segmax_start + 1;
1297 if(cursegmax < min_compartment_hit_len) {
1304 if(box1[2*w] < segmax_start) {
1305 h1->Modify(2 * w, segmax_start);
1308 if(segmax_stop < box1[2*w+1]) {
1309 h1->Modify(2 * w + 1, segmax_stop);
1313 if(ihr == ihr_e)
break;
1320 template<
class THit>
1324 if(m_compartments.size()) {
1326 return &m_compartments[m_iter++];
1334 template<
class THit>
1337 for(
size_t i = 0, dim = m_compartments.size();
i < dim; ++
i) {
1338 m_compartments[
i].UpdateMinMax();
1341 stable_sort(m_compartments.begin(), m_compartments.end(),
1345 template<
class THit>
1349 const size_t dim = m_compartments.size();
1350 if(m_iter == -1 || m_iter >=
int(dim)) {
1355 return &m_compartments[m_iter++];
1360 template<
class THit>
1363 TCoord min_singleton_matches,
1366 x_Init(comp_penalty, min_matches, min_singleton_matches, cross_filter);
1370 template<
class THit>
1372 typename THitRefs::iterator istart,
1373 typename THitRefs::iterator ifinish,
1376 TCoord min_singleton_matches,
1379 const vector<pair<TCoord, TCoord> > *gaps)
1381 x_Init(comp_penalty, min_matches, min_singleton_matches, cross_filter);
1382 Run(istart, ifinish, scope, gaps);
1386 template<
class THit>
1389 TCoord min_singleton_matches,
1392 m_Penalty = comp_penalty;
1393 m_MinMatches = min_matches;
1394 m_MinSingletonMatches = min_singleton_matches;
1395 m_CrossFiltering = cross_filter;
1401 template<
class THit>
1403 typename THitRefs::iterator ifinish,
1405 const vector<pair<TCoord, TCoord> > *gaps)
1408 if(istart == ifinish)
return;
1413 typename THitRefs::iterator ib = istart, ie = ifinish, ii = ib,
1416 THitComparator sorter (THitComparator::eSubjStrand);
1417 stable_sort(ib, ie, sorter);
1419 TCoord minus_subj_min = kMax_TCoord, minus_subj_max = 0;
1420 for(ii = ib; ii != ie; ++ii) {
1421 if((*ii)->GetSubjStrand()) {
1426 if((*ii)->GetSubjMin() < minus_subj_min) {
1427 minus_subj_min = (*ii)->GetSubjMin();
1429 if((*ii)->GetSubjMax() > minus_subj_max) {
1430 minus_subj_max = (*ii)->GetSubjMax();
1441 gapi.
Flip(minus_subj_min, minus_subj_max);
1442 prec_gapi.
Flip(minus_subj_min, minus_subj_max);
1443 for(ii = ib; ii != iplus_beg; ++ii) {
1445 const typename THit::TCoord s0 = minus_subj_min + minus_subj_max
1446 - (*ii)->GetSubjMax();
1447 const typename THit::TCoord s1 = minus_subj_min + minus_subj_max
1448 - (*ii)->GetSubjMin();
1449 (*ii)->SetSubjStart(s0);
1450 (*ii)->SetSubjStop(s1);
1459 finder.
Run(m_CrossFiltering);
1462 for(ii = ib; ii != iplus_beg; ++ii) {
1464 const typename THit::TCoord s0 = minus_subj_min + minus_subj_max
1465 - (*ii)->GetSubjMax();
1466 const typename THit::TCoord s1 = minus_subj_min + minus_subj_max
1467 - (*ii)->GetSubjMin();
1468 (*ii)->SetSubjStart(s1);
1469 (*ii)->SetSubjStop(s0);
1472 x_Copy2Pending(finder);
1485 finder.
Run(m_CrossFiltering);
1486 x_Copy2Pending(finder);
1491 template<
class THit>
1503 if(compartment->GetMembers().size() > 0) {
1508 for(
THitRef ph (compartment->GetFirst()); ph; ph = compartment->GetNext())
1513 const TCoord* box = compartment->GetBox();
1514 m_ranges.push_back(box[0]);
1515 m_ranges.push_back(box[1]);
1516 m_ranges.push_back(box[2]);
1517 m_ranges.push_back(box[3]);
1519 m_strands.push_back(compartment->GetStrand());
1520 m_status.push_back(compartment->GetFirst()->GetScore() > 0);
1526 template<
class THit>
1530 return GetNext(compartment);
1534 template<
class THit>
1537 compartment.clear();
1538 if(m_iter < m_pending.size()) {
1539 compartment = m_pending[m_iter++];
1548 template<
class THit>
1557 if(m_pending.size()) {
1558 if(m_pending.front().size()) {
1559 const THit & h (*m_pending.front().front());
1567 for(
size_t i(0), idim(m_pending.size());
i < idim; ++
i) {
1572 TCoord range_min (
i > 0 && m_strands[
i-1] == m_strands[
i]
1576 TCoord range_max (
i + 1 < idim && m_strands[
i+1] == m_strands[
i]
1589 range_max, subj_strand));
1590 bounds.push_back(seq_loc);
1596 const THit& h (**ii);
1600 if (transcript.empty()) {
1602 sa3->
SetSegs().SetStd().push_back(sg);
1608 sg->SetLoc().push_back(query_loc);
1609 sg->SetLoc().push_back(subj_loc);
1615 ds.
SetIds().push_back(seqid_query);
1616 ds.
SetIds().push_back(seqid_subj);
1618 sas2_data.push_back(sa3);
1622 sas1_data.push_back(sa2);
User-defined methods of the data storage class.
void remove_if(Container &c, Predicate *__pred)
TCoord GetQueryStart(void) const
const TId & GetSubjId(void) const
TCoord GetQueryMin(void) const
TCoord GetSubjStart(void) const
const TId & GetQueryId(void) const
TCoord GetSubjMin(void) const
TCoord GetQueryMax(void) const
TCoord GetSubjMax(void) const
const TTranscript & GetTranscript(void) const
void Run(typename THitRefs::iterator start, typename THitRefs::iterator finish, CScope *scope=NULL, const vector< pair< TCoord, TCoord > > *gaps=NULL)
Execute: identify compartments.
bool GetStrand(size_t i) const
void SetMaxIntron(TCoord mi)
Assign the maximum intron length, in base pairs.
bool GetFirst(THitRefs &compartment)
Initialize iteration over the results.
CRef< objects::CSeq_align_set > AsSeqAlignSet(void) const
Retrieve all valid compartments in a seq-align-set.
TCoord m_MinSingletonMatches
void x_Init(TCoord comp_penalty, TCoord min_matches, TCoord min_singleton_matches, bool cross_filter)
void Get(size_t idx, THitRefs &compartment) const
Retrieve a compartment by index.
const TCoord * GetBox(size_t i) const
TCompartmentFinder::THitRefs THitRefs
CCompartmentAccessor(TCoord comp_penalty_bps, TCoord min_matches, TCoord min_singleton_matches=numeric_limits< TCoord >::max(), bool cross_filter=false)
Construct the object and assign the parameters of the algorithm.
TCompartmentFinder::TCoord TCoord
void SetMaxOverlap(TCoord max_overlap)
Assign the maximum length for compartments to overlap on the subject.
vector< TCoord > m_ranges
vector< THitRefs > m_pending
bool GetNext(THitRefs &compartment)
Proceed with iteration over the results.
bool GetStatus(size_t i) const
TCoord GetMaxIntron(void) const
Retrieve the maximum intron length, in base pairs.
pair< size_t, size_t > GetCounts(void) const
Retrieve the compartment counts.
CCompartmentFinder< THit > TCompartmentFinder
void x_Copy2Pending(TCompartmentFinder &finder)
Individual compartment representation.
const THitRef GetNext(void) const
Retrieve the next member.
void AddMember(const THitRef &hitref)
Add a new member into the compartment.
const TCoord * GetBox(void) const
Retrieve the compartment's box.
const THitRefs & GetMembers(void)
Retrieve compartment's members.
static bool s_PLowerSubj(const CCompartment &c1, const CCompartment &c2)
bool GetStrand(void) const
Retrieve the compartment's strand (true == plus)
void UpdateMinMax(void)
Make sure the compartment's box is up-to-date.
CCompartment(void)
Create an empty compartment.
THitRefs & SetMembers(void)
Assign all members of the compartment.
const THitRef GetFirst(void) const
Retrieve the first member.
void SetMaxIntron(TCoord intr_max)
Set the maximum length of an intron.
static TCoord s_GetDefaultMaxOverlap(void)
Retrieve the default compartment overlap behaviour (no overlap).
static TCoord s_GetDefaultMinCoverage(void)
Retrieve the default minimum coverage, in base pairs.
void SetMinMatches(TCoord min_matches)
Set the minimum matching residues per compartment.
void SetPenalty(TCoord penalty)
Set the penalty to open a compartment.
vector< CCompartment > m_compartments
static TCoord s_GetDefaultPenalty(void)
Retrieve the default compartment penalty, in base pairs.
size_t Run(bool cross_filter=false)
Identify compartments.
vector< THitRef > THitRefs
CCompartment * GetNext(void)
TCoord m_MinSingletonMatches
CPrecalcGapInfo< THit > * m_prec_gap_info
static TCoord s_GetDefaultMaxIntron(void)
Retrieve the default maximum length of an intron.
void SetMinSingletonMatches(TCoord min_matches)
Set the minimum matching residues per singleton compartment.
CCompartmentFinder(typename THitRefs::const_iterator start, typename THitRefs::const_iterator finish, CGapInfo< THit > *gap_info=NULL, CPrecalcGapInfo< THit > *prec_gap_info=NULL)
Create the object from the complete set of local alignments (hits) between the transcript and the gen...
static bool s_PNullRef(const THitRef &hr)
CGapInfo< THit > * m_gap_info
void OrderCompartments(void)
Order compartments by lower subj coordinate.
void SetMaxOverlap(TCoord max_overlap)
Set compartment overlap behaviour.
static size_t sx_XFilter(THitRefs &hitrefs, typename THitRefs::iterator ihr, typename THitRefs::iterator ihr_e, Uint1 w, size_t min_compartment_hit_len)
CCompartment * GetFirst(void)
void FromTranscript(TSeqPos query_start, ENa_strand query_strand, TSeqPos subj_start, ENa_strand subj_strand, const string &transcript)
Initialize from pairwise alignment transcript (a string representation produced by CNWAligner)
void Flip(TCoord subj_min, TCoord subj_max)
CGapInfo(const CSeq_id &id, CScope *scope)
CConstRef< CSeqMap > m_seq_map
bool IntersectsNonBridgeableGap(TCoord from, TCoord to)
CPrecalcGapInfo(const vector< pair< TCoord, TCoord > > *gaps)
const vector< pair< TCoord, TCoord > > * m_gaps
bool IntersectsNonBridgeableGap(TCoord from, TCoord to)
void Flip(TCoord subj_min, TCoord subj_max)
CQueryMatchAccumulator(void)
double operator()(double acm, CRef< THit > ph)
const double kPenaltyPerIntronPos
double GetTotalMatches(const typename CCompartmentFinder< THit >::THitRefs &hitrefs0)
const double kPenaltyPerIntronBase
IMPLEMENTATION.
CSplign::THitRefs THitRefs
static const char * bounds[]
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
const CSeqMap & GetSeqMap(void) const
Get sequence map.
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
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.
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
uint8_t Uint1
1-byte (8-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void Run(void)
Enter the main loop.
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.
list< CRef< CSeq_loc > > TBounds
list< CRef< CSeq_align > > Tdata
TIds & SetIds(void)
Assign a value to Ids data member.
TBounds & SetBounds(void)
Assign a value to Bounds data member.
@ eType_disc
discontinuous alignment
ENa_strand
strand of nucleic acid
unsigned int
A callback function used to compare two keys in a database.
std::istream & in(std::istream &in_, double &x_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
SHitStatus(EType type, int prev, double score)