MESSAGE
DATE | 2016-11-26 |
FROM | Ruben Safir
|
SUBJECT | Subject: [Learn] Fitch etc
|
From learn-bounces-at-nylxs.com Sat Nov 26 18:23:40 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 833B4161313; Sat, 26 Nov 2016 18:23:40 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id 4B4A0160E77 for ; Sat, 26 Nov 2016 18:23:38 -0500 (EST) From: Ruben Safir To: learn-at-nylxs.com Message-ID: <8450e8ce-da24-dfd6-82b5-8b4c40880741-at-mrbrklyn.com> Date: Sat, 26 Nov 2016 18:23:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Subject: [Learn] Fitch etc X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list Reply-To: NYLXS Discussions List List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
I finally fixed the type problem with my fitch program. Not that I've finished the program, but I finally understand the problem. I got lost in the data flow of the program. I am trying to print out the vector of states, which have objects of pairs. That requires an overload of operator<<() of the states object AND a range operation of the vector itself. http://www.nylxs.com/docs/thesis/src/fitch/nodes.h.html
1 /* 2 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 3 * 4 * Filename: nodes.h 5 * 6 * Description: description of phylogentic nodes as per 7 * Fitch and Sannkoff as describd by Felenstein 8 * 9 * Version: 1.0 10 * Created: Nov 4 21:15:49 EDT 2016 11 * Revision: none 12 * Compiler: gcc 13 * 14 * Author: Ruben Safir, 15 * Company: LIU Thesis 16 * 17 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 18 */ 19 #ifndef NODES_H 20 #define NODES_H 21 #include 22 #include 23 #include 24 namespace tree { 25 26 27 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D 28 * Class NODE - 29 * Description - This is a node in the tree that must undergo parsimony evaluation 30 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D 31 */ 32 template 33 class NODE{ 34 public: 35 =C2=A6 //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3DLIFECYCLE=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 36 =C2=A6 /* Constructor */ 37 NODE( std::string xt, const unk &x , NODE *xcl=3D 0, NODE *xcr =3D 0, NODE *xp =3D 0 ):_trait{xt},_states{x}, _cl{xcl}, _cr{xcr}, _p{xp} {//child left, child right etc 38 std::cout << trait() << " node " << "has the following states =3D> " << states() << std::endl; 39 }; 40 41 NODE(const NODE &other); //copy constructor 42 =C2=A6 ~NODE(); 43 =C2=A6 44 =C2=A6 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ACCESSORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 45 //no need for inline when you are defineing functions within the class definition 46 std::string trait()const{ 47 return _trait; 48 } 49 unk states()const{ 50 =C2=A6 =C2=A6 return _states; 51 =C2=A6 }; 52 NODE * cl()const{ 53 =C2=A6 =C2=A6 return _cl; 54 =C2=A6 }; 55 NODE * cr()const{ 56 =C2=A6 =C2=A6 return _cr; 57 =C2=A6 }; 58 NODE * p()const{ 59 =C2=A6 =C2=A6 return _p; 60 =C2=A6 }; 61 void states(const unk &x){ 62 =C2=A6 =C2=A6 _states =3D x; 63 =C2=A6 } 64 void trait(std::string xt){ 65 =C2=A6_trait =3D xt; //With genetics this is a A C G T althoug= h it is just a label 66 =C2=A6} 67 void cl(NODE *xcl){ //This is the left child node in the tree 68 =C2=A6 =C2=A6 _cl =3D xcl; 69 =C2=A6 } 70 void cr(NODE *xcr){//This is the right node child node in the tree 71 =C2=A6 =C2=A6 _cr =3D xcr; 72 =C2=A6 } 73 void p(NODE *xp){//This is the parent node in the tree 74 =C2=A6 =C2=A6 _p =3D xp; 75 =C2=A6 } 76 =C2=A6 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D MUTATORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 77 =C2=A6 78 =C2=A6 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D OPERATORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 79 //void display(); 80 template 81 friend std::ostream& operator<<(std::ostream& os, const T&); 82 83 template 84 friend std::ostream& operator<<(std::ostream& os, const NODE &); 85 86 protected: 87 =C2=A6 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D DATA MEMBERS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 88 =C2=A6 89 =C2=A6 90 private: 91 =C2=A6 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D DATA MEMBERS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 92 =C2=A6std::string _trait; 93 =C2=A6unk _states; 94 =C2=A6NODE * _cl, * _cr, * _p; 95 96 97 }; /* ----- end of template class NODE ----- */ 98 99 template 100 std::ostream& operator<<(std::ostream& os, const NODE& vec){ 101 102 for( auto& y : vec.state() ) 103 os << y << std::endl; 104 return os; 105 } 106 107 108 109 template 110 tree::NODE::~NODE(){ 111 } 112 113 /* 114 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 115 * Class: State 116 * Description: This describes a possible individual state or charactoristic 117 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 118 */ 119 template 120 class state 121 { 122 public: 123 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = LIFECYCLE =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 124 =C2=A6 =C2=A6 =C2=A6 =C2=A6 =C2=A6 =C2=A6 =C2=A6 =C2=A6/* = constructor */ 125 //r is the minimum cost of a single state when compared to the child nodes 126 explicit state(std::string const xa, cost xr) 127 :_nam{xa}, _r{xr} 128 { 129 std::cout << "Building a state pair" << std::endl; 130 std::cout << "nam =3D> " << nam() << "\tcost=3D> " << r() << std::endl; 131 }; 132 133 134 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D ACCESSORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 135 std::string nam()const {return _nam;}; 136 cost r() const {return _r;}; 137 void r(cost b ){_r =3D b;}; 138 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = MUTATORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 139 140 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D OPERATORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 141 friend std::ostream & operator << ( std::ostream & os, const state & obj ) 142 { 143 os << obj.nam() << ": " << obj.r() ; 144 return os; 145 } /* ----- end of function operator << ----- */ 146 147 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D DATA MEMBERS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 148 protected: 149 150 private: 151 std::string _nam; 152 cost _r; 153 154 }; /* ----- end of class State ----- */ 155 156 /* 157 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 158 * Class: Pstates 159 * Description: vector of all possible states 160 * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 161 */ 162 template 163 class Pstates 164 { 165 public: 166 167 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D LIFECYCLE =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 168 /* constructor */ 169 Pstates (std::vector< state > x) 170 : _vstate{x} 171 { 172 for( auto& y : _vstate) 173 std::cout << y << std::endl; 174 }; 175 176 ~Pstates (){}; /* destructor */ 177 178 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ACCESSORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 179 const std::vector< state >& vstate() const{ 180 return _vstate; 181 } 182 void vstate(std::vector< state > in ){ 183 _vstate =3D in; 184 } 185 186 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D MUTATORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 187 188 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D OPERATORS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 189 190 const Pstates& operator =3D ( const Pstates &other ); /* assignment operator */ 191 =C2=A6 192 friend std::ostream & operator << ( std::ostream & os, const Pstates & obj ) 193 { 194 for(auto state_pair : obj.vstate() ) 195 std::cout << state_pair; 196 return os; 197 } /* ----- end of function operator << ----- */ 198 199 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D DATA MEMBERS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ 200 protected: 201 202 private: 203 std::vector< state > _vstate; 204 205 }; /* ----- end of class Pstates ----- */
-- =
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 _______________________________________________ hangout mailing list hangout-at-nylxs.com http://www.nylxs.com/
_______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|