CLexToken :
public CObject 56CLexToken(
unsigned inttoken_type) { m_TokenType = token_type; m_HasError =
false; }
57 virtual~CLexToken() {}
58 unsigned intGetTokenType() {
returnm_TokenType; }
59 boolHasError () {
returnm_HasError; }
61 virtual unsigned intGetInt() {
return0; }
62 virtual stringGetString() {
return ""; }
81 unsigned intm_TokenType;
85 typedefvector< CRef<CLexToken> > TLexTokenArray;
87 bools_ParseLex (
string text, TLexTokenArray &token_list);
89 classCLexTokenString :
publicCLexToken
92CLexTokenString (
stringtoken_data);
93 virtual~CLexTokenString();
94 virtual stringGetString() {
returnm_TokenData; };
99CLexTokenString::CLexTokenString(
stringtoken_data) : CLexToken (e_String)
101m_TokenData = token_data;
104CLexTokenString::~CLexTokenString()
108 classCLexTokenInt :
publicCLexToken
111CLexTokenInt (
unsigned inttoken_data);
112 virtual~CLexTokenInt ();
113 virtual unsigned intGetInt() {
returnm_TokenData; };
115 unsigned intm_TokenData;
118CLexTokenInt::CLexTokenInt(
unsigned inttoken_data) : CLexToken (e_Int)
120m_TokenData = token_data;
123CLexTokenInt::~CLexTokenInt()
127 classCLexTokenAccession :
publicCLexToken {
129CLexTokenAccession (
const string&token_data);
130 virtual~CLexTokenAccession();
131 virtual stringGetString(
void) {
returnm_TokenData; };
136CLexTokenAccession::CLexTokenAccession(
const string&token_data )
137: CLexToken(e_Accession), m_TokenData(token_data)
141CLexTokenAccession::~CLexTokenAccession()
145 classCLexTokenParenPair :
publicCLexToken
148CLexTokenParenPair (
unsigned inttoken_type,
stringbetween_text);
149 virtual~CLexTokenParenPair();
156TLexTokenArray m_TokenList;
159CLexTokenParenPair::CLexTokenParenPair(
unsigned inttoken_type,
stringbetween_text) : CLexToken (token_type)
162m_HasError = ! s_ParseLex (between_text, m_TokenList);
165CLexTokenParenPair::~CLexTokenParenPair()
171 CRef<CSeq_loc>retval = ReadLocFromTokenList(m_TokenList,
id, helper);
173 if(m_TokenType == e_Complement) {
185 unsigned intlist_pos;
186TLexTokenArray before_comma_list;
187vector <unsigned int> comma_pos;
190 if(token_list.size() < 1) {
195 for(list_pos = 0; list_pos < token_list.size(); list_pos++) {
196 if(token_list[list_pos]->GetTokenType() == CLexToken::e_Comma) {
197comma_pos.push_back (list_pos);
201 if(comma_pos.size() > 0) {
204 for(
unsigned intk = 0; k < comma_pos.size(); k++) {
205before_comma_list.clear();
206 while(list_pos < comma_pos[k]) {
207before_comma_list.push_back (token_list[list_pos]);
210add = ReadLocFromTokenList(before_comma_list,
id, helper);
225before_comma_list.clear();
226 while(list_pos < token_list.size()) {
227before_comma_list.push_back (token_list[list_pos]);
230add = ReadLocFromTokenList(before_comma_list,
id, helper);
240 switch(token_list[0]->GetTokenType()) {
241 caseCLexToken::e_Accession:
242 id=
new CSeq_id( token_list[0]->GetString() );
243token_list.erase( token_list.begin() );
245 caseCLexToken::e_Int:
246 if(token_list.size() == 1) {
248retval =
new CSeq_loc(*
id, token_list[0]->GetInt() - 1);
249}
else if(token_list[1]->GetTokenType() == CLexToken::e_DotDot) {
250 if(token_list.size() < 3 || token_list[2]->GetTokenType() != CLexToken::e_Int) {
254 if(token_list.size() > 4) {
258 if(token_list.size() == 4 && token_list[3]->GetTokenType() != CLexToken::e_RightPartial) {
263retval =
new CSeq_loc(*
id, token_list[0]->GetInt() - 1, token_list[2]->GetInt() - 1);
265 if(retval && retval->
IsInt() &&
273 if(token_list.size() == 4) {
278 caseCLexToken::e_LeftPartial:
279 if(token_list.size() < 2) {
282}
else if(token_list.size() == 2) {
284retval =
new CSeq_loc(*
id, token_list[1]->GetInt() - 1);
286}
else if(token_list[2]->GetTokenType() == CLexToken::e_DotDot) {
287 if(token_list.size() < 4 || token_list[3]->GetTokenType() != CLexToken::e_Int) {
291 if(token_list.size() > 5) {
295 if(token_list.size() == 5 && token_list[4]->GetTokenType() != CLexToken::e_RightPartial) {
300retval =
new CSeq_loc(*
id, token_list[1]->GetInt() - 1, token_list[3]->GetInt() - 1);
302 if(token_list.size() == 5) {
308 caseCLexToken::e_ParenPair:
309 caseCLexToken::e_Join:
310 caseCLexToken::e_Order:
311 caseCLexToken::e_Complement:
312 if(token_list.size() > 1) {
316retval = token_list[0]->GetLocation(
id, helper);
318 caseCLexToken::e_String:
320 caseCLexToken::e_DotDot:
322 caseCLexToken::e_RightPartial:
324 caseCLexToken::e_Comma:
338 for(pos = 0; pos <
str.length(); pos++) {
339 if(!
isspace((
unsigned char)
str[pos]) && (
str[pos] !=
'~')) {
347 size_ts_GetParenLen (
string text)
349string::size_type
offset= 0;
350 unsigned intparen_count;
351string::size_type next_quote;
360 while(
offset!=
text.length() && paren_count > 0) {
371 if(next_quote == string::npos) {
380 if(paren_count > 0) {
387 bools_ParseLex (
string text, TLexTokenArray &token_list)
391string::size_type paren_len,
offset= 0, end_pos;
406 if(end_pos == string::npos) {
416 case '0':
case '1':
case '2':
case '3':
case '4':
417 case '5':
case '6':
case '7':
case '8':
case '9':
419 while(end_pos <
text.length() &&
isdigit(
text.c_str()[end_pos])) {
427paren_len = s_GetParenLen(
text.substr(
offset));
428 if(paren_len == 0) {
431token_list.push_back (
CRef<CLexToken>(
newCLexTokenParenPair (CLexToken::e_ParenPair,
text.substr(
offset+ 1, paren_len - 2))));
432 if(token_list[token_list.size() - 1]->HasError()) {
444paren_len = s_GetParenLen(
text.substr(
offset));
445 if(paren_len == 0) {
448token_list.push_back (
CRef<CLexToken>(
newCLexTokenParenPair (CLexToken::e_Join,
text.substr(
offset+ 1, paren_len - 2))));
462paren_len = s_GetParenLen(
text.substr(
offset));
463 if(paren_len == 0) {
466token_list.push_back (
CRef<CLexToken>(
newCLexTokenParenPair (CLexToken::e_Order,
text.substr(
offset+ 1, paren_len - 2))));
478paren_len = s_GetParenLen(
text.substr(
offset));
479 if(paren_len == 0) {
482token_list.push_back (
CRef<CLexToken>(
newCLexTokenParenPair (CLexToken::e_Complement,
text.substr(
offset+ 1, paren_len - 2))));
490token_list.push_back (
CRef<CLexToken>(
newCLexToken (CLexToken::e_DotDot)));
495token_list.push_back (
CRef<CLexToken>(
newCLexToken (CLexToken::e_DotDot)));
502token_list.push_back (
CRef<CLexToken>(
newCLexToken (CLexToken::e_RightPartial)));
506token_list.push_back (
CRef<CLexToken>(
newCLexToken (CLexToken::e_LeftPartial)));
511token_list.push_back (
CRef<CLexToken>(
newCLexToken (CLexToken::e_Comma)));
516token_list.push_back (
CRef<CLexToken>(
newCLexToken (CLexToken::e_DotDot)));
528 while(end_pos <
text.length() &&
isupper(
text.c_str()[end_pos])) {
531 while(end_pos <
text.length() &&
isdigit(
text.c_str()[end_pos])) {
534 if(
text.c_str()[end_pos] ==
'.') {
536 while(end_pos <
text.length() &&
isdigit(
text.c_str()[end_pos])) {
540 if(
text.c_str()[end_pos] !=
':') {
583TLexTokenArray token_list;
591 if(s_ParseLex (
text, token_list)) {
592retval = CLexTokenParenPair::ReadLocFromTokenList (token_list, this_id, helper);
@ eExtreme_Positional
numerical value
User-defined methods of the data storage class.
virtual CRef< CSeq_loc > Seq_loc_Add(const CSeq_loc &loc1, const CSeq_loc &loc2, CSeq_loc::TOpFlags flags)
virtual ~CGetSeqLocFromStringHelper(void)
virtual CRef< CSeq_loc > GetRevComplement(const CSeq_loc &loc)
Wraps up any functionality needed that might be outside the scope of this library.
The NCBI C++ standard methods for dealing with std::string.
static string s_RemoveWhiteSpace(string str)
static const char * str(char *buf, int n)
unsigned int TSeqPos
Type for sequence locations and lengths.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
void Add(const CSeq_loc &other)
Simple adding of seq-locs.
void SetPartialStart(bool val, ESeqLocExtremes ext)
set / remove e_Lim fuzz on start or stop (lt/gt - indicating partial interval)
void SetStrand(ENa_strand strand)
Set the strand for all of the location's ranges.
void SetPartialStop(bool val, ESeqLocExtremes ext)
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the 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 EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
TFrom GetFrom(void) const
Get the From member data.
E_Choice Which(void) const
Which variant is currently selected.
TTo GetTo(void) const
Get the To member data.
bool IsInt(void) const
Check if variant Int is selected.
const TInt & GetInt(void) const
Get the variant data.
@ e_not_set
No variant selected.
static void text(MDB_val *v)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
CRef< CSeq_loc > GetSeqLocFromString(const string &text, const CSeq_id *id, CGetSeqLocFromStringHelper *helper)
CSeq_loc * GetReverseComplement(const CSeq_loc &loc, CReverseComplementHelper *helper)
Get reverse complement of the seq-loc (?).
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