Part 1: Computers

Computers abound in the sciences and not knowing how to use them puts one at a great disadvantage these days. It is therefore important for you to develop at least a working knowledge if not an 'intuitive' sense of how things work with these machines. There will always be little problems that will confront you and it would be of great help to you and others to be able to at least attempt to solve them on your own. Isn't that why you are at a university in the first place ... to learn how to problem solve on your own?

Computers play a two major roles in modern nmr spectrometers. First, they are used to program and control the hardware. In other words, to acquire the spectrum the digitizer must be set to function at the appropriate rate, the interpulse delay must be set according to the user's wishes and a number of other hardware details must be attended to in order for a successful data acquisition to occur. These are generally set by the computer. One sets up a parameter table either by manually inputting values or by reading a saved parameter file into the table. When the acquire command is issued then the computer sets up and initializes the hardware and starts the acquisition. The second use of the computer is to manipulate the data in various ways, the most obvious being to Fourier transform from the time domain to the frequency domain. Here, as with the control of the spectrometer hardware, one can set up a table of values that will in some way control the data manipulation. The same applies to the plotting functions.

The Unix Operating System

Many years ago when computer programmers were first programming their machines it was recognized that there were many operations that were relatively common to all programs such as data output to a printer, input from a keyboard or punch card reader. It was decided that these operations should be separated from the application programs and put into a separate program that all application programs could call upon when needed to perform very basic functions. This would save the effort of writing these routines separately for each program and was a sort of 'core' program that ran on the machine and which loaded application program and provide services to them. This is now known as the operating system. There have been many systems developed over the years ... TOPS10, TOPS20, VMS, MULTICS, CP/M, MSDOS, MacOS, WINDOWS 95/98 and UNIX, to name a few.

Many nmr spectrometers are controlled by a computer running the unix operating system. This is a mature (25 years), robust, multitasking and networking operating system that is capable of performing almost any task that the user can think of. Under unix, the philosophy is that there is a central 'kernel' that does the very low level work ... that is, it deals directly with the hardware in the computer, serial input/output chips, printer circuitry and any of the other miscellaneous things that one might find inside the machine. Another important task of the kernel is to take care of file organization on the hard disk. It also takes care of security in the sense that a user's priviledges to run or not to run a program or to view or not view a file are checked here. The kernel also keeps track of all of the processes that are running concurrently. Under unix there are generally, at a minimum, several process running at once and frequently dozens. These are multitasked, that is, they share cpu time amongst each other and may have higher or lower cpu priority depending on the task being performed. On top of the kernel are the user programs. Generally, one types the name of the user program at the prompt (more on the prompt later) and the program runs (if you have permission to run it!). Some examples of common programs are:

ls - list files in a directory

rm - remove (delete) files or directories

df - print disk space usage

lp or lpr - print a file

grep - find an occurrence of a word in a file

wc - count words or lines in a file

cd - change directory

mv - move a file

ps - print task queue

The great utility of these programs is that they will compile and run on any unix machine. You will find these programs on almost all unix computers. If you know how to use it on one machine then you will know how to use it on the other. There is also the ability built into unix to 'pipe' program outputs together to build a large 'super' program. Using the '|' character one can feed the output of one program into the input of the next. For example, if I wish to list all of the files in a directory with the characters 'brown' in them I would type 'ls | grep brown'. This would have the effect of generating a list of all files in the current directory and then sifting through them for any that have the characters 'brown' in them and printing only those that satisfy this criterium.

Unix File Structure

The file structure of unix is built around the directory structure. There is a root directory, '/', which can be viewed as the top of an inverted treelike directory strucure. Below the root directory are various subdirectories. On the Bruker spectrometer some of these are:

Figure 1.

Each of these is considered a subdirectory which contains its own files, somewhat like a filing cabinet that holds file folders which individually hold files. The cabinet is the entire directory structure, the file folders are the subdirectories and the files are the files. In fact, some operating systems, notably the MacIntosh, uses the folders analogy to represent subdirectories. The newer versions of Microsoft Windows does the same thing.

To use the unix computer it is necessary to login with a username and (usually) a password. Most users will have priviledges only withing their special areas or group areas. Files and directories are arranged with user priviledges. For example, a partial listing of the bin directory shows us:

total 4231

drwxr-xr-x 18 root root 512 Jan 15 09:41 ..

drwxr-xr-x 2 bin bin 1648 Sep 5 1997 .

-rwxr-x--x 1 root root 291120 May 20 1997 bash

-rwxr-xr-x 1 root root 45208 Jun 24 1994 tar

-rwxrwxr-x 1 root root 66960 Jan 11 1994 tar_new

-rwxr-xr-x 1 bin bin 21924 Dec 6 1993 ls

-rwxr-xr-x 1 root bin 18280 Dec 6 1993 du

-rwxr-xr-x 1 root root 22464 Dec 6 1993 dd

-rwxr-xr-x 1 bin bin 19440 Dec 6 1993 tail

-rwxr-xr-x 1 bin bin 12732 Feb 4 1993 wc

-r-sr-sr-x 1 root root 30400 Jun 9 1992 ps

-rwxrwxr-x 3 bin bin 18944 Oct 31 1991 ln

-rwxrwxr-x 3 bin bin 18944 Oct 31 1991 mv

-rwxrwxr-x 3 bin bin 18944 Oct 31 1991 cp

Table 1.

Most of the files have the characters '-rwxr-xr-x' in the left column. These are the permission characters, grouped in threes. 'rwx' means read/write/execute and the 'd' in the first couple of lines refers to the files being subdirectories. Read means that the file can be read into, for example, a word processor or text editor. Write means that the file may be altered in some fashion, including deleted. Execute means that if the file is an executable program then it will be executed when the user types the filename at the prompt. The leftmost column of three is the user permissions, the middle column is the group permissions and the rightmost is the world permissions. In the case of the 'ls' program the permissions are '-rwxr-xr-x'. This means that the owner (root) has read, write and execute permission for this file. The group (bin) permission is r-x which is read and execute permission. Anyone belonging to the group 'bin' would be able to read and/or execute this file. Similarly, world (anyone) permissions are r-w or read-execute. This means that anyone at all has read-execute permission. There exists on all unix machines a very special user called the 'superuser' with username 'root'. This is normally the administrator of the computer system and has 'super' priviledges that allow her/him to anything necessary to keep the system operating, including erasing any files, whether or not they belong to him/her. The two columns with 'root' and 'bin' in them are the owner and group designations for the files, respectively. Therefore, the file 'du' is owned by root and belongs to the group bin. The file is executable by root and bin and also world (anyone)

Unix can be used with either a command line interface or a windowing interface. The command line system is similar to the msdos interface in which a text mode is presented to the user at login. The unix windowing system, called the X11 windowing system, is the unix version of the MacIntosh or Win98 windowing system. Here you might be presented, after login in, with a graphics screen having a few icons on it. To issue any commands you will need a 'shell', which is simply the program that takes your commands and passes them to the kernel to be interpreted and acted upon. If you are using a command line interface you will be presented with the shell prompt immediately after loggin in. In either case, when you start a shell you are presented with the system 'prompt', which is simply a visual cue to tell you that the computer is waiting for you to begin typing. You then type the name of the program that you wish to run. Most simple unix commands are issued this way.

At login you are always placed in a default subdirectory, determined by the system administrator and given a shell. On the Bruker spectrometer this is usually something like /u/username:

Figure 2.

To switch to another subdirectory, perhaps your data directory, you would use the 'cd' command ... 'cd /u/data/username/nmr'. This would place you in your data directory and you could then use the ls command to list all of your data files. Actually, with the Bruker spectrometer, these would not be files but other subdirectories containing your spectral data. So, if the ls command showed something like:

ptlc1-cjb99-6

ptlc3-cjb101-6

ptlc3-cjb89-6

these are subdirectories containing the data for each of these samples ie.

Figure 3.

Remember that the /nmr directory is itself a subdirectory below the username from Figure 2. The directory '/u/data/username/nmr/ptlc1-cjb99-6' contains two subdirectories, '/1' and '/2'. One might be a proton spectrum and one a carbon-13 spectrum, perhaps. '/ptlc1-cjb99-6/1' contains the raw data in the form of the digitized fid and acquisition parameter files. Below this is the '/pdata' subdirectory which contains further subdirectories that contain the transformed data and plotting information. The directory architecture is complex and time consuming to learn and not particularly useful to the casual user but it is still useful to know about its existence. It makes the Bruker data storage system easier to understand. If you look at Table 1. you will see two 'files' named '.' and '..'. These are special unix files that stand for 'here' and 'the above directory'. Therefore if you wanted to change directories to the one above you would simply type 'cd ../'.

Unix uses other special characters for various purposes. There are two 'wildcard' characters, '*' and '?'. Wildcard means that when these are used the operating system will substitute any characters for them. The '*' character is the multiple wildcard character and the '?' character is the single wildcard character. So, if you were to type 'ls' you might get an output looking like:

F4-cjb115-6

PTLC1-cjb99-6

jianhengs

paulos

ptlc1-cjb99-6

ptlc3-cjb101-6

ptlc3-cjb89-6

However, typing 'ls p*' would give any file beginning with 'p' (lowercase p, not uppercase ... unix is case sensitive) and matching any other characters after the 'p':

paulos:

4

ptlc1-cjb99-6:

1

ptlc3-cjb101-6:

1

2

ptlc3-cjb89-6:

1

2

Note that here, only the files starting with 'p' have been shown. Actually, in this case the 'files' are subdirectories and so the ls command shows us what is in the subdirectories as well as the name of the directory. There are many options available to the user for this and other commands. The 'man' command on the unix system will show a concise (sometimes very concise) summary of these options and their use. For ls you would type 'man ls' and get a description of all of the available options.

Other special characters are '/', '&', and '$'. These should not be used in file names! If you were to use the '/' character in a file name it would create an extra subdirectory somewhere in the Bruker directory hierarchy and the nmr program would not then be able to find your data! Also, unix has trouble deleting files with the characters '(', ')', '[', ']' and ''' in them. These files can be deleted but usually it requires that the superuser do so manually ... automated purge programs that delete files after a backup cannot deal with them. You are best to keep your file names to ones involving simple alphanumeric characters.

After logging in most users will immediately start the nmr program. On the Bruker this program is 'uxnmr' for the AMX spectrometer and 'xwinnmr' for the newer Avance spectrometers. The program will initialize and read its startup files and then present you with a graphical interface to the spectrometer. You will be able to acquire data, process it and plot it. The data will be stored in the previously mentioned subdirectories. When you are assigned a username you are also assigned to a group, usually the research group that you belong to. You will be able to read and alter anyone's files in your group but not other groups. This is a consequence of the permissions talked about earlier. Your files have user and group read/write/execute permissions but the world permissions are only read/execute.

Unix is extremely well suited to networking. This is probably because the modern network protocols were originally developed under unix and have had a long time to mature. There are many ways to interconnect unix computers to perform various tasks. For example, it is quite possible to have a program run on one machine and have its output appear on the screen of another, networked unix computer. Data transfer between machines is extremely easy and amenable to automation. Here in our labs, data backup is done from the AMX 300 spectrometer and the 500 MHz spectrometers to a PC runing Linux, a variant of the unix OS, by simply copying the entire subdirectory hierarchy of the Bruker file system between machines. Copying data from the spectrometer to an offline workstation is similarly easily done.

Spectrometer User Interfaces