81 std::cerr <<
"Missing EMISSION tag from emission. Please check the formatting. This is what was handed to the emission class:\n " << txt << std::endl;
93 typeBegin = line.
indexOf(
"P(X)");
97 typeBegin = line.
indexOf(
"LOG");
101 typeBegin = line.
indexOf(
"COUNTS");
104 else if (line.
contains(
"REAL_NUMBER")){
105 typeBegin = line.
indexOf(
"REAL_NUMBER");
111 else if (line.
contains(
"MULTI_CONTINUOUS")){
112 typeBegin = line.
indexOf(
"MULTI_CONTINUOUS");
118 else if (line.
contains(
"CONTINUOUS")){
119 typeBegin = line.
indexOf(
"CONTINUOUS");
126 else if (line.
contains(
"FUNCTION")){
127 typeBegin = line.
indexOf(
"FUNCTION");
131 std::string info =
"Couldn't parse Value type in the Emission: " + txt +
" Please check the formatting. The allowed types are: P(X), LOG, COUNTS, or REAL_NUMBER. \n";
132 std::cerr << info << std::endl;
139 std::vector<track*> tempTracks;
140 for(
size_t i=1;i<typeBegin;i++){
143 std::cerr <<
"Emissions tried to add a track named: " << line[i] <<
" . However, there isn't a matching track in the model. Please check to model formatting.\n";
154 if (tempTracks.size()>1){
155 std::cerr <<
"Multiple tracks listed under Real Track Emission Definition\n";
164 if (tempTracks.size()==1){
165 std::cerr <<
"Only a single track listed under MULTI_CONTINUOUS\n\
166 Use CONTINUOUS instead of MULTI-CONTINUOUS\n";
172 trcks =
new std::vector<track*> (tempTracks);
182 size_t function_idx = line.
indexOf(
"PDF") + 1;
187 size_t parameter_idx = line.
indexOf(
"PARAMETERS");
192 for(
size_t i = parameter_idx+1 ; i< line.
size() ; i++){
205 if (tempTracks.size()>1){
206 std::cerr <<
"Multiple tracks listed under CONTINUOUS Track Emission Definition\n\
207 Must use MULTI_CONTINUOUS for multivariate emissions\n";
216 size_t function_idx = line.
indexOf(
"PDF") + 1;
219 size_t parameter_idx = line.
indexOf(
"PARAMETERS");
224 for(
size_t i = parameter_idx+1 ; i< line.
size() ; i++){
237 std::string& functionName = line[typeBegin+1];
243 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
256 std::cerr <<
"Couldn't find ORDER in non-Real_Number emission. Please check the formatting" << std::endl;
261 std::vector<int> tempOrder;
264 size_t orderIdx = line.
indexOf(
"ORDER");
268 bool containsAmbig = line.
contains(
"AMBIGUOUS");
270 if (containsAmbig){ambIdx=line.
indexOf(
"AMBIGUOUS");}
271 else{ ambIdx= line.
size();}
273 for(
size_t i=orderIdx;i<ambIdx;i++){
277 std::cerr <<
"Emission Order not numeric" << std::endl;
282 std::cerr <<
"Emission order is greater than 32. Must be 32 or less" << std::endl;
286 tempOrder.push_back(tempValue);
289 if (tempOrder.size() == tempTracks.size()){
290 for(
size_t i=0;i<tempOrder.size();i++){
295 std::cerr <<
"Different number of tracks and orders parsed in Emission: " << txt <<
" Check the formatting of the Emission" << std::endl;
303 if (line.
size()<=ambIdx){
304 std::cerr <<
"No scoring type after AMBIGUOUS label\nAssuming AVG\n";
313 else if (line[ambIdx].compare(
"P(X)")==0)
318 if (ambIdx>=line.
size()){
319 std::cerr <<
"Missing Ambiguous Value" << std::endl;
326 std::cerr <<
"Ambiguous Value couldn't be parsed: "<< line[ambIdx] << std::endl;
332 else if (line[ambIdx].compare(
"LOG")==0){
336 if (ambIdx>=line.
size()){
337 std::cerr <<
"Missing Ambiguous Value" << std::endl;
344 std::cerr <<
"Ambiguous Value couldn't be parsed: "<< line[ambIdx] << std::endl;
353 size_t expectedColumns(1);
354 size_t expectedRows(1);
365 for (
size_t iter = 2; iter< ln.
size();iter++){
369 if (iter==2 && ln[iter][0]==
'@'){
376 if (line[0][0]==
'@'){
382 if (temp.size() != expectedColumns){
383 std::string info =
"The following line couldn't be parsed into the required number of columns. Expected Columns: " +
int_to_string(expectedColumns) +
"\n The line appears as: " + ln[iter] ;
385 std::cerr << info << std::endl;
393 log_prob->push_back(temp);
396 log_prob->push_back(temp);
398 prob->push_back(temp);
400 else if (valtyp ==
COUNTS){
401 counts->push_back(temp);
403 prob->push_back(temp);
405 log_prob->push_back(temp);
410 if (log_prob->size() != expectedRows){
411 std::cerr <<
" The Emission table doesn't contain enough rows. Expected Rows: " << expectedRows <<
" \n Please check the Emission Table and formatting for " << txt << std::endl;
436 std::cerr <<
"Missing EMISSION tag from emission. Please check the formatting. This is what was handed to the emission class:\n " << txt << std::endl;
458 std::string info =
"Couldn't parse Value type in the Emission: " + txt +
" Please check the formatting. The allowed types are: P(X), LOG, COUNTS, or REAL_NUMBER. \n";
459 std::cerr << info << std::endl;
466 std::vector<track*> temp_tracks;
467 temp_tracks.push_back(trk);
474 std::cerr <<
"Couldn't find ORDER in non-Real_Number emission. Please check the formatting" << std::endl;
479 std::vector<int> temp_order;
482 size_t orderIdx = line.
indexOf(
"ORDER");
486 bool containsAmbig = line.
contains(
"AMBIGUOUS");
488 if (containsAmbig){ambIdx=line.
indexOf(
"AMBIGUOUS");}
489 else{ ambIdx= line.
size();}
491 for(
size_t i=orderIdx;i<ambIdx;i++){
495 std::cerr <<
"Emission Order not numeric" << std::endl;
500 std::cerr <<
"Emission order is greater than 32. Must be 32 or less" << std::endl;
504 temp_order.push_back(temp_value);
507 if (temp_order.size() == temp_tracks.size()){
508 for(
size_t i=0;i<temp_order.size();i++){
513 std::cerr <<
"Different number of tracks and orders parsed in Emission: " << txt <<
" Check the formatting of the Emission" << std::endl;
521 if (line.
size()<=ambIdx){
522 std::cerr <<
"No scoring type after AMBIGUOUS label\nAssuming AVG\n";
528 else if (line[ambIdx].compare(
"P(X)")==0)
533 if (ambIdx>=line.
size()){
534 std::cerr <<
"Missing Ambiguous Value" << std::endl;
541 std::cerr <<
"Ambiguous Value couldn't be parsed: "<< line[ambIdx] << std::endl;
547 else if (line[ambIdx].compare(
"LOG")==0){
551 if (ambIdx>=line.
size()){
552 std::cerr <<
"Missing Ambiguous Value" << std::endl;
559 std::cerr <<
"Ambiguous Value couldn't be parsed: "<< line[ambIdx] << std::endl;
568 size_t expectedColumns(1);
569 size_t expectedRows(1);
580 for (
size_t iter = 2; iter< ln.
size();iter++){
584 if (iter==2 && ln[iter][0]==
'@'){
591 if (line[0][0]==
'@'){
597 if (temp.size() != expectedColumns){
598 std::string info =
"The following line couldn't be parsed into the required number of columns. Expected Columns: " +
int_to_string(expectedColumns) +
"\n The line appears as: " + ln[iter] ;
600 std::cerr << info << std::endl;
608 log_prob->push_back(temp);
611 log_prob->push_back(temp);
613 prob->push_back(temp);
615 else if (valtyp ==
COUNTS){
616 counts->push_back(temp);
618 prob->push_back(temp);
620 log_prob->push_back(temp);
625 if (log_prob->size() != expectedRows){
626 std::cerr <<
" The Emission table doesn't contain enough rows. Expected Rows: " << expectedRows <<
" \n Please check the Emission Table and formatting for " << txt << std::endl;
633 std::cerr <<
"Not NULL" << std::endl;
643 if (lst.
size() == 0){
651 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
657 std::cerr <<
"Couldn't parse Emission Tag: " << lst.
stringify() << std::endl;
665 std::cerr <<
"No Track defined with name:\t" << trackName <<
"\nEmission Tag:\n" << txt << std::endl;
682 double final_emission(-INFINITY);
688 final_emission=log(1-exp(final_emission));
703 final_emission=log(1-exp(final_emission));
711 final_emission=log(1-exp(final_emission));
723 return final_emission;
734 double final_emission;
740 final_emission=log(1-exp(final_emission));
755 final_emission=log(1-exp(final_emission));
763 final_emission=log(1-exp(final_emission));
775 return final_emission;
796 std::string emissionString(
"EMISSION:\t");
801 emissionString+=
":\t";
803 emissionString+=
"REAL_NUMBER";
805 emissionString+=
":\tCOMPLEMENT\t";
808 emissionString+=
"\t";
815 emissionString+=
"\n";
820 emissionString+=
":\tCONTINUOUS";
825 emissionString+=
"\n\t";
827 emissionString+=
"PDF:\t";
828 emissionString+=
pdfName +
"\tPARAMETERS:\t";
830 emissionString+=
"\n";
838 emissionString+=(*trcks)[i]->getName();
840 emissionString+=
":\tMULTI_CONTINUOUS";
845 emissionString+=
"\n\t";
847 emissionString+=
"PDF:\t";
848 emissionString+=
pdfName +
"\tPARAMETERS:\t";
850 emissionString+=
"\n";
854 emissionString+=
":\tFUNCTION:\t";
856 emissionString+=
"\t";
862 emissionString+=
"\n";
873 emissionString+=
":\t";
875 emissionString+=
"LOG";
879 emissionString +=
"\t";
884 emissionString+=
"\n\tORDER:\t";
896 emissionString+=
"\tAMBIGUOUS:\t";
901 emissionString+=
"\n";
906 emissionString+=
"\n";
908 return emissionString;