Skip to content

Commit

Permalink
bugfix for chrs with no non-zero obs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej-fischer committed May 27, 2014
1 parent 7f67bcc commit d37754f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/common-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void get_dims( const char * data_fn,
stringstream line_ss;
data_ifs.open( data_fn, ios::in);
if (data_ifs.fail()){
printf("ERROR in get_data(): file %s cannot be opened.\n", data_fn);
printf("ERROR: file %s cannot be opened.\n", data_fn);
exit(1);
}
nSites.clear();
Expand All @@ -45,9 +45,11 @@ void get_dims( const char * data_fn,
line_ss.str(line);
}
line_ss >> chr >> l;
if (chr != old ){//new chromosome encounter
if (ct>0) nSites.push_back(ct);
chrs.push_back(chr);
if (chr != old ){//new chromosome encounter
if (ct>0){
nSites.push_back(ct);
chrs.push_back(old);
}
ct=0;
}
old=chr;
Expand All @@ -58,7 +60,10 @@ void get_dims( const char * data_fn,
}
if (keep || r>0) ct++;
}
nSites.push_back(ct);
if (ct>0){
nSites.push_back(ct);
chrs.push_back(old);
}
nTimes = nT;
data_ifs.close();
}
Expand Down
5 changes: 4 additions & 1 deletion src/emission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ Emission::Emission(){

// real constructor
void Emission::set(int ntimes, vector<int>& Chrs, vector<int>& nsites, int grid){
if ((int) Chrs.size() != (int) nsites.size()) abort();
if ((int) Chrs.size() != (int) nsites.size()){
cout<<"FATAL ERROR (use gdb to locate).\n";
abort();
}
nSamples = (int) nsites.size();
nTimes = ntimes;
nSites = new int [nSamples];
Expand Down

0 comments on commit d37754f

Please sign in to comment.