Skip to main content
VierApparatus
On this page
  1. References

Level 07 · Bioinformatics and Computational Biology

Linux and Command-Line Computing

Working in a Unix-like command line for biological data, covering the file system and permissions, the text-processing tools that filter and transform large files, pipes and redirection, shell scripts that repeat steps over many samples, environment variables and package management, and the remote access and process monitoring needed to run analyses on servers and clusters.

1 min read · Updated

Listen to this moduleComing soon

Learning objectives

  • Use the command line to find, inspect, filter and transform biological files without opening them in a graphical program.
  • Write a shell script that repeats an analysis over a set of samples and records what it did.

Most bioinformatics software is run from a command line, and the large files of biological data are handled far more easily there than in a graphical application. The command line is a language for combining small, specialised programs, each of which does one job and reads and writes plain text. A researcher who can use it can filter a file with millions of lines, count the records that match a condition or run an alignment over a hundred samples, without writing a new program for each step.

The topic begins with the file system, the permissions that control who can read and change a file, and the basic commands for moving through directories and listing their contents. It then covers the text-processing tools that select lines, extract columns and transform fields, and the pipes that connect them. Shell scripts repeat a sequence of commands over many inputs, and the environment variables and package managers set up the software on which the commands rely.

The last chapters address the setting in which large analyses are run. Analyses are often performed on remote servers and clusters, which requires secure remote login, the monitoring of running processes and the recording of what was run. Stein (2010) described how genome analysis moved to shared and remote computing, and the command line is the usual interface to those resources.

Taschuk and Wilson (2017) recommended that research software be written so that it can be run by others, and the command-line habits in this topic are the first step in that direction. Sandve et al. (2013) recommended that every command that produces a result be recorded, and a script or a logged command history serves that purpose.

Chapters in this module

  • Why the Command Line

    Why a command-line interface suits biological data and bioinformatics software, the terminal and the shell, the difference between a graphical application and a command that can be repeated and combined, the Unix philosophy of small tools that read and write text and the practical gains in speed, reproducibility and scale that the command line brings.

  • Files, Directories and Permissions

    How a Unix-like file system is organised into a tree of directories, the paths that locate a file, the commands that list, copy, move and remove files, the permission bits that control reading, writing and execution by the owner, the group and others, and the care needed when deleting or overwriting the raw data of an analysis.

  • Pipes, Redirection and Text Processing

    How standard input, standard output and standard error are redirected to files and joined by pipes, the text-processing tools that select lines by pattern, extract and cut columns, sort and count records and the practical use of these tools on tab-separated biological files, such as counting the reads that match a feature or extracting the sequence identifiers from an annotation.

  • Shell Scripts and Loops

    How a shell script collects a sequence of commands into a file that can be run again, how loops apply the same command to every sample in a directory, how variables and arguments make a script reusable, how a script checks its inputs and stops on error and why a script that processes many samples must record which samples succeeded.

  • Environment Variables, Paths and Packages

    How environment variables hold the settings that programs read, how the search path tells the shell where to find a command, the risks of installing software into the system directories, the use of package managers and isolated environments to install bioinformatics tools with fixed versions and the recording of the installed versions so that an analysis can be repeated.

  • Remote Computing with SSH

    How secure shell connects a local terminal to a remote server or cluster, the use of key-based authentication instead of passwords, how files are transferred between a local machine and a remote one, the risk of running long analyses in an interactive session that can be lost and the use of terminal multiplexers to keep work running after a disconnection.

  • Processes and Resource Monitoring

    How the operating system runs programs as processes, how to list and stop them, how processes use the central processor and memory, how to watch the resource use of a long bioinformatic job and why an analysis that exhausts memory or runs without limit must be detected early, with the practices that keep shared computers usable for everyone.

  • Reproducible Command-Line Work

    How command-line work is made reproducible, including the recording of the commands and their outputs in logs, the use of version control for scripts and configuration files, the separation of raw data, code and results in a directory layout, the checksums that confirm a file has not changed and the project documentation that allows another person to run the analysis from the start.

References

  1. Taschuk, M., & Wilson, G. (2017). Ten simple rules for making research software more robust. PLOS Computational Biology, 13(4), e1005412. https://doi.org/10.1371/journal.pcbi.1005412
  2. Sandve, G. K., Nekrutenko, A., Taylor, J., & Hovig, E. (2013). Ten Simple Rules for Reproducible Computational Research. PLoS Computational Biology, 9(10), e1003285. https://doi.org/10.1371/journal.pcbi.1003285
  3. Stein, L. D. (2010). The case for cloud computing in genome informatics. Genome Biology, 11(5), 207. https://doi.org/10.1186/gb-2010-11-5-207

Callouts marked Commentary or Speculation in the lesson separate interpretation and open questions from established findings.