55#include < cstddef>
66#include < fstream>
77#include < string>
8- #include < sstream>
98#include < iterator>
109#include < cstring>
1110
1211
1312
14- std::string match = " match" ;
15- std::string matchp = " matchp" ;
16- std::string dup = " dup" ;
17- std::string exch = " exch" ;
18- std::string pop = " pop" ;
19- std::string nop = " nop" ;
20- std::string nul = " nul" ;
21- std::string split = " split" ;
22- std::string send = " send" ;
23- std::string fork = " fork" ;
24- std::string empty = " empty" ;
25- std::string length = " length" ;
26- std::string lt = " lt" ;
27- std::string pop2 = " pop2" ;
28- std::string copy = " copy" ;
13+ symbol match = " match" ;
14+ symbol matchp = " matchp" ;
15+ symbol dup = " dup" ;
16+ symbol exch = " exch" ;
17+ symbol pop = " pop" ;
18+ symbol nop = " nop" ;
19+ symbol nul = " nul" ;
20+ symbol split = " split" ;
21+ symbol send = " send" ;
22+ symbol fork = " fork" ;
23+ symbol empty = " empty" ;
24+ symbol length = " length" ;
25+ symbol lt = " lt" ;
26+ symbol pop2 = " pop2" ;
27+ symbol copy = " copy" ;
28+ symbol perm = " perm" ;
29+
30+ std::unordered_set<std::string> bimolTags = {match,matchp,perm};
31+ std::unordered_set<std::string> unimolTags = {exch,pop,nop,split,length,fork,empty,pop2,copy,lt};
32+
2933
3034
3135bool isNumber (const std::string& mol){
@@ -56,9 +60,6 @@ symbol molToString(const molecule_pointer mol){
5660}
5761
5862
59- std::unordered_set<std::string> bimolTags = {match,matchp};
60- std::unordered_set<std::string> unimolTags = {exch,pop,nop,split,length,fork,empty,pop2,copy,lt};
61-
6263
6364
6465const molecule_pointer fraglets::makeUniqueUnimol (const molecule_pointer mol){
@@ -126,10 +127,10 @@ void fraglets::addEdge(const molecule_pointer mol,const molecule_pointer resultM
126127
127128
128129 if (this ->nodesTable .find (mol) == this ->nodesTable .end ()){
129- this ->addNode (mol,isunimol (mol),isMatchp (mol),isbimol (mol));
130+ this ->addNode (mol,isunimol (mol),isperm (mol),isbimol (mol));
130131 }
131132 if (this ->nodesTable .find (resultMol) == this ->nodesTable .end ()){
132- this ->addNode (resultMol,isunimol (resultMol),isMatchp (resultMol),isbimol (resultMol));
133+ this ->addNode (resultMol,isunimol (resultMol),isperm (resultMol),isbimol (resultMol));
133134 }
134135 Agnode_t* tailNode = nodesTable[resultMol];
135136 Agnode_t* headNode = nodesTable[mol];
@@ -156,6 +157,13 @@ opResult r_match(const molecule_pointer activeMolecule, const molecule_pointer p
156157}
157158
158159
160+ opResult r_perm (const molecule_pointer activeMolecule, const molecule_pointer passiveMolecule){
161+ opResult result = r_match (activeMolecule,passiveMolecule);
162+ // molecule newMol = std::make_shared<molecule_pointer( activeMolecule);
163+ result.emplace (result.begin (),activeMolecule);
164+ return result;
165+ }
166+
159167opResult r_matchp (const molecule_pointer activeMolecule, const molecule_pointer passiveMolecule){
160168 opResult result = r_match (activeMolecule,passiveMolecule);
161169 // molecule newMol = std::make_shared<molecule_pointer( activeMolecule);
@@ -415,7 +423,7 @@ opResult r_pop2(const molecule_pointer mol){
415423}
416424
417425
418- std::unordered_map<std::string,bimolOp> const bimolOpMap = {{match,r_match},{matchp,r_matchp}};
426+ std::unordered_map<std::string,bimolOp> const bimolOpMap = {{match,r_match},{matchp,r_matchp},{perm,r_perm} };
419427std::unordered_map<std::string,unimolOp> const unimolOpMap = {{dup,r_dup},
420428 {exch,r_exch},
421429 {pop,r_pop},
@@ -453,7 +461,6 @@ double random_double(){
453461void fraglets::inject (const molecule_pointer mol,int mult){
454462 if (mol->vector .empty () or mult < 1 ){return ;}
455463 if (mol->vector .size ()>= 1 ){
456-
457464 if (this ->isbimol (mol)){
458465 const molecule_pointer newMol = this ->makeUniqueActive (mol);
459466 std::shared_ptr<symbol> key = newMol->vector [1 ];
@@ -482,10 +489,16 @@ void fraglets::inject(const molecule_pointer mol,int mult){
482489}
483490
484491bool fraglets::isbimol (const molecule_pointer mol){
492+ if (mol->vector .size () < 2 ){ return false ;}
493+ std::shared_ptr<symbol> tag = mol->vector [0 ];
494+ return (*tag == match) or (*tag == matchp) or (*tag == perm);
495+ }
496+
497+ bool fraglets::isperm (const molecule_pointer mol){
485498 if (mol->vector .empty ()){ return false ;}
486499
487500 std::shared_ptr<symbol> tag = mol->vector [0 ];
488- return (*tag == match) or (*tag == matchp );
501+ return (*tag == perm );
489502}
490503
491504bool fraglets::isMatchp (const molecule_pointer mol){
@@ -617,6 +630,7 @@ int fraglets::run_unimol(){
617630
618631void fraglets::run_bimol (){
619632 if (this ->wt <= 0 ){return ;}
633+ std::cout << " test2\n " ;
620634 double w = random_double () * this ->wt ;
621635 this ->react (w);
622636}
@@ -634,6 +648,7 @@ void fraglets::inject_list(opResult result){
634648
635649void fraglets::iterate (){
636650 this ->propensity ();
651+ std::cout << " test\n " ;
637652 if (!this ->idle ){
638653 this ->run_bimol ();
639654 }
@@ -728,12 +743,12 @@ void fraglets::run(int niter,int molCap){
728743 // total = this->active.total + this->passive.total;
729744 // }
730745 if (this ->idle ){
731- // this->drawGraphViz();
746+ this ->drawGraphViz ();
732747 std::cout<< " idle\n " ;
733748 return ;
734749 }
735750 }
736- // this->drawGraphViz();
751+ this ->drawGraphViz ();
737752 std::cout<< " done\n " ;
738753 return ;
739754}
@@ -742,16 +757,16 @@ void fraglets::run(int niter,int molCap){
742757
743758void fraglets::drawGraphViz (){
744759
745- for (auto edge : this ->edgeTable ){
760+ // for(auto edge : this->edgeTable){
746761
747- auto t =edge.first ;
748- int reactionCount = ((this ->reactionCoutTable .mult ()/(this ->reactionCoutTable .mult (t)+1 )))+1 ;
762+ // auto t =edge.first;
763+ // int reactionCount = ((this->reactionCoutTable.mult()/(this->reactionCoutTable.mult(t)+1)))+1;
749764
750- std::string s = std::to_string (reactionCount);
751- char *weight = const_cast <char *>(s.c_str ());
752- agsafeset (edge.second ," weight" ,weight,weight);
753- agsafeset (edge.second ," penwidth" ,weight,weight);
754- }
765+ // std::string s = std::to_string(reactionCount);
766+ // char *weight = const_cast<char *>(s.c_str());
767+ // agsafeset(edge.second,"weight",weight,weight);
768+ // agsafeset(edge.second,"penwidth",weight,weight);
769+ // }
755770
756771 GVC_t* graphContext = gvContext ();
757772
0 commit comments