69 getline(input_, nextLine_);
75 if (!hasMoreFeature())
76 throw Exception(
"GtfFeatureReader::nextFeature(). No more feature in file.");
81 throw Exception(
"GtfFeatureReader::nextFeature(). Wrong GTF file format: should have 9 tab delimited columns.");
87 unsigned int start = TextTools::to<unsigned int>(st.
nextToken()) - 1;
88 unsigned int end = TextTools::to<unsigned int>(st.
nextToken());
89 double score = TextTools::to<double>(st.
nextToken());
93 map<string, string> attributes;
99 string::size_type idx = item.find_first_of(
' ');
100 string key(item.substr(0, idx));
101 string value(item.substr(idx));
110 value.erase(value.begin());
116 value[value.size() - 1] ==
'"'
120 value.erase(value.end() - 1);
122 attributes[key] = value;
132 if (phase !=
".") feature.
setAttribute(GTF_PHASE, phase);
135 for (map<std::string, std::string>::iterator it = attributes.begin(); it != attributes.end(); ++it) {
A very simple implementation of the SequenceFeature class.
void setAttribute(const std::string &attribute, const std::string &value)
Set the value of an attribute.
static const std::string GTF_TRANSCRIPT_ID
static const std::string GTF_PHASE
static const std::string GTF_GENE_ID
const BasicSequenceFeature nextFeature()
size_t numberOfRemainingTokens() const
const std::string & nextToken()
bool hasMoreToken() const
std::string removeSurroundingWhiteSpaces(const std::string &s)
bool isWhiteSpaceCharacter(char c)
bool isEmpty(const std::string &s)