Use library command to make ape functions accessible by this
script
library(ape)
## Warning: package 'ape' was built under R version 4.3.3
Use paste() function to create a chr vector of accession numbers for
Gasterosteus sequences
These sequences all belong to one genus of sticklebacks
Download all sequential sequences from Genbank
This would be really hard to do my hand
Note that the downloaded sequences are stored in a single variable
called a list
sequences <- read.GenBank(seq1,
seq.names = seq1,
species.names = TRUE,
as.character = TRUE)
Write the sequences to a fasta file
write.dna(sequences, "fish.fasta", format = "fasta")
Pan paniscus (Bonobo) Mitochondrial CO1 Gene Sequence Analysis
This script automates the download of mitochondrial CO1 gene
sequences for Pan Paniscus (bonobo) from GenBank using the ape
package in R. The taxonomic ID for Pan paniscus is txid:9597.
Read in search result file containing accession numbers
accessions = read.table("bonobo.seq",
stringsAsFactors = FALSE)$V1
str(accessions)
## chr [1:21] "GU189677.1" "GU189676.1" "GU189675.1" "GU189674.1" ...
Download all sequences from GenBank
bonoboSeqs = read.GenBank(accessions,
seq.names = accessions,
species.name = TRUE,
as.character = TRUE)
Export sequences to FASTA file
write.dna(sequences,
"bonobo_CO1.fasta",
format = "fasta")