Course materials for Michael Dunn's course at the 2018 LOT Winter School
Exercise 1: Bayesian Phylogenetic Inference with MrBayes
Datafile: Aslian28.nex
Exercise 2: Constraints and multiple partitions
Datafiles: new-britain-swadesh.nex, new-britain-structural.nex
Exercise 3: Ancestral State Reconstruction and the DISCRETE test
Datafiles: Aslian28+structure1.nex, Aslian28.nex.trees, Aslian-complexity.txt, Aslian-semantics.txt
The software carpentry version of this is nice to read:
Windows computers have something called “Powershell”. According to the wikipedia documentation, all the basic unix commands are aliases to equivalent Powershell commands, so the following instructions should work on Windows too (although I wouldn’t expect the option flags to be the same).
The description below is stolen from http://mally.stanford.edu/~sr/computing/basic-unix.html. I’ve chopped out the bits I don’t think you need, and added a couple of other things. Things written like this
are what you should type into the Terminal window. Things in ALL CAPS
should be substituted for actual file/directory names, etc. Unix commands are all case-sensitive: myFile.txt
is not the same things as MYFILE.txt
or myfile.TXT
, etc.
Directories (also called “folders” on a Macintosh), are used to group files together in a hierarchical structure. These are the same directories you can see using the MaxOSX Finder.
cd DIRNAME
— change directory. You basically ‘go’ to another directory, and you will see the files in that directory when you do ls
.
cd
without arguments.cd ..
will get you one level up from your current position. ~
in a path means ‘home directory’pwd
— tells you where you currently are.
mkdir DIRNAME
— make a new directory called DIRNAME
Directories are separated by a forward slash (/
); Two dots (..
) means the next directory up and ~
means the home directory. For example, cd ../../..
moves you three directories up in the hierarchy; cd ../Temp
moves you to a sister directory called Temp
; cd ~/Temp
moves you to the Temp
directory under the home directory. Some examples:
# go to a directory
cd Documents/Phylogenetics/Exercises/Lecture_1
# go up one level, and then down into directory Lecture_2
cd ../Lecture_2
# go straight to Documents directory in home
cd ~/Documents
# you could also do this in two steps (remember 'cd' without
# arguments takes you home)
cd
cd Documents
Files
ls
— lists your files
ls -l
— lists your files in ‘long format’, which contains lots of useful information, e.g. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified.
ls -a
— lists all files, including the ones whose filenames begin in a dot, which you do not always want to see.
There are many more options, for example to list files by size, by date, recursively etc. The command man ls
takes you to a document that lists these all. Try ls --color=auto
, ls -F
, ls -atrl
mv FILENAME1 FILENAME2
— moves a file to a new name (if FILENAME2
is already a file, or doesn’t exist).
mv FILENAME DIRNAME
— moves a file into a directory (if DIRNAME
is a directory)
mv FILENAME1 FILENAME2 DIRNAME
— moves a series of files into a directory (if DIRNAME is a directory)
cp FILENAME1 FILENAME2
— copies a file, leaving the original in place.
rm FILENAME
— removes a file. It is wise to use the option rm -i
, which will ask you for confirmation before actually deleting anything. You can make this your default by making an alias in your .cshrc/.bashrc file.
rmdir DIRNAME
— removes a directory, providing it is empty (use rm
to remove all the files inside the directory first).
rm -r DIRNAME
— remove DIRNAME
and everything inside it. Use with care!
File Compression
gzip FILENAME
— compresses files, so that they take up much less space. The resultant file is called FILENAME.gz
. Usually text files compress to about half their original size, but it depends very much on the size of the file and the nature of the contents. Gzip produces files with the ending ‘.gz’ appended to the original filename. Some clever text editors can read (and write) files directly in gzipped format.
gunzip FILENAME.gz
— uncompresses files compressed by gzip.
You can use bzip2
and bunzip2
in exactly the same way as gzip
; bzip2
has a better compression ratio than gzip
. Files compressed with bzip2
have the ending ‘.bz2’.
You can also use zip
and unzip
in almost the same way. The following makes a compressed archive containing the file FILENAME
:
zip archive.zip FILENAME
Windows people are more likely to know what to do with zip files. An advantage of zip
is that it can be used directly on a group of files::
zip archive.zip FILE1 FILE2 FILE3
To run gzip
or bzip2
on a group of files you use the tar
tool with the following options:
# substitute 'archive' with your own name for the compressed bundle,
# and substitute FILE1 etc with a list of files
tar cvfz archive.tar.gz FILE1 FILE2 FILE3 # gzip compression
# or
tar cvfj archive.tar.bz2 FILE1 file2 file3 # bzip2 compression
To decompress:
tar xvfz archive.tar.gz FILE1 FILE2 FILE3 # gzip compression
# or
tar xvfj archive.tar.bz2 FILE1 FILE2 FILE3 # bzip2 compression
open
which I find very useful. open FILENAME
opens a file using whatever program is associated with that file. open DIRNAME
opens a directory in the Finder. A useful trick: open .
opens the current directory.man PROGNAME
displays the manual page for each of these utilities, explaining all the options, Try man ls
, man cp
, etc…Convenience
chmod a+x
below), names of directories, and names of files. So if you wanted to run the commandline:
cd /Volumes/eoss/Data\ collection/Northern\ Baluchi
then all you would need to type is (“<TAB>
” indicates the tab key):
cd /Vo<TAB>eo<TAB>Da<TAB>No<TAB>
When you get the hang of this you will find it very fast — most likely faster than using a graphical user interface such as the finder.
edit FILENAME
will open a file in TextWrangler, and twdiff FILENAME1 FILENAME2
will open two files side by side and highlight the differences between them.Inconvenience
Shells assume that the names of functions, files, directories, etc are delimited by white space. If there is white space in the file name then you have to indicate this to the shell specificially. Here’s an example of the problem. Assume I have a file called “my file.txt” and I want to rename it to “my_file.txt”:
$ ls
my file.txt
$ mv my file.txt my_file.txt
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
This failed because the shell understands this command to be referring to a file called my
and a file called file.txt
. There are two ways to work around this, either you can put the name in quotes, e.g.:
$ mv "my file.txt" my_file.txt
or you can put a bash slash (\
) before the space to indicate that it should be interpreted as a character rather than as a delimiter, e.g.:
$ mv my\ file.txt my_file.txt
Tab completion is clever and knows about literal spaces, so if you type mv my<tab>
in the example above it will fill out the full file name with back slashes.