Skip to main content

Module progress

Module progress 

Source
Expand description

Live terminal progress reporting, drawn in place:

FastQC-Rust v1.1.0

Failed to process notes.txt: ID line didn't start with '@' at line 1
  sample_1.fastq.gz  ⠹ ━━━━━━━━━━━━━━━━━━━━╸━━━━━━━  72%  2.1M reads     4s
  sample_2.fastq.gz  ✔ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%  3.0M reads     6s

  ┌───────────────────────────────────┬────────────────┬────────────────┐
  │ Measure                           │ sample_1.fast… │ sample_2.fast… │
  ├───────────────────────────────────┼────────────────┼────────────────┤
  │ File type                         │ Conventional … │ Conventional … │
  │ ...                               │ ...            │ ...            │
  └───────────────────────────────────┴────────────────┴────────────────┘
Complete. Analysed 2 files in 00:06

The bars, the table and the closing summary are a redrawn region pinned to the bottom of the terminal. The name and version, and any warning or error, are ordinary log lines that scroll up above it.

The display adapts to the size of the run:

  • 1-10 files get a progress bar each, in the order given on the command line, showing that file’s own progress.
  • More than 10 files collapse to a single bar counting completed files, because a screenful of bars is worse than no bars at all.
  • A live statistics table is drawn underneath whenever the terminal is wide enough for every column to be readable — so a wide terminal gets it for more files, and a narrow one does without. Its columns are the files and its rows the Basic Statistics measures from the top of the HTML report. Cells start as - and fill in as the analysis runs; the final values are exactly those in the report, because both are rendered from the same counters (see crate::modules::basic_stats::BasicStatsCounters::rows).

§Animation and colour

These are two independent switches, each auto-detected and each overridable through the environment — there are no command-line flags for them. --quiet beats both and says nothing but warnings and errors.

Animation (FASTQC_PROGRESS=auto|always|never) — the default auto draws the display only for an interactive stderr. When stderr is a pipe, a log file or a workflow engine’s capture, or when TERM says the terminal cannot handle a redrawn region (dumb, or unset on Unix), a redrawn region would be noise or outright corruption, so the reporter degrades to one plain line per file at start and finish. always draws it regardless — for recording a demo, or feeding a consumer that re-renders the stream — by handing indicatif the terminal directly instead of its self-hiding stderr draw target, sizing itself from COLUMNS/LINES since there is no terminal to measure. never always takes the plain path.

Colour follows console::colors_enabled_stderr, which implements the usual conventions: the clicolors spec CLICOLOR=0 disables colour and CLICOLOR_FORCE=1 forces it on even for a pipe, and TERM=dumb disables it. A non-empty NO_COLOR disables it over all of those, which console does not do on its own. indicatif’s template styling reads the same function, so one signal covers this module’s styling and the bars alike.

Because the two are independent: colour off still draws the bars, just without escape codes; and the plain fallback still colours its lines when colour is forced on, which is what a CI log viewer wants — it renders escape sequences happily while not being a terminal.

§Log lines

Anything printed while the display is up has to go through log_line, or ProgressReporter::error. Writing to stderr directly would land in the middle of the display and be erased by the next frame. A warning raised from an inner analysis loop pairs log_line with an OncePerRun latch, so the run says it once instead of once per base.

Those lines are written above the redrawn region and scroll up as ordinary terminal output, which is what rich, tqdm, indicatif, cargo and Nextflow all do. The log is the permanent record and has to be able to grow without bound, and the terminal’s scrollback is the only place unbounded output can go. The version banner is printed by ProgressPlan::new before the run does anything else, so everything the run has to say appears beneath it in the order it happened.

The exception is the closing Complete. Analysed N files in mm:ss, which is the last line of the redrawn region so that it always lands below the bars and the table. --quiet suppresses it along with everything else.

Structs§

FileProgress
A progress handle for a single file group.
OncePerRun
A latch for a warning raised from an innermost analysis loop, where the same message can be produced millions of times — once per bad base, once per unreadable read.
ProgressPlan
A decided-but-not-yet-drawn display, and the first half of starting a run.
ProgressReporter
The terminal progress display for a whole run.

Enums§

When
A tri-state switch for behaviour that is normally auto-detected.

Constants§

LOGO_BLUE
The FastQC logo’s two colours, as the nearest xterm-256 entries.
LOGO_RED
PROGRESS_ENV
Environment variable selecting the progress display. FASTQC_-prefixed so that it cannot collide with anything in the environment it is read from.

Functions§

log_line
Emit a line above the progress display, wherever it is called from. Falls back to plain stderr when no display is active.