32 transi =
new (std::nothrow) std::vector<transition*>;
45 transi =
new std::vector<transition*>;
46 parse(txt,names,trcks, wts,funcs);
74 size_t stateHeaderInfo = txt.find(
"STATE:");
75 size_t transitionsInfo = txt.find(
"TRANSITION:");
76 size_t emissionInfo = txt.find(
"EMISSION:");
79 if (stateHeaderInfo==std::string::npos){
80 std::cerr <<
"Couldn't identify state Header Information. Please check the formatting. The supplied text was : " << txt << std::endl;
84 if (transitionsInfo == std::string::npos){
85 std::cerr <<
"Couldn't identify state Transitions Information. Please check the formatting. The supplied text was : " << txt << std::endl;
90 std::string header = txt.substr(stateHeaderInfo,transitionsInfo-stateHeaderInfo);
97 std::string trans = (emissionInfo==std::string::npos) ? txt.substr(transitionsInfo) : txt.substr(transitionsInfo, emissionInfo - transitionsInfo);
105 if (emissionInfo != std::string::npos){
106 std::string emmis = txt.substr(emissionInfo);
108 std::cerr <<
"Couldn't parse the emissions for state: " <<
name << std::endl;
114 if (
name.compare(
"INIT")!=0){
115 std::cerr <<
"No emission defined for State: " <<
name << std::endl;
137 if (idx+1 < lst.
size()){
142 std::cerr <<
"The states NAME couldn't be parsed from " << txt << std::endl;
147 if (
name.compare(
"INIT")==0){
152 std::cerr <<
"No NAME found in state header information. Please check formatting. Following is header information recieved: " << txt << std::endl;
159 if (idx+1 < lst.
size()){
164 std::cerr <<
"The states PATH_LABEL couldn't be parsed from " << txt << std::endl;
170 std::cerr <<
"No PATH_LABEL found in state header information. Please check formatting. Following is header information recieved: " << txt << std::endl;
177 if (idx+1 < lst.
size()){
182 std::cerr <<
"The states GFF_DESC couldn't be parsed from " << txt << std::endl;
200 lst.
splitND(txt,
"TRANSITION:");
203 for(
size_t iter=0;iter<lst.
size();iter++){
219 std::cerr <<
"Unrecognized Transition type(STANDARD, DURATION, LEXICAL):" << txt << std::endl;
230 std::cerr <<
"Unrecognized Transition value type( P(X), LOG, COUNTS): " << txt << std::endl;
239 for(
size_t iter=1;iter<line.
size();iter++){
243 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
247 if (!temp->
parse(line[iter], names, valtyp, trks, wts, funcs)){
248 std::cerr <<
"Couldn't parse Transition " << std::endl;
251 std::string transName = temp->
getName();
253 if (transName==
"END"){
269 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
273 if (!temp->
parse(line,names,valtyp,trks,wts,funcs)){
274 std::cerr <<
"Couldn't parse Transition "<< std::endl;
277 std::string transName = temp->
getName();
301 for(
size_t iter=0; iter<lst.
size();iter++){
302 emm* temp =
new(std::nothrow)
emm;
305 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
309 if (!temp->
parse(lst[iter],trks,wts,funcs)){
327 std::string stateString;
328 stateString+=
"STATE:\n";
329 stateString+=
"\tNAME:\t" +
name +
"\n";
331 if (
name.compare(
"INIT")!=0){
332 if (!
gff.empty()){ stateString+=
"\tGFF_DESC:\t" +
gff +
"\n";}
333 stateString+=
"\tPATH_LABEL:\t" +
label +
"\n";
336 std::string standardString;
337 std::string distribString;
338 std::string lexicalString;
341 for(
size_t i=0;i<
transi->size();i++){
342 if ((*
transi)[i]==NULL){
continue;}
344 transType tp = (*transi)[i]->getTransitionType();
346 if (standardString.empty()){
347 standardString+=
"TRANSITION:\tSTANDARD:\tLOG\n";
349 standardString+=(*transi)[i]->stringify() +
"\n";
352 distribString+=
"TRANSITION:\tDURATION:\tLOG\n";
353 distribString+=(*transi)[i]->stringify();
357 if ((*
transi)[i]->LexFunctionDefined()){
358 lexicalString+=
"TRANSITION:\tLEXICAL:\tFUNCTION:\t";
359 lexicalString+=(*transi)[i]->getLexicalFunctionName();
363 lexicalString+=
"TRANSITION:\tLEXICAL:\tLOG\n";
364 lexicalString+=(*transi)[i]->stringify();
373 if (standardString.empty()){
374 standardString+=
"TRANSITIONS:\tSTANDARD:\tLOG\n";
380 if (
name.compare(
"INIT")==0){
381 stateString+=standardString +
"\n\n";
385 if (!standardString.empty()){
386 stateString+=standardString +
"\n";
389 if (!distribString.empty()){
390 stateString+=distribString +
"\n";
393 if (!lexicalString.empty()){
394 stateString+=lexicalString +
"\n";
401 for(
size_t i=0;i<
emission.size();i++){
402 stateString+=
emission[i]->stringify();
412 double value(
emission[0]->get_emission(seqs,iter));
413 for(
size_t i=1;i<
emission.size();i++){
414 value+=
emission[i]->get_emission(seqs,iter);
431 value = (*transi)[
to]->log_trans;
434 std::cerr <<
"Need to implement this functionality" <<std::endl;
435 value = (*transi)[
to]->getTransition(iter,&seqs);
451 void state::checkLabels(std::set<std::string>& labels, std::set<std::string>& gff, std::set<std::string>& name){
452 for(
size_t i = 0;i<(*transi).size();i++){
462 if (!name.count(tn)){
463 std::cerr <<
"Model Function or Distribution traceback definition contains Unknown State Name:\t" << tn << std::endl;
468 std::cerr <<
"Model function or distribution traceback definition contains Unknown GFF Descrition:\t" << tn << std::endl;
472 if (!labels.count(tn)){
473 std::cerr <<
"Model function or distribution traceback definition contains Unknown Path Label:\t" << tn << std::endl;
485 if (!name.count(cn)){
486 std::cerr <<
"Traceback Combine definition contains Unknown State Name:\t" << cn << std::endl;
491 std::cerr <<
"Traceback Combine definition contains Unknown GFF Descrition:\t" << cn << std::endl;
495 if (!labels.count(cn)){
496 std::cerr <<
"Traceback Combine definition contains Unknown Path Label:\t" << cn << std::endl;
518 size_t number_of_states = state_index.size();
519 std::vector<transition*>* fixed_trans =
new std::vector<transition*>(number_of_states-1,NULL);
522 for(
size_t i = 0; i <
transi->size(); i++){
527 std::cerr <<
"State: " << name <<
" was declared but not defined in the model." << std::endl;
531 (*fixed_trans)[index]=temp;
542 for(
size_t i=0; i <
emission.size() ; ++i){
553 for(
size_t i=0;i<(*transi).size();++i){
559 if ((*
transi)[i]->isComplex()){