From 0d1558cc6b7b1303329b661e8971bc7173ec444e Mon Sep 17 00:00:00 2001 From: Jacqui Keane Date: Mon, 26 Sep 2016 15:59:13 +0100 Subject: [PATCH 1/2] Fix minor typos and added clarification on how to follow the course --- Notebooks/Unix/basic/basic.ipynb | 40 +++++++++++------- .../Unix/cheat_sheet/unix_cheat_sheet.ipynb | 1 + Notebooks/Unix/files/files.ipynb | 42 ++++++++++--------- Notebooks/Unix/index.ipynb | 8 ++-- Notebooks/index.ipynb | 2 +- 5 files changed, 53 insertions(+), 40 deletions(-) diff --git a/Notebooks/Unix/basic/basic.ipynb b/Notebooks/Unix/basic/basic.ipynb index 467e4bd..7f2e93f 100644 --- a/Notebooks/Unix/basic/basic.ipynb +++ b/Notebooks/Unix/basic/basic.ipynb @@ -22,12 +22,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "collapsed": false, "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cd /Users/jm15/pathogen-informatics-training/Notebooks/Unix/basic\r\n" + ] + } + ], "source": [ "echo \"cd $PWD\"" ] @@ -36,7 +44,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", @@ -106,7 +114,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:" ] }, { @@ -125,9 +133,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:" ] }, { @@ -157,7 +165,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:" ] }, { @@ -213,7 +221,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:" ] }, { @@ -273,7 +281,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." ] }, { @@ -369,7 +377,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/`?" ] }, { @@ -387,7 +395,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:" ] }, { @@ -429,7 +437,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:" ] }, { @@ -447,7 +455,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." ] }, { @@ -483,7 +491,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:" ] }, { @@ -560,7 +568,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:" ] }, { @@ -601,7 +609,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", diff --git a/Notebooks/Unix/cheat_sheet/unix_cheat_sheet.ipynb b/Notebooks/Unix/cheat_sheet/unix_cheat_sheet.ipynb index 454890a..247cd29 100644 --- a/Notebooks/Unix/cheat_sheet/unix_cheat_sheet.ipynb +++ b/Notebooks/Unix/cheat_sheet/unix_cheat_sheet.ipynb @@ -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", diff --git a/Notebooks/Unix/files/files.ipynb b/Notebooks/Unix/files/files.ipynb index 65758f3..c3048f4 100644 --- a/Notebooks/Unix/files/files.ipynb +++ b/Notebooks/Unix/files/files.ipynb @@ -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:" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -141,7 +141,7 @@ " \n", " fin \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" ] }, { @@ -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" ] @@ -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:" ] }, { @@ -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." ] }, { @@ -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" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -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:" ] }, { @@ -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", @@ -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", diff --git a/Notebooks/Unix/index.ipynb b/Notebooks/Unix/index.ipynb index 27daed1..6b28afa 100644 --- a/Notebooks/Unix/index.ipynb +++ b/Notebooks/Unix/index.ipynb @@ -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." ] }, { @@ -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." ] }, { diff --git a/Notebooks/index.ipynb b/Notebooks/index.ipynb index d369070..0ce19c6 100644 --- a/Notebooks/index.ipynb +++ b/Notebooks/index.ipynb @@ -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", From d797a3d496d9dffee4d4cc934359e19d4efbab83 Mon Sep 17 00:00:00 2001 From: Jacqui Keane Date: Mon, 26 Sep 2016 16:00:53 +0100 Subject: [PATCH 2/2] Fix minor typos in basic section --- Notebooks/Unix/basic/basic.ipynb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Notebooks/Unix/basic/basic.ipynb b/Notebooks/Unix/basic/basic.ipynb index 7f2e93f..df5952b 100644 --- a/Notebooks/Unix/basic/basic.ipynb +++ b/Notebooks/Unix/basic/basic.ipynb @@ -22,20 +22,12 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "cd /Users/jm15/pathogen-informatics-training/Notebooks/Unix/basic\r\n" - ] - } - ], + "outputs": [], "source": [ "echo \"cd $PWD\"" ]