library(phangorn) accessionNumbers <- c("U15717", "U15718", "U15719", "U15720", "U15721", "U15722", "U15723", "U15724") #These come from a paper by Paradis (1997) on Tanagers #USE THE read.GenBank command TO DOWNLOAD THESE SEQUENCES FROM GENBANK AND PUT THEM IN AN OBJECT CALLED sequences. sequences<-read.GenBank(accessionNumbers) #Note that it's read.GenBank, not read.Genbank, read.genbank, readGenBank, etc. Programming is usually very case-sensitive distanceMatrix<-dist.dna(sequences) #get a distance matrix print(distanceMatrix) convertedSeqs<-phyDat(sequences) #convert to a format useful for phangorn treeBad<-upgma(distanceMatrix) #the UPGMA starting tree actually is not that bad (and a NJ tree is the same as the maximum parsimony tree). So let's make it challenging by giving you a bad starting tree (for larger problems, you would not have this "problem" of a starting tree that is too good) while(parsimony(treeBad,convertedSeqs)<220) { treeBad<-rNNI(treeBad) } maximumTries<-50 #GET SCORE OF STARTING TREE, treeBad #STORE THE CURRENT BEST TREE, WHICH IS treeBad #PRINT THE STARTING SCORE for (tryNumber in 1:maximumTries) { #GET A NEW TREE BY DOING newTree<-rNNI( __SOMETHING__ ) #COMPARE THE SCORE OF THE NEW TREE TO THE OLD TREE #USE AN IF BLOCK (if (new