void AddSpotId(string& short_id, const CBamAlignIterator* iter) { string seq = iter->GetShortSequence(); if ( iter->IsSetStrand() && IsReverse(iter->GetStrand()) ) { seq = Reverse(seq); } SShortSeqInfo& info = m_ShortSeqs[short_id]; if ( info.spot1.empty() ) { info.spot1 = seq; short_id += ".1"; return; } if ( info.spot1 == seq ) { short_id += ".1"; return; } if ( info.spot2.empty() ) { ++m_ResolveCount; info.spot2 = seq; short_id += ".2"; return; } if ( info.spot2 == seq ) { short_id += ".2"; return; } short_id += ".?"; }
void CSeqVector_CI::SetStrand(ENa_strand strand) { if ( IsReverse(m_Strand) == IsReverse(strand) ) { m_Strand = strand; return; } TSeqPos pos = GetPos(); m_Strand = strand; x_ResetBackup(); if ( x_CacheSize() ) { x_ResetCache(); if ( m_Seg ) { m_Seg = CSeqMap_CI(); x_SetPos(pos); } } }
// return true if there is zero-length gap before current position // it might happen only if current position is at the beginning of buffer bool CSeqVector_CI::HasZeroGapBefore(void) { if ( x_CacheOffset() != 0 ) { return false; } TSeqPos pos = GetPos(); if ( IsReverse(m_Strand) ) { pos = x_GetSize() - pos; } return m_SeqMap->HasZeroGapAt(pos, m_Scope.GetScopeOrNull()); }
//--------------------------------------------------------------------- void BaseTween::ForceToEnd(float _time) { m_currentTime = _time - GetFullDuration(); m_step = m_repeatCount*2 + 1; m_flags.ChangeMask(eIsIteratingStep, false); if(IsReverse(m_repeatCount*2)) { ForceStartValues(); } else { ForceEndValues(); } }
//--------------------------------------------------------------------- void BaseTween::ForceToStart() { m_currentTime = -m_delay; m_step = -1; m_flags.ChangeMask(eIsIteratingStep, false); if(IsReverse(0)) { ForceEndValues(); } else { ForceStartValues(); } }
// Corresponds to SortFeatItemListByPos from the C toolkit int CSeq_feat::CompareNonLocation(const CSeq_feat& f2, const CSeq_loc& loc1, const CSeq_loc& loc2) const { const CSeqFeatData& data1 = GetData(); const CSeqFeatData& data2 = f2.GetData(); CSeqFeatData::E_Choice type1 = data1.Which(); CSeqFeatData::E_Choice type2 = data2.Which(); // operon first if ( int diff = s_IsOperon(data2) - s_IsOperon(data1) ) { return diff; } if ( type1 != type2 ) { // order by feature type int order1 = GetTypeSortingOrder(type1); int order2 = GetTypeSortingOrder(type2); int diff = order1 - order2; if ( diff != 0 ) return diff; } // minus strand last ENa_strand strand1 = loc1.GetStrand(); ENa_strand strand2 = loc2.GetStrand(); if ( int diff = IsReverse(strand1) - IsReverse(strand2) ) { return diff; } if ( int diff = loc1.CompareSubLoc(loc2, strand1) ) { return diff; } {{ // compare subtypes CSeqFeatData::ESubtype subtype1 = data1.GetSubtype(); CSeqFeatData::ESubtype subtype2 = data2.GetSubtype(); int diff = subtype1 - subtype2; if ( diff != 0 ) return diff; }} // subtypes are equal, types must be equal too _ASSERT(type1 == type2); // type dependent comparison if ( type1 == CSeqFeatData::e_Cdregion ) { // compare frames of identical CDS ranges if ( int diff = s_GetCdregionOrder(data1)-s_GetCdregionOrder(data2) ) { return diff; } } else if ( type1 == CSeqFeatData::e_Imp ) { // compare labels of imp features int diff = NStr::CompareNocase(data1.GetImp().GetKey(), data2.GetImp().GetKey()); if ( diff != 0 ) return diff; } // XXX - should compare parent seq-annots // XXX 1. parent Seq-annot idx.itemID // XXX 2. features itemID return 0; // unknown }
//--------------------------------------------------------------------- void BaseTween::UpdateStep() { while(IsStepValid(m_step)) { if(!IsIterationStep() && m_currentTime + m_dt <= 0.0f) { m_flags.ChangeMask(eIsIteratingStep, true); -- m_step; float fDt = 0.0f - m_currentTime; m_dt -= fDt; m_currentTime = m_duration; (IsReverse(m_step)) ? ForceStartValues() : ForceEndValues(); CallCallback(eTweenBackStart); OnUpdate(m_step, m_step + 1, IsIterationStep(), fDt); } else if(!IsIterationStep() && m_currentTime + m_dt >= m_repeatDelay) { m_flags.ChangeMask(eIsIteratingStep, true); ++ m_step; float fDt = m_repeatDelay - m_currentTime; m_dt -= fDt; m_currentTime = 0.0f; (IsReverse(m_step)) ? ForceEndValues() : ForceStartValues(); CallCallback(eTweenStart); OnUpdate(m_step, m_step - 1, IsIterationStep(), fDt); } else if(IsIterationStep() && m_currentTime + m_dt < 0.0f) { m_flags.ChangeMask(eIsIteratingStep, false); -- m_step; float fDt = 0.0f - m_currentTime; m_dt -= fDt; m_currentTime = 0.0f; OnUpdate(m_step, m_step + 1, IsIterationStep(), fDt); CallCallback(eTweenBackEnd); if(m_step < 0 && m_repeatCount >= 0) { CallCallback(eTweenBackComplete); } else { m_currentTime = m_repeatDelay; } } else if(IsIterationStep() && m_currentTime + m_dt > m_duration) { m_flags.ChangeMask(eIsIteratingStep, false); ++ m_step; float fDt = m_duration - m_currentTime; m_dt -= fDt; m_currentTime = m_duration; OnUpdate(m_step, m_step - 1, IsIterationStep(), fDt); CallCallback(eTweenEnd); if(m_step > m_repeatCount*2 && m_repeatCount >= 0) { CallCallback(eTweenComplete); } m_currentTime = 0.0f; } else if(IsIterationStep()) { float fDt = m_dt; m_dt -= fDt; m_currentTime += fDt; OnUpdate(m_step, m_step, IsIterationStep(), fDt); break; } else { float fDt = m_dt; m_dt -= fDt; m_currentTime += fDt; break; } } }
bool CSeq_interval::x_IsMinusStrand(void) const { return IsSetStrand() && IsReverse(GetStrand()); }
CAnnotCompare::TCompareFlags CAnnotCompare::CompareFeats(const CSeq_feat& feat1, const CSeq_loc& loc1, CScope& scope1, const CSeq_feat& feat2, const CSeq_loc& loc2, CScope& scope2, vector<ECompareFlags>* complex_flags, list<string>* comments) { TCompareFlags loc_state = 0; ENa_strand strand1 = sequence::GetStrand(loc1, &scope1); ENa_strand strand2 = sequence::GetStrand(loc2, &scope2); if (!SameOrientation(strand1, strand2)) { loc_state |= eLocation_Missing; } else { sequence::ECompare comp_val = sequence::Compare(loc1, loc2, &scope1); switch (comp_val) { case sequence::eSame: loc_state |= eLocation_Same; break; case sequence::eOverlap: loc_state |= eLocation_Complex; break; case sequence::eContains: case sequence::eContained: {{ CSeq_loc_CI loc1_iter(loc1); size_t loc1_exons = 0; for ( ; loc1_iter; ++loc1_iter, ++loc1_exons) { } CSeq_loc_CI loc2_iter(loc2); size_t loc2_exons = 0; for ( ; loc2_iter; ++loc2_iter, ++loc2_exons) { } bool rev = IsReverse(strand1); TSeqRange range1 = loc1.GetTotalRange(); TSeqRange range2 = loc2.GetTotalRange(); if (loc1_exons == loc2_exons) { bool agreement_3prime; bool agreement_5prime; if (!rev) { agreement_5prime = range1.GetFrom() == range2.GetFrom(); agreement_3prime = range1.GetTo() == range2.GetTo(); } else { agreement_3prime = range1.GetFrom() == range2.GetFrom(); agreement_5prime = range1.GetTo() == range2.GetTo(); } loc1_iter.Rewind(); loc2_iter.Rewind(); bool agreement_internal = true; for (unsigned int i = 0; i < loc1_exons; ++i, ++loc1_iter, ++loc2_iter) { if ((i != 0 || rev) && (i != loc1_exons - 1 || !rev)) { if (loc1_iter.GetRange().GetFrom() != loc2_iter.GetRange().GetFrom()) { agreement_internal = false; break; } } if ((i != 0 || !rev) && (i != loc1_exons - 1 || rev)) { if (loc1_iter.GetRange().GetTo() != loc2_iter.GetRange().GetTo()) { agreement_internal = false; break; } } } if (!agreement_internal) { loc_state |= eLocation_Complex; } else if (agreement_5prime && !agreement_3prime) { loc_state |= eLocation_3PrimeExtension; } else if (agreement_3prime && !agreement_5prime) { loc_state |= eLocation_5PrimeExtension; } else { // both 3' and 5' disagreement loc_state |= eLocation_Complex; } } else { loc1_iter.Rewind(); loc2_iter.Rewind(); while (loc1_iter && loc2_iter) { if (loc1_iter.GetRange() == loc2_iter.GetRange()) { ++loc1_iter; ++loc2_iter; } else { if (loc1_exons > loc2_exons) { ++loc1_iter; } else { ++loc2_iter; } } } if ((loc1_exons > loc2_exons && !loc2_iter) || (loc2_exons > loc1_exons && !loc1_iter)) { loc_state |= eLocation_MissingExon; } else { loc_state |= eLocation_Complex; } } }} break; default: case sequence::eNoOverlap: loc_state |= eLocation_Missing; break; } } /// /// now, do a very simple sequence comparison /// CSeqVector v1(loc1, scope1); CSeqVector v2(loc2, scope2); CSeqVector_CI v1_iter = v1.begin(); CSeqVector_CI v2_iter = v2.begin(); TCompareFlags seq_state = 0; for (size_t count = 0; v1_iter != v1.end() && v2_iter != v2.end(); ++v1_iter, ++v2_iter, ++count) { if (*v1_iter != *v2_iter) { seq_state |= eSequence_DifferentSeq; break; } } if (v1_iter != v1.end() || v2_iter != v2.end()) { seq_state |= eSequence_DifferentSeq; } if (seq_state) { loc_state |= seq_state; } else { loc_state |= eSequence_SameSeq; } /// /// also compare products /// if (feat1.IsSetProduct() && feat2.IsSetProduct()) { CSeqVector v1(feat1.GetProduct(), scope1); CSeqVector v2(feat2.GetProduct(), scope2); CSeqVector_CI v1_iter = v1.begin(); CSeqVector_CI v2_iter = v2.begin(); for ( ; v1_iter != v1.end() && v2_iter != v2.end(); ++v1_iter, ++v2_iter) { if (*v1_iter != *v2_iter) { loc_state |= eSequence_DifferentProduct; break; } } if ((loc_state & eSequence_DifferentProduct) == 0) { loc_state |= eSequence_SameProduct; } } else if (feat1.IsSetProduct() != feat2.IsSetProduct()) { loc_state |= eSequence_DifferentProduct; } return loc_state; }
//-------------------------------------------------------------------------------- void Timeline::OnUpdate (int _step, int _lastStep, bool _isIterationStep, float _dt) { if(!_isIterationStep && _step > _lastStep) { TWEEN_ASSERT(_dt >= 0, "Delta should be positive"); float currentDelta = IsReverse(_lastStep) ? (-_dt - 1.0f) : (_dt + 1.0f); UpdateChildren(currentDelta); return; } if(!_isIterationStep && _step < _lastStep) { TWEEN_ASSERT(_dt <= 0, "Delta should be negative"); float currentDelta = IsReverse(_lastStep) ? (-_dt - 1.0f) : (_dt + 1.0f); UpdateChildren(currentDelta, true); return; } TWEEN_ASSERT(_isIterationStep, "Not an iteration step and last step equal to step should not happen"); if(_step > _lastStep) { if(IsReverse(_step)) { ForceEndValues(); } else { ForceStartValues(); } UpdateChildren(_dt); } else if( _step < _lastStep) { if(IsReverse(_step)) { ForceStartValues(); } else { ForceEndValues(); } UpdateChildren(_dt, true); } else { float currentDelta = IsReverse(_step) ? -_dt : _dt; if(_dt >= 0.0f) { UpdateChildren(currentDelta); } else { UpdateChildren(currentDelta, true); } } }