mColumnDelimiter(
" \t"),
62mSplitFlags(
NStr::fSplit_MergeDelimiters),
65mColorByStrand(
false)
88 stringnextLine =
"";
89 while(!lineReader.
AtEOF()) {
90nextLine = *(++lineReader);
120 const string& line)
const 143 stringtrack, values;
145 if(track !=
"track") {
149 throwerrorTrackLineOutOfOrder;
153 if(values.empty()) {
157vector<string> trackPieces;
161 for(
int i= 1;
i< trackPieces.size() - 1; ++
i) {
162vector<string> words;
164 autopendingKey = words.back();
174 mUseScore= (!useScore.empty() && useScore !=
"0"&& useScore !=
"false");
177 mItemRgb= (itemRgb ==
"on"|| itemRgb ==
"On");
178 if(!itemRgb.empty() && !
mItemRgb) {
179errorInvalidTrackValue.
AmendMessage(
"Bad itemRgb value --- ignored");
184 if(!colorByStrand.empty()) {
186 stringcolorStrandPlus, colorStrandMinus;
188colorByStrand,
" ", colorStrandPlus, colorStrandMinus);
189vector<string> rgbComponents;
190 NStr::Split(colorStrandPlus,
",", rgbComponents);
191 if(rgbComponents.size() != 3) {
192 throwstd::exception();
197rgbComponents.clear();
198 NStr::Split(colorStrandMinus,
",", rgbComponents);
199 if(rgbComponents.size() != 3) {
200 throwstd::exception();
206 catch(std::exception&) {
208 "Bad colorByStrand value --- ignored");
233 throwerrorInvalidColumnCount;
239 throwerrorInvalidColumnCount;
246 constvector<string>&
columns,
269 throwerrorInvalidChromStartValue;
276 throwerrorInvalidChromEndValue;
281 const auto& strand =
columns[5];
282 if(strand !=
"+"&& strand !=
"-"&& strand !=
".") {
283 throwerrorInvalidStrandValue;
285 if(strand ==
"-") {
294 constvector<string>&
columns,
319 constvector<string>&
columns,
335rgbValue.
R= rgbValue.
B= rgbValue.
G= -1;
341 constvector<string>&
columns,
347 "Invalid strand value- setting color to BLACK.",
353rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
371 constvector<string>&
columns,
387rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
396rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
400 if(scoreValue < 0) {
404 else if(scoreValue > 1000) {
408 if(scoreValue == 0) {
409rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
412 if(scoreValue > 998) {
413rgbValue.
R= rgbValue.
G= rgbValue.
B= 255;
417scoreValue =
static_cast<int>(scoreValue / 111);
418rgbValue.
R= rgbValue.
G= rgbValue.
B= (13 + 29*scoreValue);
425 constvector<string>&
columns,
433rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
440vector<string > rgbSplits;
442 switch(rgbSplits.size()) {
444 throwerrorInvalidRgbValue;
446 unsigned longrgbInt = 0;
448 autohexDigits = rgb.substr(2, string::npos);
452 autohexDigits = rgb.substr(1, string::npos);
459rgbValue.
R= (rgbInt & 0xff0000) >> 16;
460rgbValue.
G= (rgbInt & 0x00ff00) >> 8;
461rgbValue.
B= (rgbInt & 0x0000ff);
473rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
477 if(rgbValue.
R< 0 || 255 < rgbValue.
R) {
478rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
482 if(rgbValue.
G< 0 || 255 < rgbValue.
G) {
483rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
487 if(rgbValue.
B< 0 || 255 < rgbValue.
B) {
488rgbValue.
R= rgbValue.
G= rgbValue.
B= 0;
497 constvector<string>&
columns,
516 throwerrorInvalidThickStartValue;
523 throwerrorInvalidThickEndValue;
530 constvector<string>&
columns,
544 constvector<string>&
columns,
545 unsigned int& blockCount,
546vector<int>& blockStarts,
547vector<int>& blockSizes)
570 catch(std::exception&) {
571 throwerrorInvalidBlockCountValue;
577vector<string> blockSizesSplits;
579 if(blockSizesSplits.back().empty()) {
580blockSizesSplits.pop_back();
582 for(
autoblockSize: blockSizesSplits) {
586 catch(std::exception&) {
587 throwerrorInvalidBlockSizesValue;
589 if(blockCount != blockSizes.size()) {
590 throwerrorInconsistentBlocksInformation;
594vector<string> blockStartsSplits;
596 if(blockStartsSplits.back().empty()) {
597blockStartsSplits.pop_back();
599 for(
autoblockStart: blockStartsSplits) {
603 catch(std::exception&) {
604 throwerrorInvalidBlockStartsValue;
606 if(blockCount != blockStarts.size()) {
607 throwerrorInconsistentBlocksInformation;
614 constvector<string>&
columns,
638 TSeqPosthickStart = chromStart, thickEnd = chromStart;
640 if(thickStart < chromStart || thickEnd > chromEnd) {
641 throwerrorInvalidThickInterval;
647 unsigned intblockCount;
648vector<int> blockStarts, blockSizes;
651record.
Initialize(chromId, chromStart, chromEnd, name, score, chromStrand,
652thickStart, thickEnd, rgbValue, blockCount, blockStarts, blockSizes);
std::string ValueOf(const std::string &) const
void SetValue(const std::string &, const std::string &)
void Initialize(const std::string &, TSeqPos, TSeqPos, const std::string &, double, ENa_strand, TSeqPos, TSeqPos, const RgbValue &, unsigned int, const std::vector< int > &, const std::vector< int > &)
void xInitializeRgb(const std::vector< string > &, CBedImportData::RgbValue &)
void xInitializeThickInterval(const std::vector< std::string > &, TSeqPos &, TSeqPos &)
void xInitializeRgbFromScoreColumn(const std::vector< string > &, CBedImportData::RgbValue &)
void xInitializeRgbFromRgbColumn(const std::vector< string > &, CBedImportData::RgbValue &)
CBedImportData::RgbValue mRgbStrandMinus
void xInitializeRgbFromStrandColumn(const std::vector< string > &, CBedImportData::RgbValue &)
void SetInputStream(CNcbiIstream &, bool=false) override
void xInitializeScore(const std::vector< string > &, double &)
bool xProcessTrackLine(const string &)
std::string mColumnDelimiter
CBedLineReader(CImportMessageHandler &)
void xInitializeBlocks(const std::vector< string > &, unsigned int &blockCount, std::vector< int > &blockStarts, std::vector< int > &blockSizes)
void xSplitLine(const std::string &, std::vector< std::string > &)
void xInitializeChromInterval(const std::vector< std::string > &, std::string &, TSeqPos &, TSeqPos &, ENa_strand &)
CBedImportData::RgbValue mRgbStrandPlus
void xInitializeRecord(const std::vector< std::string > &, CFeatImportData &) override
void xInitializeChromName(const std::vector< std::string > &, std::string &)
bool GetNextRecord(CStreamLineReader &, CFeatImportData &) override
bool xIgnoreLine(const string &) const override
virtual void xReportProgress()
virtual bool xIgnoreLine(const string &) const
CAnnotImportData mAnnotInfo
CImportMessageHandler & mErrorReporter
unsigned int LineCount() const
virtual void SetInputStream(CNcbiIstream &, bool=false)
unsigned int mRecordCount
void AmendMessage(const std::string &amend)
virtual void ReportError(const CImportError &)
Simple implementation of ILineReader for i(o)streams.
static const column_t columns[]
unsigned int TSeqPos
Type for sequence locations and lengths.
bool AtEOF(void) const
Indicates (negatively) whether there is any more input.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static CTempString TruncateSpaces_Unsafe(const CTempString str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
static unsigned long StringToULong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned long.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
ENa_strand
strand of nucleic acid
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4