Clean up extra debug printing.
authorDariusz Murakowski <murakdar@mit.edu>
Thu, 7 May 2015 21:06:25 +0000 (17:06 -0400)
committerDariusz Murakowski <murakdar@mit.edu>
Thu, 7 May 2015 21:14:07 +0000 (17:14 -0400)
ss.cpp

diff --git a/ss.cpp b/ss.cpp
index 9705e55..3356b2e 100644 (file)
--- a/ss.cpp
+++ b/ss.cpp
@@ -49,32 +49,32 @@ bool does_species_appear_in_reactants(Species *s, Reaction *rxn)
         for (Species_parray::iterator t = dynamic_cast<ElementaryReaction*>(rxn)->reactants.begin(),
                                       f = dynamic_cast<ElementaryReaction*>(rxn)->reactants.end();
                                       t != f; ++t) {
-            if (s == *t){std::cout << "elem: " << rxn->name << '\n'; return true;}
+            if (s == *t) { return true; }
         }
         break;
     case RxnType::Virus:
-        if (s == dynamic_cast<VirusReaction*>(rxn)->V){std::cout << "virus: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<VirusReaction*>(rxn)->V) { return true; }
         break;
     case RxnType::VirusDeath:
-        if (s == dynamic_cast<VirusDeathReaction*>(rxn)->V){std::cout << "vdeath: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<VirusDeathReaction*>(rxn)->V) { return true; }
         break;
     case RxnType::Killing:
-        if (s == dynamic_cast<KillingReaction*>(rxn)->V || s == dynamic_cast<KillingReaction*>(rxn)->T){std::cout << "killing: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<KillingReaction*>(rxn)->V || s == dynamic_cast<KillingReaction*>(rxn)->T) { return true; }
         break;
     case RxnType::CTLActivation:
-        if (s == dynamic_cast<CTLActivationReaction*>(rxn)->V || s == dynamic_cast<CTLActivationReaction*>(rxn)->Tfrom){std::cout << "ctlact: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<CTLActivationReaction*>(rxn)->V || s == dynamic_cast<CTLActivationReaction*>(rxn)->Tfrom) { return true; }  // rxn->Tto is irrelevant to rate
         break;
     case RxnType::NTVirus:
-        if (s == dynamic_cast<NTVirusReaction*>(rxn)->V){std::cout << "ntvirus: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<NTVirusReaction*>(rxn)->V) { return true; }
         break;
     case RxnType::NTVirusDeath:
-        if (s == dynamic_cast<NTVirusDeathReaction*>(rxn)->V){std::cout << "ntvdeath: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<NTVirusDeathReaction*>(rxn)->V) { return true; }
         break;
     case RxnType::AAKilling:
-        if (s == dynamic_cast<AAKillingReaction*>(rxn)->V || s == dynamic_cast<AAKillingReaction*>(rxn)->T){std::cout << "aakilling: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<AAKillingReaction*>(rxn)->V || s == dynamic_cast<AAKillingReaction*>(rxn)->T) { return true; }
         break;
     case RxnType::CTLaaActivation:
-        if (s == dynamic_cast<CTLaaActivationReaction*>(rxn)->V || s == dynamic_cast<CTLaaActivationReaction*>(rxn)->Tfrom){std::cout << "ctlaaact: " << rxn->name << '\n'; return true;}
+        if (s == dynamic_cast<CTLaaActivationReaction*>(rxn)->V || s == dynamic_cast<CTLaaActivationReaction*>(rxn)->Tfrom) { return true; }  // rxn->Tto is irrelevant to rate
         break;
     }
 
@@ -99,90 +99,67 @@ bool does_affect(Reaction *newrxn, Reaction *rxn)
         for (Species_parray::iterator s = dynamic_cast<ElementaryReaction*>(newrxn)->products.begin(),
                                       e = dynamic_cast<ElementaryReaction*>(newrxn)->products.end();
                                       s != e; ++s) {
-            std::cout << "newrxn = Elementary: " << newrxn->name << '\n';
             affects |= does_species_appear_in_reactants(*s,rxn);
+            if (affects) { return true; }
         }
         break;
     }
 
     case RxnType::Virus: {
-        std::cout << "newrxn = Virus: " << newrxn->name << '\n';
         Species *s = dynamic_cast<VirusReaction*>(newrxn)->V;
         affects = does_species_appear_in_reactants(s,rxn);
-        return affects;
         break;
     }
 
     case RxnType::VirusDeath: {
-        std::cout << "newrxn = VirusDeath: " << newrxn->name << '\n';
         Species *s = dynamic_cast<VirusDeathReaction*>(newrxn)->V;
         affects = does_species_appear_in_reactants(s,rxn);
-        return affects;
         break;
     }
 
     case RxnType::Killing: {
-        std::cout << "newrxn = Killing: " << newrxn->name << '\n';
         Species *s = dynamic_cast<KillingReaction*>(newrxn)->V;
         affects = does_species_appear_in_reactants(s,rxn);
-        return affects;
-        //Species *s2 = dynamic_cast<KillingReaction*>(newrxn)->T;
-        //affects |= does_species_appear_in_reactants(s2,rxn);
-        //return affects;
+        // newrxn->T is irrelevant because it does not change when firing
         break;
     }
 
     case RxnType::CTLActivation: {
-        std::cout << "newrxn = CTLActivation: " << newrxn->name << '\n';
-        Species *s;
-        //s = dynamic_cast<CTLActivationReaction*>(newrxn)->V;
-        //affects = does_species_appear_in_reactants(s,rxn);
-        //return affects;
-        s = dynamic_cast<CTLActivationReaction*>(newrxn)->Tfrom;
+        Species *s = dynamic_cast<CTLActivationReaction*>(newrxn)->Tfrom;
         affects = does_species_appear_in_reactants(s,rxn);
-        //return affects;
+        if (affects) { return affects; }
         s = dynamic_cast<CTLActivationReaction*>(newrxn)->Tto;
         affects |= does_species_appear_in_reactants(s,rxn);
-        return affects;
+        // newrxn->V is irrelevant because it does not change when firing
         break;
     }
 
     case RxnType::NTVirus: {
-        std::cout << "newrxn = NTVirus: " << newrxn->name << '\n';
         Species *s = dynamic_cast<NTVirusReaction*>(newrxn)->V;
         affects = does_species_appear_in_reactants(s,rxn);
-        return affects;
         break;
     }
 
     case RxnType::NTVirusDeath: {
-        std::cout << "newrxn = NTVirusDeath: " << newrxn->name << '\n';
         Species *s = dynamic_cast<NTVirusDeathReaction*>(newrxn)->V;
         affects = does_species_appear_in_reactants(s,rxn);
         break;
     }
 
     case RxnType::AAKilling: {
-        std::cout << "newrxn = AAKilling: " << newrxn->name << '\n';
         Species *s = dynamic_cast<AAKillingReaction*>(newrxn)->V;
         affects = does_species_appear_in_reactants(s,rxn);
-        return affects;
-        //Species *s2 = dynamic_cast<AAKillingReaction*>(newrxn)->T;
-        //affects = does_species_appear_in_reactants(s2,rxn);
-        //return affects;
+        // newrxn->T is irrelevant because it does not change when firing
         break;
     }
 
     case RxnType::CTLaaActivation: {
-        std::cout << "newrxn = CTLaaActivation: " << newrxn->name << '\n';
-        //Species *s = dynamic_cast<CTLaaActivationReaction*>(newrxn)->V;
-        //affects = does_species_appear_in_reactants(s,rxn);
-        //return affects;
-        Species *s2 = dynamic_cast<CTLaaActivationReaction*>(newrxn)->Tfrom;
-        affects |= does_species_appear_in_reactants(s2,rxn);
-        s2 = dynamic_cast<CTLaaActivationReaction*>(newrxn)->Tto;
-        affects |= does_species_appear_in_reactants(s2,rxn);
-        return affects;
+        Species *s = dynamic_cast<CTLaaActivationReaction*>(newrxn)->Tfrom;
+        affects |= does_species_appear_in_reactants(s,rxn);
+        if (affects) { return affects; }
+        s = dynamic_cast<CTLaaActivationReaction*>(newrxn)->Tto;
+        affects |= does_species_appear_in_reactants(s,rxn);
+        // newrxn->V is irrelevant because it does not change when firing
         break;
     }
 
@@ -197,7 +174,6 @@ bool does_affect(Reaction *newrxn, Reaction *rxn)
 // in order to update the existing Reaction objects' "affects" member
 void update_rxn_dependents(Rxn_parray &reactions)
 {
-    printf("----------\n");
     Reaction *newrxn = reactions.back();
 
     Rxn_parray::iterator rxn = reactions.begin(),
@@ -205,11 +181,9 @@ void update_rxn_dependents(Rxn_parray &reactions)
 
     for (; rxn != end; ++rxn) {
         if (does_affect(newrxn,*rxn)) { // newrxn affects old?
-            printf("new affects old\n\n");
             newrxn->affects.push_back(*rxn);
         }
         if (does_affect(*rxn,newrxn)) { // old reaction affects new?
-            printf("old affects new\n\n");
             (*rxn)->affects.push_back(newrxn);
         }
     }
@@ -369,7 +343,7 @@ void run(RunParameters_SS &r, unsigned seed) {
 
 void print_species_header(const Species_parray &print_spec)
 {
-    std::cout << "step\ttime";
+    std::cout << "time";
     for (Species_parray::const_iterator spec = print_spec.begin(),
             end = print_spec.end();
             spec != end; ++spec)
@@ -382,7 +356,7 @@ void print_species_header(const Species_parray &print_spec)
 
 void print_species_traj(double t, long step, const Species_parray &print_spec, bool verbose)
 {
-    std::cout << step << '\t' << t;
+    std::cout << t;
     for (Species_parray::const_iterator spec = print_spec.begin(),
                                          end = print_spec.end();
             spec != end; ++spec)
@@ -484,9 +458,9 @@ void simulate(Rxn_parray &reactions, Species_parray &species, double t_end, long
             oldA = (*rxn2)->propensity;
             (*rxn2)->recalc();
             newA = (*rxn2)->propensity;
-            if (oldA == newA && newA != 0.0) {
-                std::cout << "SAME: " << (*rxn)->name << " affected " << (*rxn2)->name << " with propensity " << newA << '\n';
-            }
+            //if (oldA == newA && newA != 0.0) {
+            //    std::cout << "SAME: " << (*rxn)->name << " affected " << (*rxn2)->name << " with propensity " << newA << '\n';
+            //}
             total_propensity = total_propensity - oldA + newA;
         }