26 stringMapIter existing = qualifiers.find(qualifier);
27 if (existing != qualifiers.end()) {
28 existing->second.append(1,
'\n');
29 existing->second.append(value);
32 qualifiers[qualifier] = value;
38 size_t vlen = value.length();
42 stringCIter
start = value.begin();
43 stringCIter end = start+vlen-1;
46 if (vlen == 1 || *end !=
'"') {
60 static void appendData(
string&
id,
const string& data,
int maxAppend) {
65 size_t old_id_len =
id.length();
70 stringCIter end = data.end();
71 bool insideWord =
false;
72 bool seenNonDigit =
false;
74 for (stringCIter i = data.begin(); maxAppend>0 && i != end; ++i) {
77 if (!insideWord) c = toupper(c);
81 if (!seenNonDigit && isalpha(c)) { seenNonDigit =
true; }
83 else if (isspace(c) || c ==
'-') {
92 id.resize(old_id_len);
98 stringMapCIter not_found = qualifiers.end();
99 stringMapCIter product = qualifiers.find(
"product");
100 stringMapCIter gene = qualifiers.find(
"gene");
102 const size_t maxidlen = 30;
105 id.reserve(maxidlen+10);
106 if (gene != not_found) {
107 appendData(
id, gene->second, maxidlen-
id.length());
110 if (product != not_found) {
111 appendData(
id, product->second, maxidlen-
id.length());
116 if (isdigit(
id[
id.
length()-1])) {
117 if (
id.
length() == maxidlen)
id.resize(maxidlen-1);
128 if (!location->
isInRange(1, seqLength)) {
129 throw GBS_global_string(
"Illegal feature location (outside sequence 1..%li)", seqLength);
136 stringMapIter e = qualifiers.end();
137 for (stringMapIter i = qualifiers.begin(); i != e; ++i) {
138 if (i->second.empty()) {
139 if (i->first ==
"replace") {
143 i->second =
"<empty>";
void setOrAppendQualifiedEntry(stringMap &qualifiers, const string &qualifier, const string &value)
virtual bool isInRange(long pos1, long pos2) const =0
const char * GBS_global_string(const char *templat,...)
LocationPtr parseLocation(const string &source)
static HelixNrInfo * start
Feature(const std::string &Type, const std::string &locationString)
std::string createGeneName() const
std::map< std::string, std::string > stringMap
void addQualifiedEntry(const std::string &qualifier, const std::string &value)
void expectLocationInSequence(long seqLength) const
void fixEmptyQualifiers()
static void appendData(string &id, const string &data, int maxAppend)