1 Introduction

This is a report created using RMarkdown. It includes code for downloading a multi-fasta file and annotating it using blast. Blast software can be downloaded here.

1.1 Download Software

#select directory to download the software
cd /home/jovyan/applications
# download the software
curl -O https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.13.0+-x64-linux.tar.gz
# unzip the file
tar -xf ncbi-blast-2.13.0+-x64-linux.tar.gz
# check that the software is working
~/applications/ncbi-blast-2.13.0+/bin/blastx -h

1.2 Create blast database

# download the file from the url
curl -O https://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/complete/uniprot_sprot.fasta.gz
# rename the file
mv uniprot_sprot.fasta.gz uniprot_sprot_r2023_01.fasta.gz
# unzip the file
gunzip -k uniprot_sprot_r2023_01.fasta.gz
# list the files in the data directory
ls ../data
#create Blast database using makeblastdb
~/applications/ncbi-blast-2.13.0+/bin/makeblastdbcd  \
#specify file name and location to be used to make database
-in ../data/uniprot_sprot_r2023_01.fasta \
#specify the type of data
-dbtype prot \
#specify output file name and location
-out ../blastdb/uniprot_sprot_r2023_01

1.3 Get the query sequence

#download the sequences
curl https://eagle.fish.washington.edu/cnidarian/Ab_4denovo_CLC6_a.fa \
-k \
#specify where they will be downloaded to and the file name
> ../data/Ab_4denovo_CLC6_a.fa
#look at the data
head ../data/Ab_4denovo_CLC6_a.fa
echo "How many sequences are there?"
grep -c ">" ../data/Ab_4denovo_CLC6_a.fa

1.4 Run blast on the query sequence

~/applications/ncbi-blast-2.13.0+/bin/blastx \
-query ../data/Ab_4denovo_CLC6_a.fa \
-db ../blastdb/uniprot_sprot_r2023_01 \
#create a blast table in the output directory
-out ../output/Ab_4-uniprot_blastx.tab \
#add specifications to blast
-evalue 1E-20 \
-num_threads 20 \
-max_target_seqs 1 \
-outfmt 6
curl -o "uniprot_table_r2023_01.tab" -H "Accept: text/plain; format=tsv" "https://gannet.fish.washington.edu/seashell/snaps/uniprot_table_r2023_01.tab"
#look at the table
head -2 ../output/Ab_4-uniprot_blastx.tab
wc -l ../output/Ab_4-uniprot_blastx.tab

1.5 Join the blast table with the annotation table

tr '|' '\t' < ../output/Ab_4-uniprot_blastx.tab | head -2
#replace  "|" with "\t" in the file "Ab_4-uniprot_blastx.tab"
tr '|' '\t' < ../output/Ab_4-uniprot_blastx.tab \
#save the output to the file "Ab_4-uniprot_blastx_sep.tab"
> ../output/Ab_4-uniprot_blastx_sep.tab
#look at the table
head -2 ../data/uniprot_table_r2023_01.tab
wc -l ../data/uniprot_table_r2023_01.tab
#assign blast table to bltabl
bltabl <- read.csv("../output/Ab_4-uniprot_blastx_sep.tab", sep = '\t', header = FALSE)
#assign annotation table to spgo
spgo <- read.csv("../output/uniprot_table_r2023_01.tab", sep = '\t', header = TRUE)
#view the structure of the annotation table
str(spgo)
#use left_joion to merge bltablt and spgo
left_join(bltabl, spgo,  by = c("V3" = "Entry")) %>%
  select(V1, V3, V13, Protein.names, Organism, Gene.Ontology..biological.process., Gene.Ontology.IDs) %>% mutate(V1 = str_replace_all(V1, 
            pattern = "solid0078_20110412_FRAG_BC_WHITE_WHITE_F3_QV_SE_trimmed", replacement = "Ab")) %>%
  #save new table to output as "blast_annot_go.tab"
  write_delim("../output/blast_annot_go.tab", delim = '\t')
#assign "blast_annot_go.tab" to "annot_tab"
annot_tab <- read.csv("../output/blast_annot_go.tab", sep = '\t', header = TRUE)
#look at structure of "annot_tab"
str(annot_tab)