GenModel.cpp File Reference

#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

Function Documentation

bool allLessVector ( const vector< int > &  v1,
const vector< int > &  v2 
)

Referenced by Noschain::Noschain().

bool appendChainSingle2Many ( Noschain c1,
Noschain c2 
)

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

Returns:
0 for good, 1 for out of order, 2 for duplicated

Referenced by Noschain::Noschain().

int cmpEditMinusChainFirstFront ( Noschain c1,
Noschain c2,
int &  edit 
)

int cmpEditPlusChainFirstFront ( Noschain c1,
Noschain c2,
int &  edit 
)

int cmpEditPlusChainIdenticalFront ( Noschain c1,
Noschain c2,
int &  edit 
)

int compareMinusChainFirstBefore ( Noschain c1,
Noschain c2,
int &  edit 
)

int compareMinusChainIdenticalRight ( Noschain c1,
Noschain c2,
int &  edit 
)

int compareMultipleWithSingle ( Noschain c1,
Noschain c2,
int &  edit 
)

int comparePlusChainFirstBefore ( Noschain c1,
Noschain c2,
int &  edit 
)

int comparePlusChainIdenticalLeft ( Noschain c1,
Noschain c2,
int &  edit 
)

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().

void errorMessageFix1 ( Noschain c1,
Noschain c2,
int  status,
int  end 
)

for debuging

References Noschain::show().

int exonOverlapLengthManyToOne ( const Noschain c1,
const Noschain c2 
)

bool frontCompareMinus ( Noschain c1,
Noschain c2,
int &  edit,
int  i 
)

bool frontComparePlus ( Noschain c1,
Noschain c2,
int &  edit,
int  i 
)

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().

Noschain operator- ( int  c,
const Noschain chain 
)

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 
)

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  ) 

void reverseEdit ( int &  ed  ) 

void string2Vector ( vector< int > &  v,
const string &  str 
)

Referenced by Noschain::Noschain().

int tilingMinus ( const Noschain A,
const Noschain B 
)

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().

int tilingMinusLength ( const Noschain A,
const Noschain B 
)

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().

bool tilingPlus ( const Noschain A,
const Noschain B 
)

int tilingPlusLength ( const Noschain A,
const Noschain B 
)

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().


Variable Documentation

int FUZZYMARGIN = 21


Generated on Wed Aug 10 11:57:02 2011 for Softwares from Orpara by  doxygen 1.5.6