60 string first = cit->m_Chrom;
61 for (cit++; cit !=
m_Values.end(); ++cit) {
62 if (cit->m_Chrom !=
first) {
78 m_TrackType(eTrackType_invalid)
112 if (readerData.empty()) {
130 bool haveData =
false;
159 for (
auto curData = readerData.begin(); curData != readerData.end(); curData++) {
160 auto line = curData->mData;
190 auto curIt = readerData.cbegin();
191 while (curIt != readerData.end()) {
192 auto firstLine(curIt->mData);
197 fixedStepInfo, ++curIt, readerData, rawdata);
203 varStepInfo, ++curIt, readerData, rawdata);
214 TReaderData::const_iterator& curIt,
224 unsigned int pos(fixedStepInfo.
mStart);
225 while (curIt != readerData.end()) {
226 auto line(curIt->mData);
231 pos += fixedStepInfo.
mStep;
241 TReaderData::const_iterator& curIt,
251 while (curIt != readerData.end()) {
252 auto line(curIt->mData);
274 (m_iFlags & fAsByte) ? (ret += rows) : (ret += 8*rows);
288 for (
size_t i = 1;
i <
size; ++
i ) {
304 for (
size_t i = 1;
i <
size; ++
i ) {
315 const int range = 255;
326 for (
size_t i = 1;
i <
size; ++
i ) {
327 if (
m_Values[
i].m_Pos == nv.back().GetEnd() &&
328 m_Values[
i].m_Value == nv.back().m_Value ) {
335 if ( nv.size() !=
size ) {
371 interval.
SetId(chrom_id);
384 table->SetFeat_type(0);
391 table->SetColumns().push_back(col_id);
392 col_id->
SetHeader().SetField_name(
"Seq-table location");
398 table->SetColumns().push_back(col_id);
407 seq_id.reserve(
size);
410 seq_id.push_back(pId);
417 table->SetColumns().push_back(col_pos);
432 table->SetColumns().push_back(col_span);
433 col_span->
SetHeader().SetField_name(
"span");
438 span_ptr = &col_span->
SetData().SetInt();
439 span_ptr->reserve(
size);
445 table->SetColumns().push_back(col_step);
446 col_step->
SetHeader().SetField_name(
"value_gap");
452 table->SetColumns().push_back(col_min);
453 col_min->
SetHeader().SetField_name(
"value_min");
457 table->SetColumns().push_back(col_step);
458 col_step->
SetHeader().SetField_name(
"value_step");
462 table->SetColumns().push_back(col_val);
463 col_val->
SetHeader().SetField_name(
"values");
466 values.reserve(
size);
468 pos.push_back(it->m_Pos);
470 span_ptr->push_back(it->m_Span);
472 values.push_back(stat.
AsByte(it->m_Value));
477 table->SetColumns().push_back(col_val);
478 col_val->
SetHeader().SetField_name(
"values");
480 values.reserve(
size);
483 pos.push_back(it->m_Pos);
485 span_ptr->push_back(it->m_Span);
487 values.push_back(it->m_Value);
502 graph->
SetLoc(*graph_loc);
510 if (!trackName.empty()) {
535 TSeqPos pos = it->m_Pos - start;
540 int v = stat.
AsByte(it->m_Value);
541 for ( ; span > 0; span -= stat.
m_Span, ++
i ) {
554 const char* ptr = line.c_str();
556 for (
size_t len = line.size(); skip <
len; ++skip ) {
558 if ( c !=
' ' && c !=
'\t' ) {
562 line = line.substr(skip);
563 return !line.empty();
571 const char* ptr = line.c_str();
573 for (
size_t len = line.size(); skip <
len; ++skip ) {
575 if ( c ==
' ' || c ==
'\t' ) {
582 "Identifier expected");
585 string word(ptr, skip);
586 line = line.substr(skip);
595 const char* ptr = line.c_str();
597 for (
size_t len = line.size(); skip <
len; ++skip ) {
600 string name(ptr, skip);
601 line = line.substr(skip+1);
604 if ( c ==
' ' || c ==
'\t' ) {
619 const char* ptr = line.c_str();
620 size_t len = line.size();
621 if (
len && *ptr ==
'"' ) {
623 for ( ; pos <
len; ++pos ) {
626 string value(ptr, pos);
627 line = line.substr(pos+1);
647 "Integer value expected");
649 char c = line.c_str()[0];
650 if ( c < '0' || c >
'9' ) {
655 const char* ptr = line.c_str();
656 for (
size_t skip = 0; ; ++skip ) {
658 if ( c >=
'0' && c <=
'9' ) {
659 ret = ret*10 + (c-
'0');
661 else if ( (c ==
' ' || c ==
'\t' || c ==
'\0') && skip ) {
662 line = line.substr(skip);
679 const char* ptr = line.c_str();
681 bool negate =
false, digits =
false;
693 if ( c >=
'0' && c <=
'9' ) {
695 ret = ret*10 + (c-
'0');
697 else if ( c ==
'.' ) {
701 else if ( c ==
'\0' ) {
716 double digit_mul = 1;
719 if ( c >=
'0' && c <=
'9' ) {
722 ret += (c-
'0')*digit_mul;
724 else if ( (c ==
' ' || c ==
'\t' || c ==
'\0') && digits ) {
726 v = (negate ? -ret : ret);
744 const char* ptr = line.c_str();
746 v = strtod(ptr, &endptr);
747 if ( endptr == ptr ) {
750 "Floating point value expected");
756 "Extra text on line");
847 "Invalid track type");
854 TReaderData::const_iterator& curIt,
858 auto firstLine(curIt->mData);
874 TReaderData::const_iterator& curIt,
878 auto firstLine(curIt->mData);
893 const string& directive,
901 "Track \"type=wiggle_0\" is required");
909 auto line(directive.substr(
string(
"fixedStep").size() + 1));
911 fixedStepInfo.
Reset();
915 if (name ==
"chrom") {
919 if (name ==
"start") {
921 if (0 == fixedStepInfo.
mStart) {
924 "Bad start value: must be positive. Assuming \"start=1\"");
930 if (name ==
"step") {
934 if (name ==
"span") {
940 "Bad parameter name. Ignored");
943 if (fixedStepInfo.
mChrom.empty()) {
946 "Missing chrom parameter");
949 if (fixedStepInfo.
mStart == 0) {
952 "Missing start parameter");
955 if (fixedStepInfo.
mStep == 0) {
958 "Missing step parameter");
966 TReaderData::const_iterator& curIt,
975 while (curIt != readerData.end()) {
976 auto line(curIt->mData);
986 const string& directive,
994 "Track \"type=wiggle_0\" is required");
1002 varStepInfo.
Reset();
1003 auto line(directive.substr(
string(
"variableStep").size() + 1));
1007 if ( name ==
"chrom" ) {
1010 else if ( name ==
"span" ) {
1016 "Bad parameter name. Ignored");
1020 if ( varStepInfo.
mChrom.empty() ) {
1023 "Missing chrom parameter");
1031 TReaderData::const_iterator& curIt,
1039 while (curIt != readerData.end()) {
1040 string line(curIt->mData);
1052 TReaderData::const_iterator& curIt,
1056 while (curIt != readerData.end()) {
1057 auto line(curIt->mData);
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
void AddRecord(CRawWiggleRecord record)
Common file reader utility functions.
static CRef< CSeq_id > AsSeqId(const string &rawId, long flags=0, bool localInts=true)
Convert a raw ID string to a Seq-id, based in given customization flags.
Defines and provides stubs for a general interface to a variety of file readers.
unique_ptr< CReaderMessageHandler > m_pMessageHandler
void xGuardedGetData(ILineReader &, TReaderData &, ILineErrorListener *)
virtual bool xUngetLine(ILineReader &)
virtual CRef< CSeq_annot > xCreateSeqAnnot()
unsigned int m_uDataCount
unsigned int m_uLineNumber
unique_ptr< CTrackData > m_pTrackDefaults
virtual bool xProgressInit(ILineReader &istr)
vector< TReaderLine > TReaderData
virtual bool xGetLine(ILineReader &, string &)
virtual void xGuardedProcessData(const TReaderData &, CSeq_annot &, ILineErrorListener *)
virtual bool xIsBrowserLine(const CTempString &)
virtual bool xParseTrackLine(const string &)
virtual void xAssignTrackData(CSeq_annot &)
struct SReaderLine { SReaderLine(unsigned int line, string data):mLine(line), mData(data) {} TReaderLine
virtual bool xIsTrackLine(const CTempString &)
void xGetData(ILineReader &, TReaderData &) override
bool xProcessVariableStepData(TReaderData::const_iterator &, const TReaderData &)
bool xProcessFixedStepData(TReaderData::const_iterator &, const TReaderData &)
virtual bool ReadTrackData(ILineReader &, CRawWiggleTrack &, ILineErrorListener *=nullptr)
string xGetParamValue(string &)
bool xReadVariableStepDataRaw(const SVarStepInfo &, TReaderData::const_iterator &, const TReaderData &, CRawWiggleTrack &)
CRef< CSeq_table > xMakeTable()
string xGetParamName(string &)
string xGetWord(string &)
vector< SValueInfo > TValues
bool xTryGetDoubleSimple(string &, double &v)
void xProcessData(const TReaderData &, CSeq_annot &) override
void xSetChrom(const string &chrom)
void xSetTotalLoc(CSeq_loc &loc, CSeq_id &chrom_id)
double xEstimateSize(size_t rows, bool fixed_span) const
void xGetPos(string &, TSeqPos &v)
void xGetVariableStepInfo(const string &, SVarStepInfo &)
void xPostProcessAnnot(CSeq_annot &) override
void xPreprocessValues(SWiggleStat &)
void xReadVariableStepData(const SVarStepInfo &, TReaderData::const_iterator &, const TReaderData &)
CRef< CSeq_annot > m_Annot
CRef< CSeq_annot > ReadSeqAnnot(ILineReader &, ILineErrorListener *=nullptr) override
Read an object from a given line reader, render it as a single Seq-annot, if possible.
void xGetFixedStepInfo(const string &, SFixedStepInfo &)
bool xReadFixedStepDataRaw(const SFixedStepInfo &, TReaderData::const_iterator &, const TReaderData &, CRawWiggleTrack &)
void xReadFixedStepData(const SFixedStepInfo &, TReaderData::const_iterator &, const TReaderData &)
bool xParseTrackLine(const string &) override
void xAddValue(const SValueInfo &value)
bool xValuesAreFromSingleSequence() const
bool xProcessBedData(TReaderData::const_iterator &, const TReaderData &)
void xGetDouble(string &line, double &v)
bool xParseBrowserLine(const string &, CSeq_annot &) override
CRef< CSeq_id > xMakeChromId()
CRef< CSeq_graph > xMakeGraph()
CWiggleReader(int=fDefaults, const string &="", const string &="", CReaderListener *=nullptr)
Abstract base class for lightweight line-by-line reading.
container_type::const_iterator const_iterator
Include a standard set of the NCBI C++ Toolkit most basic headers.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
void SetHeader(THeader &value)
Assign a value to Header data member.
void SetData(TData &value)
Assign a value to Data data member.
vector< CRef< CSeq_id > > TId
void SetDefault(TDefault &value)
Assign a value to Default data member.
@ eField_id_location_id
location Seq-id
@ eField_id_location_from
interval from
void SetTo(TTo value)
Assign a value to To data member.
void SetId(TId &value)
Assign a value to Id data member.
void SetFrom(TFrom value)
Assign a value to From data member.
void SetA(TA value)
Assign a value to A data member.
void SetMin(TMin value)
Assign a value to Min data member.
void SetTitle(const TTitle &value)
Assign a value to Title data member.
void SetNumval(TNumval value)
Assign a value to Numval data member.
void SetComp(TComp value)
Assign a value to Comp data member.
TValues & SetValues(void)
Assign a value to Values data member.
void SetGraph(TGraph &value)
Assign a value to Graph data member.
void SetB(TB value)
Assign a value to B data member.
void SetMax(TMax value)
Assign a value to Max data member.
void SetLoc(TLoc &value)
Assign a value to Loc data member.
void SetAxis(TAxis value)
Assign a value to Axis data member.
void SetData(TData &value)
Assign a value to Data data member.
const TData & GetData(void) const
Get the Data member data.
E_Choice Which(void) const
Which variant is currently selected.
@ e_not_set
No variant selected.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
Lightweight interface for getting lines of data with minimal memory copying.
range(_Ty, _Ty) -> range< _Ty >
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
static SLJIT_INLINE sljit_ins lr(sljit_gpr dst, sljit_gpr src)
int AsByte(double v) const
void SetFirstSpan(TSeqPos span)
void SetFirstValue(double v)
void AddSpan(TSeqPos span)