Table Of ContentCalculator Programming
for
Chemistry and the Life Sciences
FRANK H. CLARKE
Pharmaceuticals Division
CIBA -GEIGY Corporation
Ardsley, New York
1981
ACADEMIC PRESS
A Subsidiary of Harcourt Brace Jovanovich, Publishers
New York London Toronto Sydney San Francisco
COPYRIGHT © 1981, BY ACADEMIC PRESS, INC.
ALL RIGHTS RESERVED.
NO PART OF THIS PUBLICATION MAY BE REPRODUCED OR
TRANSMITTED IN ANY FORM OR BY ANY MEANS, ELECTRONIC
OR MECHANICAL, INCLUDING PHOTOCOPY, RECORDING, OR ANY
INFORMATION STORAGE AND RETRIEVAL SYSTEM, WITHOUT
PERMISSION IN WRITING FROM THE PUBLISHER.
ACADEMIC PRESS, INC.
Ill Fifth Avenue, New York, New York 10003
United Kingdom Edition published by
ACADEMIC PRESS, INC. (LONDON) LTD.
24/28 Oval Road, London NW1 7DX
Library of Congress Cataloging in Publication Data
Clarke, Frank H.
Calculator programming for chemistry and the life
sciences.
Includes bibliographical references and index.
1. Chemistry, Pharmaceutical—Computer programs.
2. Biological research—Computer programs.
3. Programmable calculators. I. Title.
RS418.C55 542'.8 81-15046
ISBN 0-12-175320-4 AACR2
PRINTED IN THE UNITED STATES OF AMERICA
81 82 83 84 9 8 7 6 5 4 3 2 1
Preface
This book illustrates the power of the programmable calculator as a
tool that provides new dimensions to scientific research. Calculations that
once were tedious are now easily performed and provide the scientist with
a freedom to explore areas he would not otherwise have considered. It is
not possible to be complete in a book of this nature. It is enough if the
illustrations with specific and detailed examples encourage others to ex
periment with such fascinating and challenging problems.
Many people helped to make this book possible. I want to express my
appreciation especially to Roland Winter of CIBA-GEIGY Plastics and
Additives Division for introducing me to calculator programming in the
first place; to Professor Jon Clardy of Cornell University for providing me
with Eq. (2-4) for the conversion of x-ray crystallographic coordinates to
orthogonal coordinates; to Dennis Artman of CIBA-GEIGY Analytical
Research for helpful discussions of potentiometric titrations; to Murray
Selwyn of CIBA-GEIGY Pharmaceuticals Division for Eqs. (3-13) and
(3-14) for the confidence intervals of the parameters derived by nonlinear
regression; to Barry Ritter, formerly of CIBA-GEIGY, who worked with
me on early design of the statistics programs, and to John Belanger and
Daniel Ben-David who worked with me to perform the potentiometric
titrations. I am especially grateful to James Henkel, of the University of
Connecticut School of Pharmacy who demonstrated that these programs
can be written in Reverse Polish Notation by providing equivalent pro
grams for Chapter 3. My appreciation is also expressed to Mrs. Dorothy
Vivian of the Chemistry Division, CIBA-GEIGY Pharmaceuticals, for
typing and retyping the manuscript.
Frank H. Clarke
vu
Introduction
The pocket calculator enables chemists and biologists to solve prob
lems that once required computer assistance [1,2]. In fact, the calculator
provides approaches to experimental design and data interpretation that
otherwise would not be available to the average student or laboratory
scientist. It is the purpose of this book to illustrate with specific, detailed
examples this new capacity for research. The examples selected fall into
three main categories: molecular shapes, potentiometric titrations, and
regression analysis. The first and last of these usually involve computers
but the calculator enables the scientist to explore their potential on his
own. Calculators are now used in acid-base titrations [2], and new meth
odology has been provided with computers (see references in Chapter 3),
which is now available to calculator users as well. A convenient method is
provided thereby for the determination of partition coefficients that may
aid research in the life sciences.
The programs presented in this book are practical and will be useful
for students and scientists with no experience in the use of computers.
They are illustrated with specific examples and the instructions are simple
and may be used directly. However, the design of the programs is de
scribed in detail with the help of decision maps and program notes. Thus,
the reader is encouraged to change the programs to suit a particular need
or adapt them to meet the requirements of a different calculator.
The programs in this book make full use of the Texas Instruments TI-59
programmable calculator and the PCIOOA printer attachment. The owner
of a Texas Instruments TI-59 programmable calculator [3] or of a Hewlett-
Packard HP-41C [4] will find that the corresponding instruction manual
fully explains the elements of calculator programming including the use of
decision maps. Some of the programs can be used without the printer but
most of them are so complicated that the printer is required to use them to
their best advantage.
1
2 INTRODUCTION
Three of the programs of Chapter 3 have been transcribed for use with
Hewlett-Packard calculators that use Reverse Polish Notation (RPN).
Two of these are for the HP-41C and one is for the HP-67 calculator. The
programs of Chapters 2 and 4 use the Master Library Module of the TI-59
calculator to find the determinant and inverse of a matrix. Corresponding
programs for the HP-41C calculator may require the Matrix Operations
program of the Mathematics Application Pac (or its equivalent).
The programs are written with the laboratory scientist in mind. Data
input is often requested by the printer so that the user does not need to
remember the order of entry. The printer request becomes a label and
when the calculated results are also labeled by the printer, the printout is a
record for entry into the laboratory notebook. Many of the programs are
complex—one uses 79 data storage memories, most of them several times
over during a calculation. The iterative programs may require 30 min or so
to reach an answer that is finally printed. In this case, there are built-in
safeguards, such as the flashing of interim results that assure the user that
a solution to the problem is being approached.
Chapter 1 presents two smaller programs on percentage composition
and molecular formula calculations. The former is a simple calculation,
but the program allows easy access to the percentage composition of
mixtures, which is especially useful for salts and solvates. The second
uses carbon, hydrogen, and nitrogen analyses to provide quickly an empir
ical formula.
A few notes will provide a background for the other programs of the
book that are designed to assist in the cooperative interaction of chemistry
and biology. Nowhere is this interaction more challenging than in the
study of ligand-receptor (or drug-receptor) interactions. An excellent dis
cussion of computer applications in this area is provided by P. Gund, J. B.
Rhodes, and G. M. Smith in a recent article entitled, "Three-Dimensional
Molecular Modeling and Drug Design" [5]. The authors describe the
enormous capacity of the computerized display console to provide the
researcher with a three-dimensional picture of molecular shapes and the
interactions of bioorganic molecules. Although the calculator is slow and
cumbersome compared to the computer, it can be used to advantage in
conjunction with a set of molecular model components [6]. The student,
working at his own desk, can duplicate much of what the computer dis
play accomplishes, and there is the additional satisfaction of working with
physical models. The programs of Chapter 2 illustrate this application
with practical examples. The mathematical background is provided for
the calculations that are made possible by the capacity of the Master
Library Module to perform matrix calculations.
A drug reaches its receptor by crossing biological membranes. This
INTRODUCTION 3
transport involves a partitioning, sometimes repeatedly, of the drug be
tween aqueous and lipid phases. A recent review entitled, "Lipophilicity
and Drug Activity," by Kubinyi [7] describes and interprets the partition
coefficient, which is used in the study of this phenomenon. Hansch and
Leo have provided a tabulation of partition coefficients [8], and Hansch
described their usefulness in quantitative approaches to pharmacological
structure-activity relationships (QSAR) [9]. Calculator techniques for find
ing the endpoint of a potentiometric titration are described in Chapter 3.
The reader is then shown how titrations in the presence and absence of
octanol provide a convenient method for determining partition coeffi
cients. A measure of the accuracy of the results is provided by one of the
programs that calculates the titration curve with and without octanol. The
equations involved are derived for the reader and the power of the intera-
tive method to solve nonlinear equations is illustrated.
The partition coefficient is only one of a number of physical properties
that may be correlated with biological activity [9]. The use of regression
analysis in such correlations has been critically reviewed by Martin in
4'Quantitative Drug Design" [10]. The study of QSAR involves chemists
and biologists working in close collaboration with computer specialists.
Regression analysis can be used to correlate other phenomena as well
[11]. Programmable calculators are provided with a built-in capacity to
perform simple correlations and a statistics module provides additional
capacity. However, in Chapter 4 the reader is taken much further. Pro
grams are provided for regression analyses involving up to and including
five variables. Regression coefficients are provided together with their
95% confidence limits. The programs calculate the Student's/ value. The
correlation coefficient and the/7 value are also obtained; provision is made
for the addition and subtraction of data points. A special feature is the
provision of converting trivariate data to any of three combinations of
bivariate data. A program is also provided for solving the bilinear equation
of Kubinyi [7].
These programs in no way diminish our dependence on the computer
specialist, but they do provide the scientist with a tool to look critically at
his own data, to study it in various ways, and to have a much better
understanding of how the computer specialist can help.
The reader will appreciate that the programs described in this book are
particular ones used by the author in his own research. No attempt is
made to cover the wide range of practical problems that can be solved
with the calculator. Barnes and Waring in their recent book, ς'Pocket
Programmable Calculators in Biochemistry" [2], provide a wide variety of
solutions to such problems. They also discuss the Hewlett-Packard HP-
67/97 calculator and the compatibility of the HP-41C calculator, which has
4 INTRODUCTION
increased capacity. Comparison of the three programs in Chapter 3, which
are provided in both algebraic and Reverse Polish Notation, will help the
user of the HP-41C calculator to adapt the other programs to his own
requirements. Some program steps may be confusing to a Hewlett-
Packard user. Sequences such as RCL 01 -r (+/- + RCL 02) = which
occur in calculating/?^ in the programs of Chapter 3 save one program
step. They should be changed to RCL 01 + (RCL 02 - RCL 01) = be
fore being transcribed into reverse Polish notation for the Hewlett-
Packard calculator. Programs in Chapters 2 and 4, which use the Master
Library Module for matrix calculations, conserve program space by in
serting pointers in the program rather than calling on the module to do so.
The memory locations are selected to correspond to the requirements of
the Master Library Module. For these details the TI Programmable 58/59
Master Library Instruction Manual should be consulted.
The book is designed for easy use. Programs are listed together with
instructions and each program is illustrated with examples. The mathe
matical background to the programs is provided. For those interested in
program design, there are decision maps to assist in following the pro
grams. Tables of register contents and labels are provided and, in addition
to a general description of program design, there are detailed notes ac
companying each program. Diagrams and figures are used liberally to help
with the explanations. Finally, each chapter (except Chapter 1) has its
own list of references to the original literature.
REFERENCES
1. B. Clare, Calculated freedom—how you can dispense with the mainframe computer.
Chem. Br. 16, 249, 1980.
2. J. E. Barnes and A. J. Waring, "Pocket Programmable Calculators in Biochemistry."
Wiley, New York, 1980.
3. "Personal Programming," TI Programmable 58/59 Owner's Manual, Texas Instru
ments, Inc., Dallas, Texas, 1977.
4. "Owner's Handbook and Programming Guide, HP-41C," Hewlett-Packard Company,
Corvallis, Oregon, 1979.
5. P. Gund, J. D. Androse, J. B. Rhodes, and G. M. Smith, Three-dimensional molecular
modeling and drug design. Science 208, 1425, 1980.
6. F. H. Clarke, H. Jaggi, and R. A. Lovell, Conformation of 2,9-dimethyl-3'-hydroxy-5-
phenyl-6,7-benzomorphan and its relation to other analgetics and enkephalin. J. Med.
Chem. 21, 600, 1978.
7. H. Kubinyi, Lipophilicity and drug activity. In "Progress in Drug Research" (E.
Jucker, ed.), p. 97. Birkhäuser, Basel, 1979.
8. C. Hansch and A. Leo, "Substituent Constants for Correlation Analysis in Chemistry
and Biology." Wiley, New York, 1979.
INTRODUCTION 5
9. C. Hansch, Quantitative approaches to pharmacological structure-activity relation
ships. In "Structure-Activity Relationships" (C. J. Cavallito, ed.), p. 75. Pergamon,
New York, 1973.
10. Y. C. Martin, "Quantitative Drug Design." Marcel Dekker, New York, 1978.
11. N. B. Chapman and J. Shorter, "Correlation Analysis in Chemistry." Plenum, New
York, 1978.
CHAPTER 1
Molecular Formulas
I. Introduction 6
A. Program 11, Percentage Composition 6
B. Program 12, Empirical Formula 7
II. Calculations 7
A. Program 11, Percentage Composition 7
B. Program 12, Empirical Formula 8
III. Examples 9
A. Percentage Composition 9
B. Empirical Formula 9
IV. Instructions 12
A. Program 11, Percentage Composition 12
B. Program 12, Empirical Formula 13
V. Design 13
A. Program 11, Registers and Flags 13
B. Program 11, Labels 14
C. Program 12, Registers and Flags 15
D. Program 12, Labels 16
VI. Programs 16
A. Program Listings 16
B. Program Notes 21
I. INTRODUCTION
A. Program 11, Percentage Composition
The programmable calculator offers advantages even for such seem
ingly routine calculations as those of molecular weight and percentage
composition. Program 11 (percentage composition) illustrates this and the
great versatility that is achieved with personal programming. The calcula
tions themselves are simple and the program is not complicated. Never-
6
II. CALCULATIONS 7
theless, the results are immediately useful to all organic chemists who
need to calculate molecular weights or percentage composition.
Program 11 allows for the inclusion of a second component in any
proportion that may be an acid involved in salt formation, a solvent of
crystallization, or the second component of a mixture. The steps are short
ened when the solvent is water. A third component may easily be added.
The program may be modified slightly and used without a printer. How
ever, it was designed for use with a printer and rapidly provides a printout
of the formula calculated and the carbon, hydrogen, and nitrogen analyses
to two decimal places. The molecular weight is also printed and the input
and results are labeled. When water is a solvent of crystallization, the
percentage of water is provided.
B. Program 12, Empirical Formula
When the results of the carbon, hydrogen, and nitrogen analyses do
not agree with the calculated percentage composition, it is often possible
to show that the analysis is probably "off" because of the incomplete
removal of a solvent of crystallization. Program 11 is very useful for
examining this possibility. However, it may be that the compound ana
lyzed is not what is anticipated or it may be that the empirical formula is
not known at all. It is a simple matter of arithmetic to calculate an empiri
cal formula that will give the computed percentage composition (or rea
sonably close values), and the empirical formula calculated in this way is
often useful at least in eliminating unlikely possibilities for the formula of
the unknown compound. Although the usefulness of such a calculation
depends on the precision of the experimental analysis and the purity of the
sample analyzed, program 12 (empirical formula) provides an empirical
formula in C, H, N, and sometimes O as well for any set of carbon,
hydrogen, and nitrogen analyses. It also provides the exact atomic ratios
that assist in determining how precisely the analysis fits the derived
formula.
II. CALCULATIONS
A. Program 11, Percentage Composition
For program 11, the percentage of an element present in a compound is
provided by Eq (1-1):
_ _. Weight sum of the element
% El emen4t = *rz-.: :——r-r- x 11Λ0Λ0 (Λ(1 1-Λ1 )
Molecular weight