Migrant Fish Walkthrough

Genomics in Ecology and Evolution · Session 1

The Migrant: a walkthrough

A guide to every stage of the hunt, for when you want to understand what you are doing or need a push. It runs next to the terminal and the field notebook.

Open on your phone
i

How to use this guide

Codes, hints and spoilers.

This guide walks you through the hunt one stage at a time. Use it next to the terminal (sandbox.bio) and the field notebook.

  • Stage 0 is open. Every other stage opens here when you type its Notebook code, printed at the top of that stage's CLUE.txt.
  • Each stage starts with the background you need, then hints that get more detailed one at a time. Open only as many as you need: the last hint is close to the answer.
  • Really stuck? Each stage ends with a Spoiler button. Hold it down for three seconds to see the answer and the full command. Use it to keep moving, then go back and understand why it works.
  • You never need to write awk or "regular expressions" from scratch. Every command is given: your job is to understand what it does and change the one part marked ___.
  • Your progress stays in this browser. Write your passwords on your answer sheet too: you need them to come back later.
↺

Coming back later

Your files vanish when the terminal tab closes. Here is how to pick up where you left off.

The terminal forgets your files when you close its tab. To carry on later:

cd ~
curl -O https://gee.pleiades-genomics.nl/hunt.zip
unzip hunt.zip
cd migrant-fish
bash unlock.sh 1 <password for stage 1>
bash unlock.sh 2 <password for stage 2>

Repeat bash unlock.sh N <password> for every stage you reached. The field notebook's Coming back later box builds these lines for you from the passwords you saved there. Stage 5 includes the filtered file from stage 4, so you do not need to redo stage 4.

?

Command glossary

Every command used in the hunt, with the R equivalent.
Where am I? pwd, ls, cd
pwd prints the folder you are in (like getwd()). ls lists what is there (list.files()). cd stage1 goes into a folder (setwd()); cd .. goes back up; cd ~/migrant-fish goes to the main folder from anywhere.
Look inside a file cat, head, less
cat file prints all of it. head -n 5 file prints the first 5 lines (head(x, 5)). less file lets you scroll; press q to quit.
Compressed files gzip -dc
A name ending in .gz is compressed. gzip -dc file.gz prints the unpacked text to the screen and leaves the file as it is.
The pipe |
Sends what one command prints into the next command, like |> in R. gzip -dc file.gz | head reads: unpack, then show the first lines.
Counting wc -l
Counts lines (length(x)).
Finding lines grep
grep 'word' file prints the lines that contain word (x[grepl("word", x)]). Add -c to count them, -v to keep the lines that do NOT match, -w to match whole words only, -A 3 to also print the 3 lines after each match.
Columns cut -f
cut -f 2,3 file keeps columns 2 and 3 of a tab-separated file (df[, c(2, 3)]).
Sorting sort -k
sort -k5,5nr sorts on column 5, as numbers (n), largest first (r), like df[order(-df[[5]]), ].
Small programs awk
awk reads a file line by line. A command looks like awk 'CONDITION {ACTION}' file: on every line where the condition is true, it does the action. $1, $2 ... are the columns, NR is the line number, -F'\t' says columns are separated by tabs. You will only ever change a number or a word in the awk commands given here.
Character sets [!-4]
Inside grep, square brackets mean "any ONE of these characters". [!-4] means any character from ! to 4 in the ASCII table. LC_ALL=C in front makes the computer use plain ASCII order.
Unlocking bash unlock.sh
bash unlock.sh 2 secret opens stage 2 with the password secret. Run it from the main folder (cd ~/migrant-fish first).
Saving a file to your laptop download
download filtered.vcf saves that file from the terminal to your computer.