88 return ref->GetNormDone();
109 size_t identical_locs = 0;
112 size_t identical_seqs = 0;
115 size_t identical_prods = 0;
118 size_t identical_locs_seqs = 0;
121 size_t identical_locs_prods = 0;
124 size_t identical_seqs_prods = 0;
127 size_t identical_locs_seqs_prods = 0;
132 TFeatCountMap feat_counts;
135 TCountNotFound count_not_found;
143 subtype = iter->feat1->GetData().GetKey();
144 }
else if (iter->feat2) {
145 subtype = iter->feat2->GetData().GetKey();
152 TFeatCountMap::iterator it =
153 feat_counts.insert(make_pair(subtype, TCountMap())).first;
155 TCountMap::iterator count_it = it->second.insert(elt).first;
161 ++identical_seqs_prods;
175 ++identical_locs_seqs_prods;
178 ++identical_locs_seqs;
181 ++identical_locs_prods;
186 iter->feat1 ? iter->feat1_seq : iter->feat2_seq;
188 iter->feat1 ? *iter->feat1 : *iter->feat2;
193 TCountNotFound::iterator i1 = count_not_found.insert(v1).first;
196 TFeatCountMap::iterator i2 = i1->second.insert(
v2).first;
199 TCountMap::iterator i3 = i2->second.insert(v3).first;
204 ostr <<
"Evaluated " <<
m_Rows.size() <<
" total comparisons.\n\n";
206 ostr << setw(10) << identical_locs <<
" Identical location\n";
207 ostr << setw(10) << identical_seqs <<
" Identical sequence\n";
208 ostr << setw(10) << identical_prods <<
" Identical product\n";
209 ostr << setw(10) << identical_locs_seqs <<
" Identical location + sequence\n";
210 ostr << setw(10) << identical_locs_prods <<
" Identical location + product\n";
211 ostr << setw(10) << identical_seqs_prods <<
" Identical sequence + product\n";
212 ostr << setw(10) << identical_locs_seqs_prods <<
" Identical location + sequence + product\n";
215 ostr <<
"\nFeatures Not Found:\n";
216 ostr <<
"-------------------\n";
217 ITERATE (TCountNotFound, iter, count_not_found) {
221 size_t total_feats = 0;
222 ITERATE (TFeatCountMap, it, iter->second) {
223 ITERATE (TCountMap,
i, it->second) {
224 total_feats +=
i->second;
227 ostr << setw(10) << total_feats <<
" Not found on " << s <<
"\n";
228 ITERATE (TFeatCountMap, it, iter->second) {
230 ITERATE (TCountMap,
i, it->second) {
233 ostr << setw(14) << count <<
" " << it->first;
237 ostr <<
" not found\n";
244 ostr <<
"\nFeature Comparisons by Feature Type:\n";
245 ostr <<
"------------------------------------\n";
246 ITERATE (TFeatCountMap, iter, feat_counts) {
248 size_t total_feats = 0;
249 ITERATE (TCountMap, it, iter->second) {
250 total_feats += it->second;
253 ostr << setw(10) << total_feats <<
" " << iter->first;
254 if (total_feats != 1) {
259 ITERATE (TCountMap, it, iter->second) {
260 ostr << setw(14) << it->second <<
" ";
279 ostr <<
"identical location";
282 ostr <<
"missing exons";
285 ostr <<
"5' extension";
288 ostr <<
"3' extension";
291 ostr <<
"5' extra exons";
294 ostr <<
"3' extra exons";
297 ostr <<
"overlap, shared intervals";
300 ostr <<
"complex location comparison";
306 ostr <<
"overlap, no shared intervals";
309 ostr <<
"different strand";
313 ostr <<
"comparison unknown";
318 ostr <<
", same sequence";
321 ostr <<
", same product sequence";
339 "Failed to start job: " << e.GetMsg());
352 switch (e.GetErrCode()) {
361 "Error canceling job: " << e);
378 x_OnAppJobNotification(evt);
508 return string(
"CFeatCompareJob");
531 , m_Align(&alignment)
559 list<CSeq_id_Handle> ids;
562 for (
size_t i = 0;
i < rows; ++
i) {
569 TFeats& feats = fmap[sih];
570 for ( ; feat_iter; ++feat_iter) {
572 feats[ref] = *feat_iter;
583 ITERATE (list<CSeq_id_Handle>, idh_iter1, ids) {
586 ITERATE (list<CSeq_id_Handle>, idh_iter2, ids) {
587 if (idh_iter1 == idh_iter2) {
591 bool do_swap = (*idh_iter2 < *idh_iter1);
597 const TFeats& feat_set1 = (do_swap ? fmap[sih2] : fmap[sih1]);
598 TFeats& feat_set2 = (do_swap ? fmap[sih1] : fmap[sih2]);
607 ITERATE (TFeats, fiter1, feat_set1) {
621 for ( ; iter; ++iter) {
641 TFeats::iterator fi2 = feat_set2.find(ref2);
642 if (fi2 != feat_set2.end()) {
643 feat_set2.erase(fi2);
653 ITERATE (TCompMap, cmiter, comp_map) {
659 row.
feat2.
Reset(&cmiter->second.GetOriginalFeature());
734 back_inserter(m_Alignments));
754 align_set.
Get().end(),
755 back_inserter(m_Alignments));
841 for ( ; feat_iter; ++feat_iter) {
858 for ( ; feat_iter2; ++feat_iter2) {
867 }
else if (annot_name.empty()) {
884 if (comp_map.size()) {
886 ITERATE (TCompMap, cmiter, comp_map) {
893 row.
feat2.
Reset(&cmiter->second.GetOriginalFeature());
static CRef< CScope > m_Scope
ON_EVENT(CAppJobNotification, CAppJobNotification::eStateChanged, &CAnnotCompareDS::OnAJNotification) void CAnnotCompareDS
void Add(const CDense_seg &ds, TAddFlags flags=0)
void Merge(TMergeFlags flags=0)
const CSeq_align & GetSeqAlign(void) const
objects::CScope & GetScope() const
CAppJobDispatcher::TJobID m_ActiveJob
control of background loading
size_t GetRows(void) const
void RegisterListener(CEventHandler *listener)
register a listener to respond to background job completion events
CEventHandler * m_Listener
const SRow & GetRow(size_t row_idx) const
CRef< objects::CScope > m_Scope
virtual void x_OnAppJobNotification(CEvent *evt)
float GetProgress() const
return progress indicator
void DumpTextReport(CNcbiOstream &ostr) const
dump a text report of the comparisons
const TRows & GetData() const
void x_BackgroundJob(IAppJob *job)
CAnnotCompare_AlignDS(objects::CScope &scope, const objects::CSeq_annot &annot)
list< CConstRef< objects::CSeq_align > > m_Alignments
our original alignments
CConstRef< objects::CSeq_align > m_Align
merged alignment from the above
CConstRef< objects::CSeq_loc > m_Loc
CAnnotCompare_LocationDS(objects::CScope &scope, const objects::CSeq_loc &loc)
~CAnnotCompare_LocationDS()
TCompareFlags CompareFeats(const CSeq_feat &feat1, CScope &scope1, const CSeq_feat &feat2, CScope &scope2, vector< ECompareFlags > *complex_flags, list< string > *comments)
compare two different features, possibly living in different scopes.
@ eLocation_3PrimeExtraExon
@ eLocation_RegionOverlap
locations exhibit a non-shared-exon overlap of total range
@ eLocation_MissingExon
missing an exon, either 5', 3', or internal
@ eLocation_5PrimeExtension
5', 3' extended exon
@ eLocation_Overlap
locations overlap without sharing exon boundaries
@ eSequence_SameSeq
sequence categories (genomic and product)
@ eLocation_Complex
complex relation - results may be returned as a set of the above
@ eLocationMask
masks for the above
@ eLocation_Subset
one location is a subset of another
@ eLocation_DifferentStrand
locations annotated on different strands
@ eLocation_3PrimeExtension
@ eSequence_SameProduct
locations have the same product sequence
@ eLocation_Missing
genomic location categories
@ eLocation_Same
no difference in lcoation
@ eLocation_5PrimeExtraExon
5', 3' extra exons
size_t GetSize(void) const
IAppJobListener Interface for components that need to be notified about changes in Jobs.
CAppJobNotification Notification send by CAppJobEventTranslator.
CAppJobProgress Default implementation for IAppJobProgress - the class encapsulates a text message an...
CEvent - generic event implementation TODO TODO - Attachments.
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
CFeatCompareJob_Align(CScope &scope, const CSeq_align &alignment)
CConstRef< CSeq_align > m_Align
Annotation Comparison by location alone This is done by checking a few constraints.
CFeatCompareJob_Location(CScope &scope, const CSeq_loc &loc)
CConstRef< CSeq_loc > m_Loc
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
Alignment-based data source.
virtual CConstIRef< IAppJobProgress > GetProgress()
return progress object, the function shall be synchronized internally.
CFeatCompareJob(CScope &scope)
CRef< CAppJobError > m_Error
size_t m_TotalComparisons
for status reporting
virtual CRef< CObject > GetResult()
Returns the Job Result.
CRef< CFeatCompare_Result > m_Result
virtual CConstIRef< IAppJobError > GetError()
Returns IAppJobError object describing internal error that caused the Job to fail.
size_t m_CompletedComparisons
virtual string GetDescr() const
Returns a human readable description of the Job (optional)
AppJobs for background loading and preparation.
CAnnotCompareDS::TRows m_Rows
row represents a pair of compared features
Base class to build jobs with cancel functionality.
ESubtype GetSubtype(void) const
string GetKey(EVocabulary vocab=eVocabulary_full) const
CRange< TSeqPos > GetSeqRange(TDim row) const
GetSeqRange NB: On a Spliced-seg, in case the product-type is protein, these only return the amin par...
TDim CheckNumRows(void) const
Validatiors.
const CSeq_id & GetSeq_id(TDim row) const
Get seq-id (the first one if segments have different ids).
ENa_strand GetSeqStrand(TDim row) const
Get strand (the first one if segments have different strands).
namespace ncbi::objects::
@ eWidgetDataChanged
notification from child to parent that the underlying data has changed
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
static CAppJobDispatcher & GetInstance()
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
virtual bool IsCanceled() const override
bool DeleteJob(TJobID job_id)
when a Job is deleted the listener is not notified
EJobState
Job states (describe FSM)
TJobID StartJob(IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be...
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
CConstIRef< IAppJobProgress > GetJobProgress(TJobID job_id)
TJobState GetState() const
virtual bool Send(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Sends an event synchronously.
void SetNormDone(float done)
@ eEngine_UnknownJob
the job is not registered in the Engine
@ eUnknownJob
Job record lost.
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.
CSeq_id_Handle GetIdHandle(const CSeq_loc &loc, CScope *scope)
CRef< CSeq_loc > Map(const CSeq_loc &src_loc)
Map seq-loc.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
CSeq_loc_Mapper_Base & SetMergeAbutting(void)
Merge only abutting intervals, keep overlapping.
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
const CSeqFeatData & GetData(void) const
const string & GetName(void) const
const CSeq_loc & GetLocation(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
const CSeq_feat_Handle & GetSeq_feat_Handle(void) const
Get original feature handle.
SAnnotSelector & SetFeatSubtype(TFeatSubtype subtype)
Set feature subtype (also set annotation and feat type)
SAnnotSelector & ExcludeNamedAnnots(const CAnnotName &name)
Add named annot to set of annots names to exclude.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
const Tdata & Get(void) const
Get the member data.
const TData & GetData(void) const
Get the Data member data.
E_Choice Which(void) const
Which variant is currently selected.
const TAlign & GetAlign(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
E_Choice Which(void) const
Which variant is currently selected.
double value_type
The numeric datatype used by the parser.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
objects::CSeq_id_Handle feat2_seq
CRef< objects::CScope > scope
CConstRef< objects::CSeq_loc > feat2_loc
CConstRef< objects::CSeq_loc > feat1_loc
CConstRef< objects::CSeq_feat > feat1
we store a pair of features and their locations the location is stored separately because if a featur...
CConstRef< objects::CSeq_feat > feat2
objects::CAnnotCompare::TCompareFlags loc_state
objects::CSeq_id_Handle feat1_seq