57 typedef list<T> TypeList;
58 size_t Count = List.size();
61 ITERATE(
typename TypeList, Iter, List) {
70 typedef list<T> TypeList;
71 size_t Count = List.size();
73 double RunningTotal = 0;
74 ITERATE(
typename TypeList, Iter, List) {
75 RunningTotal += ((*Iter - Mean) * (*Iter - Mean))/
double(Count);
78 return sqrt(RunningTotal);
82 void s_CalcDevs(
const list<T>& Values,
T Mean,
double StdDev, list<double>& Devs) {
83 typedef list<T> TypeList;
85 ITERATE(
typename TypeList, Iter, Values) {
86 double Dist =
fabs(
double(*Iter) -
double(Mean));
87 double Dev = (Dist/StdDev);
100 <<
" to " <<
range.Subjt <<
"+"
101 <<
" (" <<
range.AlignId
102 <<
"," <<
range.SegmtId
103 <<
"," <<
range.SplitId <<
")";
132 return (
A.Query ==
B.Query &&
A.Subjt ==
B.Subjt);
136 if(
A.Query.GetFrom() !=
B.Query.GetFrom())
137 return (
A.Query.GetFrom() <
B.Query.GetFrom());
138 else if(
A.Query.GetTo() !=
B.Query.GetTo())
139 return (
A.Query.GetTo() <
B.Query.GetTo());
140 else if(
A.Subjt.GetFrom() !=
B.Subjt.GetFrom())
141 return (
A.Subjt.GetFrom() <
B.Subjt.GetFrom());
142 else if(
A.Subjt.GetTo() !=
B.Subjt.GetTo())
143 return (
A.Subjt.GetTo() <
B.Subjt.GetTo());
145 return A.Strand <
B.Strand;
151 if(
A.Subjt.GetFrom() !=
B.Subjt.GetFrom())
152 return (
A.Subjt.GetFrom() <
B.Subjt.GetFrom());
153 else if(
A.Subjt.GetTo() !=
B.Subjt.GetTo())
154 return (
A.Subjt.GetTo() <
B.Subjt.GetTo());
155 else if(
A.Query.GetFrom() !=
B.Query.GetFrom())
156 return (
A.Query.GetFrom() <
B.Query.GetFrom());
157 else if(
A.Query.GetTo() !=
B.Query.GetTo())
158 return (
A.Query.GetTo() <
B.Query.GetTo());
160 return A.Strand <
B.Strand;
232 ERR_POST(
Info <<
"CEquivRange::CalcRelative:: Got a eWTF ("
233 << *
this <<
") vs (" <<
Check <<
")" );
337 if(
A.Query.GetFrom() >=
B.Query.GetTo() ) {
338 QD =
A.Query.GetFrom() -
B.Query.GetTo();
340 QD =
B.Query.GetFrom() -
A.Query.GetTo();
344 if(
A.Subjt.GetFrom() >=
B.Subjt.GetTo() ) {
345 SD =
A.Subjt.GetFrom() -
B.Subjt.GetTo();
347 SD =
B.Subjt.GetFrom() -
A.Subjt.GetTo();
356 return max(
D, DeltaInt);
363 AQR += EquivIter->Query;
364 ASR += EquivIter->Subjt;
367 BQR += EquivIter->Query;
368 BSR += EquivIter->Subjt;
395 return max(
D, DeltaInt);
401 : x_GAlignId(0), x_GSegmtId(0), x_GSplitId(0)
412 bool MadeCuts =
false;
419 Sources.push_back(*OrigIter);
421 TEquivList::iterator NE;
422 sort(Sources.begin(), Sources.end());
423 NE = unique(Sources.begin(), Sources.end());
424 Sources.erase(NE, Sources.end());
428 Equivs.swap(Sources);
433 typedef vector<TSeqPos> TPointContainer;
435 TPointContainer QueryPoints, SubjtPoints;
436 QueryPoints.reserve(Sources.size()*2);
437 SubjtPoints.reserve(Sources.size()*2);
439 ITERATE(vector<CEquivRange>, SourceIter, Sources) {
440 QueryPoints.push_back(SourceIter->Query.GetFrom());
441 QueryPoints.push_back(SourceIter->Query.GetTo()+1);
442 SubjtPoints.push_back(SourceIter->Subjt.GetFrom());
443 SubjtPoints.push_back(SourceIter->Subjt.GetTo()+1);
447 vector<TSeqPos>::iterator NE;
448 sort(QueryPoints.begin(), QueryPoints.end());
449 NE = unique(QueryPoints.begin(), QueryPoints.end());
450 QueryPoints.erase(NE, QueryPoints.end());
451 sort(SubjtPoints.begin(), SubjtPoints.end());
452 NE = unique(SubjtPoints.begin(), SubjtPoints.end());
453 SubjtPoints.erase(NE, SubjtPoints.end());
462 size_t F = 0,
T = QueryPoints.size()-1;
485 for(TPointContainer::const_iterator StartIter = QueryPoints.begin()+JumpTo;
486 StartIter != QueryPoints.end(); ++StartIter) {
488 TPointContainer::const_iterator Next = StartIter;
490 if(Next == QueryPoints.end())
496 Range.
SetTo(*Next-1);
501 if(Range == Equiv.
Query) {
502 Equivs.push_back(Equiv);
507 Equivs.push_back(Temp);
518 size_t F = 0,
T = SubjtPoints.size()-1;
539 for(TPointContainer::const_iterator StartIter = SubjtPoints.begin()+JumpTo;
540 StartIter != SubjtPoints.end(); ++StartIter) {
542 TPointContainer::const_iterator Next = StartIter;
544 if(Next == SubjtPoints.end())
550 Range.
SetTo(*Next-1);
556 if(Range == Equiv.
Subjt) {
557 Equivs.push_back(Equiv);
562 Equivs.push_back(Temp);
684 TEquivList::iterator NE;
685 sort(Equivs.begin(), Equivs.end());
686 NE = unique(Equivs.begin(), Equivs.end());
687 Equivs.erase(NE, Equivs.end());
692 ITERATE(vector<CEquivRange>, EquivIter, Equivs) {
693 Splits.push_back(*EquivIter);
696 return !Splits.empty();
703 bool MadeChanges =
false;
709 Sources.insert(Sources.end(), Originals.begin(), Originals.end());
711 Sources.insert(Sources.end(), Merges.begin(), Merges.end());
713 TEquivList::iterator NE;
715 NE = unique(Sources.begin(), Sources.end());
716 Sources.erase(NE, Sources.end());
724 if(SourceIter->Empty()) {
734 Curr.
AlignId == SourceIter->AlignId &&
735 Curr.
SegmtId == SourceIter->SegmtId) {
736 Curr =
Merge(Curr, *SourceIter);
742 Merges.push_back(Curr);
748 Merges.push_back(Curr);
750 }
while(MadeChanges);
773 for(
int Loop = 0; Loop < SegCount; Loop++) {
774 size_t StartIndex = (Loop*Denseg.
GetDim());
776 if (Denseg.
GetStarts()[StartIndex] == -1 ||
796 SubjtStrand = Denseg.
GetStrands()[StartIndex+1];
814 Equivs.push_back(Curr);
823 objects::CBioseq_Handle SubjtHandle,
837 QRange += CurrEquiv.
Query;
838 SRange += CurrEquiv.
Subjt;
841 string QueryStr, SubjtStr;
863 for(
size_t Loop = 0; Loop < CurrEquiv.
Subjt.
GetLength(); Loop++) {
864 size_t QLoop = QOffset+Loop;
865 size_t SLoop = SOffset+Loop;
870 if(QueryStr[QLoop] == SubjtStr[SLoop]) {
955 }
else if(Original.
Query == Inter) {
1000 }
else if(Original.
Subjt == Inter) {
1004 Slice.
Subjt = Inter;
1056 cerr << __LINE__ <<
" ERROR" << endl;
1058 cerr << __LINE__ <<
" ERROR" << endl;
1060 cerr << __LINE__ <<
" ERROR" << endl;
void CalcMatches(objects::CBioseq_Handle QueryHandle, objects::CBioseq_Handle SubjtHandle, TEquivList &Equivs)
CEquivRange SliceOnSubjt(const CEquivRange &Original, const CRange< TSeqPos > &pSubjt)
bool MergeAbuttings(const TEquivList &Originals, TEquivList &Merges)
void ExtractRangesFromSeqAlign(const objects::CSeq_align &Alignment, TEquivList &Equivs)
CEquivRange Merge(const CEquivRange &First, const CEquivRange &Second)
CEquivRange SliceOnQuery(const CEquivRange &Original, const CRange< TSeqPos > &pQuery)
bool SplitIntersections(const TEquivList &Originals, TEquivList &Splits)
ERelative CalcRelative(const CEquivRange &Check) const
bool AbuttingWith(const CEquivRange &Other) const
ERelative CalcRelativeDuo(const CEquivRange &Check) const
static TSeqPos Distance(const CEquivRange &A, const CEquivRange &B)
objects::ENa_strand Strand
vector< TSeqPos > MisMatchSubjtPoints
bool IntersectingWith(const CEquivRange &Other) const
void s_CalcDevs(const list< T > &Values, T Mean, double StdDev, list< double > &Devs)
bool s_SortEquivBySubjt(const CEquivRange &A, const CEquivRange &B)
bool operator<(const CEquivRange &A, const CEquivRange &B)
double s_CalcStdDev(const list< T > &List, T Mean)
T s_CalcMean(const list< T > &List)
string s_RelToStr(CEquivRange::ERelative rel)
bool operator==(const CEquivRange &A, const CEquivRange &B)
CNcbiOstream & operator<<(CNcbiOstream &out, const CEquivRange &range)
vector< CEquivRange > TEquivList
std::ofstream out("events_result.xml")
main entry point for tests
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.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Info(CExceptionArgs_Base &args)
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
position_type GetLength(void) const
TThisType & SetLengthDown(position_type length)
bool IntersectingWith(const TThisType &r) const
TThisType IntersectionWith(const TThisType &r) const
TThisType & SetLength(position_type length)
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
void SetFrom(TFrom value)
Assign a value to From data member.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
void SetTo(TTo value)
Assign a value to To data member.
const TDenseg & GetDenseg(void) const
Get the variant data.
const TStarts & GetStarts(void) const
Get the Starts member data.
const TLens & GetLens(void) const
Get the Lens member data.
TDim GetDim(void) const
Get the Dim member data.
bool IsDisc(void) const
Check if variant Disc is selected.
bool CanGetStrands(void) const
Check if it is safe to call GetStrands method.
TNumseg GetNumseg(void) const
Get the Numseg member data.
list< CRef< CSeq_align > > Tdata
const TDisc & GetDisc(void) const
Get the variant data.
const TStrands & GetStrands(void) const
Get the Strands member data.
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
ENa_strand
strand of nucleic acid
unsigned int
A callback function used to compare two keys in a database.
range(_Ty, _Ty) -> range< _Ty >
constexpr auto sort(_Init &&init)
Magic spell ;-) needed for some weird compilers... very empiric.
#define F(x)
Make a parametrized function appear to have only one variable.