21 #define THIS_FILE "xgbfeat.cpp"
40 #define THIS_MODULE this_module
44 #define ERR_FEATURE 1, 0
45 #define ERR_FEATURE_UnknownFeatureKey 1, 1
46 #define ERR_FEATURE_MissManQual 1, 2
47 #define ERR_FEATURE_QualWrongThisFeat 1, 3
48 #define ERR_FEATURE_FeatureKeyReplaced 1, 4
49 #define ERR_FEATURE_LocationParsing 1, 5
50 #define ERR_FEATURE_IllegalFormat 1, 6
51 #define ERR_QUALIFIER 2, 0
52 #define ERR_QUALIFIER_InvalidDataFormat 2, 1
53 #define ERR_QUALIFIER_Too_many_tokens 2, 2
54 #define ERR_QUALIFIER_MultiValue 2, 3
55 #define ERR_QUALIFIER_UnknownSpelling 2, 4
56 #define ERR_QUALIFIER_Xtratext 2, 5
57 #define ERR_QUALIFIER_SeqPosComma 2, 6
58 #define ERR_QUALIFIER_Pos 2, 7
59 #define ERR_QUALIFIER_EmptyNote 2, 8
60 #define ERR_QUALIFIER_NoteEmbeddedQual 2, 9
61 #define ERR_QUALIFIER_EmbeddedQual 2, 10
62 #define ERR_QUALIFIER_AA 2, 11
63 #define ERR_QUALIFIER_Seq 2, 12
64 #define ERR_QUALIFIER_BadECnum 2, 13
65 #define ERR_QUALIFIER_Cons_splice 2, 14
67 #define ParFlat_Stoken_type 1
68 #define ParFlat_BracketInt_type 2
69 #define ParFlat_Integer_type 3
70 #define ParFlat_Number_type 4
77 bool perform_corrections);
82 bool perform_corrections);
89 const Char* array_string[],
94 bool perform_corrections);
101 #define ParFlat_SPLIT_IGNORE 4
103 "citation",
"EC_number",
"rpt_type",
"usedin"
154 for (TQualVector::iterator cur = quals.begin(); cur != quals.end();) {
155 const string& qual_str = (*cur)->GetQual();
156 if (qual_str ==
"gsdb_id") {
168 if (qual_type == cur_type) {
181 if (perform_corrections) {
182 cur = quals.erase(cur);
194 for (
const auto& cur : quals) {
209 if (perform_corrections)
231 for (
auto& cur : quals) {
232 const string& qual_str = cur->GetQual();
238 if (! cur->IsSetVal()) {
242 string val_str = cur->GetVal();
243 if (*val_str.begin() !=
'(') {
246 if (*val_str.rbegin() !=
')') {
250 val_str = val_str.substr(1, val_str.size() - 2);
251 size_t sep_pos = val_str.find(
',');
252 if (sep_pos == string::npos) {
253 cur->SetVal(val_str);
259 cur->SetVal(val_str.substr(0, sep_pos));
261 size_t offset = sep_pos + 1;
262 sep_pos = val_str.find(
',',
offset);
263 while (sep_pos != string::npos) {
269 quals.push_back(qual_new);
439 auto val_class = QUAL_TYPE_TO_VAL_CLASS_MAP.
find(qual_type);
440 if (val_class == QUAL_TYPE_TO_VAL_CLASS_MAP.
end()) {
444 return val_class->second;
452 "EXPERIMENTAL",
"NOT_EXPERIMENTAL"
462 "long_terminal_repeat",
463 "non_LTR_retrotransposon_polymeric_tract",
464 "X_element_combinatorial_repeat",
467 "centromeric_repeat",
468 "engineered_foreign_repetitive_element",
488 for (TQualVector::iterator cur = quals.begin(); cur != quals.end();) {
489 const string& qual_str = (*cur)->GetQual();
490 if (qual_str ==
"gsdb_id") {
503 if (perform_corrections) {
504 cur = quals.erase(cur);
516 ret =
CkQualNote(*(*cur), error_msgs, perform_corrections);
522 ret =
CkQualText(*(*cur),
nullptr,
false, error_msgs, perform_corrections);
558 ret =
CkQualEcnum(*(*cur), error_msgs, perform_corrections);
606 if ((*cur)->IsSetVal() && ! (*cur)->GetVal().empty()) {
611 if (perform_corrections) {
620 cur = quals.erase(cur);
649 size_t comma = caa.find(
',');
650 if (comma != string::npos) {
651 caa = caa.substr(0, comma);
657 while (*
str !=
'\0' && (*
str ==
' ' || *
str ==
')'))
708 while (*
str !=
'\0' && (*
str ==
',' || *
str ==
' '))
718 string aa(
str, eptr);
772 bool has_embedded =
false;
775 retval =
CkQualText(cur, &has_embedded,
true, error_msgs, perform_corrections);
779 string val_str = cur.
GetVal();
780 std::replace(val_str.begin(), val_str.end(),
'\"',
'\'');
802 for (bptr =
value; *bptr !=
'\0';) {
803 for (; *bptr !=
'/' && *bptr !=
'\0'; bptr++)
807 for (++bptr, ptr = bptr; *bptr !=
'=' && *bptr !=
' ' && *bptr !=
'\0'; bptr++)
810 string qual(ptr, bptr);
834 bool perform_corrections)
842 *has_embedded =
false;
852 if (perform_corrections) {
861 while (*
str !=
'\0' && (*
str ==
' ' || *
str ==
'\"')) {
864 if (*(
str - 1) ==
'\"') {
873 while (*
str !=
'\0' && (*
str ==
' ' || *
str ==
'\"'))
882 string value(bptr, eptr);
911 const Char* eptr =
nullptr;
923 while (*
str !=
'\0' && (*
str ==
',' || *
str ==
' '))
933 string aa(
str, eptr);
988 while (*
str !=
'\0' && *
str ==
' ')
992 string msg(bptr, eptr);
994 for (
Int2 i = 0;
i < totalstr; ++
i) {
1031 retval =
CkQualText(cur,
nullptr,
false, error_msgs, perform_corrections);
1036 while (*
str !=
'\0' && (*
str ==
' ' || *
str ==
'\"'))
1039 for (; *
str !=
'\0' && *
str !=
'\"';
str++)
1067 const Char* yes_or_no =
"not \'YES\', \'NO\' or \'ABSENT\'";
1084 for (; *
str ==
' ';
str++)
1086 for (; *
str ==
',';
str++)
1088 for (; *
str ==
' ';
str++)
1107 while (*
str !=
'\0' && (*
str ==
' ' || *
str ==
')'))
1113 bptr =
"extra characters";
1163 bool token_there =
false;
1172 if (! token_there) {
1183 while (*
str !=
'\0' && *
str ==
' ')
1188 string token(bptr, eptr);
1217 bptr =
"Invalid [integer] format";
1220 bptr =
"Not an integer number";
1223 bptr =
"Invalid format";
1227 bptr =
"Bad qualifier value";
1261 return "NULL value";
1315 if (*
str ==
'.' && *(
str + 1) ==
'.') {
@Gb_qual.hpp User-defined methods of the data storage class.
bool IsLegalQualifier(EQualifier qual) const
Test wheather a certain qualifier is legal for the feature.
EQualifier
List of available qualifiers for feature keys.
@ eQual_environmental_sample
@ eQual_recombination_class
@ eQual_UniProtKB_evidence
@ eQual_culture_collection
@ eQual_ribosomal_slippage
@ eQual_calculated_mol_wt
@ eQual_metagenome_source
@ eQual_mobile_element_type
@ eQual_artificial_location
const TQualifiers & GetMandatoryQualifiers(void) const
Get the list of all mandatory qualifiers for the feature.
static EQualifier GetQualifierType(CTempString qual)
convert qual string to enumerated value
static CTempString GetQualifierAsString(EQualifier qual)
Convert a qualifier from an enumerated value to a string representation or empty if not found.
const_iterator end() const
const_iterator find(const key_type &key) const
bool StringEquNI(const char *s1, const char *s2, size_t n)
uint8_t Uint1
1-byte (8-bit) unsigned integer
int16_t Int2
2-byte (16-bit) signed integer
#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 CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
@ eTrunc_End
Truncate trailing spaces only.
static const char label[]
const TVal & GetVal(void) const
Get the Val member data.
void SetQual(const TQual &value)
Assign a value to Qual data member.
bool IsSetQual(void) const
Check if a value has been assigned to Qual data member.
void SetVal(const TVal &value)
Assign a value to Val data member.
const TQual & GetQual(void) const
Get the Qual member data.
bool IsSetVal(void) const
Check if a value has been assigned to Val data member.
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
static const char * str(char *buf, int n)
#define ParFlat_Stoken_type
#define ERR_QUALIFIER_Pos
static int CkQualMatchToken(CGb_qual &cur, bool error_msgs, const Char *array_string[], Int2 totalstr)
int XGBFeatKeyQualValid(CSeqFeatData::ESubtype subtype, TQualVector &quals, bool error_msgs, bool perform_corrections)
static int CkQualPosaa(CGb_qual &cur, bool error_msgs)
#define ERR_QUALIFIER_MultiValue
static const Char * CkNumberType(const Char *str)
static int CkQualPosSeqaa(CGb_qual &cur, bool error_msgs, string &aa, const Char *eptr)
#define ERR_FEATURE_QualWrongThisFeat
#define ERR_QUALIFIER_UnknownSpelling
static int CkQualText(CGb_qual &cur, bool *has_embedded, bool from_note, bool error_msgs, bool perform_corrections)
const Char * ParFlat_IntOrString[]
#define ParFlat_Number_type
const Char * ParFlat_LRBString[]
#define ERR_QUALIFIER_SeqPosComma
#define ParFlat_SPLIT_IGNORE
static const Char * CkLabelType(const Char *str)
#define ERR_QUALIFIER_Too_many_tokens
#define ERR_QUALIFIER_BadECnum
static int CkQualSeqaa(CGb_qual &cur, bool error_msgs)
#define ERR_FEATURE_MissManQual
char ValidAminoAcid(const string &abbrev)
static ETokenClass GetQualifierClass(CSeqFeatData::EQualifier qual_type)
static Int2 GBQualSplit(const Char *qual)
static int CkQualNote(CGb_qual &cur, bool error_msgs, bool perform_corrections)
#define ParFlat_Integer_type
#define ERR_QUALIFIER_EmptyNote
static int CkQualEcnum(CGb_qual &cur, bool error_msgs, bool perform_corrections)
const Char * GBQual_names_split_ignore[4]
static const Char * CkBracketType(const Char *str)
static int CkQualTokenType(CGb_qual &cur, bool error_msgs, Uint1 type)
static bool ScanEmbedQual(const Char *value)
#define ParFlat_BracketInt_type
static const Char * this_module
#define ERR_QUALIFIER_InvalidDataFormat
const Char * ParFlat_RptString[]
#define ERR_QUALIFIER_Seq
static int GBQualSemanticValid(TQualVector &quals, bool error_msgs, bool perform_corrections)
static int SplitMultiValQual(TQualVector &quals)
static int CkQualSite(CGb_qual &cur, bool error_msgs)
#define ERR_QUALIFIER_Xtratext
#define ERR_QUALIFIER_Cons_splice
const Char * ParFlat_ExpString[]
#define GB_FEAT_ERR_SILENT
std::vector< CRef< objects::CGb_qual > > TQualVector
#define GB_FEAT_ERR_REPAIRABLE