You are on page 1of 42

Mastering Python for Bioinformatics

Ken Youens Clark


Visit to download the full and correct content document:
https://textbookfull.com/product/mastering-python-for-bioinformatics-ken-youens-clark
/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Python for Bioinformatics, Second Edition Sebastian


Bassi

https://textbookfull.com/product/python-for-bioinformatics-
second-edition-sebastian-bassi/

Bioinformatics Algorithms Design and Implementation in


Python 1st Edition Miguel Rocha

https://textbookfull.com/product/bioinformatics-algorithms-
design-and-implementation-in-python-1st-edition-miguel-rocha/

Mastering Large Datasets with Python Parallelize and


Distribute Your Python Code 1st Edition John T Wolohan

https://textbookfull.com/product/mastering-large-datasets-with-
python-parallelize-and-distribute-your-python-code-1st-edition-
john-t-wolohan/

Translational Bioinformatics for Therapeutic


Development Joseph Markowitz

https://textbookfull.com/product/translational-bioinformatics-
for-therapeutic-development-joseph-markowitz/
Mastering Python forensics : master the art of digital
forensics and analysis with Python First Published
October 2015 Edition Uhrmann

https://textbookfull.com/product/mastering-python-forensics-
master-the-art-of-digital-forensics-and-analysis-with-python-
first-published-october-2015-edition-uhrmann/

Mastering Time Series Analysis and Forecasting with


Python Bridging Theory and Practice Through Insights
Techniques and Tools for Effective Time Series Analysis
in Python 1st Edition Sulekha Aloorravi
https://textbookfull.com/product/mastering-time-series-analysis-
and-forecasting-with-python-bridging-theory-and-practice-through-
insights-techniques-and-tools-for-effective-time-series-analysis-
in-python-1st-edition-sulekha-aloorravi/

JBoss Weld CDI for Java Platform 1st Edition Finnigan


Ken

https://textbookfull.com/product/jboss-weld-cdi-for-java-
platform-1st-edition-finnigan-ken/

Mastering Machine Learning with Python in Six Steps: A


Practical Implementation Guide to Predictive Data
Analytics Using Python 1st Edition Manohar Swamynathan
(Auth.)
https://textbookfull.com/product/mastering-machine-learning-with-
python-in-six-steps-a-practical-implementation-guide-to-
predictive-data-analytics-using-python-1st-edition-manohar-
swamynathan-auth/

Bleeding blue giving my all for the game Clark

https://textbookfull.com/product/bleeding-blue-giving-my-all-for-
the-game-clark/
Mastering Python for
Bioinformatics
How to Write Flexible, Documented, Tested Python
Code for Research Computing

Ken Youens-Clark
Mastering Python for Bioinformatics
by Ken Youens-Clark
Copyright © 2021 Charles Kenneth Youens-Clark. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.

Acquisitions Editor: Michelle Smith

Development Editor: Corbin Collins

Production Editor: Caitlin Ghegan

Copyeditor: Sonia Saruba

Proofreader: Rachel Head

Indexer: Sue Klefstad

Interior Designer: David Futato

Cover Designer: Karen Montgomery

Illustrator: Kate Dullea

May 2021: First Edition


Revision History for the First Edition
2021-05-04: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781098100889 for


release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
Mastering Python for Bioinformatics, the cover image, and related
trade dress are trademarks of O’Reilly Media, Inc.
The views expressed in this work are those of the author, and do not
represent the publisher’s views. While the publisher and the author
have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and
the author disclaim all responsibility for errors or omissions,
including without limitation responsibility for damages resulting from
the use of or reliance on this work. Use of the information and
instructions contained in this work is at your own risk. If any code
samples or other technology this work contains or describes is
subject to open source licenses or the intellectual property rights of
others, it is your responsibility to ensure that your use thereof
complies with such licenses and/or rights.
978-1-098-10088-9
[LSI]
Preface

Programming is a force multiplier. We can write computer programs


to free ourselves from tedious manual tasks and to accelerate
research. Programming in any language will likely improve your
productivity, but each language has different learning curves and
tools that improve or impede the process of coding.
There is an adage in business that says you have three choices:

1. Fast
2. Good
3. Cheap
Pick any two.
When it comes to programming languages, Python hits a sweet spot
in that it’s fast because it’s fairly easy to learn and to write a working
prototype of an idea—it’s pretty much always the first language I’ll
use to write any program. I find Python to be cheap because my
programs will usually run well enough on commodity hardware like
my laptop or a tiny AWS instance. However, I would contend that it’s
not necessarily easy to make good programs using Python because
the language itself is fairly lax. For instance, it allows one to mix
characters and numbers in operations that will crash the program.
This book has been written for the aspiring bioinformatics
programmer who wants to learn about Python’s best practices and
tools such as the following:

Since Python 3.6, you can add type hints to indicate, for
instance, that a variable should be a type like a number or a
list, and you can use the mypy tool to ensure the types are
used correctly.
Testing frameworks like pytest can exercise your code with
both good and bad data to ensure that it reacts in some
predictable way.
Tools like pylint and flake8 can find potential errors and
stylistic problems that would make your programs more
difficult to understand.
The argparse module can document and validate the
arguments to your programs.
The Python ecosystem allows you to leverage hundreds of
existing modules like Biopython to shorten programs and
make them more reliable.

Using these tools practices individually will improve your programs,


but combining them all will improve your code in compounding
ways. This book is not a textbook on bioinformatics per se. The
focus is on what Python offers that makes it suitable for writing
scientific programs that are reproducible. That is, I’ll show you how
to design and test programs that will always produce the same
outputs given the same inputs. Bioinformatics is saturated with
poorly written, undocumented programs, and my goal is to reverse
this trend, one program at a time.
The criteria for program reproducibility include:
Parameters
All program parameters can be set as runtime arguments. This
means no hard-coded values which would require changing the
source code to change the program’s behavior.

Documentation
A program should respond to a --help argument by printing the
parameters and usage.

Testing
You should be able to run a test suite that proves the code meets
some specifications

You might expect that this would logically lead to programs that are
perhaps correct, but alas, as Edsger Dijkstra famously said,
“Program testing can be used to show the presence of bugs, but
never to show their absence!”
Most bioinformaticians are either scientists who’ve learned
programming or programmers who’ve learned biology (or people like
me who had to learn both). No matter how you’ve come to the field
of bioinformatics, I want to show you practical programming
techniques that will help you write correct programs quickly. I’ll start
with how to write programs that document and validate their
arguments. Then I’ll show how to write and run tests to ensure the
programs do what they purport.
For instance, the first chapter shows you how to report the
tetranucleotide frequency from a string of DNA. Sounds pretty
simple, right? It’s a trivial idea, but I’ll take about 40 pages to show
how to structure, document, and test this program. I’ll spend a lot of
time on how to write and test several different versions of the
program so that I can explore many aspects of Python data
structures, syntax, modules, and tools.

Who Should Read This?


You should read this book if you care about the craft of
programming, and if you want to learn how to write programs that
produce documentation, validate their parameters, fail gracefully,
and work reliably. Testing is a key skill both for understanding your
code and for verifying its correctness. I’ll show you how to use the
tests I’ve written as well as how to write tests for your programs.
To get the most out of this book, you should already have a solid
understanding of Python. I will build on the skills I taught in Tiny
Python Projects (Manning, 2020), where I show how to use Python
data structures like strings, lists, tuples, dictionaries, sets, and
named tuples. You need not be an expert in Python, but I definitely
will push you to understand some advanced concepts I introduce in
that book, such as types, regular expressions, and ideas about
higher-order functions, along with testing and how to use tools like
pylint, flake8, yapf, and pytest to check style, syntax, and
correctness. One notable difference is that I will consistently use
type annotations for all code in this book and will use the mypy tool
to ensure the correct use of types.

Programming Style: Why I Avoid OOP and


Exceptions
I tend to avoid object-oriented programming (OOP). If you don’t
know what OOP means, that’s OK. Python itself is an OO language,
and almost every element from a string to a set is technically an
object with internal state and methods. You will encounter enough
objects to get a feel for what OOP means, but the programs I
present will mostly avoid using objects to represent ideas.
That said, Chapter 1 shows how to use a class to represent a
complex data structure. The class allows me to define a data
structure with type annotations so that I can verify that I’m using
the data types correctly. It does help to understand a bit about OOP.
For instance, classes define the attributes of an object, and classes
can inherit attributes from parent classes, but this essentially
describes the limits of how and why I use OOP in Python. If you
don’t entirely follow that right now, don’t worry. You’ll understand it
once you see it.
Instead of object-oriented code, I demonstrate programs composed
almost entirely of functions. These functions are also pure in that
they will only act on the values given to them. That is, pure
functions never rely on some hidden, mutable state like global
variables, and they will always return the same values given the
same arguments. Additionally, every function will have an associated
test that I can run to verify it behaves predictably. It’s my opinion
that this leads to shorter programs that are more transparent and
easier to test than solutions written using OOP. You may disagree
and are of course welcome to write your solutions using whatever
style of programming you prefer, so long as they pass the tests. The
Python Functional Programming HOWTO documentation makes a
good case for why Python is suited for functional programming (FP).
Finally, the programs in this book also avoid the use of exceptions,
which I think is appropriate for short programs you write for
personal use. Managing exceptions so that they don’t interrupt the
flow of a program adds another level of complexity that I feel
detracts from one’s ability to understand a program. I’m generally
unhappy with how to write functions in Python that return errors.
Many people would raise an exception and let a try/catch block
handle the mistakes. If I feel an exception is warranted, I will often
choose to not catch it, instead letting the program crash. In this
respect, I’m following an idea from Joe Armstrong, the creator of the
Erlang language, who said, “The Erlang way is to write the happy
path, and not write twisty little passages full of error correcting
code.”
If you choose to write programs and modules for public release, you
will need to learn much more about exceptions and error handling,
but that’s beyond the scope of this book.

Structure
The book is divided into two main parts. The first part tackles 14 of
the programming challenges found at the Rosalind.info website.1
The second part shows more complicated programs that
demonstrate other patterns or concepts I feel are important in
bioinformatics. Every chapter of the book describes a coding
challenge for you to write and provides a test suite for you to
determine when you’ve written a working program.
Although the “Zen of Python” says “There should be one—and
preferably only one—obvious way to do it,” I believe you can learn
quite a bit by attempting many different approaches to a problem.
Perl was my gateway into bioinformatics, and the Perl community’s
spirit of “There’s More Than One Way To Do It” (TMTOWTDI) still
resonates with me. I generally follow a theme-and-variations
approach to each chapter, showing many solutions to explore
different aspects of Python syntax and data structures.

Test-Driven Development
More than the act of testing, the act of designing tests is one of
the best bug preventers known. The thinking that must be done to
create a useful test can discover and eliminate bugs before they
are coded—indeed, test-design thinking can discover and eliminate
bugs at every stage in the creation of software, from conception
to specification, to design, coding, and the rest.
—Boris Beizer, Software Testing Techniques
(Thompson Computer Press)
Underlying all my experimentation will be test suites that I’ll
constantly run to ensure the programs continue to work correctly.
Whenever I have the opportunity, I try to teach test-driven
development (TDD), an idea explained in a book by that title written
by Kent Beck (Addison-Wesley, 2002). TDD advocates writing tests
for code before writing the code. The typical cycle involves the
following:
1. Add a test.
2. Run all tests and see if the new test fails.
3. Write the code.
4. Run tests.
5. Refactor code.
6. Repeat.
In the book’s GitHub repository, you’ll find the tests for each
program you’ll write. I’ll explain how to run and write tests, and I
hope by the end of the material you’ll believe in the common sense
and basic decency of using TDD. I hope that thinking about tests
first will start to change the way you understand and explore coding.

Using the Command Line and Installing Python


My experience in bioinformatics has always been centered around
the Unix command line. Much of my day-to-day work has been on
some flavor of Linux server, stitching together existing command-line
programs using shell scripts, Perl, and Python. While I might write
and debug a program or a pipeline on my laptop, I will often deploy
my tools to a high-performance compute (HPC) cluster where a
scheduler will run my programs asynchronously, often in the middle
of the night or over a weekend and without any supervision or
intervention by me. Additionally, all my work building databases and
websites and administering servers is done entirely from the
command line, so I feel strongly that you need to master this
environment to be successful in bioinformatics.
I used a Macintosh to write and test all the material for this book,
and macOS has the Terminal app you can use for a command line. I
have also tested all the programs using various Linux distributions,
and the GitHub repository includes instructions on how to use a
Linux virtual machine with Docker. Additionally, I tested all the
programs on Windows 10 using the Ubuntu distribution Windows
Subsystem for Linux (WSL) version 1. I highly recommend WSL for
Windows users to have a true Unix command line, but Windows
shells like cmd.exe, PowerShell, and Git Bash can sometimes work
sufficiently well for some programs.
I would encourage you to explore integrated development
environments (IDEs) like VS Code, PyCharm, or Spyder to help you
write, run, and test your programs. These tools integrate text
editors, help documentation, and terminals. Although I wrote all the
programs, tests, and even this book using the vim editor in a
terminal, most people would probably prefer to use at least a more
modern text editor like Sublime, TextMate, or Notepad++.
I wrote and tested all the examples using Python versions 3.8.6 and
3.9.1. Some examples use Python syntax that was not present in
version 3.6, so I would recommend you not use that version. Python
version 2.x is no longer supported and should not be used. I tend to
get the latest version of Python 3 from the Python download page,
but I’ve also had success using the Anaconda Python distribution.
You may have a package manager like apt on Ubuntu or brew on
Mac that can install a recent version, or you may choose to build
from source. Whatever your platform and installation method, I
would recommend you try to use the most recent version as the
language continues to change, mostly for the better.
Note that I’ve chosen to present the programs as command-line
programs and not as Jupyter Notebooks for several reasons. I like
Notebooks for data exploration, but the source code for Notebooks is
stored in JavaScript Object Notation (JSON) and not as line-oriented
text. This makes it very difficult to use tools like diff to find the
differences between two Notebooks. Also, Notebooks cannot be
parameterized, meaning I cannot pass in arguments from outside
the program to change the behavior but instead have to change the
source code itself. This makes the programs inflexible and
automated testing impossible. While I encourage you to explore
Notebooks, especially as an interactive way to run Python, I will
focus on how to write command-line programs.
Getting the Code and Tests
All the code and tests are available from the book’s GitHub
repository. You can use the program Git (which you may need to
install) to copy the code to your computer with the following
command. This will create a new directory called biofx_python on
your computer with the contents of the repository:

$ git clone https://github.com/kyclark/biofx_python

If you enjoy using an IDE, it may be possible to clone the repository


through that interface, as shown in Figure P-1. Many IDEs can help
you manage projects and write code, but they all work differently. To
keep things simple, I will show how to use the command line to
accomplish most tasks.

Figure P-1. The PyCharm tool can directly clone the GitHub repository for you
Some tools, like PyCharm, may automatically try to create a virtual
environment inside the project directory. This is a way to insulate the
version of Python and modules from other projects on your computer.
Whether or not you use virtual environments is a personal preference.
It is not a requirement to use them.

You may prefer to make a copy of the code in your own account so
that you can track your changes and share your solutions with
others. This is called forking because you’re breaking off from my
code and adding your programs to the repository.
To fork my GitHub repository, do the following:

1. Create an account on GitHub.com.


2. Go to https://github.com/kyclark/biofx_python.
3. Click the Fork button in the upper-right corner (see Figure P-
2) to make a copy of the repository in your account.

Figure P-2. The Fork button on my GitHub repository will make a copy of the code
in your account

Now that you have a copy of all my code in your repository, you can
use Git to copy that code to your computer. Be sure to replace
YOUR_GITHUB_ID with your actual GitHub ID:
$ git clone https://github.com/YOUR_GITHUB_ID/biofx_python

I may update the repo after you make your copy. If you would like
to be able to get those updates, you will need to configure Git to set
my repository as an upstream source. To do so, after you have
cloned your repository to your computer, go into your biofx_python
directory:

$ cd biofx_python

Then execute this command:

$ git remote add upstream https://github.com/kyclark/biofx_python.git

Whenever you would like to update your repository from mine, you
can execute this command:

$ git pull upstream main

Installing Modules
You will need to install several Python modules and tools. I’ve
included a requirements.txt file in the top level of the repository.
This file lists all the modules needed to run the programs in the
book. Some IDEs may detect this file and offer to install these for
you, or you can use the following command:

$ python3 -m pip install -r requirements.txt

Or use the pip3 tool:

$ pip3 install -r requirements.txt

Sometimes pylint may complain about some of the variable names


in the programs, and mypy will raise some issues when you import
modules that do not have type annotations. To silence these errors,
you can create initialization files in your home directory that these
programs will use to customize their behavior. In the root of the
source repository, there are files called pylintrc and mypy.ini that you
should copy to your home directory like so:

$ cp pylintrc ~/.pylintrc
$ cp mypy.ini ~/.mypy.ini

Alternatively, you can generate a new pylintrc with the following


command:

$ cd ~
$ pylint --generate-rcfile > .pylintrc

Feel free to customize these files to suit your tastes.

Installing the new.py Program


I wrote a Python program called new.py that creates Python
programs. So meta, I know. I wrote this for myself and then gave it
to my students because I think it’s quite difficult to start writing a
program from an empty screen. The new.py program will create a
new, well-structured Python program that uses the argparse module
to interpret command-line arguments. It should have been installed
in the preceding section with the module dependencies. If not, you
can use the pip module to install it, like so:

$ python3 -m pip install new-py

You should now be able to execute new.py and see something like
this:

$ new.py
usage: new.py [-h] [-n NAME] [-e EMAIL] [-p PURPOSE] [-t] [-f] [--
version]
program
new.py: error: the following arguments are required: program

Each exercise will suggest that you use new.py to start writing your
new programs. For instance, in Chapter 1 you will create a program
called dna.py in the 01_dna directory, like so:

$ cd 01_dna/
$ new.py dna.py
Done, see new script "dna.py".

If you then execute ./dna.py --help, you will see that it generates
help documentation on how to use the program. You should open
the dna.py program in your editor, modify the arguments, and add
your code to satisfy the requirements of the program and the tests.
Note that it’s never a requirement that you use new.py. I only offer
this as an aid to getting started. This is how I start every one of my
own programs, but, while I find it useful, you may prefer to go a
different route. As long as your programs pass the test suites, you
are welcome to write them however you please.

Why Did I Write This Book?


Richard Hamming spent decades as a mathematician and researcher
at Bell Labs. He was known for seeking out people he didn’t know
and asking them about their research. Then he would ask them
what they thought were the biggest, most pressing unanswered
questions in their field. If their answers for both of these weren’t the
same, he’d ask, “So why aren’t you working on that?”
I feel that one of the most pressing problems in bioinformatics is
that much of the software is poorly written and lacks proper
documentation and testing, if it has any at all. I want to show you
that it’s less difficult to use types and tests and linters and
Create your dna.py program in the 01_dna directory, as this contains
the test files for the program. Here is how I will start the dna.py
program. The --purpose argument will be used in the program’s
documentation:

$ new.py --purpose 'Tetranucleotide frequency' dna.py


Done, see new script "dna.py."

If you run the new dna.py program, you will see that it defines many
different types of arguments common to command-line programs:

$ ./dna.py --help
usage: dna.py [-h] [-a str] [-i int] [-f FILE] [-o] str

Tetranucleotide frequency

positional arguments:
str A positional argument

optional arguments:
-h, --help show this help message and exit
-a str, --arg str A named string argument (default: )
-i int, --int int A named integer argument (default: 0)
-f FILE, --file FILE A readable file (default: None)
-o, --on A boolean flag (default: False)

The --purpose from new.py is used here to describe the program.

The program accepts a single positional string argument.

The -h and --help flags are automatically added by argparse


and will trigger the usage.

This is a named option with short (-a) and long (--arg) names
for a string value.
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Mémoires d'un
jeune homme rangé
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Mémoires d'un jeune homme rangé


roman

Author: Tristan Bernard

Release date: September 13, 2023 [eBook #71635]

Language: French

Original publication: Paris: Éditions de la revue blanche, 1899

Credits: Laurent Vogel (This file was produced from images


generously made available by the Bibliothèque nationale de
France (BnF/Gallica))

*** START OF THE PROJECT GUTENBERG EBOOK MÉMOIRES


D'UN JEUNE HOMME RANGÉ ***
TRISTAN BERNARD

Mémoires
d’un
jeune homme rangé
roman

PARIS
ÉDITIONS DE LA REVUE BLANCHE
23, BOULEVARD DES ITALIENS, 23

1899

Tous droits de traduction et reproduction réservés pour tous les pays y compris la
Suède et la Norvège.
DU MÊME AUTEUR :

Vous m’en direz tant, nouvelles (avec Pierre Veber).


Les Contes de Pantruche et d’ailleurs, nouvelles.
Sous toutes réserves, nouvelles.

Théâtre.

Les Pieds nickelés.


Allez, Messieurs !
Le Fardeau de la Liberté.
Silvérie ou les Fonds hollandais (avec Alphonse Allais).
Le seul Bandit du Village.
Je vais m’en aller.
Franches Lippées.
Le vrai courage.
Une aimable Lingère.
L’Anglais tel qu’on le parle.
Il a été tiré à part quinze exemplaires de luxe, numérotés à la
presse,
savoir :
Trois exemplaires sur japon impérial, de 1 à 3
Douze exemplaires sur hollande, de 4 à 15.

JUSTIFICATION DU TIRAGE :
A

JULES RENARD

Mon cher Renard, c’est moins votre ami qui vous dédie ce livre,
que votre lecteur. Je ne suis devenu votre ami qu’après vous avoir
lu, et je n’ai fait votre connaissance que parce que je voulais vous
connaître. J’ai été pour l’Écornifleur ce que j’avais été pour David
Copperfield, un de ces frères obscurs que les écrivains tels que vous
vont toucher à travers le monde. Je croyais alors que Dickens vous
avait fortement impressionné. J’ai su depuis que vous le lisiez peu.
Mais vous possédiez comme lui cette lanterne sourde, dont la clarté
si pénétrante ne vous aveugle point, et qui vous permet de
descendre en vous, et d’y retrouver sûrement de l’humanité générale
et nouvelle. Ainsi vous éclairez, en vous et en nous, ces coins
sauvages où nous sommes encore nous-mêmes, où les écrivains ne
sont pas venus arracher les mauvaises herbes et les plantes vivaces
pour y poser leurs jolis pots de fleur.
C’est une grande joie dans votre nombreuse famille, anonyme et
dispersée, quand un volume récent, une page inédite, lui apporte de
vos nouvelles et que le cousin Jules Renard nous envoie de son vin
naturel, de ses œufs frais, ou quelque volaille bien vivante. C’est une
bonne gloire pour vous que ce concert de gratitudes qui vous vient
vous ne savez d’où. Comme cette clientèle naturelle est plus
précieuse et plus difficile à conquérir que certaines élites parquées,
où il suffit pour se faire comprendre, d’employer un dialecte spécial
dont les mots ont acquis, grâce à des sortes de clés, un sens
profond d’avance ! A vos frères inconnus vous parlez un langage
connu, et je vous admire, cher Jules Renard, de savoir leur
transmettre votre pensée tout entière, par votre style classique,
fidèle messager.

T. B.
Mémoires d’un jeune homme rangé
I
DÉPART POUR LE BAL

La jeunesse de Daniel Henry se passa alternativement à


mépriser les prescriptions de la mode, et à tenter de vains efforts
pour s’y conformer.
Il employa des années de sa vie à rêver la conquête de ces
fantômes insaisissables : un chapeau élégant, un col de chemise
bien dégagé, un veston bien coupé. Les haut-de-forme, si reluisants
et séduisants tant qu’ils habitaient le magasin orné de glaces,
contractaient au contact de la tête de Daniel Henry une sorte de
maladie de vulgarité. Les collets de veston montaient jusqu’à la
nuque, au mépris absolu des cols de chemise, dont ils ne laissaient
plus rien voir.
Daniel avait été élevé par sa famille dans cette idée que les
tailleurs fashionables et chers n’étaient pas plus adroits que certains
tailleurs à bon marché qui habitaient dans les rues étroites du
quartier Montorgueil.
— D’ailleurs, disait la mère du jeune Henry quand elle avait
découvert un nouveau tailleur en chambre, c’est un homme qui
travaille pour les premières maisons de Paris, et l’on peut avoir pour
quatre-vingt-dix francs chez lui un vêtement qu’on paierait facilement
le double ailleurs.
Daniel s’était commandé un habit de soirée à l’occasion de sa
vingtième année. C’était son deuxième habit. Il s’était beaucoup
développé en trois ans, et le premier était décidément trop étroit.
Pendant plusieurs semaines, il avait vécu dans l’espérance de ce
vêtement neuf, qui devait le mettre enfin au niveau social d’André
Bardot et de Lucien Bayonne, deux jeunes gens qu’il devait
rencontrer au bal des Voraud, et qui l’avaient toujours médusé par
leur inaccessible élégance.
Sur les conseils de sa mère, il avait commandé cet habit chez un
petit tailleur de la rue d’Aboukir, qui travaillait d’après les modes
anglaises. Ce petit homme à favoris gris, habillé d’une jaquette trop
étroite et d’un pantalon trop large — deux laissés pour compte —
avait apporté un portefeuille gonflé de gravures de mode, qui toutes
représentaient des messieurs, très grands, très sveltes et pourvus
de belles moustaches ou de barbes bien taillées. L’un d’eux, en habit
de soirée, tendait le bras gauche, d’un geste oiseux, vers un
monsieur en costume de chasse et, la tête tournée à droite,
regardait froidement une jeune amazone.
Bien qu’il fût de taille médiocre et qu’il eût les épaules une idée
tombantes, Daniel s’était assimilé dans son esprit à l’un de ces
jeunes hommes, qui portait un monocle sous des cheveux
légèrement ondulés et séparés par une raie.
Jamais les cheveux de Daniel Henry n’avaient voulu se séparer
ainsi. Il n’avait jamais eu, comme le jeune homme de la gravure, une
moustache blonde bien fournie. Ses joues étaient fertiles en poils
noirs, mais sa moustache s’obstinait à ne pas pousser. Ses tempes
aussi le désespéraient. Ses cheveux n’avaient pas à cet endroit le
contour arrêté qui rendait si remarquable le front de tel ou tel
élégant. Ils ne se terminaient pas par une bordure très nette. Ils se
raréfiaient plutôt, pour ménager une transition entre la peau nue et le
cuir chevelu.
Daniel, cependant, tout à la contemplation intérieure de cette
merveilleuse vision du gentleman de la gravure, s’identifiait à lui en
pensée, oubliant l’insuffisance de sa moustache et la mauvaise
conduite de ses cheveux du front.
Il alla pour l’essayage chez le tailleur. L’escalier montait tout droit
jusqu’à l’entresol, à la loge du concierge, puis, après cette formalité,
se livrait dans sa cage obscure à des combinaisons de paliers et de
détours imprévus, de sorte que le tailleur habitait à un étage mal
défini. Daniel arriva à sa porte après avoir dérangé deux personnes,
un fabricant de descentes de lit et une ouvrière en fleurs de
chapeaux, qui lui fournirent, en entrebâillant leur porte, deux rapides
aperçus sur la flore artificielle et la faune honoraire de ce domaine
citadin.
Daniel pénétra enfin dans une chambre assez bien éclairée, qui
sentait l’oignon, et qu’un tuyau de poêle oblique traversait dans sa
largeur. A côté de quelques gravures de modes, d’autres images
exprimaient l’éloge suranné de M. Adolphe Thiers, soit qu’on le
montrât en apothéose, sur son lit mortuaire, soit, vivant encore, au
milieu du Parlement, et recevant vénérablement l’acclamation de
Gambetta, qui saluait en lui le libérateur du territoire.
Le tailleur sortit de la chambre à côté. Daniel fut tout de suite
impressionné par ses favoris gris et son pince-nez. Tout le monde,
dans sa famille, ayant bonne vue, il n’avait jamais fréquenté de près
des personnes ornées d’un binocle, qui restait pour lui une marque
de supériorité sociale.
L’habit noir, rayé de petits traits de fil blanc et dépourvu de sa
manche droite, ne ressemblait pas encore à l’habit de la gravure :
Daniel, en se regardant dans la glace, remarqua que son dos n’avait
jamais paru si rond.
Il en détourna les yeux de désespoir, et murmura d’une voix
étranglée : « Le col un peu plus dégagé, n’est-ce pas ? »
Ce à quoi répondit à peine, d’un petit signe de tête approbatif,
l’arrogant mangeur d’épingles.
En sortant de chez le tailleur, Daniel était un peu rembruni. Mais
il se dit qu’il y avait bien loin d’un habit essayé à un habit fini, et que
l’aspect général changerait notablement, le jour où il aurait un
pantalon noir assorti à la place du pantalon marron, fatigué du
genou, qu’il avait gardé pour l’essayage.
Le soir du bal chez les Voraud, on apporta l’habit de cérémonie.
Daniel se hâta de l’endosser, et le trouva bien différent de ses rêves.
Le collet cachait encore le col de chemise, qui, lui-même, était un
peu bas (ce qui, entre le chemisier et le tailleur, rendait bien difficile
l’attribution des responsabilités). De plus, les pans et la taille étaient
trop courts. Daniel, sans mot dire, se regardait dans la glace. Après
les éloges de sa mère et l’enthousiasme de sa tante Amélie, il n’eut
plus d’opinion. Il n’osa d’ailleurs pas avouer qu’il se sentait un peu
gêné aux entournures.
Quand il fut prêt des pieds à la tête, serré au cou dans un col un
peu étroit, avec le nœud tout fait de sa cravate blanche et des
bottines qu’il avait prises très larges (c’était le seul moyen de faire
cesser la torture des chaussures), il alla se montrer dans la salle à
manger, où son père et son oncle terminaient une partie d’impériale.
Il était près de dix heures et demie. Il fallait arriver chez les Voraud
vers les onze heures. Daniel attachait une importance énorme à son
entrée. Il ne s’était jamais rendu un compte exact de la place qu’il
occupait dans le monde. Tantôt il pensait être le centre des
préoccupations de l’assistance, tantôt il se considérait comme un
être obscur et injustement négligé. Mais il ne concevait pas qu’il y
pût produire une sensation médiocre.
Son père l’examina avec une indifférence affectée, tira sa montre
et dit :
— Il faut te mettre en chemin. Tu prendras le petit tram, rue de
Maubeuge, avec une correspondance pour Batignolles-Clichy-
Odéon, qui te déposera sur la place du Théâtre-Français.
— Pourquoi ça ? dit l’oncle Émile. Il a bien plus d’avantages à
prendre Chaussée du Maine-Gare du Nord ? Qu’est-ce que tu veux
qu’il attende pour la correspondance ? Chaussée du Maine le mène
rue de Rivoli.
— Trouvera-t-il de la place dans Chaussée du Maine ? dit M.
Henry qui tenait à son idée.
— Toujours à cette heure-ci, dit l’oncle Émile.
Daniel, qui était décidé à prendre une voiture, écoutait
placidement cette discussion.
II
QUADRILLE DES LANCIERS

Les Voraud donnaient un bal par saison. M. Voraud, avec sa


barbe grise, ses gilets confortables et ses opinions bonapartistes ;
Mme Voraud, avec ses cheveux dorés et son habitude des
premières, effrayaient beaucoup Daniel Henry. Il n’était guère
rassuré, non plus, par leur fille Berthe, qui semblait posséder, autant
que ses parents, un sens profond de la vie.
Est-il possible que M. Voraud ait jamais pu être un petit enfant ?
Quelle autorité dans son regard, dans ses gilets, dans son col blanc
d’une blancheur et d’une raideur inconcevables, arrondi en avant
comme une cuvette, et que remplit comme une mousse grise une
barbe bien fournie !
Daniel pénètre dans l’antichambre et se demande s’il doit aller
présenter ses compliments à la maîtresse de la maison.
Mais il n’a préparé que des phrases bien incomplètes, et puis
Mme Voraud se trouve de l’autre côté du salon ; pour traverser ce
parquet ciré, au milieu de ce cercle de dames, il faudrait à Daniel
l’aplomb d’Axel Paulsen, le roi du Patin, habitué à donner des
séances d’adresse sous les regards admiratifs d’une galerie
d’amateurs.
Daniel préfère aller serrer la main au jeune Édouard, un neveu
de la maison, qui peut avoir dans les douze ans. Car Daniel est un
bon jeune homme, qui fait volontiers la causette avec les petits
garçons dédaignés. Il demande au jeune Édouard dans quelle
classe il est, quelles sont ses places dans les différentes branches,
et si son professeur est un chic type.
Puis Daniel aperçut et considéra en silence les deux modèles
qu’il s’était proposés, André Bardot et Lucien Bayonne, deux
garçons de vingt-cinq ans, qui dansaient avec une aisance
incomparable et qui parlaient aux femmes avec une surprenante
facilité. Daniel, qui les connaissait depuis longtemps, ne trouvait
d’ordinaire d’autre ressource que de leur parler sournoisement de
ses études de droit ; car ils n’avaient pas fait leurs humanités.
Leurs habits de soirée étaient sans reproche ; ils dégageaient
bien l’encolure. Bayonne avait un collet de velours et un gilet de
cachemire blanc. Leurs devants de chemises, qu’on portait alors
empesés, semblaient si raides que Daniel n’était pas loin d’y voir un
sortilège. Dans le trajet de chez lui au bal, son plastron s’était déjà
gondolé.
Alors, délibérément, il lâcha toute prétention au dandysme, et prit
un air exagéré de rêveur, détaché des vaines préoccupations de
costume, habillé proprement, mais sans élégance voulue.
On ne peut pas faire les deux choses à la fois : penser aux
grands problèmes de la vie et de l’univers, et valser.
Il s’installa dans un coin de l’antichambre et attendit des
personnes de connaissance. D’ailleurs, dès qu’il en voyait entrer
une, il se hâtait de détourner les yeux, et paraissait absorbé dans
l’admiration d’un tableau ou d’un objet d’art.
Pourtant il se permit de regarder les Capitan, car il n’avait aucune
relation avec eux et n’était pas obligé d’aller leur dire bonjour. Mme
Capitan, la femme du coulissier, était une beauté célèbre, une forte
brune, aux yeux familiers et indulgents. Daniel avait toujours regardé
ces yeux-là avec des yeux troublés, et ne pouvait concevoir
qu’Eugène Capitan perdît son temps à aller dans le monde, au lieu
de rester chez lui à se livrer aux plaisirs de l’amour, en compagnie
d’une si admirable dame. Il avait beau se dire : « Ils viennent de
s’embrasser tout à l’heure et c’est pour cela qu’ils sont en retard au
bal », il n’admettait pas qu’on pût se rassasier de ces joies-là. Ce
jeune homme chaste et extravagant n’admettait que les plaisirs
éternels.
Un jeune sous-officier de dragons, préposé à la garde d’une
Andromède anémique, s’approche inopinément de Daniel et lui
demande :
— Voulez-vous faire un quatrième aux lanciers ?
Daniel accepte. C’est la seule danse où il se risque, une danse
calme et compliquée. Il met un certain orgueil à se reconnaître dans
les figures. Pour lui, les lanciers sont à la valse ce qu’un jeu savant
et méritoire est à un jeu de hasard.
Il se met en quête d’une danseuse et aperçoit une petite femme
courte, à la peau rouge, et dont la tête est légèrement enfoncée
dans les épaules. Elle n’a pas encore dansé de la soirée. Il l’invite
pour prouver son bon cœur.
Puis commence ce jeu de révérences très graves et de passades
méthodiques où revivent les élégances cérémonieuses des siècles
passés, et qu’exécutent en cadence avec leurs danseuses les trois
partenaires de Daniel, une sorte de gnome barbu à binocle, le
maréchal des logis de dragons et un gros polytechnicien en sueur.
Le polytechnicien se trompe dans les figures, malgré sa force
évidente en mathématiques. Daniel le redresse poliment. Lui-même
exécute ces figures avec une nonchalance affectée, l’air du grand
penseur dérangé dans ses hautes pensées, et qui est venu donner
un coup de main au quadrille pour rendre service.
En entrant au bal, et en apercevant le buffet, Daniel s’était dit : Je
vais étonner le monde par ma sobriété. (A ce moment-là, il n’avait
encore ni faim ni soif. Et puis il se méfiait du café glacé et du
champagne, à cause de ses intestins délicats.)
Le quadrille fini, il conduisit au buffet sa danseuse, persistant
dans son rôle de généreux chevalier et lui offrant à l’envi toutes ces
consommations gratuites, en se donnant ainsi une contenance pour
s’en régaler lui-même. Mais le destin lui était néfaste. Précisément, à
l’instant où il se trouve là, arrive Mme Voraud. Daniel se sent rougir,
comme si elle devait penser, en le voyant, qu’il n’a pas quitté de
toute la soirée la table aux consommations. Pour comble de
malheur, il éprouve mille peines à donner la main à cette dame, car il
se trouve tenir à la fois un sandwich et un verre de champagne. Il
finit par lui tendre des doigts un peu mouillés et reste affligé, pendant
une demi-heure, à l’idée que sans doute il lui a taché son gant.
III
COUP DE FOUDRE

Daniel était venu à ce bal avec l’idée qu’une chose définitive allait
se passer dans sa vie. Il ne se déplaçait d’ailleurs qu’à cette
condition.
Ou bien il allait être prié de réciter des vers et les réciterait de
telle façon qu’il enfiévrerait la foule.
Ou bien il rencontrerait l’âme sœur, l’élue à qui il appartiendrait
pour la vie et qui lui vouerait un grand amour.
A vrai dire, cette femme-là n’était pas une inconnue. Elle était
toujours déterminée, mais ce n’était pas toujours la même. Elle
changeait selon les circonstances. Il y avait une sorte de roulement
sur une liste de trois jeunes personnes.
Ces trois demoiselles étaient Berthe Voraud, une blonde svelte,
d’un joli visage un peu boudeur ; Romana Stuttgard, une grande
brune ; enfin, la petite Saül, maigre et un peu aigre. Daniel avait joué
avec elle étant tout petit, et ça l’inquiétait un peu et le troublait de
penser que cette petite fille était devenue une femme.
D’ailleurs il n’avait jamais dit un mot révélateur de ses pensées à
aucune de ces trois élues, qui lui composaient une sorte de harem
imaginaire. Aucune d’elles ne lui avait fourni la moindre marque
d’inclination.

You might also like