Read population state and epitopes from separate files.
authorDariusz Murakowski <murakdar@mit.edu>
Mon, 17 Feb 2014 10:36:56 +0000 (05:36 -0500)
committerDariusz Murakowski <murakdar@mit.edu>
Mon, 17 Feb 2014 10:36:56 +0000 (05:36 -0500)
wf.cpp
wf.h

diff --git a/wf.cpp b/wf.cpp
index 7570931..fcb55de 100644 (file)
--- a/wf.cpp
+++ b/wf.cpp
@@ -53,6 +53,7 @@ void run(RunParameters &r, unsigned seed) {
     if (r.useTwoSite && supout == NULL) { perror("File error"); exit(1); }
     
     if (r.importState) importState(r);      // <infile>.st
+    if (r.useEpitope)  importEpitope(r);    // <infile>.ep
     fflush(stdout);
     
 
@@ -208,6 +209,20 @@ void importState(RunParameters &r) {
 
     std::cout << "\n";  // XXX
     
+}
+
+
+// load epitope definitions from file
+
+void importEpitope(RunParameters &r) {
+
+    FILE *input=fopen(r.epitopeInfile.c_str(),"r");   // <infile>.st
+    if (input == NULL) { perror((std::string("ERROR in importEpitope: ") + r.epitopeInfile).c_str()); exit(1); }
+    
+    char o;
+    //double frac;
+       unsigned int site;
+    
     // Import targeted epitope
     
     while (fscanf(input,"%u",&site)==1) {
@@ -233,8 +248,6 @@ void importState(RunParameters &r) {
         if (o=='\n') break;
         
     }
-    
-    r.useEpitope=true;
 
 }
 
@@ -261,12 +274,12 @@ void usage()
 " -d  (string)        working directory\n"
 " -i  (string)        input couplings file\n"
 " -o  (string)        output file stem\n"
-" -s  (string)        input state file, containing initial population fraction and targeted epitope\n"
+" -s  (string)        input state file, containing initial population fraction\n"
+" -e  (string)        input file containing targeted epitope\n"
 " -n  (int/double)    population size\n"
 " -g  (int/double)    number of generations\n"
 " -mu (double)        mutation rate\n"
 " -b  (double)        \"inverse temperature\" multiplier\n"
-" -e  (int) (int)     targeted epitope spans sites [e#1, ..., e#2], assuming all WT\n"
 " -r                  flag to use relative energy condition for survival probability\n"
 " -esc                flag to run until escape observed (or max number of generations reached)\n"
 " -v                  flag for verbose output\n"
@@ -289,11 +302,11 @@ void usage()
  *  -i  (string)        input couplings file
  *  -o  (string)        output file stem
  *  -s  (string)        input state file, containing initial population fraction and targeted epitope
+ *  -e  (string)        input file containing targeted epitope
  *  -n  (int/double)    population size
  *  -g  (int/double)    number of generations
  *  -mu (double)        mutation rate
  *  -b  (double)        "inverse temperature" multiplier
- *  -e  (int) (int)     targeted epitope spans sites [e#1, ..., e#2], assuming all WT
  *  -r                  flag to use relative energy condition for survival probability
  *  -esc                flag to run until escape observed (or max number of generations reached)
  *  -v                  flag for verbose output
@@ -313,7 +326,8 @@ int main(int argc, char *argv[]) {
         if      (strcmp(argv[i],"-d")==0) { if (++i==argc) break; else r.directory=argv[i];                         }
         else if (strcmp(argv[i],"-i")==0) { if (++i==argc) break; else r.infile=argv[i];                            }
         else if (strcmp(argv[i],"-o")==0) { if (++i==argc) break; else r.outfile=argv[i];                           }
-        else if (strcmp(argv[i],"-s")==0) { if (++i==argc) break; else { r.statefile=argv[i]; r.importState=true; r.useEpitope=true; } }
+        else if (strcmp(argv[i],"-s")==0) { if (++i==argc) break; else { r.statefile=argv[i]; r.importState=true; } }
+        else if (strcmp(argv[i],"-e")==0) { if (++i==argc) break; else { r.epitopefile=argv[i]; r.useEpitope=true; } }
         
         else if (strcmp(argv[i],"-n")==0)  { if (++i==argc) break; else r.n=(unsigned int)strtodouble(argv[i]); }
         else if (strcmp(argv[i],"-g")==0)  { if (++i==argc) break; else r.g=(unsigned int)strtodouble(argv[i]); }
@@ -322,10 +336,6 @@ int main(int argc, char *argv[]) {
         else if (strcmp(argv[i],"-bh")==0) { if (++i==argc) break; else r.bh=strtodouble(argv[i]);              }
         else if (strcmp(argv[i],"-bJ")==0) { if (++i==argc) break; else r.bJ=strtodouble(argv[i]);              }
         
-//        else if (strcmp(argv[i],"-e")==0) { if (argc-i<2) break; else { r.estart=strtoint(argv[++i]);
-//                                                                        r.eend=strtoint(argv[++i]);
-//                                                                        r.useEpitope=true;            } }
-        
         else if (strcmp(argv[i],"-r")==0)   { r.useRelative=true;    }
         else if (strcmp(argv[i],"-esc")==0) { r.runUntilEscape=true; }
         else if (strcmp(argv[i],"-v")==0)   { r.useVerbose=true;     }
diff --git a/wf.h b/wf.h
index eb9eb51..bcfd2e9 100644 (file)
--- a/wf.h
+++ b/wf.h
@@ -78,7 +78,7 @@ public:
     std::string infile;         // Input file from which couplings are to be read
     std::string outfile;        // Output file (prefix) where data is to be written
     std::string statefile;      // Input state file which contains initial population fractions
-                                // and targeted epitope
+    std::string epitopefile;    // Input file name for targeted epitopes
     
     unsigned int n;             // Population size
     unsigned int g;             // Number of generations
@@ -111,6 +111,7 @@ public:
     std::string trajectoryOutfile;
     std::string supplementaryOutfile;
     std::string stateInfile;
+    std::string epitopeInfile;
     
     
     RunParameters() {
@@ -151,6 +152,7 @@ public:
             trajectoryOutfile=directory+"/"+outfile+".dat";
             supplementaryOutfile=directory+"/"+outfile+".sum";
             stateInfile=directory+"/"+statefile+".st";
+            epitopeInfile=directory+"/"+epitopefile+".ep";
             
         }
         
@@ -160,6 +162,7 @@ public:
             trajectoryOutfile=outfile+".dat";
             supplementaryOutfile=outfile+".sum";
             stateInfile=statefile+".st";
+            epitopeInfile=epitopefile+".ep";
         
         }
         
@@ -173,6 +176,7 @@ public:
 
 void run(RunParameters &r);
 void importState(RunParameters &r);
+void importEpitope(RunParameters &r);
 
 
 #endif