Skip to content

Commit

Permalink
Merge pull request #25 from jacquikeane/master
Browse files Browse the repository at this point in the history
Updates to basic and files section for the NGS Bioinformatics 2016 course
  • Loading branch information
martinghunt authored Sep 27, 2016
2 parents 6a02ea3 + d797a3d commit 20583ba
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 38 deletions.
28 changes: 14 additions & 14 deletions Notebooks/Unix/basic/basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It should say something like `cd /home/manager/Module_3_Linux_Scripting/basic`. Type whatever it said into your terminal and press `Enter`.\n",
"It should say something like `cd /home/manager/pathogen-informatics-training/Notebooks/Unix/basic`. Type whatever it said into your terminal and press `Enter`.\n",
"\n",
"Then continue through the course, entering any commands that you encounter into your terminal window. \n",
"\n",
Expand Down Expand Up @@ -106,7 +106,7 @@
"\n",
"The command `ls` stands for list. The `ls` command can be used to list the contents of a directory.\n",
"\n",
"To list the contents of your current working directory use:"
"To list the contents of your current working directory type:"
]
},
{
Expand All @@ -125,9 +125,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You should see that there are 6 items in this directory.\n",
"You should see that there are 4 items in this directory.\n",
"\n",
"To list the contents of a directory with extra information about the items use:"
"To list the contents of a directory with extra information about the items type:"
]
},
{
Expand Down Expand Up @@ -157,7 +157,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To list all contents of a directory including hidden files and directories use:"
"To list all contents of a directory including hidden files and directories type:"
]
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To list the contents of the directory called Pfalciparum with extra information use:"
"To list the contents of the directory called Pfalciparum with extra information type:"
]
},
{
Expand Down Expand Up @@ -273,7 +273,7 @@
"\n",
"The `cd` command will change the current working directory to another, in other words allow you to move up or down in the directory hierarchy. \n",
"\n",
"To move into the `Styphi` directory type the following. Note, you'll rmember this more easily if you type this into the terminal rather copying and pasting. Also remember that you can use tab completion to save typing all of it."
"To move into the `Styphi` directory type the following. Note, you'll remember this more easily if you type this into the terminal rather than copying and pasting. Also remember that you can use tab completion to save typing all of it."
]
},
{
Expand Down Expand Up @@ -369,7 +369,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Try moving between directories a few times. Can you get into the `Pfalciparum/` and back into `Styphi/`?"
"Try moving between directories a few times. Can you get into the `Pfalciparum/` and then back into `Styphi/`?"
]
},
{
Expand All @@ -387,7 +387,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To copy the file `Styphi.gff` to a new file called `StyphiCT18` use:"
"To copy the file `Styphi.gff` to a new file called `StyphiCT18.gff` type:"
]
},
{
Expand Down Expand Up @@ -429,7 +429,7 @@
"\n",
"The `mv` command will move a file from one location to another. This moves the file rather than copies it, therefore you end up with only one file rather than two. When using the command, the path or pathname is used to tell Unix where to find the file. You refer to files in other directories by using the list of hierarchical names separated by slashes. For example, the file called bases in the directory genome has the path genome/bases. If no path is specified, Unix assumes that the file is in the current working directory.\n",
"\n",
"To move the file `StyphiCT18.gff` from the current directory to the directory above use:"
"To move the file `StyphiCT18.gff` from the current directory to the directory above type:"
]
},
{
Expand All @@ -447,7 +447,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the `ls` command to check the contents of the current directory and the directory above to see that `Styphi.fa` has been moved."
"Use the `ls` command to check the contents of the current directory and the directory above to see that `StyphiCT18.gff` has been moved."
]
},
{
Expand Down Expand Up @@ -483,7 +483,7 @@
"\n",
"The `rm` command will delete a file permanently from your computer so take care!\n",
"\n",
"To remove the copy of the S. typhi genome file, called `StyphiCT18.gff` use:"
"To remove the copy of the S. typhi file, called `StyphiCT18.gff` type:"
]
},
{
Expand Down Expand Up @@ -560,7 +560,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To find all the subdirectories contained in the current directory use:"
"To find all the subdirectories contained in the current directory type:"
]
},
{
Expand Down Expand Up @@ -601,7 +601,7 @@
"\n",
"Many people panic when they are confronted with a Unix prompt! Don’t! All the commands you need to solve these exercises are provided above and don't be afraid to make a mistake. If you get lost ask a demonstrator. If you are a person skilled at Unix, be patient this is only a short exercise.\n",
"\n",
"To begin, open a terminal window and navigate to the `basic` directory in the `Unix_course` directory (remember use the Unix command `cd`) and then complete the exercise below.\n",
"To begin, open a terminal window and navigate to the `basic` directory in the `Unix` directory (remember use the Unix command `cd`) and then complete the exercise below.\n",
"\n",
"1. Use the `ls` command to show the contents of the `basic` directory.\n",
"2. How many files are there in the `Pfalciparum` directory?\n",
Expand Down
1 change: 1 addition & 0 deletions Notebooks/Unix/cheat_sheet/unix_cheat_sheet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"\n",
"## Pro tips\n",
"\n",
"* Use tab completion - it will save you time!\n",
"* Always have a quick look at files with `less` or `head` to double check their format\n",
"* Watch out for data in headers and that you don't accidentally grep some if you don't want them\n",
"* Watch out for spaces, especially if you're using awk; if in doubt, use `-F\"\\t\"`\n",
Expand Down
42 changes: 22 additions & 20 deletions Notebooks/Unix/files/files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"\n",
"A common task is to look at the contents of a file. This can be achieved using several different Unix commands, `less`, `head` and `tail`. Let us consider some examples.\n",
"\n",
"But first, change directory into the `Unix/files/` directory (hint: you might need to go up a few directories first using `cd ../..`). Check that the following commands give you a similar output:"
"But first, change directory into the `Unix/files/` directory (hint: you might need to go up a directories first using `cd ../..`). Check that the following commands give you a similar output:"
]
},
{
Expand All @@ -29,7 +29,7 @@
"source": [
"## less\n",
"\n",
"The `less` command displays the contents of a specified file one screen at a time. To test this command, open a terminal window on the computer, navigate to the directory `files` in the `Unix_course` directory and type the following command followed by the enter key:"
"The `less` command displays the contents of a specified file one screen at a time. To test this command type the following command followed by the enter key:"
]
},
{
Expand Down Expand Up @@ -63,7 +63,7 @@
"source": [
"The `head` command displays the first ten lines of a file.\n",
"\n",
"To look at the beginning of the fie `Styphi.gff` file use:"
"To look at the beginning of the fie `Styphi.gff` file type:"
]
},
{
Expand All @@ -83,7 +83,7 @@
"source": [
"The `tail` command displays the last ten lines of a file.\n",
"\n",
"To look at the end of `Styphi.gff` use:"
"To look at the end of `Styphi.gff` type:"
]
},
{
Expand Down Expand Up @@ -141,7 +141,7 @@
" \n",
" fin <press the TAB key>\n",
" \n",
"Although tab completion works on commands and filenames, unfortunatly it rarely works on options or other arguments.\n"
"Although tab completion works on commands and filenames, unfortunately it rarely works on options or other arguments.\n"
]
},
{
Expand All @@ -150,7 +150,7 @@
"source": [
"## Getting help man\n",
"\n",
"To obtain further information on any of the Unix commands introduced in this course you can use the `man` command. For example, to get a full description and examples of how to use the sort command use the following command in a terminal window.\n",
"To obtain further information on any of the Unix commands introduced in this course you can use the `man` command. For example, to get a full description and examples of how to use the `tail` command type the following command in a terminal window.\n",
"\n",
" man tail"
]
Expand All @@ -170,7 +170,7 @@
"\n",
"So far we've been running commands and outputting the results into the terminal. That's obviously useful but what if you want to save the results to another file?\n",
"\n",
"Run this:"
"Type this:"
]
},
{
Expand All @@ -188,7 +188,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It's likely that nothing will have happened. This is because the `>` character has _redirected_ the output of the `head` command. Instead of writing to the _standard output_ (your terminal) it sent the output into the file `first_Styphi_line.txt`. Note that tab completion works for `Styphi.gff` because it exists but doesn't work for `first_Styphi_line.txt` because it doesn't exist yet."
"It may look like nothing has happened. This is because the `>` character has _redirected_ the output of the `head` command. Instead of writing to the _standard output_ (your terminal) it sent the output into the file `first_Styphi_line.txt`. Note that tab completion works for `Styphi.gff` because it exists but doesn't work for `first_Styphi_line.txt` because it doesn't exist yet."
]
},
{
Expand All @@ -215,7 +215,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We don't need `first_Styphi_line.txt` any more so let's delete it"
"We don't need `first_Styphi_line.txt` any more so delete it by typing"
]
},
{
Expand All @@ -233,11 +233,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The `cat` command can also be given the names of multiple files, one after the other and it will just output both. You can use this and the `>` symbol to join files together.\n",
"The `cat` command can also be given the names of multiple files, one after the other and it will just output the contents of all files. The order in which the files are displayed is determined by the order in which they appear in the command line. You can use this concept and the `>` symbol to join files together into a single file.\n",
"\n",
"Having looked at the beginning and end of the `Styphi.gff` file you should notice that in the GFF file the annotation comes first, then the DNA sequence at the end. If you had two separate files containing the annotation and the DNA sequence, it is possible to concatenate or join the two together to make a single file like the `Styphi.gff` file you have just looked at. The command `cat` can be used to join two or more files into a single file. The order in which the files are joined is determined by the order in which they appear in the command line. \n",
"Having looked at the beginning and end of the `Styphi.gff` file you should notice that in the GFF file the annotation comes first, then the DNA sequence at the end. If you had two separate files containing the annotation and the DNA sequence, it is possible to concatenate or join the two together to make a single file like the `Styphi.gff` file you have just looked at.\n",
"\n",
"For example, we have two separate files, `Styphi.noseq.gff` and `Styphi.fa`, that contain the annotation and DNA sequence, respectively for the Salmonella typhi CT18 genome. To join together these files use:"
"For example, we have two separate files, `Styphi.noseq.gff` and `Styphi.fa`, that contain the annotation and DNA sequence, respectively for the Salmonella typhi CT18 genome. To join together these files type:"
]
},
{
Expand Down Expand Up @@ -317,7 +317,7 @@
"source": [
"Both give a similar answer. In the first example you tell `wc` the file that you want it to review (`Styphi.gff`) and pass the `-l` option to say that you're only interested in the number of lines.\n",
"\n",
"In the second example you use the `|` symbol which is also known as the _pipe_ symbol. This _pipes_ the output of `cat Styphi.gff` into the input of `wc -l`. This means that you can also use the same `wc` tool to count other things. For example to count the number of files that are listed by `ls` use:"
"In the second example you use the `|` symbol which is also known as the _pipe_ symbol. This _pipes_ the output of `cat Styphi.gff` into the input of `wc -l`. This means that you can also use the same `wc` tool to count other things. For example to count the number of files that are listed by `ls` type:"
]
},
{
Expand All @@ -335,7 +335,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can connect as many commands as you want. For example:"
"You can connect as many commands as you want. For example, type:"
]
},
{
Expand Down Expand Up @@ -364,9 +364,11 @@
"\n",
"The `sort` lets you sort the contents of the input. When you sort the input, lines with identical content end up next to each other in the output. This is useful as the output can then be fed to the `uniq` command (see below) to count the number of unique lines in the input.\n",
"\n",
"To sort the contents of a BED file use:\n",
"To sort the contents of a BED file type:\n",
"\n",
" sort Pfalciparum.bed"
" sort Pfalciparum.bed\n",
" \n",
"Now type:"
]
},
{
Expand Down Expand Up @@ -400,7 +402,7 @@
"\n",
" sort -k 2 -n Pfalciparum.bed\n",
" \n",
"The `sort` command can sort by multiple columns e.g. 1st column and then 2nd column by specifying successive -k parameters in the command."
"The `sort` command can sort by multiple columns e.g. 1st column and then 2nd column by specifying successive -k parameters in the command. Type the following commands:"
]
},
{
Expand Down Expand Up @@ -447,7 +449,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To get the list of chromosomes in the Pfalciparum bed file use:"
"To get the list of chromosomes in the Pfalciparum bed file type:"
]
},
{
Expand All @@ -467,7 +469,7 @@
"source": [
"How many chromosomes are there? You will learn more about the `awk` command later in this course.\n",
"\n",
"Warning: `uniq` is really stupid; it can only spot that two lines are the same if they are right next to one another. Your therefore almost always want to `sort` your input data before using `uniq`.\n",
"Warning: `uniq` is really stupid; it can only spot that two lines are the same if they are right next to one another. You therefore almost always want to `sort` your input data before using `uniq`.\n",
"\n",
"Do you understand how this command is working? Why not try building it up piece by piece to see what it does?\n",
"\n",
Expand All @@ -484,7 +486,7 @@
"source": [
"## Exercises\n",
"\n",
"Open up a new terminal window, navigate to the `files` directory in the `Unix_course` directory and complete the following exercise:\n",
"Open up a new terminal window, navigate to the `files` directory in the `Unix` directory and complete the following exercise:\n",
"\n",
"1. Use the `head` command to extract the first 500 lines of the file `Styphi.gff` and store the output in a new file called `Styphi.500.gff`.\n",
"2. Use the `wc` command to count the number of lines in the `Pfalciparum.bed` file.\n",
Expand Down
8 changes: 5 additions & 3 deletions Notebooks/Unix/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"\n",
"## Following the course in a terminal \n",
"\n",
"In this course you will use a terminal window to type in your Unix commands. This is similar to the \"Command Prompt\" window on MS Windows systems, which allows the user to type DOS commands to manage files. \n",
"To follow this course, please type all the commands you see into a terminal window. This is similar to the \"Command Prompt\" window on MS Windows systems, which allows the user to type DOS commands to manage files.\n",
"\n",
"To follow the course by typing the commands into a terminal yourself, run the following cell in this notebook, either by pressing control and enter, or by selecting it with the mouse and then in the menu at the top of the page choosing Cell -> Run."
"To get started, select the cell below with the mouse and then either press control and enter or choose Cell -> Run in the menu at the top of the page."
]
},
{
Expand All @@ -55,7 +55,9 @@
"source": [
"Now open a new terminal on your computer and type the command that was output by the previous cell followed by the enter key. The command will look similar to this:\n",
"\n",
" cd /home/manager/Module_3_Linux_Scripting"
" cd /home/manager/pathogen-informatics-training/Notebooks/Unix/\n",
" \n",
"Now follow the instruction in the [Basic unix](basic/basic.ipynb) section."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion Notebooks/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Pathogen Informatics Training\n",
"\n",
"Welcome to the Pathgen Informatics training courses. \n",
"Welcome to the Pathogen Informatics training courses. \n",
"\n",
"\n",
"## Courses\n",
Expand Down

0 comments on commit 20583ba

Please sign in to comment.