28 fragment(
int chrPos,
int aliPos,
int len) : chrPos(chrPos), aliPos(aliPos), len(len) {}
30 int chrEnd()
const {
return chrPos + len - 1; }
42 friend class boost::serialization::access;
43 template<
class Archive>
44 void serialize(Archive & ar,
const unsigned int version)
64 AlignmentRow(
string seqID,
int chrPos, Strand strand,
string rowbuffer);
70 int getSeqLen()
const {
return chrEnd() - chrStart() + 1; }
71 int getCumFragLen()
const {
return cumFragLen; }
72 void setCumFragLen(
int len) { cumFragLen = len;}
73 int gapLenAfterFrag(
size_t i)
const {
74 if (i+1 >= frags.size())
76 return frags[i+1].chrPos - frags[i].chrPos - frags[i].len;
78 void addFragment(
int chrPos,
int aliPos,
int len);
79 void addFragment(
fragment &f) { addFragment(f.chrPos, f.aliPos, f.len); }
80 string getSignature()
const {
return seqID + ((strand == minusstrand)?
"-" :
"+");}
82 friend ostream& operator<< (ostream& strm,
const AlignmentRow &row);
90 int getAliPos(
int chrPos, vector<fragment>::const_iterator from);
91 int getAliPos(
int chrPos, vector<fragment>::const_iterator *from);
96 int getChrPos(
int aliPos, vector<fragment>::const_iterator from);
97 int getChrPos(
int aliPos) {
return getChrPos(aliPos, frags.begin()); }
108 vector<fragment> frags;
119 friend class boost::serialization::access;
120 template<
class Archive>
121 void serialize(Archive & ar,
const unsigned int version)
162 Alignment(
size_t k) : aliLen(0), rows(k, NULL) {}
164 for (
unsigned i=0; i<rows.size(); i++)
167 friend bool mergeable (
Alignment *a1,
Alignment *a2,
int maxGapLen,
float mergeableFrac,
bool strong);
168 friend ostream& operator<< (ostream& strm,
const Alignment &a);
169 void printTextGraph(ostream& strm);
172 friend void capAliSize(list<Alignment*> &alis,
int maxRange);
173 friend void reduceOvlpRanges(list<Alignment*> &alis,
size_t maxCov,
float covPen);
175 int numRows()
const {
return rows.size(); }
176 int numFilledRows()
const;
177 int getCumFragLen()
const;
178 int getMaxSeqIdLen()
const;
180 string getSignature()
const;
182 void shiftAliPositions(
int offset);
186 void convertAlignment(
int r,
int start,
int end);
191 vector<AlignmentRow*> rows;
201 friend class boost::serialization::access;
202 template<
class Archive>
203 void serialize(Archive & ar,
const unsigned int version)
220 if (a2->rows[s] == NULL)
222 if (a1->rows[s] == NULL)
224 if (a1->rows[s]->seqID < a2->rows[s]->seqID)
226 if (a1->rows[s]->seqID > a2->rows[s]->seqID)
229 return (a1->rows[s]->chrStart() < a2->rows[s]->chrStart());
238 IdxSortCriterion(vector<Alignment*>
const &a_,
size_t speciesIdx) : s(speciesIdx), a(a_) {};
239 bool operator() (
int i,
int j){
241 if (a[j]->rows[s] == NULL && a[i]->rows[s])
243 if (a[i]->rows[s] == NULL)
245 if (a[i]->rows[s]->seqID < a[j]->rows[s]->seqID)
247 if (a[i]->rows[s]->seqID > a[j]->rows[s]->seqID)
250 return (a[i]->rows[s]->chrStart() < a[j]->rows[s]->chrStart());
253 vector<Alignment*>
const &a;
264bool mergeable (
Alignment *b1,
Alignment *b2,
int maxGapLen,
float mergeableFrac,
bool strong);
266inline bool isGap(
char c){
267 return (c ==
'-' || c ==
'.');
277 string sigstr()
const{
279 for (
unsigned s = 0; s < sigrows.size(); ++s)
280 if (sigrows[s] !=
"")
281 str += itoa(s) +
":" + sigrows[s];
284 vector<string> sigrows;
291 return (sumCumFragLen > other.sumCumFragLen);
295 bool fits(
const Alignment &a,
size_t s)
const {
296 return a.rows[s] && (sigrows[s] == a.rows[s]->seqID + strandChar(a.rows[s]->strand));
298 static int maxSigStrLen;
303typedef pair<size_t, int> BoundaryFragment;
311 bool operator()(BoundaryFragment& bf1, BoundaryFragment& bf2) {
312 return bf1.second > bf2.second;
353 StringAlignment(
size_t numrows) : rows(numrows,
""), k(numrows), len(0) {}
367 void insert(std::list<MsaInsertion> &insList,
int maxInsertLen = INT_MAX);
381 bool isGapOnlyCol(
size_t col){
382 for (
size_t s = 0; s < k; ++s)
383 if (!rows[s].empty() && rows[s].at(col) !=
'-')
392 size_t m = 0, rowlen;
393 for (
size_t s = 0; s < k; ++s){
394 rowlen = rows[s].length();
398 else if (m != rowlen)
399 throw length_error(
"StringAlignment with rows of differing lengths");
405 friend ostream& operator<< (ostream& strm,
const StringAlignment &msa);
global multiple sequence alignment
Definition alignment.hh:61
int getAliPos(int chrPos, vector< fragment >::const_iterator from)
Definition alignment.cc:101
friend void appendRow(AlignmentRow **r1, const AlignmentRow *r2, int aliLen1, string sigstr)
Definition alignment.cc:147
global multiple sequence alignment with efficiently stored long gaps.
Definition alignment.hh:160
friend void capAliSize(list< Alignment * > &alis, int maxRange)
Definition alignment.cc:348
Definition alignment.hh:309
Definition alignment.hh:320
bool operator<(const MsaInsertion &other) const
Definition alignment.hh:328
size_t insertpos
index of species
Definition alignment.hh:342
string insert
at which position to insert
Definition alignment.hh:343
MsaSignature is a summary of the seqId/strand combinations of the alignment.
Definition alignment.hh:275
global multiple sequence alignment in (standard) string representation
Definition alignment.hh:351
void insert(std::list< MsaInsertion > &insList, int maxInsertLen=INT_MAX)
Definition alignment.cc:924
void computeLen()
Definition alignment.hh:391
size_t removeGapOnlyCols()
Definition alignment.cc:954
gapless alignment fragment
Definition alignment.hh:26
Definition alignment.hh:237
Definition alignment.hh:216