コード例 #1
0
// Translate the SeqCoord c from the frame of coord[0] to coord[1]
SeqCoord Match::translate(const SeqCoord& c) const
{
	// In overlap with indelsm the coord[] are not the same length
    // assert(coord[0].length() == coord[1].length()); // ensure translation is valid
    SeqCoord out;
    out.seqlen = coord[1].seqlen;
	
	//The offset of start and end should be adjusted according to the indels.
    out.interval.start = c.interval.start + calculateTranslation();
	out.interval.end = c.interval.end + calculateTranslationEnd();
			
    if(isRC())
        out.flip();

	// the offset t is not accurate under indels overlap
	// if(out.interval.end >= out.seqlen)
		// out.interval.end = out.seqlen-1;

	// if(out.interval.start <0)
		// out.interval.start = 0;


	// assert(out.interval.start>=0 && out.interval.start<out.interval.end);
		
    return out;
}
コード例 #2
0
// Calculation the translation offset to shift
// a coord[1] position to a coord[0]. This must be calculated
// using canonical coordinates
int Match::calculateInverseTranslation() const
{
    if(!isRC())
        return coord[0].interval.start - coord[1].interval.start;
    else
    {
        SeqCoord f = coord[0];
        f.flip();
        return f.interval.start - coord[1].interval.start;
    }
}
コード例 #3
0
int Match::calculateTranslationEnd() const
{
    if(!isRC())
        return coord[1].interval.end - coord[0].interval.end;
    else
    {
        SeqCoord f = coord[1];
        f.flip();
        return f.interval.end - coord[0].interval.end;
    }
}
コード例 #4
0
// Translate the SeqCoord c from the frame of coord[1] to coord[0]
SeqCoord Match::inverseTranslate(const SeqCoord& c) const
{
    // assert(c.isExtreme());    
    SeqCoord out;
    out.seqlen = coord[0].seqlen; //seqlen was extended
    out.interval.start = c.interval.start + calculateInverseTranslation();
	out.interval.end = c.interval.end + calculateInverseTranslationEnd();
	
    if(isRC())
        out.flip();

	// if((int)c.length() !=(int)out.length())
		// std::cout << c.length() << "\t"<< out.length() <<"\n";

	// assert(out.interval.start>=0 && out.interval.start<out.interval.end);

    return out;
}