53 #define NCBI_USE_ERRCODE_X VDBGraphReader
67 static bool use_vdb_index =
NCBI_PARAM_TYPE(VDBGRAPH, USE_VDB_INDEX)::GetDefault();
68 return !use_vdb_index;
115 bool another_vdb =
false;
129 "Cannot open VDB graph table: "<<path,
140 TVDBRowId last_row = curs->m_Cursor.GetMaxRowId();
144 ERR_POST(
Warning<<
"CVDBGraphDb: sid index not found. Scanning sequentially.");
150 if ( *seq_id ==
info.m_SeqId ) {
153 info.m_SeqLength = start +
len;
156 if ( !
info.m_SeqId.empty() ) {
159 info.m_SeqId = *seq_id;
165 if ( !
info.m_SeqId.empty() ) {
166 info.m_RowLast = last_row;
173 info.m_SeqId = *seq_id;
175 info.m_RowSize = *curs->LEN(
row);
181 if (
range.second > 1 ) {
223 bool ret = curs->m_GR_ZOOM_Q100;
234 return *iter->second;
247 info.m_RowFirst = first_row;
248 TSeqPos first_len = *curs->LEN(first_row);
249 info.m_RowSize = first_len;
253 if (
range.second > 1 ) {
256 info.m_RowLast = last_row;
258 TSeqPos last_len = *curs->LEN(last_row);
259 info.m_SeqLength = last_start + last_len;
263 info.m_RowLast = first_row;
265 info.m_SeqLength = first_start + first_len;
279 return *iter->second;
284 const CTextseq_id* text_id = seq_id->GetTextseq_Id();
294 if ( !
range.second ) {
298 auto first_row =
range.first;
301 info.m_Seq_id_Handle = idh;
302 info.m_RowFirst = first_row;
303 TSeqPos first_len = *curs->LEN(first_row);
304 info.m_RowSize = first_len;
305 if (
range.second > 1 ) {
308 info.m_RowLast = last_row;
310 TSeqPos last_len = *curs->LEN(last_row);
311 info.m_SeqLength = last_start + last_len;
315 info.m_RowLast = first_row;
317 info.m_SeqLength = first_start + first_len;
356 "CVDBGraphSeqIterator is invalid");
362 template<
class DstVector,
class SrcVector>
363 static void sx_Assign(DstVector& dst,
const SrcVector& src)
366 dst.reserve(src.size());
367 ITERATE (
typename SrcVector, it, src ) {
388 if ( !annot_name.empty() ) {
397 const TValue kMinIntValue =
kMin_I4;
398 const TValue kMaxIntValue =
kMax_I4;
399 const TValue kMinByteValue = 0;
400 const TValue kMaxByteValue =
kMax_UI1;
411 pos <
range.GetToOpen();
414 for (
size_t index = pos%row_size/step;
415 index < values.
size() && pos <
range.GetToOpen();
416 ++index, pos += step ) {
417 TValue v = values[index];
418 bool switch_to_real =
false;
421 switch_to_real = v < kMinIntValue;
425 switch_to_real = v > kMaxIntValue;
427 if ( switch_to_real && int_vv ) {
430 real_graph = &graph->
SetGraph().SetReal();
437 int_vv->push_back(
int(v));
440 real_vv->push_back(
double(v));
443 if ( pos <
range.GetToOpen() &&
444 pos < (
row-
info.m_RowFirst+1)*row_size ) {
446 "CVDBGraphSeqIterator: graph data array is too short");
450 if ( min_v >= kMinByteValue && max_v <= kMaxByteValue ) {
452 numval = int_vv->size();
454 byte_graph->SetAxis(0);
455 byte_graph->SetMin(
int(min_v));
456 byte_graph->SetMax(
int(max_v));
457 sx_Assign(byte_graph->SetValues(), *int_vv);
458 graph->
SetGraph().SetByte(*byte_graph);
462 else if ( real_graph ) {
464 numval = real_vv->size();
466 real_graph->
SetMin(
double(min_v));
467 real_graph->
SetMax(
double(max_v));
471 numval = int_vv->size();
473 int_graph->
SetMin(
int(min_v));
474 int_graph->
SetMax(
int(max_v));
481 graph->
SetA(1./scale);
485 "CVDBGraphSeqIterator::x_MakeGraph: graph too big");
502 const TValue kMinIntValue =
kMin_I4;
503 const TValue kMaxIntValue =
kMax_I4;
505 TValue min_v = 0, max_v = 0;
510 for ( ; pos <
range.GetToOpen(); ++
row, pos += row_size ) {
515 TValue v = vv_arr[off+
i];
527 table->SetFeat_type(0);
531 table->SetColumns().push_back(col_id);
532 col_id->
SetHeader().SetField_name(
"Seq-table location");
537 table->SetColumns().push_back(col_id);
544 table->SetColumns().push_back(col_pos);
550 table->SetColumns().push_back(col_span);
551 col_span->
SetHeader().SetField_name(
"span");
555 table->SetColumns().push_back(col_val);
556 col_val->
SetHeader().SetField_name(
"values");
559 TValue cur_v = vv[0];
560 if ( min_v < kMinIntValue || max_v > kMaxIntValue ) {
565 arr_pos.push_back(cur_i+
range.GetFrom());
566 arr_span.push_back(
i-cur_i);
567 arr_vv.push_back(
double(cur_v));
572 arr_pos.push_back(cur_i+
range.GetFrom());
573 arr_span.push_back(
size-cur_i);
574 arr_vv.push_back(
double(cur_v));
581 arr_pos.push_back(cur_i+
range.GetFrom());
582 arr_span.push_back(
i-cur_i);
583 arr_vv.push_back(
int(cur_v));
588 arr_pos.push_back(cur_i+
range.GetFrom());
589 arr_span.push_back(
size-cur_i);
590 arr_vv.push_back(
int(cur_v));
596 table->SetColumns().push_back(col_step);
597 col_step->
SetHeader().SetField_name(
"value_step");
600 if ( arr_pos.size() >
size_t(
kMax_Int) ) {
602 "CVDBGraphSeqIterator::x_MakeTable: graph too big");
604 table->SetNum_rows(
int(arr_pos.size()));
612 if ( !cursor.m_NUM_SWITCHES ) {
617 const TValue kMinIntValue =
kMin_I4;
618 const TValue kMaxIntValue =
kMax_I4;
619 const TValue kMinByteValue = 0;
620 const TValue kMaxByteValue =
kMax_UI1;
621 TValue min_v = 0, max_v = 0;
628 for ( ; pos <
range.GetToOpen(); ++
row, pos += row_size ) {
630 switches += *cursor.NUM_SWITCHES(
info.m_RowFirst+
row);
631 TValue v = cursor.GR_Q100(
info.m_RowFirst+
row);
639 size_t table_value_size =
640 min_v < kMinIntValue || max_v > kMaxIntValue?
sizeof(double):
sizeof(
int);
641 size_t graph_value_size =
642 min_v < kMinByteValue || max_v > kMaxByteValue? table_value_size: 1;
644 (table_value_size+2*
sizeof(
int))*switches;
646 graph_value_size*values;
647 return table_size < graph_size;
654 if (
range.GetToOpen() >
info.m_SeqLength ) {
657 if (
range.Empty() ) {
664 return seq_table_is_smaller;
670 const string& annot_name,
677 if ( range0.
Empty() ) {
683 if ( !annot_name.empty() ) {
686 annot->
SetDesc().Set().push_back(desc);
695 "several zoom tracks are requested");
706 range.GetToOpen() + (step - adjust)));
718 obj.
SetType().SetStr(
"AnnotationTrack");
719 obj.
AddField(
"ZoomLevel",
int(step));
720 obj.
AddField(
"StatisticsType",
"Percentiles");
721 annot->
SetDesc().Set().push_back(desc);
725 if ( !(content &
f) ) {
732 step, *curs, curs->m_GR_Q0 , 0);
736 step, *curs, curs->m_GR_Q10 , 10);
740 step, *curs, curs->m_GR_Q50 , 50);
744 step, *curs, curs->m_GR_Q90 , 90);
748 step, *curs, curs->m_GR_Q100, 100);
754 annot->
SetData().SetGraph().push_back(graph);
762 "several zoom tracks are requested");
773 range.GetToOpen() + (step - adjust)));
785 obj.
SetType().SetStr(
"AnnotationTrack");
786 obj.
AddField(
"ZoomLevel",
int(step));
787 obj.
AddField(
"StatisticsType",
"Percentiles");
788 annot->
SetDesc().Set().push_back(desc);
792 if ( !(content &
f) ) {
799 step, *curs, curs->m_GR_ZOOM_Q0 , 0);
803 step, *curs, curs->m_GR_ZOOM_Q10 , 10);
807 step, *curs, curs->m_GR_ZOOM_Q50 , 50);
811 step, *curs, curs->m_GR_ZOOM_Q90 , 90);
815 step, *curs, curs->m_GR_ZOOM_Q100, 100);
821 annot->
SetData().SetGraph().push_back(graph);
834 bool as_table =
false;
848 obj.
SetType().SetStr(
"Track Data");
849 obj.
AddField(
"track type",
"graph");
850 annot->
SetDesc().Set().push_back(desc);
859 1, *curs, curs->m_GRAPH, -1);
860 annot->
SetData().SetGraph().push_back(graph);
@ eNotFoundTable
DB table not found.
virtual TErrCode GetErrCode(void) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
CVDBTableIndex m_LookupIndex
CRef< SGraphTableCursor > Graph(void)
bool HasMidZoomGraphs(void)
CVDBObjectCache< SGraphTableCursor > m_Graph
TSeqInfoMapBySeq_id m_SeqMapBySeq_id
CVDBGraphDb_Impl(CVDBMgr &mgr, CTempString path, ELookupType lookup_type=eLookupDefault)
SSeqInfo GetSeqInfoAtRow(TVDBRowId row)
void Put(CRef< SGraphTableCursor > &curs)
bool LookupIsInMemory() const
SSeqInfo GetSeqInfo(const CSeq_id_Handle &seq_id)
TSeqInfoMapByFirstRow m_SeqMapByFirstRow
const CVDBTable & GraphTable(void)
virtual ~CVDBGraphDb_Impl(void)
list< SSeqInfo > TSeqInfoList
CVDBGraphDb_Impl::SSeqInfo m_Info
bool x_SeqTableIsSmaller(COpenRange< TSeqPos > range, SGraphTableCursor &cursor) const
CVDBGraphDb_Impl & GetDb(void) const
bool SeqTableIsSmaller(COpenRange< TSeqPos > range) const
CRef< CSeq_graph > x_MakeGraph(const string &annot_name, CSeq_loc &loc, const SSeqInfo &info, const COpenRange< TSeqPos > &range, TSeqPos step, SGraphTableCursor &cursor, CVDBColumn &column, int level) const
CVDBGraphSeqIterator & operator++(void)
CRef< CSeq_table > x_MakeTable(const string &annot_name, CSeq_loc &loc, const SSeqInfo &info, const COpenRange< TSeqPos > &range, SGraphTableCursor &cursor) const
CVDBGraphSeqIterator(void)
CRef< CSeq_annot > GetAnnot(COpenRange< TSeqPos > range, const string &annot_name=kEmptyStr, TContentFlags content=fDefaultContent) const
const SSeqInfo & GetInfo(void) const
TVDBRowIdRange Find(const string &value) const
const_iterator end() const
iterator_bool insert(const value_type &val)
container_type::value_type value_type
const_iterator find(const key_type &key) const
The NCBI C++ standard methods for dealing with std::string.
static const char * column
NCBI_DEFINE_ERR_SUBCODE_X(1)
NCBI_PARAM_DECL(bool, VDBGRAPH, USE_VDB_INDEX)
static void sx_Assign(DstVector &dst, const SrcVector &src)
NCBI_PARAM_DEF_EX(bool, VDBGRAPH, USE_VDB_INDEX, true, eParam_NoThread, VDBGRAPH_USE_VDB_INDEX)
unsigned int TSeqPos
Type for sequence locations and lengths.
#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 ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
C * SerialClone(const C &src)
Create on heap a clone of the source object.
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.
TObjectType & GetNCObject(void) const
Get object.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
TThisType & SetToOpen(position_type toOpen)
position_type GetToOpen(void) const
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static string & ToUpper(string &str)
Convert string to upper case – string& version.
void SetType(TType &value)
Assign a value to Type data member.
void SetHeader(THeader &value)
Assign a value to Header data member.
void SetData(TData &value)
Assign a value to Data data member.
void SetDefault(TDefault &value)
Assign a value to Default data member.
@ eField_id_location_id
location Seq-id
@ eField_id_location_from
interval from
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
TVersion GetVersion(void) const
Get the Version member data.
bool IsSetRelease(void) const
Check if a value has been assigned to Release data member.
bool IsSetVersion(void) const
Check if a value has been assigned to Version data member.
bool IsSetName(void) const
Check if a value has been assigned to Name data member.
const TAccession & GetAccession(void) const
Get the Accession member data.
void SetA(TA value)
Assign a value to A data member.
void SetAxis(TAxis value)
Assign a value to Axis data member.
void SetTitle(const TTitle &value)
Assign a value to Title data member.
TValues & SetValues(void)
Assign a value to Values data member.
void SetAxis(TAxis value)
Assign a value to Axis data member.
void SetNumval(TNumval value)
Assign a value to Numval data member.
void SetComp(TComp value)
Assign a value to Comp data member.
void SetGraph(TGraph &value)
Assign a value to Graph data member.
void SetMax(TMax value)
Assign a value to Max data member.
void SetMax(TMax value)
Assign a value to Max data member.
void SetComment(const TComment &value)
Assign a value to Comment data member.
void SetLoc(TLoc &value)
Assign a value to Loc data member.
void SetMin(TMin value)
Assign a value to Min data member.
void SetMin(TMin value)
Assign a value to Min data member.
TValues & SetValues(void)
Assign a value to Values data member.
void SetData(TData &value)
Assign a value to Data data member.
void SetDesc(TDesc &value)
Assign a value to Desc data member.
TName & SetName(void)
Select the variant.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
TUser & SetUser(void)
Select the variant.
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in SRA C++ support libraries.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
double f(double x_, const double &y_)
#define NCBI_THROW2_FMT(exception_class, err_code, message, extra)
#define row(bind, expected)
SGraphTableCursor(const CVDBTable &table)
#define INIT_VDB_COLUMN(name)
pair< TVDBRowId, TVDBRowCount > TVDBRowIdRange
#define INIT_OPTIONAL_VDB_COLUMN(name)