1 #ifndef SEQ_LOC_MAPPER_BASE__HPP
2 #define SEQ_LOC_MAPPER_BASE__HPP
89 bool GoodSrcId(
const CSeq_id&
id)
const;
92 {
return m_Dst_id_Handle; }
114 bool Map_Strand(
bool is_set_strand,
123 void x_Map_Fuzz(
TFuzz& fuzz)
const;
262 m_Ranges.push_back(offset_rg);
263 m_TotalRange.CombineWith(offset_rg);
300 bool GetAlign_Dense_seg_TotalRange(
void)
const;
306 bool GetAlign_Sparse_ToFirst(
void)
const;
307 bool GetAlign_Sparse_ToSecond(
void)
const;
313 bool GetMapSingleLevel(
void)
const;
318 bool GetTrimMappedLocation(
void)
const;
326 bool x_IsSetOption(
int opt)
const;
327 void x_SetOption(
int opt,
bool enable);
354 fAlign_Dense_seg_TotalRange = 1 << 0,
358 fAlign_Sparse_ToFirst = 0,
359 fAlign_Sparse_ToSecond = 1 << 1,
367 fMapSingleLevel = 1 << 2,
372 fTrimMappedLocation = 1 << 3
378 eSplicedRow_Prod = 0,
386 fFuzzOption_CStyle = 1 << 0,
389 fFuzzOption_RemoveLimTlOrTr = 1 << 1
540 fAnnotMap_Location = 1 << 0,
541 fAnnotMap_Product = 1 << 1,
542 fAnnotMap_Both = fAnnotMap_Location | fAnnotMap_Product,
547 fAnnotMap_RemoveNonMapping = 1 << 2,
550 fAnnotMap_ThrowOnFailure = 1 << 3,
552 fAnnotMap_Default = fAnnotMap_Both
573 bool LastIsPartial(
void);
612 void x_InitializeFeat(
const CSeq_feat& map_feat,
613 EFeatMapDirection dir);
623 void x_InitializeAlign(
const CSeq_align& map_align,
625 const CSeq_id* from_id =
nullptr);
627 void x_InitializeAlign(
const CSeq_align& map_align,
628 const TSynonyms& to_ids,
629 const TSynonyms* from_ids =
nullptr);
631 void x_InitializeAlign(
const CSeq_align& map_align,
633 size_t from_row =
size_t(-1));
643 void x_PreserveDestinationLocs(
void);
647 void x_NextMappingRange(
const CSeq_id& src_id,
663 void x_AddConversion(
const CSeq_id& src_id,
676 void x_MapSeq_loc(
const CSeq_loc& src_loc);
682 void x_PushRangesToDstMix(
void);
705 :
range(rg), fuzz(fz), group(grp) {}
749 bool x_CheckSeqTypes(
const CSeq_loc& loc,
758 ESeqType x_ForceSeqTypes(
const CSeq_loc& loc)
const;
772 void x_InitAlign(
const CDense_diag& diag,
size_t to_row,
size_t from_row);
773 void x_InitAlign(
const CDense_seg& denseg,
size_t to_row,
size_t from_row);
774 void x_InitAlign(
const CStd_seg& sseg,
size_t to_row);
775 void x_InitAlign(
const CPacked_seg& pseg,
size_t to_row,
size_t from_row);
777 const TSynonyms& to_ids);
778 void x_InitSpliced(
const CSpliced_seg& spliced, ESplicedRow to_row);
779 void x_InitSparse(
const CSparse_seg& sparse,
size_t to_row);
791 void x_AddExonPartsMapping(
TSeqPos& mapping_len,
806 bool x_MapNextRange(
const TRange& src_rg,
809 const TRangeFuzz& src_fuzz,
810 TSortedMappings& mappings,
814 bool x_MapInterval(
const CSeq_id& src_id,
818 TRangeFuzz orig_fuzz);
821 void x_SetLastTruncated(
void);
829 void x_PushNullLoc(
void);
839 size_t strand_idx)
const;
845 const TRangeFuzz& fuzz,
891 bool x_ReverseRangeOrder(
int str)
const;
902 bool x_IsSynonym(
const CSeq_id&
id,
const TSynonyms& synonyms)
const;
917 fTrimSplicedSegs = 1 << 0,
919 fKeepNonmapping = 1 << 1,
922 fCheckStrand = 1 << 2,
924 fIncludeSrcLocs = 1 << 3,
926 fMixedAlignsAsSpliced = 1 << 4,
929 fErrorOnPartial = 1 << 5
934 void x_SetMiscFlag(EMiscFlags flag,
bool value);
994 int GetWidthById(
const CSeq_id&
id)
const;
1002 void CollectSynonyms(
const CSeq_id_Handle&
id, TSynonyms& synonyms)
const;
1008 static bool GetNonMappingAsNull(
void);
1088 void ResetObject(
void);
1116 if (x->m_Src_from != y->m_Src_from) {
1117 return x->m_Src_from < y->m_Src_from;
1120 if (x->m_Src_to != y->m_Src_to) {
1121 return x->m_Src_to > y->m_Src_to;
1132 if (x->m_Src_to != y->m_Src_to) {
1133 return x->m_Src_to > y->m_Src_to;
1136 if (x->m_Src_from != y->m_Src_from) {
1137 return x->m_Src_from < y->m_Src_from;
1338 : m_SeqInfo(0), m_Options(0) {}
1343 : m_SeqInfo(seq_info), m_Options(opts) {}
1347 : m_SeqInfo(0), m_Options(opts) {}
User-defined methods of the data storage class.
CLocalRange< TOffset > TRange
define for the fundamental building block of sequence ranges
Helper class for mapping graphs.
CMappingRange - describes a single interval to interval mapping.
Storage for multiple mapping ranges.
Default IMessage implementation: text and severity only.
Class used to map seq-alignments.
namespace ncbi::objects::
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
CSeq_loc_Mapper_Base –.
CSeq_loc_Mapper_Options –.
container_type::const_iterator const_iterator
const_iterator end() const
const_iterator find(const key_type &key) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char si[8][64]
std::ofstream out("events_result.xml")
main entry point for tests
CRange< Position > Map(const CRange< Position > &target, const CRange< Position > &range)
unsigned int TSeqPos
Type for sequence locations and lengths.
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
EDiagSev
Severity level for the posted diagnostics.
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
CRef< IMapper_Sequence_Info > m_SeqInfo
pair< TFuzz, TFuzz > TRangeFuzz
TDstStrandMap m_DstRanges
CSeq_loc_Mapper_Options & SetMapperSequenceInfo(IMapper_Sequence_Info *seq_info)
CSeq_loc_Mapper_Base & SetErrorOnPartial(bool value=true)
Report source range trimming as an error.
void x_SetMiscFlag(EMiscFlags flag, bool value)
CRef< CSeq_loc > Map(const CSeq_loc &src_loc)
Map seq-loc.
bool operator()(const CRef< CMappingRange > &x, const CRef< CMappingRange > &y) const
set< CSeq_id_Handle > TSynonyms
virtual void CollectSynonyms(const CSeq_id_Handle &id, TSynonyms &synonyms)=0
Collect all synonyms for the id including the id itself.
ESeqType GetSeqTypeById(const CSeq_id_Handle &idh) const
Methods for getting sequence types, use cached types (m_SeqTypes) if possible.
TRangeMap::const_iterator TRangeIterator
CRef< CGraphRanges > m_GraphRanges
bool operator<(const SMappedRange &rg) const
CSeq_loc_Mapper_Base & TruncateNonmappingRanges(void)
map< CSeq_id_Handle, TRangeMap > TIdMap
EMapResult
Result of seq-annot mapping.
CSeq_id_Handle m_Dst_id_Handle
void AddRange(const TRange &rg)
const CSeq_id_Handle & GetDstIdHandle(void) const
CSeq_align::C_Segs::TDendiag TDendiag
CSeq_loc_Mapper_Options(void)
list< SMappedRange > TMappedRanges
const TIdMap & GetIdMap() const
TSeqPos GetLength(void) const
CSeq_loc_Mapper_Options & SetTrimMappedLocation(bool value=true)
ESplicedRow
Spliced-seg row indexing constants.
bool operator()(const CRef< CMappingRange > &x, const CRef< CMappingRange > &y) const
IMapper_Sequence_Info * GetMapperSequenceInfo(void) const
Sequence type, length etc.
CMappingRanges::TRangeIterator TRangeIterator
FAnnotMapFlag
Flags defining seq-annot mapping options.
virtual TSeqPos GetSequenceLength(const CSeq_id_Handle &idh)=0
Get sequence length or kInvalidSeqPos.
bool GetTrimMappedLocation(void) const
Mapped location trimming at sequence end.
void SetSeqTypeById(const CSeq_id_Handle &idh, ESeqType seqtype) const
Methods for setting sequence types.
CSeq_loc_Mapper_Base & SetGapPreserve(void)
Whether to preserve or remove NULL sub-locations (usually indicating gaps) from the result.
EFeatMapDirection
Mapping direction used when initializing the mapper with a feature.
vector< TMappedRanges > TRangesByStrand
CRangeMultimap< CRef< CMappingRange >, TSeqPos > TRangeMap
CSeq_loc_Mapper_Options m_MapOptions
const CSeq_id_Handle & CollectSynonyms(const CSeq_id_Handle &id) const
map< CSeq_id_Handle, TDstRanges > TDstIdMap
CSeq_loc_Mapper_Base & SetMergeNone(void)
Intervals' merging mode MergeNone and MergeAbutting do not change the order of ranges in the destinat...
CSeq_loc_Mapper_Base & SetTrimSplicedSeg(bool trim)
For mapping spliced-segs only: preserve or trim starting/ending indels.
EMapOptions
Options for interpretations of locations.
void SetReverseSrc(bool value=true)
CSeq_loc_Mapper_Options & SetAlign_Sparse_ToFirst(bool value=true)
CSeq_align::C_Segs::TStd TStd
bool GoodSrcId(const CSeq_id &id) const
Check if the id is on the source sequence.
TSeqPos GetDst_from(void) const
void SetReverseDst(bool value=true)
CSeq_loc_Mapper_Options & SetAlign_Dense_seg_TotalRange(bool value=true)
EObjectType Which(void) const
Check type of the object stored in the message.
list< TRange > TDstRanges
map< CSeq_id_Handle, CSeq_id_Handle > TSynonymMap
vector< CRef< CMappingRange > > TSortedMappings
bool x_IsSetOption(int opt) const
CSeq_loc_Mapper_Base::ESeqType TSeqType
bool GetAlign_Dense_seg_TotalRange(void) const
Dense-seg mapping option.
CSeq_loc_Mapper_Base & SetMergeAbutting(void)
Merge only abutting intervals, keep overlapping.
int GetWidthById(const CSeq_id_Handle &idh) const
Get sequence width.
CMappingRange::TRange TRange
bool GetAlign_Sparse_ToFirst(void) const
Mapping direction when mapping through a sparse-seg.
CMappingRanges::TRangeMap TRangeMap
TSeqPos GetOffset(void) const
CSeq_loc_Mapper_Base & SetMergeContained(void)
Merge intervals only if one is completely covered by another.
bool GetReverseSrc(void) const
CRef< CSeq_loc > m_Dst_loc
void IncOffset(TSeqPos inc)
CSeq_loc_Mapper_Base & operator=(const CSeq_loc_Mapper_Base &)
bool x_IsSetMiscFlag(EMiscFlags flag) const
CSeq_loc_Mapper_Base & SetMergeAll(void)
Merge any abutting or overlapping intervals.
map< CSeq_id_Handle, TSeqPos > TLengthMap
bool LastIsPartial(void)
Check if the last mapping resulted in partial location (not all ranges from the original location cou...
const CMappingRanges & GetMappingRanges(void) const
Get mapping ranges.
bool GetReverseDst(void) const
bool GetReverse(void) const
CRef< CSeq_loc > m_SrcLocs
CSeq_loc_Mapper_Base & MixedAlignsAsSpliced(bool value=true)
When set to 'true' if mapped alignment has exactly one genomic and one protein row,...
CMappingRange::TRange TRange
vector< TRange > TGraphRanges
CRef< CSeq_align > x_MapSeq_align(const CSeq_align &src_align, size_t *row)
virtual TSeqType GetSequenceType(const CSeq_id_Handle &idh)=0
Get information about sequence type (nuc or prot).
CSeq_loc_Mapper_Base & SetCheckStrand(bool value=true)
Check strands before mapping a range.
CRef< CMappingRanges > m_Mappings
const TGraphRanges & GetRanges(void) const
TSeqPos GetSrc_from(void) const
CSeq_loc_Mapper_Base & SetMergeBySeg(void)
Merge only intervals from the same group.
SMappedRange(const TRange &rg, const TRangeFuzz &fz, int grp=0)
TIdMap::const_iterator TIdIterator
ESeqType GetSeqType(const CSeq_id_Handle &idh) const
CMappingRanges::TSortedMappings TSortedMappings
CSeq_id_Handle m_Src_id_Handle
map< CSeq_id_Handle, ESeqType > TSeqTypeById
const TRange & GetTotalRange(void) const
map< CSeq_id_Handle, TRangesByStrand > TRangesById
CSeq_loc_Mapper_Options & SetMapSingleLevel(bool value=true)
CSeq_loc_Mapper_Base & SetGapRemove(void)
bool GetAlign_Sparse_ToSecond(void) const
pair< TFuzz, TFuzz > TRangeFuzz
CSeq_loc_Mapper_Base & KeepNonmappingRanges(void)
Keep ranges which can not be mapped.
void x_SetOption(int opt, bool enable)
CSeq_loc_Mapper_Base(const CSeq_loc_Mapper_Base &)
CSeq_loc_Mapper_Base & IncludeSourceLocs(bool value=true)
Include source ranges in the mapped location.
vector< TDstIdMap > TDstStrandMap
CSeq_loc_Mapper_Options & SetAlign_Sparse_ToSecond(bool value=true)
CRef< CSeq_id > GetDstId(void) const
bool GetMapSingleLevel(void) const
Mapping depth when using a seq-map, a bioseq or a GC-assembly.
void SetOffset(TSeqPos offset)
CSeq_loc_Mapper_Base::TSynonyms TSynonyms
@ eMapped_Some
Some (not all) annotations were mapped.
@ eLocationToProduct
Map from the feature's location to product.
@ fAlign_Dense_seg_TotalRange
Ignore internal dense-seg structure - map each dense-seg according to the total ranges involved.
@ fTrimMappedLocation
Enable trimming of source/destination ranges at sequence end.
@ fMapSingleLevel
Flag used when mapping through a seq-map (this includes mapping through a bioseq or a GC-assembly).
@ fAlign_Sparse_ToSecond
Map to second-id.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
list< CRef< CStd_seg > > TStd
list< CRef< CSpliced_exon_chunk > > TParts
list< CRef< CDense_diag > > TDendiag
ENa_strand
strand of nucleic acid
range(_Ty, _Ty) -> range< _Ty >
const CharType(& source)[N]
IMessage/IMessageListener interfaces and basic implementations.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
int GetLoc(const string &acc, const string &pat, CSeq_loc &loc, CScope &scope)
static const char * str(char *buf, int n)