Small bug fix
authorTim Reddy Tim <treddy@hudsonalpha.org>
Mon, 23 Feb 2009 17:44:07 +0000 (17:44 +0000)
committerTim Reddy Tim <treddy@hudsonalpha.org>
Mon, 23 Feb 2009 17:44:07 +0000 (17:44 +0000)
htswanalysis/src/profile_reads_against_features.cpp

index ad48803fbcaf0a5c938784c0397758da1ac08cf4..34d725dae98a35c3657793cd0a77ab3142bf8d7d 100755 (executable)
@@ -81,7 +81,7 @@ int main(int argc, char** argv) {
     string line_str(line);
     vector<string> fields;
     split(line_str, delim, fields);
-    if(fields.size() == 3) { continue; }
+    if(fields.size() <= 3) { continue; }
  
     vector<string> location; split(fields[3], location_delim, location);
     string chr = location[0];
@@ -129,8 +129,14 @@ int main(int argc, char** argv) {
   ;
   }
   
-  for(unsigned int i = 0; i < profile.size(); i++) {
-    cout << (int)i - (int)1000 << "\t" << (double)profile[i] / (double)data.size() << endl;;
+  if(data.size() == 0) {
+    for(unsigned int i = 0; i < profile.size(); i++) {
+      cout << (int)i - (int)1000 << "\t0\n";
+    }
+  } else {
+    for(unsigned int i = 0; i < profile.size(); i++) {
+      cout << (int)i - (int)1000 << "\t" << (double)profile[i] / (double)data.size() << endl;;
+    }
   }
 }