// This file is part of BULL, a program for phylogenetic simulations // most of the code was written by Mark T. Holder. // This program is for internal use by the lab of Dr. Tandy Warnow only. // Do not redistribute the code. It is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // Some of the code is from publically available source by Paul Lewis, Ziheng Yang, // John Huelsenbeck, David Swofford , and others (as noted in the code). // In fact the main structure of the program was created by modifying Paul Lewis' // basiccmdline.cpp from his NCL // // This code was used in Mark's dissertation, some changes were made in order to // get it to compile on gcc. It is possible that this porting introduced bugs (very // little debugging has been done on UNIX platforms). I would suggest checking // the simulator by generating data on trees with short branches, etc. // This file is part of BULL, a program for phylogenetic simulations // most of the code was written by Mark T. Holder. // This program is for internal use by the lab of Dr. Tandy Warnow only. // Do not redistribute the code. It is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // Some of the code is from publically available source by Paul Lewis, Ziheng Yang, // John Huelsenbeck, David Swofford , and others (as noted in the code). // In fact the main structure of the program was created by modifying Paul Lewis' // basiccmdline.cpp from his NCL // // This code was used in Mark's dissertation, some changes were made in order to // get it to compile on gcc. It is possible that this porting introduced bugs (very // little debugging has been done on UNIX platforms). I would suggest checking // the simulator by generating data on trees with short branches, etc. #include "like_attribute_sets.hpp" using namespace bull; SetOfLikeAttr::SetOfLikeAttr(int i) { assert(i>0); nparts=i; likeAttribs=new LikeAttr**[nparts]; nmods=new int[nparts]; for (int j=0;j < nparts;j++) {likeAttribs[j]=NULL; nmods[j]=0; } nmodparts=0; } SetOfTreeSimAttr::SetOfTreeSimAttr(int i) { assert(i>0); nparts=i; simAttribs=new TreeSimAttr**[nparts]; nmods=new int[nparts]; for (int j=0;j < nparts;j++) {simAttribs[j]=NULL; nmods[j]=0; } nmodparts=0; nChar=new int[i]; modelMixingParam=new FreqParamGroup *[i]; } SetOfTreeSimAttr::~SetOfTreeSimAttr() { delete [] modelMixingParam;//partitions responsible for deleting the acutal parameters delete [] nChar; assert(nmods && simAttribs); for (int i=0;i < nparts;i++) { assert(simAttribs[i]); for (int j=0;j < nmods[i];j++) {assert(simAttribs[i][j]); delete simAttribs[i][j]; } delete [] simAttribs[i]; } delete []simAttribs; delete nmods; } void SetOfTreeSimAttr::SetNumModsInPart(int partnum,int modnum) { nmodparts+=(modnum-nmods[partnum]); for (int i=0;i < nmods[partnum];i++) delete simAttribs[partnum][i]; delete [] simAttribs[partnum]; nmods[partnum]=modnum; simAttribs[partnum]=new TreeSimAttr*[modnum]; for (int i=0;i < modnum;i++) *(simAttribs[partnum]+i)=NULL; } void SetOfTreeSimAttr::AddAtt(int p,int m,TreeSimAttr *tsa) { assert(p < nparts); assert(m < nmods[p]); delete simAttribs[p][m]; simAttribs[p][m]=tsa; } void SetOfTreeSimAttr::PrintModel(std::ostream &usrstream) { for (int np=0;np < nparts;np++) for (int nm=0;nm < nmods[np];nm++) simAttribs[np][nm]->GetModel()->PrintPAUPLsetCommand(); } SetOfLikeAttr::~SetOfLikeAttr() { assert(nmods && likeAttribs); for (int i=0;i < nparts;i++) { assert(likeAttribs[i]); for (int j=0;j < nmods[i];j++) {assert(likeAttribs[i][j]); delete likeAttribs[i][j]; } delete [] likeAttribs[i]; } delete []likeAttribs; delete [] nmods; } void SetOfTreeSimAttr::InitializeModelMixingParams() { for (int i=0;i < nparts;i++) if (nmods[i]>1) {assert(modelMixingParam && modelMixingParam[i]); modelMixingParam[i]->Initialize(); } } void SetOfTreeSimAttr::InitializeLikeAttrStatics(int partnum,int modn) { LikeAttr::currNChar=GetNCharInEachDataSet(partnum); LikeAttr::currNStates=GetNStates(partnum,modn); LikeAttr::currModelDirty=true;//TEMPORARY } void SetOfLikeAttr::SetNumModsInPart(int partnum,int modnum) { nmodparts+=(modnum-nmods[partnum]); for (int i=0;i < nmods[partnum];i++) delete likeAttribs[partnum][i]; delete [] likeAttribs[partnum]; nmods[partnum]=modnum; likeAttribs[partnum]=new LikeAttr*[modnum]; for (int i=0;i < modnum;i++) *(likeAttribs[partnum]+i)=NULL; } void SetOfLikeAttr::AddLikeAtt(int p,int m,LikeAttr *la) { assert(p < nparts); assert(m < nmods[p]); delete likeAttribs[p][m]; likeAttribs[p][m]=la; }