80 new CScope(bio_handle.GetScope().GetObjectManager())
83 s_ScopeTls.SetValue(s, TlsValCleanup<TScopeRef>, 0);
101 auto TaxId =
GetTaxId(fExtOrgLookup);
118 list<CRef<CSeqdesc> > seqdesclist = bio_handle.
GetDescr().
Get();
119 for (
auto seqdesc : seqdesclist) {
120 if (seqdesc->IsTitle()) {
136 if (!
m_TaxId && fExtOrgLookup) {
175 if (biosrc.IsSetTaxname()) {
176 taxonomy = biosrc.GetTaxname();
177 const COrg_ref &org = biosrc.GetOrg();
200 if (taxonomy.empty())
210 m_CreateConsensus(
false),
211 m_isDataReadSync(
false)
226 LOG_POST(
Error <<
"CAlnVecMultiDataSource::~CAlnVecMultiDataSource(): "
227 <<
"failed to delete job: " << e.
GetMsg());
242 return m_ConsRowIndex;
248 vector< CConstRef<CSeq_align> > aligns;
250 if(annot.GetData().IsAlign() ) {
252 aligns.emplace_back(*it);
255 Init(aligns, sync, select_anchor);
261 vector< CConstRef<CSeq_align> > aligns;
267 aligns.emplace_back(&*it);
269 Init(aligns, sync, select_anchor);
274 bool sync,
bool select_anchor)
326 ERR_POST(
"CAlnVecMultiDataSource::OnAppJobNotification() - unknown Job ID " << job_id);
353 progressSoFar->GetText(), progressSoFar->GetNormDone());
375 if (!row->IsConsensus())
413 string text = prg->GetText();
433 if(
m_AlnVec->GetDenseg().IsSetWidths()) {
443 }
catch (exception& e) {
515 return (row >= 0 && row < m_AlnVec->
GetNumRows());
527 return m_AlnVec->GetBioseqHandle(row);
542 return m_AlnVec->IsPositiveStrand(row);
548 return m_AlnVec->IsNegativeStrand(row);
554 bool try_reverse_dir)
const
556 return m_AlnVec->GetAlnPosFromSeqPos(for_row, aln_pos,
563 bool try_reverse_dir)
const
585 if(seq_start > seq_stop) {
586 swap(seq_start, seq_stop);
596 if(aln_from > aln_to) {
597 swap(aln_from, aln_to);
615 TSeqPos aln_from =
max(aln_start, it->GetFrom());
678 fill_n(base_count, numBases, 0);
681 for (
size_t i = 0;
i < rows.size(); ++
i) {
682 if (col >= rows[
i].
size())
759 fill_n(base_count, numBases, 0);
762 for (
size_t i = 0;
i < rows.size(); ++
i) {
767 if (0 <= pos && pos < numBases)
775 bool isNucleotide =
m_AlnVec->GetBioseqHandle(0).IsNucleotide();
777 const int numBases = isNucleotide ? 4 : 26;
778 const auto num_rows =
m_AlnVec->GetNumRows();
779 const auto num_segs =
m_AlnVec->GetNumSegs();
785 int gap_seg_thresh = num_rows - num_rows / 2;
787 for (
auto j = 0; j < num_segs; ++j) {
790 auto seg_len =
m_AlnVec->GetLen(j, 0);
791 for (
auto i = 0;
i < num_rows; ++
i) {
801 if (gap_count > gap_seg_thresh) {
802 consens[j].resize(seg_len);
803 for (
size_t i = 0;
i < seg_len; ++
i)
812 ((num_rows - gap_count) * 7 + 5) / 10;
816 consens[j].resize(seg_len);
819 vector<string> segs(num_rows);
820 m_AlnVec->RetrieveSegmentSequences(j, segs);
826 for (
auto i = 0;
i < seg_len; ++
i) {
842 for (
int k = 0; k < numBases; ++k) {
852 if (rev_map.count(rev_map.begin()->first) == 1 &&
853 rev_map.begin()->first >= base_thresh) {
854 consens[j][
i] = isNucleotide ?
855 m_AlnVec->ToIupac(rev_map.begin()->second) :
856 (rev_map.begin()->second +
'A');
862 unsigned char c = 0x00;
864 TRevMap::iterator curr = rev_map.begin();
865 TRevMap::iterator
prev = rev_map.begin();
867 curr != rev_map.end() &&
868 (freq < base_thresh ||
prev->first == curr->first);
876 unsigned char cur_char = curr->second +
'A';
882 c = (cur_char ==
'N' || cur_char ==
'D') ?
'B' :
'X';
885 c = (cur_char ==
'Q' || cur_char ==
'E') ?
'Z' :
'X';
888 c = (cur_char ==
'I' || cur_char ==
'L') ?
'J' :
'X';
900 consens[j][
i] = isNucleotide ?
'N' :
'X';
903 consens[j][
i] = isNucleotide ?
m_AlnVec->ToIupac(c) : c;
935 unique_ptr<vector<string>> consens(
new vector<string>);
936 consens->resize(
m_AlnVec->GetNumSegs());
939 CSeq_id consensus_id(
"lcl|consensus");
942 *bioseq, consensus_id, consens.get());
947 m_AlnVec->GetScope().AddTopLevelSeqEntry(*entry);
961 auto seq_len = new_seq.size();
962 seq.resize(seq_len * 3);
964 for (
size_t i = 0;
i < seq_len; ++
i) {
966 seq[n_i] = seq[n_i + 1] = seq[n_i + 2] = new_seq[
i];
970 #ifdef _SHOW_CONSENSUS_IN_PANORAMA_
977 'W',
'Y',
'X',
' ',
'-'
981 'A',
'C',
'G',
'T',
'N',
' ',
'-'
985 #define ADD_BASE_TO_GRAPH(b) \
986 { if (graphs[b].size() == 0) graphs[b].resize(ref_len, 0); graphs[b][curr_pos] += 1; }
999 char ambiguous_residue =
' ';
1000 if (align_type == IAlnExplorer::EAlignType::fDNA)
1001 ambiguous_residue =
'N';
1003 ambiguous_residue =
'X';
1012 if (translate_sequence)
1015 bool ref_is_consensus = anchor != -1 && anchor == consensus_idx;
1017 #ifdef _SHOW_CONSENSUS_IN_PANORAMA_
1018 const set<char>* non_ambiguous_set =
nullptr;
1019 if (consensus_idx >= 0) {
1021 non_ambiguous_set = &ss_NonAmbiguousAA;
1023 non_ambiguous_set = &ss_NonAmbiguousDNA;
1029 if (row == consensus_idx)
1032 unique_ptr<IAlnSegmentIterator> p_it
1055 if (curr_aln_start < aln_range.
GetFrom()) {
1056 pos = aln_range.
GetFrom() - curr_aln_start;
1058 off = curr_aln_start - aln_range.
GetFrom();
1060 size_t curr_pos = off;
1064 if (translate_sequence)
1068 while (pos < seg_len && curr_pos < ref_len) {
1070 char base = aln_seq[pos];
1073 }
else if (anchor >=0 && curr_pos < ref_len) {
1074 #ifdef _SHOW_CONSENSUS_IN_PANORAMA_
1076 if (non_ambiguous_set && non_ambiguous_set->count(ref_str[curr_pos]) == 0)
1080 if (base != ref_str[curr_pos] && base != ambiguous_residue) {
1081 if (ref_str[curr_pos] != ambiguous_residue || ref_is_consensus) {
static CRef< CScope > m_Scope
static void s_GetTaxonomyInfoFromService(int tax_id, string &taxonomy)
USING_SCOPE(ncbi::objects)
static void s_TranslateAndExpand(string &seq, int gen_code)
static objects::CScope & s_GetPristineScope(const objects::CBioseq_Handle &bio_handle)
static void s_GetTaxonomyInfoFromBiosrc(const objects::CBioSource &biosrc, std::string &taxonomy)
void CollectNucleotideFrequences(const vector< string > &rows, int col, int base_count[], int numBases)
ON_EVENT(CAppJobNotification, CAppJobNotification::eStateChanged, &CAlnVecMultiDataSource::OnAppJobNotification) ON_EVENT(CAppJobNotification
void CollectProteinFrequences(const vector< string > &rows, int col, int base_count[], int numBases)
void TlsValCleanup(T *oldVal, void *)
#define ADD_BASE_TO_GRAPH(b)
static CStaticTls< TScopeRef > s_ScopeTls
CAlnVecMultiDataSource - implementation of IAlnMultiDataSource for CAlnVec-based alignments.
virtual const IAlignRowHandle * GetRowHandle(TNumrow row) const
virtual void x_OnJobProgress(CAppJobNotification ¬n)
virtual bool IsPositiveStrand(TNumrow row) const
virtual TSeqPos GetSeqStop(TNumrow row) const
virtual void GetAlnFromSeq(TNumrow row, const TRangeColl &seq_coll, TRangeColl &aln_coll) const
virtual TNumrow GetNumRows(void) const
number of rows in alignment
virtual void CreateConsensus()
virtual TSignedSeqPos GetAlnPosFromSeqPos(TNumrow row, TSeqPos seq_pos, TSearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const
virtual void GetSeqFromAln(TNumrow row, const TRangeColl &aln_coll, TRangeColl &seq_coll) const
virtual void Init(const objects::CSeq_annot &annot, bool sync=false, bool select_anchor=false)
virtual bool SetAnchor(TNumrow anchor)
virtual TSeqPos GetSeqStart(TNumrow row) const
virtual void SetGapChar(TResidue gap_char)
vector< CAlnVecRowHandle * > THandleVector
virtual void x_DeleteJob()
virtual TSignedSeqPos GetSeqPosFromAlnPos(TNumrow for_row, TSeqPos aln_pos, TSearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const
virtual TSeqPos GetBaseWidth(TNumrow row) const
virtual bool IsNegativeStrand(TNumrow row) const
virtual IAlnSegmentIterator * CreateSegmentIterator(TNumrow row, const IAlnExplorer::TSignedRange &range, IAlnSegmentIterator::EFlags flags) const
CAlnVecMultiDataSource(objects::CScope &scope)
virtual string & GetAlnSeqString(TNumrow row, string &buffer, const IAlnExplorer::TSignedRange &aln_range) const
virtual TSeqPos GetAlnStart(void) const
virtual bool IsSetAnchor(void) const
Anchoring methods.
virtual IAlnExplorer::EAlignType GetAlignType() const
virtual void x_CreateHandles()
void OnAppJobNotification(CEvent *evt)
virtual TSeqPos GetAlnStop(void) const
virtual bool UnsetAnchor(void)
CRef< objects::CScope > m_Scope
virtual const objects::CSeq_id & GetSeqId(TNumrow row) const
CRef< objects::CAlnVec > m_AlnVec
virtual bool x_IsJobRunning()
virtual void x_ClearHandles()
~CAlnVecMultiDataSource()
virtual bool CanGetId(TNumrow row) const
virtual void x_Assign(objects::CAlnVec &aln_vec)
virtual bool CanCreateConsensus()
virtual const objects::CBioseq_Handle & GetBioseqHandle(TNumrow row) const
CRef< CBuildAlnVecJob > m_Job
virtual bool IsEmpty() const
virtual TNumrow GetAnchor(void) const
virtual bool CanChangeAnchor(void) const
virtual int GetGenCode(IAlnExplorer::TNumrow row) const
CAlnVecRowHandle is inherited from IAlignRowHandle and represents a row of CAlnVec-based alignment.
static void TranslateNAToAA(const string &na, string &aa, int gen_code=kDefaultGenCode)
CAppJobNotification Notification send by CAppJobEventTranslator.
CRef< objects::CAlnVec > m_AlnVec
CUpdate - notification send by CUIDataSource to the listener.
virtual void NotifyListener(CUpdate &update)
CEvent - generic event implementation TODO TODO - Attachments.
void GetLabel(string *label) const
TThisType & CombineWith(const TRange &r)
string GetTaxname(int tax_id)
static CTaxonCache & GetInstance()
string GetCommon(int tax_id)
string GetLabel(int tax_id)
string GetBlastName(int tax_id)
IAlignRowHandle provides an abstract way to access alignment row data.
virtual bool CanGetBioseqHandle() const =0
virtual const string & GetOrgLabel(bool fExtOrgLookup=false) const
virtual int GetGenCode() const =0
virtual const objects::CBioseq_Handle & GetBioseqHandle() const =0
virtual void GetTaxonomy(string &taxonomy, bool fExtOrgLookup=false) const
virtual int GetTaxId(bool fExtOrgLookup=false) const
virtual IAlnSegmentIterator * CreateSegmentIterator(const IAlnExplorer::TSignedRange &range, IAlnSegmentIterator::EFlags flags) const =0
virtual const string & GetText() const =0
ESearchDirection
Position search options.
@ eRight
Towards higher aln coord (always to the right)
@ eLeft
Towards lower aln coord (always to the left)
virtual IAlnExplorer::EAlignType GetAlignType() const =0
virtual int GetConsensusRow() const =0
returns index of the Consensus row or -1 if it doesn't exist
void CollectAlignStats(const TSignedSeqRange &range, TStatGraphs &graphs, bool translate_sequence=false) const
IAlnExplorer::TResidue TResidue
virtual IAlnSegmentIterator * CreateSegmentIterator(TNumrow row, const IAlnExplorer::TSignedRange &range, IAlnSegmentIterator::EFlags flags) const =0
IAlnExplorer::TNumrow TNumrow
virtual TNumrow GetNumRows(void) const =0
number of rows in alignment
virtual bool IsSetAnchor(void) const =0
Anchoring methods.
virtual TNumrow GetAnchor(void) const =0
virtual string & GetAlnSeqString(TNumrow row, string &buffer, const IAlnExplorer::TSignedRange &aln_range) const =0
Alignment segment iterator interface.
@ eAllSegments
Iterate all segments.
Alignment segment interface.
virtual const TSignedRange & GetRange(void) const =0
Get the selected row range.
@ fAligned
Aligned segment.
@ fIndel
Either anchor or the selected row is not present in the segment.
@ fGap
Both anchor row and the selected row are not included in the segment (some other row is present and t...
virtual TSegTypeFlags GetType(void) const =0
Get current segment type.
virtual const TSignedRange & GetAlnRange(void) const =0
Get alignment range for the segment.
virtual int GetGenCode(IAlnExplorer::TNumrow row) const =0
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
int TSignedSeqPos
Type for signed sequence position.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#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.
const string & GetMsg(void) const
Get message string.
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
static bool IsVDBAccession(const string &acc)
Check if string starts with ("SRA", "SRR", "DRR", "ERR")
CConstIRef< IAppJobError > GetError() const
returns non-null pointer only if job Failed
void RunSync(IAppJob &job, TJobID &jobId, CEventHandler &listener)
Runs jon synchronously sending job notifications synchronously Returns when job is finished.
static CAppJobDispatcher & GetInstance()
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
bool DeleteJob(TJobID job_id)
when a Job is deleted the listener is not notified
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...
CConstIRef< IAppJobProgress > GetProgress() const
returns non-null pointer only if notification type is eProgress
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
TJobState GetState() const
const CBioSource * GetBioSource(const CBioseq &bioseq)
Retrieve the BioSource object for a given bioseq handle.
TTaxId GetTaxId(const CBioseq_Handle &handle)
return the tax-id associated with a given sequence.
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
const TDescr & GetDescr(void) const
bool CanGetDescr(void) const
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
position_type GetLength(void) const
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const TOrg & GetOrg(void) const
Get the Org member data.
TFrom GetFrom(void) const
Get the From member data.
bool CanGetCommon(void) const
Check if it is safe to call GetCommon method.
const TCommon & GetCommon(void) const
Get the Common member data.
TSeq & SetSeq(void)
Select the variant.
bool CanGet(void) const
Check if it is safe to call Get method.
const TInst & GetInst(void) const
Get the Inst member data.
list< CRef< CSeq_align > > TAlign
const Tdata & Get(void) const
Get the member data.
TMol GetMol(void) const
Get the Mol member data.
static void text(MDB_val *v)
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static pcre_uint8 * buffer