52 std::cout << i <<
"\t" <<
defs[i]->stringify() << std::endl;
88 return defs[position]->getState();
91 std::cerr <<
"Calling getAbsState on weighted state" << std::endl;
102 return !
defs[position]->isAbsolute();
113 return defs[position]->getWeight(stateIter);
141 if (!
weights.defined(stateIter)){
169 for(
size_t i=0;i<
weights.size();i++){
188 std::string comment_char=
"#";
189 std::string ws=
" []";
190 std::string split=
"\t:";
192 while(ln.
fromDef(file, ws, split)){
194 if (ln[0].compare(
"EXDEF")==0){
196 if (ln[1].compare(
"ABSOLUTE")==0){
199 else if (ln[1].compare(
"WEIGHTED")==0){
203 std::cerr << ln[0] <<
" not a valid external definition\n";
208 char nl_peek=file.peek();
227 std::vector<size_t> path;
229 for (
size_t i=2;i<ln.
size();i++){
230 std::string& tag=ln[i];
232 std::cerr <<
"Missing additional information for Absolute Definition: TAG: " << ln[i] << std::endl;
236 if (tag.compare(
"START")==0){
240 std::cerr <<
"Value in External Definition START is not numeric: " << ln[i+1] << std::endl;
244 startPosition=tempInt;
249 else if (tag.compare(
"END")==0){
253 std::cerr <<
"Value in External Definition END is not numeric: " << ln[i+1] << std::endl;
258 stopPosition=tempInt;
262 else if (tag.compare(
"TRACE")==0){
263 std::string& trace=ln[i+1];
264 std::vector<std::string> traces;
268 size_t expectedSize=stopPosition-startPosition+1;
270 if (traces.size()!=expectedSize){
271 std::cerr <<
"Expected external definition trace size: " << expectedSize <<
"\n but got " << trace << std::endl;
274 path.assign(traces.size(),-2);
276 for(
size_t k=0;k<traces.size();k++){
281 std::cerr <<
"External definition Trace state name: " << traces[k] <<
" doesn't exist in the model" << std::endl;
289 std::cerr <<
"Invalid tag found in sequence external definition: " << ln[i] <<std::endl;
294 if (start && stop && state){
295 for(
size_t i=startPosition-1;i<stopPosition;i++){
296 size_t state=path[i-(startPosition-1)];
298 if (!
defs[i]->absolute){
299 std::cerr <<
"Absolute overlaps weighted state definition" << std::endl;
302 else if (state!=
defs[i]->getState()){
303 std::cerr <<
"Two absolute paths defined for " << i+1 <<
" position in sequence" <<std::endl;
308 defs[i]->setState(state);
325 size_t startPosition(0);
326 size_t stopPosition(0);
328 std::set<size_t> definedStates;
329 std::set<size_t>::iterator setIterator;
333 for (
size_t line_iter=2; line_iter < ln.
size();line_iter++){
334 std::string& tag=ln[line_iter];
336 if (ln.
size()<=line_iter+1){
337 std::cerr <<
"External Definition for Weighted Def is missing values: " << ln[line_iter] << std::endl;
341 if (tag.compare(
"START")==0){
346 std::cerr <<
"Value in External Definition START is not numeric: " << ln[line_iter+1] << std::endl;
351 startPosition=tempInt;
355 else if (tag.compare(
"END")==0){
359 std::cerr <<
"Value in External Definition END is not numeric: " << ln[line_iter+1] << std::endl;
364 stopPosition=tempInt;
368 else if (tag.compare(
"STATE_NAME")==0){
373 else if (tag.compare(
"STATE_LABEL")==0){
375 for(
size_t temp_iter=0; temp_iter < temp.size();temp_iter++){
376 definedStates.insert(temp[temp_iter]);
381 else if (tag.compare(
"STATE_GFF")==0){
383 for(
size_t temp_iter=0; temp_iter < temp.size(); temp_iter++){
384 definedStates.insert(temp[temp_iter]);
389 else if (tag.compare(
"VALUE")==0){
393 std::cerr <<
"VALUE couldn't be converted to numerical value: " << ln[line_iter+1] << std::endl;
400 else if (tag.compare(
"VALUE_TYPE")==0){
401 std::string &type=ln[line_iter+1];
402 if (type.compare(
"P(X)")==0){
406 else if (type.compare(
"LOG")==0){
415 std::cerr <<
"Invalid tag found in Sequence external definition: " << ln[line_iter] << std::endl;
420 if (definedStates.size()>0){
424 std::cerr <<
"No valid states defined by External definition" <<std::endl;
429 if (start && stop && state && value && valType){
430 for (
size_t position=startPosition-1; position < stopPosition; position++){
433 if (
defs[position]->absolute){
434 std::cerr <<
"Can't add weight to absolute external definition" << std::endl;
441 if (
defs[position]==NULL){
442 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
448 for (setIterator=definedStates.begin();setIterator!=definedStates.end();setIterator++){
449 defs[position]->assignWeight(*setIterator, val);