#include "GenModel.h"#include <algorithm>#include <sstream>#include <exception>#include <stdexcept>#include <strformat.h>#include <limits>#include <fstream>#include "Gmapres.h"#include <iterator>Functions | |
| void | string2Vector (vector< int > &v, const string &str) |
| bool | nonincreasingVector (const vector< int > &v) |
| bool | nondecreasingVector (const vector< int > &v) |
| bool | allLessVector (const vector< int > &v1, const vector< int > &v2) |
| int | checkCoordinates (const vector< int > &points) |
| Noschain | operator- (int c, const Noschain &chain) |
| int | comparePlusChainFirstBefore (Noschain &c1, Noschain &c2, int &edit) |
| int | comparePlusChainIdenticalLeft (Noschain &c1, Noschain &c2, int &edit) |
| bool | frontComparePlus (Noschain &c1, Noschain &c2, int &edit, int i) |
| int | cmpEditPlusChainFirstFront (Noschain &c1, Noschain &c2, int &edit) |
| int | cmpEditPlusChainIdenticalFront (Noschain &c1, Noschain &c2, int &edit) |
| bool | frontCompareMinus (Noschain &c1, Noschain &c2, int &edit, int i) |
| int | cmpEditMinusChainFirstFront (Noschain &c1, Noschain &c2, int &edit) |
| int | compareMinusChainFirstBefore (Noschain &c1, Noschain &c2, int &edit) |
| int | compareMinusChainIdenticalRight (Noschain &c1, Noschain &c2, int &edit) |
| void | errorMessageFix1 (Noschain &c1, Noschain &c2, int status, int end) |
| int | compareMultipleWithSingle (Noschain &c1, Noschain &c2, int &edit) |
| void | reverseEdit (int &ed) |
| int | reverseCompareResult (int cmpres) |
| bool | tilingPlus (const Noschain &A, const Noschain &B) |
| int | tilingPlusLength (const Noschain &A, const Noschain &B) |
| int | tilingMinus (const Noschain &A, const Noschain &B) |
| int | tilingMinusLength (const Noschain &A, const Noschain &B) |
| int | exonOverlapLengthManyToOne (const Noschain &c1, const Noschain &c2) |
| bool | appendChainSingle2Many (Noschain &c1, Noschain &c2) |
| void | readandstoreGmap (const string &inputFile, map< string, set< Alnchainid *, lessChainPtr > > &alnseg, map< int, int > &pathstat) |
| helper functions | |
| void | readandstoreGmap (istream &ins, map< string, set< Alnchainid *, lessChainPtr > > &alnseg, map< int, int > &pathstat) |
| void | archiveAln (map< string, set< Alnchainid *, lessChainPtr > > &alnseg, const string &file) |
| void | archiveAln (map< string, set< Alnchainid *, lessChainPtr > > &alnseg, ostream &ous) |
Variables | |
| int | FUZZYMARGIN = 21 |
| bool allLessVector | ( | const vector< int > & | v1, | |
| const vector< int > & | v2 | |||
| ) |
Referenced by Noschain::Noschain().
References Range::begin(), Range::direction(), Range::end(), Noschain::exonIndex(), Noschain::numberOfRanges(), Noschain::reverse(), Noschain::setBegin(), Noschain::setEnd(), and Noschain::show().
Referenced by Noschain::append().
| void archiveAln | ( | map< string, set< Alnchainid *, lessChainPtr > > & | alnseg, | |
| ostream & | ous | |||
| ) |
stream version more flexible
| void archiveAln | ( | map< string, set< Alnchainid *, lessChainPtr > > & | alnseg, | |
| const string & | file | |||
| ) |
Simply stores the Alnchainid object with the toString() method exons(b1-e1,b2-e2, ...) TAB identity TAB coverage TAB estids (id1,id2, ...). The result is sorted on genomic DNA, so genomic DNA is written once at the beginning. GID: chromosome1 1-100,200-300 95 0.9 est1 2-102,202-303 92 0.92 est2
References archiveAln().
Referenced by archiveAln(), and main().
| int checkCoordinates | ( | const vector< int > & | points | ) |
helper function for Noschain constructor
Referenced by Noschain::Noschain().
References Range::begin(), Range::end(), frontCompareMinus(), FUZZYMARGIN, I, Noschain::numberOfRanges(), Range::overlap(), and Noschain::setEnd().
Referenced by Noschain::compareChainAndFix().
References Range::begin(), Range::end(), frontComparePlus(), FUZZYMARGIN, I, Noschain::numberOfRanges(), Range::overlap(), and Noschain::setEnd().
Referenced by Noschain::compareChainAndFix().
References Range::begin(), Range::end(), FUZZYMARGIN, I, Noschain::numberOfRanges(), and Noschain::setEnd().
Referenced by Noschain::compareChainAndFix().
References Range::begin(), Range::end(), FUZZYMARGIN, I, Noschain::numberOfRanges(), Noschain::setBegin(), and Noschain::setEnd().
left ends are the same
References Range::begin(), Range::end(), FUZZYMARGIN, I, Noschain::numberOfRanges(), and Noschain::setEnd().
Referenced by Noschain::compareChainAndFix().
References Range::begin(), Range::direction(), Range::end(), Noschain::exonIndex(), FUZZYMARGIN, Noschain::numberOfRanges(), Noschain::reverse(), Noschain::setBegin(), and Noschain::setEnd().
Referenced by Noschain::compareChainAndFix().
References Range::begin(), Range::end(), FUZZYMARGIN, I, Noschain::numberOfRanges(), Noschain::setBegin(), and Noschain::setEnd().
left ends are the same. replaced with cmpEditPlusChainIdenticalFront which is a better implementation.
References Range::begin(), Range::end(), FUZZYMARGIN, I, Noschain::numberOfRanges(), and Noschain::setEnd().
for debuging
References Noschain::show().
References Range::begin(), Range::contain(), Range::direction(), Range::end(), Noschain::exonIndex(), Range::length(), Noschain::numberOfRanges(), and Noschain::reverse().
Referenced by Noschain::exonOverlapLength().
References Range::begin(), Range::end(), FUZZYMARGIN, and Noschain::setBegin().
Referenced by cmpEditMinusChainFirstFront().
return false if not able to anchor
References Range::begin(), Range::end(), FUZZYMARGIN, and Noschain::setBegin().
Referenced by cmpEditPlusChainFirstFront().
| bool nondecreasingVector | ( | const vector< int > & | v | ) |
numbers goes from small to large
Referenced by Noschain::Noschain().
| bool nonincreasingVector | ( | const vector< int > & | v | ) |
numbers go from large to small
Referenced by Noschain::Noschain().
Each Range of the chain becomes (c-exons[i])
References Noschain::exons.
| void readandstoreGmap | ( | istream & | ins, | |
| map< string, set< Alnchainid *, lessChainPtr > > & | alnseg, | |||
| map< int, int > & | pathstat | |||
| ) |
stream version more flexible
References Gmapres::addAlignment(), Gmapres::addPath(), breakString(), getAllInt(), getInt(), Gmapres::storeChain(), and trimLeadingSpace().
| void readandstoreGmap | ( | const string & | inputFile, | |
| map< string, set< Alnchainid *, lessChainPtr > > & | alnseg, | |||
| map< int, int > & | pathstat | |||
| ) |
helper functions
file version use stream version
References ifstream(), and readandstoreGmap().
Referenced by getInputFromRawGmap(), main(), and readandstoreGmap().
| int reverseCompareResult | ( | int | cmpres | ) |
Referenced by Noschain::compareChainAndFix().
| void reverseEdit | ( | int & | ed | ) |
Referenced by Noschain::compareChainAndFix().
| void string2Vector | ( | vector< int > & | v, | |
| const string & | str | |||
| ) |
Referenced by Noschain::Noschain().
helper function A is to the right Condition is A<B and both on - direction possible overlap B i ===<---==<----===<-----= A j =<----===<-----===<-----====
Special case
B i ===<---==<----===<-----===== A j =====<----===<-----===<-----==== bool tilingMinus(const Noschain &A, const Noschain &B) { int i,j; if ((j=A.exonIndex(B.begin())) == -1) return false; i=0; if (j == A.numberOfRanges()-1 && B[0].end() <= A.end()) { special case overlap at both ends return true; } else if (B[i].end() == A[j].end()) { ++i; ++j; } else return false; while (j < A.numberOfRanges() && A[j] == B[i]) { if (i == B.numberOfRanges()) { cerr << "A contains B on -, should not happen\n"; exit(1); } ++i; ++j; } if (i < B.numberOfRanges() && j < A.numberOfRanges()) { if (A[j].begin() != B[i].begin()) return false; } if (j == A.numberOfRanges()-1) { // last exon of nc if (i == B.numberOfRanges()-1) { // last exon of this return true; } else if (A[j].begin() == B[i].begin() && A[j].end() >= B[i].end() && A[j].end() <= B[i].begin() only difference from + strand version ) { return true; } } return false; } helper function B ===<---=b=<--==<---=== A ==<--==<---=a==<---== or B ===<---=b=<-----=== A ==<-----=a==<---== or B ===<---=b==== A ===a==<---==
quick implementation.
References Range::b, Range::begin(), Range::end(), Noschain::exonIndex(), and Noschain::numberOfRanges().
Referenced by Noschain::exonOverlap().
length version nearly the same as the boolean version 0 B ===<---=b=<--==<---=== A ==<--==<---=a==<---== end or B ===<---=b=<-----=== A ==<-----=a==<---== or B ===<---=b==== A ===a==<---==
References Range::b, Range::begin(), Range::end(), Noschain::exonIndex(), Noschain::lastExon(), Range::length(), and Noschain::numberOfRanges().
Referenced by Noschain::exonOverlapLength().
References Range::b, Range::begin(), Range::end(), Noschain::exonIndex(), and Noschain::numberOfRanges().
Referenced by Noschain::exonOverlap().
helper function A on the left Condition is A<B and both on + direction possible overlap A j ===--->==---->===----->= B i =---->===----->===---->==== overlap at ends A j ===--->==---->===----->==== B i ===---->===----->===---->==== bool tilingPlus(const Noschain &A, const Noschain &B) { int i,j; if ((j=A.exonIndex(B.begin())) == -1) return false; i=0; if (j == A.numberOfRanges()-1 && B[0].end() >= A.end()) { return true; } else if (B[i].end() == A[j].end()) { ++i; ++j; } else return false; while (j < A.numberOfRanges() && i < B.numberOfRanges() && A[j] == B[i]) { ++i; ++j; } ///////////////////////// if (i < B.numberOfRanges() && j < A.numberOfRanges()) { if (A[j].begin() != B[i].begin()) return false; } if (j == A.numberOfRanges()-1) { // last exon of nc if (i == B.numberOfRanges()-1) { // last exon of this return true; } else if (A[j].begin() == B[i].begin() && A[j].end() >= B[i].begin() && A[j].end() <= B[i].end()) { return true; } } return false; } helper function A on the left Condition is A<B and both on + direction possible overlap A j ===--->==---->===----->= B i =---->===----->===---->==== overlap at ends A j ===--->==---->===----->==== B i ===---->===----->===---->====
Exclude containment situation. ===--->===--->===-->==== ==--->===-->= is not considered tiling situation. this is exonContain. this function will return -1 for such situation! int tilingPlusLength(const Noschain &A, const Noschain &B) { int i=0,j, ol=0; if ((j=A.exonIndex(B.begin())) == -1) return -1; if (j == A.numberOfRanges()-1 && B[0].end() >= A.end()) { overlap of ends return A.end() - B.begin() + 1; } else if (B[i].end() == A[j].end()) { ol += (A[j].end() - B.begin()); ++i; ++j; } else return -1; while (j < A.numberOfRanges() && i < B.numberOfRanges() && A[j] == B[i]) { walk all internal identical models A ===--->====---->===--->== j B ==---->===--->====-->== i ol += A[j].length(); ++i; ++j; } start with A[j] == B[i] most voting power if (A[j] != B[i]) { if (A[j].begin() != B[i].begin()) return -1; else { // A ===--->====---->===--->== j B ==---->===--->====-->== i if (j == A.numberOfRanges()) { } // last exon exhausted, do nothing else if (j == A.numberOfRanges()-1) // A j at last exon ol += A[j].length(); else { // j < A.numberOfRanges()-1 A ===--->====---->=j=--->== B ==---->=== i exhausted if (i == B.numberOfRanges()) { cerr << "A include B chain in tilingPlusChain(), this should not happen\n" << "overlap length should be the sum exon length of B object\n" << "The ends of A and B are identical.\n"; } else if (i == B.numberOfRanges() -1) { A ===--->====---->=j=--->== B ==---->=i= B[i].end() > or < A[j].end() both are bad situation if (B[i].end() < A[j].end()) { cerr << "A contain B inside tilingPlusChain(), A end longer\n"; } } return -1; } } } else { // A[j] == B[i] A ===--->====---->===--->==== j B ==---->===--->====-->== i if (A[j] == A.numberOfRanges()) { if (B[i] < B.numberOfRanges()) { // A out B not out do nothing } else { // both out, A contain B cerr << "A and B have identical ends, A contain B\n" << " inside tilingPlusChain()\n"; return -1; } } else { // A not out, B must be out return -1; } } return ol; }
References Range::b, Range::begin(), Range::end(), Noschain::exonIndex(), Noschain::lastExon(), Range::length(), and Noschain::numberOfRanges().
Referenced by Noschain::exonOverlapLength().
| int FUZZYMARGIN = 21 |
Referenced by cmpEditMinusChainFirstFront(), cmpEditPlusChainFirstFront(), cmpEditPlusChainIdenticalFront(), compareMinusChainFirstBefore(), compareMinusChainIdenticalRight(), compareMultipleWithSingle(), comparePlusChainFirstBefore(), comparePlusChainIdenticalLeft(), frontCompareMinus(), frontComparePlus(), and main().
1.5.6