// 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. #if !defined(BULLCMDLINE_H) #define BULLCMDLINE_H #include #define THREETAXONHACK #if defined HAVE_CONFIG_H && HAVE_CONFIG_H # include #endif #if defined HAVE_UNISTD_H && HAVE_UNISTD_H # include #elif defined HAVE_SYS_TYPES_H && HAVE_SYS_TYPES_H # include #endif #include "basic_bull.hpp" #include "bull_io.hpp" #include "bull_listener.hpp" #include "bull_parsers.hpp" #include "char_encoding.hpp" #include "my_nexus.hpp" #include "encoded_chars.hpp" #include "util.hpp" #include "tree.hpp" #include "ssrf_codon_sub_mod.hpp" #include "settings.hpp" #define COMMAND_MAXLEN 255 namespace bull { class NoSuchTree : public MTHException { public : NoSuchTree() : MTHException() {} NoSuchTree(const char *c) :MTHException(c) { } }; class NoModel : public MTHException { public : NoModel() : MTHException() {} NoModel(const char *c) :MTHException(c) { } }; class BullKernel; class Bull: public NexusBlock, public Nexus, public BullListener { public: Bull(); virtual ~Bull(); void OutputComment( std::string s ); void ExitingBlock( std::string blockName ); void EnteringBlock( std::string blockName ); void HandleNextCommand(); void NexusError(const std::string& msg, std::istream::pos_type pos, long line, long col ); void PreprocessNextCommand(); void ExecuteStarting() {} void ExecuteStopping() {} void Report(std::ostream& out ); void Run(char *); void SkipBlock(NexusToken &, const std::string & blockName) const; void SkippingBlock(const std::string & blockName) const; void SkippingCommand( std::string commandName ); protected: void deleteNexusBlocks(); void FactoryDefaults(); void FinishTaxaBlock(); void FinishTreesBlock(); bool FileExists( const char* fn ); Tree *FindTreeFromName(std::string); std::string GetFileName( NexusToken& token ); long GetLongInteger( NexusToken& token ); double GetDouble( NexusToken& token ); EncodingType Bull::InterpretOutputType(NexusToken &token); void RequireTokenAndAdvance(NexusToken & token, const char *expected, const char *cmd); void RequireSemicolon(NexusToken & token, const char *cmd) const; void ThrowNoSemicolon(NexusToken & token, const char *cmd) const; void HandleEndblock( NexusToken& token ); void HandleExecute( NexusToken& token ); void HandleExecuteBullBlocksInFile( NexusToken& tok ); void HandleLog( NexusToken& token ); void HandleGetTrees(NexusToken& token ); void HandleCodLikeStartVal(NexusToken& token); void HandleSimulate(NexusToken& token ); void ParseGetTrees(GetTreesOpts *, NexusToken& ttoken) const; void ParseCodLikeStartValCommand(CodLikeStartOpts *, NexusToken& ttoken) const; SimulateOpts ParseSimulateCommand(NexusToken& token) const; void ResetBlocks(); void Read( NexusToken& token ); void Reset(); void TryAdvancedCommands(NexusToken &token); void WriteSimulations(int num,Tree *t,std::string outpfn,std::string paupblockfn,int outputEncodingType,int totRepNum,long seedAtBeg,int simCondNum,bool autoPaup=false); mutable BullIO ioObject; bool quit_now; char next_command[COMMAND_MAXLEN+1]; // used to store the command that is being parsed. TreesBlock * trees_block; ///most recent NexusBlock with tree descriptions TaxaBlock * taxa_block; BullKernel * kernel; }; } //namespace bull #endif