Skip to contents

`funprofiler_stream()` is [funprofiler_runs()] without the download: instead of saving each run's reads to a file, it streams them from NCBI with `fastq-dump -Z –split-spot –skip-technical` (in `sra_env`) straight into `funcprofiler` (in `funprofiler_env`), so no reads are ever written to disk. It takes the same arguments as [funprofiler_runs()] (apart from `working_file` and `threads`), checks the KO database in the same way, writes the same profile files (`<outdir>/<run_accession>_k<k>_scale<scaled>_ko_profiles.csv`), and returns the same result, and each skips profiles the other has made.

Usage

funprofiler_stream(
  runs,
  database = "../KOs_sketched_scaled_1000.sig.zip",
  k = 11,
  scaled = 1000,
  threshold_bp = 1000,
  outdir = file.path("data", "funprofiler"),
  quiet = FALSE,
  overwrite = FALSE,
  sra_env = "sra_env",
  funprofiler_env = "funprofiler_env"
)

Arguments

runs

A data frame with a `run_accession` column (SRR, ERR or DRR accessions), such as the output of [get_bioproject_runs()].

database

Path to a KO reference sketch (`.sig.zip` or `.sbt.zip`) for `funcprofiler`. Defaults to `"../KOs_sketched_scaled_1000.sig.zip"`.

k

Protein k-mer size(s): 7, 11 and/or 15, each of which must be in `database`. Defaults to 11.

scaled

Scaled value(s) for the FracMinHash sketch, each at least the scaled value of `database`. Defaults to 1000.

threshold_bp

Minimum estimated overlap, in base pairs, for a KO to be reported (`funcprofiler -t`). Larger values are faster but less sensitive. Defaults to 1000, as in `funcprofiler`.

outdir

Directory for the profile files. Created if needed.

quiet

If `TRUE`, hide the console output of `fastq-dump` and `funcprofiler`. Defaults to `FALSE`.

overwrite

If `TRUE`, make profiles that already exist again. If `FALSE` (the default), skip them.

sra_env

Conda environment with the SRA Toolkit (see [setup_conda_sra()]).

funprofiler_env

Conda environment with fmh-funprofiler (see [setup_conda_funprofiler()]).

Value

A tibble with one row per run and combination of `k` and `scaled`, invisibly, as returned by [funprofiler_runs()].

Details

The reads reach `funcprofiler` through a named pipe (FIFO) in a temporary directory, which it reads as if it were a reads file. A stream can only be read once, so with several combinations of `k` and `scaled`, each run is streamed once per combination. See [smash_stream()] for when streaming helps.

Internet connection

The reads are downloaded while the tool runs, so a `*_stream()` function needs a steady internet connection for as long as each run is being processed, and is more likely than the `*_runs()` functions to fail if the connection is slow, drops out or is unreliable, or if NCBI is busy. A run whose stream is cut off fails (`fastq-dump`'s exit status fails the step) rather than being sketched, profiled or mapped from part of its reads; it is reported with a warning and recorded as `"failed"`, and the remaining runs still go ahead. Run the same call again to retry the failed runs; on an unreliable connection, the `*_runs()` functions, which finish each download before processing it, may be the better choice.

See also

[funprofiler_runs()], which downloads each run with `fasterq-dump` before profiling it, and [smash_stream()], [sylph_stream()] and [rgi_stream()].

Examples

if (FALSE) { # \dontrun{
runs <- get_bioproject_runs("PRJNA123456")
funprofiler_stream(runs, database = "../KOs_sketched_scaled_1000.sig.zip")
} # }