//========================================================================== void GeometryTools::splitSurfaceIntoPatches(const SplineSurface& sf, vector<SplineSurface>& pat) //========================================================================== { SplineSurface orig = sf; orig.makeBernsteinKnotsU(); orig.makeBernsteinKnotsV(); int num_u = orig.numCoefs_u(); int num_v = orig.numCoefs_v(); int order_u = orig.order_u(); int order_v = orig.order_v(); int numpat_u = num_u / order_u; int numpat_v = num_v / order_v; pat.resize(numpat_u * numpat_v); typedef vector<double>::const_iterator const_iter; const_iter itu = orig.basis_u().begin(); const_iter itv; for (int i = 0; i < numpat_u; ++i) { itv = orig.basis_v().begin(); for (int j = 0; j < numpat_v; ++j) { shared_ptr<SplineSurface> new_sf(orig.subSurface(*itu, *itv, *(itu+order_u), *(itv+order_v))); pat[numpat_u*j + i] = *new_sf; itv += order_v; } itu += order_u; } return; }
CRef<CSeq_feat> CFeatTrim::Apply(const CSeq_feat& feat, const CRange<TSeqPos>& range) { CRef<CSeq_loc> loc = Ref(new CSeq_loc()); loc->Assign(feat.GetLocation()); const TSeqPos from = range.GetFrom(); const TSeqPos to = range.GetTo(); const bool set_partial = true; x_TrimLocation(from, to, set_partial, loc); if (loc->IsNull()) { return Ref(new CSeq_feat()); } // Create a new seq-feat with the trimmed location CRef<CSeq_feat> new_sf(new CSeq_feat()); new_sf->Assign(feat); new_sf->SetLocation(*loc); if (!loc->IsNull() && (loc->IsPartialStart(eExtreme_Biological) || loc->IsPartialStop(eExtreme_Biological))) { new_sf->SetPartial(true); } // If Cdregion need to consider changes in frameshift if (new_sf->GetData().IsCdregion()) { const TSeqPos offset = x_GetStartOffset(feat, from, to); x_UpdateFrame(offset, new_sf->SetData().SetCdregion()); if (new_sf->SetData().SetCdregion().IsSetCode_break()) { // iterate over code breaks and remove if they fall outside the range list<CRef<CCode_break>>& code_breaks = new_sf->SetData().SetCdregion().SetCode_break(); code_breaks.remove_if(SOutsideRange(from,to)); if (code_breaks.empty()) { new_sf->SetData().SetCdregion().ResetCode_break(); } else { const auto strand = loc->GetStrand(); // Trim the 3' end if (strand != eNa_strand_minus) { for (auto code_break : code_breaks) { const TSeqPos cb_to = code_break->GetLoc().GetTotalRange().GetTo(); if (cb_to > to) { x_TrimCodeBreak(from, to, *code_break); } } } else { // strand == eNa_strand_minus for (auto code_break : code_breaks) { const TSeqPos cb_from = code_break->GetLoc().GetTotalRange().GetFrom(); if (cb_from < from) { x_TrimCodeBreak(from, to, *code_break); } } } } } } else if (new_sf->GetData().GetSubtype() == CSeqFeatData::eSubtype_tRNA) { auto& rna = new_sf->SetData().SetRna(); if (rna.IsSetExt() && rna.GetExt().IsTRNA()) { x_TrimTrnaExt(from, to, rna.SetExt().SetTRNA()); } } return new_sf; }