{
return false;
}
stringList ln;
ln.splitString(txt,"\n");
size_t idx;
if (ln.contains("EMISSION")){
idx = ln.indexOf("EMISSION");
}
else{
std::cerr << "Missing EMISSION tag from emission. Please check the formatting. This is what was handed to the emission class:\n " << txt << std::endl;
return false;
}
stringList line;
line.splitString(ln[idx], "\t,: ");
size_t typeBegin(0);
if (line.contains("P(X)")){
typeBegin = line.indexOf("P(X)");
}
else if (line.contains("LOG")){
typeBegin = line.indexOf("LOG");
}
else if (line.contains("COUNTS")){
typeBegin = line.indexOf("COUNTS");
}
else if (line.contains("REAL_NUMBER")){
typeBegin = line.indexOf("REAL_NUMBER");
if (line.contains("COMPLEMENT") || line.contains("1-P(X)")) {
}
}
else if (line.contains("MULTI_CONTINUOUS")){
typeBegin = line.indexOf("MULTI_CONTINUOUS");
if (line.contains("COMPLEMENT") || line.contains("1-P(X)")) {
}
}
else if (line.contains("CONTINUOUS")){
typeBegin = line.indexOf("CONTINUOUS");
if (line.contains("COMPLEMENT") || line.contains("1-P(X)")) {
}
}
else if (line.contains("FUNCTION")){
typeBegin = line.indexOf("FUNCTION");
function=true;
}
else {
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";
std::cerr << info << std::endl;
}
std::vector<track*> tempTracks;
for(size_t i=1;i<typeBegin;i++){
track* tk = trks.getTrack(line[i]);
if (tk==NULL){
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";
return false;
}
else{
tempTracks.push_back(tk);
}
}
if (tempTracks.size()>1){
std::cerr << "Multiple tracks listed under Real Track Emission Definition\n";
return false;
}
return true;
}
if (tempTracks.size()==1){
std::cerr << "Only a single track listed under MULTI_CONTINUOUS\n\
Use CONTINUOUS instead of MULTI-CONTINUOUS\n";
return false;
}
trcks =
new std::vector<track*> (tempTracks);
}
idx = ln.indexOf("PDF");
line.splitString(ln[idx],"\t:, ");
size_t function_idx = line.indexOf("PDF") + 1;
size_t parameter_idx = line.indexOf("PARAMETERS");
for(size_t i = parameter_idx+1 ; i< line.size() ; i++){
double value;
}
}
return true;
}
if (tempTracks.size()>1){
std::cerr << "Multiple tracks listed under CONTINUOUS Track Emission Definition\n\
Must use MULTI_CONTINUOUS for multivariate emissions\n";
return false;
}
idx = ln.indexOf("PDF");
line.splitString(ln[idx],"\t:, ");
size_t function_idx = line.indexOf("PDF") + 1;
size_t parameter_idx = line.indexOf("PARAMETERS");
for(size_t i = parameter_idx+1 ; i< line.size() ; i++){
double value;
}
}
return true;
}
else if (function){
std::string& functionName = line[typeBegin+1];
lexFunc =
new(std::nothrow) emissionFuncParam(functionName,funcs,tempTracks[0]);
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
return true;
}
else{
if (ln.contains("ORDER")){
idx=ln.indexOf("ORDER");
}
else{
std::cerr << "Couldn't find ORDER in non-Real_Number emission. Please check the formatting" << std::endl;
return false;
}
std::vector<int> tempOrder;
line.splitString(ln[idx],"\t:, ");
size_t orderIdx = line.indexOf("ORDER");
orderIdx++;
size_t ambIdx;
bool containsAmbig = line.contains("AMBIGUOUS");
if (containsAmbig){ambIdx=line.indexOf("AMBIGUOUS");}
else{ ambIdx= line.size();}
for(size_t i=orderIdx;i<ambIdx;i++){
int tempValue;
std::cerr << "Emission Order not numeric" << std::endl;
return false;
}
if (tempValue>32){
std::cerr << "Emission order is greater than 32. Must be 32 or less" << std::endl;
return false;
}
tempOrder.push_back(tempValue);
}
if (tempOrder.size() == tempTracks.size()){
for(size_t i=0;i<tempOrder.size();i++){
}
}
else{
std::cerr << "Different number of tracks and orders parsed in Emission: " << txt << " Check the formatting of the Emission" << std::endl;
return false;
}
if (containsAmbig){
ambIdx++;
if (line.size()<=ambIdx){
std::cerr << "No scoring type after AMBIGUOUS label\nAssuming AVG\n";
}
else if (line[ambIdx].compare("P(X)")==0)
{
ambIdx++;
if (ambIdx>=line.size()){
std::cerr << "Missing Ambiguous Value" << std::endl;
return false;
}
double tempValue;
std::cerr << "Ambiguous Value couldn't be parsed: "<< line[ambIdx] << std::endl;
return false;
}
}
else if (line[ambIdx].compare("LOG")==0){
ambIdx++;
if (ambIdx>=line.size()){
std::cerr << "Missing Ambiguous Value" << std::endl;
return false;
}
double tempValue;
std::cerr << "Ambiguous Value couldn't be parsed: "<< line[ambIdx] << std::endl;
return false;
}
}
}
size_t expectedColumns(1);
size_t expectedRows(1);
}
for (size_t iter = 2; iter< ln.size();iter++){
if (iter==2 && ln[iter][0]=='@'){
continue;
}
line.splitString(ln[iter],"\t ");
if (line[0][0]=='@'){
line.pop_ith(0);
}
std::vector<double> temp = line.toVecDouble();
if (temp.size() != expectedColumns){
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] ;
std::cerr << info << std::endl;
return false;
}
else{
prob->push_back(temp);
log_prob->push_back(temp);
}
log_prob->push_back(temp);
prob->push_back(temp);
}
counts->push_back(temp);
prob->push_back(temp);
log_prob->push_back(temp);
}
}
}
if (log_prob->size() != expectedRows){
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;
return false;
}
}
return true;
}