Chapter 6. Utilities
This chapter surveys many Python modules that are particularly important for bioinformatics programming. We will look at utilities that help you connect Python to its external environment, deal with filesystems, work with text, and debug your programs, among others. These aren’t particularly exciting, but it’s easy enough to learn how to use them. You’ll need some of them to deal with operating systems, filesystems, dates and times, and so on. Others will likewise prove extremely useful in the right circumstances, giving you ways to do in a few lines of code things that could take pages otherwise. Some of the modules aren’t necessary for simple scripts or initial development but provide the features users expect from mature programs.
System Environment
The first set of modules we’ll look at are those that allow Python to interact with its external environment. The categories included here are dates and times, command-line processing of various kinds, email, and logging.
Dates and Times: datetime
The datetime
module defines classes that represent a date, a time, a
combination of date and time, and a couple of others. There are some
basic ways of manipulating instances of these classes, as well as some
more elaborate ones that we won’t consider here.
Classes
The datetime
module
defines five classes. Their representations are simple,
consisting only of several fields with primitive types. This allows
them to define __repr__
methods that print exactly what you would enter ...
Get Bioinformatics Programming Using Python 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.