Showing posts with label Haddock and Dunn (2010). Show all posts
Showing posts with label Haddock and Dunn (2010). Show all posts

Friday, October 28, 2011

"Shebang" lines in Haddock and Dunn 2010

I've noticed a few minor typos in Chapter 9 of Haddock and Dunn's Practical Computing for Biologists. As already noted on their errata, pg 151 has an extra space in the Shebang line.

The line appears as
#!/ usr/bin/env python

with a space between the "/" and "usr/"

It should be either
#! /usr/bin/env python

with a space between "!" and "/user"

or
#!/usr/bin/env python

With no spaces at all.

This is the first time I've had any problems with the code, making the book a breeze to work with.

Thursday, October 27, 2011

awk and sed

Two programs that are suppossed to be great for processing text are awk and sed. According to Haddock and Dunn's Practical Computing For Biologists (2010), the are similar to other general expression environments like the shell function grep, but they "are like programming languages" and provide "even more opportunities to perform complex tasks" (page 78).

Rocking the Shell: Basic Mac OS X Shell commands

I'm using Haddock and Dunn's excellent Practical Computing For Biologists to learn how to use the "shell" to access files on my Mac.

Here are the basic shell commands they discuss in Chapter 4. I'm only annotating those that don't have an analog in R, or that I don't remember from using the DOS prompt on my family's 386 desktop back in the '90s!

Directory/file information:
ls
ls -a
ls -l
ls -l -a
pwd

Navigation:
cd ..
exit

View files
cat
less -- view text files
man -- view "manuals"/help files

Directory/file manipulation
mkdir
rmdir
cp -- copying files
mv -- moving files
rm

Misc.
alias -- in your bash_profile; creates shortcuts
chmod -- "change mode"
cat .bash_profile -- print the contents of the file that set your shell settings
echo $PATH -- print the locations where the shell looks for programs to be located
which -- shows the location of a program or command is stored
curl --
"see URL"; download web data
wc
file -- character, word, and line count for a file
history

history | grep "search" -- "pipe" your command history over to grep and have grep locate commands with the term "search" in them.


Curl
-0 -- output operator


Modifiers to grep
-i -- ignore case of search term
-v -- "not" or "except"
-c
-E
-l
-n
-h