This is a wrapper for blastn.

blast_n(query, database, out_file = NULL, outfmt = "6",
  other_args = NULL, echo = TRUE, wd, ...)

Arguments

query

Character vector of length one; the path to the fasta file to use as the query sequence(s).

database

Character vector of length one; the name of the blast database.

out_file

Character vector of length one; the name to use for the results file.

outfmt

Character vector of length one; value to pass to blastn outfmt argument. Default = "6".

other_args

Character vector; other arguments to pass on to blastn. For a list of options, run blastn -help.

echo

Logical; should standard error and output be printed?

wd

Character vector of length one; working directory. The blast search will be conducted here.

...

Additional other arguments. Not used by this function, but meant to be used by drake_plan for tracking during workflows.

Value

A tab-separated text file with the results of the blastn search, named with the value of out_file.

References

https://www.ncbi.nlm.nih.gov/books/NBK279690/

Examples

library(ape) # Make temp dir for storing files temp_dir <- fs::dir_create(fs::path(tempdir(), "baitfindR_example")) # Write out ape::woodmouse dataset as DNA data(woodmouse) ape::write.FASTA(woodmouse, fs::path(temp_dir, "woodmouse.fasta")) # Make blast database build_blast_db( fs::path(temp_dir, "woodmouse.fasta"), db_type = "nucl", out_name = "wood", parse_seqids = TRUE, wd = temp_dir)
#> #> #> Building a new DB, current time: 05/15/2019 16:40:36 #> New DB name: /tmp/RtmpeNC9nF/baitfindR_example/wood #> New DB title: /tmp/RtmpeNC9nF/baitfindR_example/woodmouse.fasta #> Sequence type: Nucleotide #> Keep MBits: T #> Maximum file size: 1000000000B #> Adding sequences from FASTA; added 15 sequences in 0.011471 seconds.
#> $status #> [1] 0 #> #> $stdout #> [1] "\n\nBuilding a new DB, current time: 05/15/2019 16:40:36\nNew DB name: /tmp/RtmpeNC9nF/baitfindR_example/wood\nNew DB title: /tmp/RtmpeNC9nF/baitfindR_example/woodmouse.fasta\nSequence type: Nucleotide\nKeep MBits: T\nMaximum file size: 1000000000B\nAdding sequences from FASTA; added 15 sequences in 0.011471 seconds.\n" #> #> $stderr #> [1] "" #> #> $timeout #> [1] FALSE #>
# Blast the original sequences against the database blast_n( fs::path(temp_dir, "woodmouse.fasta"), database = "wood", out_file = "blastn_results", wd = temp_dir, echo = TRUE )
#> $status #> [1] 0 #> #> $stdout #> [1] "" #> #> $stderr #> [1] "" #> #> $timeout #> [1] FALSE #>
# Take a look at the results. readr::read_tsv( fs::path(temp_dir, "blastn_results"), col_names = FALSE )
#> Parsed with column specification: #> cols( #> X1 = col_character(), #> X2 = col_character(), #> X3 = col_double(), #> X4 = col_double(), #> X5 = col_double(), #> X6 = col_double(), #> X7 = col_double(), #> X8 = col_double(), #> X9 = col_double(), #> X10 = col_double(), #> X11 = col_double(), #> X12 = col_double() #> )
#> # A tibble: 225 x 12 #> X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 #> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 No305 No305 100 964 0 0 2 965 2 965 0 1773 #> 2 No305 No1103S 98.5 960 14 0 2 961 2 961 0 1700 #> 3 No305 No306 98.2 964 17 0 2 965 2 965 0 1694 #> 4 No305 No0912S 98.3 960 16 0 2 961 2 961 0 1688 #> 5 No305 No1206S 98.1 960 18 0 2 961 2 961 0 1677 #> 6 No305 No1202S 98.1 960 18 0 2 961 2 961 0 1677 #> 7 No305 No1007S 98.1 960 18 0 2 961 2 961 0 1677 #> 8 No305 No0909S 98.1 960 18 0 2 961 2 961 0 1677 #> 9 No305 No0908S 98.1 960 18 0 2 961 2 961 0 1677 #> 10 No305 No304 98.0 961 19 0 2 962 2 962 0 1677 #> # … with 215 more rows
# Cleanup. fs::file_delete(temp_dir)