#Download ape library from CRAN repository
#install.packages("ape")

#Use library command to make ape functions accessible by this script
library(ape)

#Use paste() function to create a chr vector of accession numbers for Gasterosteus sequences
# These sequences all belong to one genus of sticklebacks
#Change in the tutorial to be sequences previous Endicott
#Bioinformatics students uploaded MT103163-MT103183
# Read accession numbers as a vector
seq_ids <- scan("sequence.seq", what = "", quiet = TRUE)

# Now download from GenBank
sequences <- read.GenBank(seq_ids,
                          species.names = TRUE,
                          as.character = TRUE)

# Write to fasta
write.dna(sequences, "butterfly.fasta", format = "fasta")