Chapter 15. Seqmagique: Creating and Formatting Reports

Often in bioinformatics projects, you’ll find yourself staring at a directory full of sequence files, probably in FASTA or FASTQ format. You’ll probably want to start by getting an idea of the distribution of sequences in the files, such as how many are in each file and the average, minimum, and maximum lengths of the sequences. You need to know if any files are corrupted—maybe they didn’t transfer completely from your sequencing center—or if any samples have far fewer reads, perhaps indicating a bad sequencing run that needs to be redone. In this chapter, I’ll introduce some techniques for checking your sequence files using hashes and the Seqmagick tool. Then I’ll write a small utility to mimic part of Seqmagick to illustrate how to create formatted text tables. This program serves as a template for any program that needs to process all the records in a given set of files and produce a table of summary statistics.

You will learn:

  • How to install the seqmagick tool

  • How to use MD5 hashes

  • How to use choices in argparse to constrain arguments

  • How to use the numpy module

  • How to mock a filehandle

  • How to use the tabulate and rich modules to format output tables

Using Seqmagick to Analyze Sequence Files

seqmagick is a useful command-line utility for handling sequence files. This should have been installed along with the other Python modules if you followed the setup instructions in the Preface. If not, ...

Get Mastering Python for Bioinformatics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.