From 70ecfc53cb30ad8a25233db13a69ab2c03dc12b6 Mon Sep 17 00:00:00 2001 From: Alan <3899850+alanwilter@users.noreply.github.com> Date: Thu, 27 Jun 2019 11:38:35 +0100 Subject: [PATCH 01/10] Update README.md --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 24febdb..10cbf8d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Materials for the course run by the Graduate School of Life Sciences, University of Cambridge. -- Course website: http://pycam.github.io/ +- Course website: http://alanwilter.github.io/pycam/ - Booking website: http://www.training.cam.ac.uk/ @@ -11,7 +11,7 @@ If you wish to run the course on your personal computer, here are the steps to f ## Clone this github project ```bash -git clone https://github.com/pycam/python-basic.git +git clone https://github.com/alanwilter/python-basic.git cd python-basic ``` @@ -34,7 +34,7 @@ pip install --upgrade pip # install jupyter pip install jupyter -# slideshow extension +# slideshow extension (optional, but nice to have it) pip install rise jupyter-nbextension install rise --py --sys-prefix jupyter nbextension enable rise --py --sys-prefix @@ -47,8 +47,9 @@ Go to the directory where you've cloned this repository, activate your virtual e Your web browser should automatically open with this url http://localhost:8888/tree where you see the directory tree of the course with all the jupyter notebooks. ```bash -cd python-basic -source venv/bin/activate +# cd python-basic +# source venv/bin/activate + jupyter notebook ``` From daaf69375cf61f4ceaad2e2a931b60d498bcfe04 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 27 Jun 2019 11:55:50 +0100 Subject: [PATCH 02/10] changed intro1 --- python_basic_1_intro.ipynb | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/python_basic_1_intro.ipynb b/python_basic_1_intro.ipynb index 954dbb3..b9a71a9 100644 --- a/python_basic_1_intro.ipynb +++ b/python_basic_1_intro.ipynb @@ -14,22 +14,6 @@ "# An introduction to solving biological problems with Python" ] }, - { - "cell_type": "markdown", - "metadata": { - "nbpresent": { - "id": "53eee250-b3d0-4262-ad09-e87fb2acf82e" - }, - "slideshow": { - "slide_type": "-" - } - }, - "source": [ - "## Today's Presenters\n", - "- Anne\n", - "- Cristian" - ] - }, { "cell_type": "markdown", "metadata": { @@ -104,8 +88,8 @@ "## Course materials\n", "\n", "- There is a course webpage with links to the materials, example solutions to the exercises etc.:\n", - " - http://pycam.github.io\n", - "- All course materiel is available on GitHub in our [python-basic repo](https://github.com/pycam/python-basic)\n", + " - http://alanwilter.github.io/pycam\n", + "- All course materiel is available on GitHub in our [python-basic repo](https://github.com/alanwilter/python-basic)\n", "- We’d like you to follow along with the example code as we go through the material, and attempt the exercises to practice what you’ve learned\n", "- Questions are welcome at any point!\n", "- If you have specific projects/problems you like to use Python for we are happy to (try to) help during the exercises\n" @@ -320,7 +304,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.7.3" }, "nbpresent": { "slides": { From f26ce14513d344b76acbe5bad7549c7715ef0139 Mon Sep 17 00:00:00 2001 From: Alan <3899850+alanwilter@users.noreply.github.com> Date: Fri, 28 Jun 2019 13:21:45 +0100 Subject: [PATCH 03/10] Update python_basic_2_intro.ipynb --- python_basic_2_intro.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_basic_2_intro.ipynb b/python_basic_2_intro.ipynb index af16b6c..562df0a 100644 --- a/python_basic_2_intro.ipynb +++ b/python_basic_2_intro.ipynb @@ -10,7 +10,7 @@ "source": [ "# An introduction to solving biological problems with Python\n", "\n", - "- Our course webpage: http://pycam.github.io\n", + "- Our course webpage: http://alanwilter.github.io/pycam\n", "- Python website: https://www.python.org/ \n", "- [Python 3 Standard Library](https://docs.python.org/3/library/index.html])" ] From 8a4e3081bdaf595799739672accf3f0a90acec30 Mon Sep 17 00:00:00 2001 From: Alan <3899850+alanwilter@users.noreply.github.com> Date: Wed, 3 Jul 2019 12:05:05 +0100 Subject: [PATCH 04/10] Update python_basic_2_3.ipynb --- python_basic_2_3.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_basic_2_3.ipynb b/python_basic_2_3.ipynb index 2d4bd34..2527537 100644 --- a/python_basic_2_3.ipynb +++ b/python_basic_2_3.ipynb @@ -286,7 +286,7 @@ "source": [ "## Exercises 2.3.1\n", "\n", - "Write a script that reads a file containing many lines of nucleotide sequence. For each line in the file, print out the line number, the length of the sequence and the sequence (There is an example file here or in `data/dna.txt` from the course materials )." + "Write a script that reads a file containing many lines of nucleotide sequence. For each line in the file, print out the line number, the length of the sequence and the sequence (There is an example file in `data/dna.txt` from the course materials )." ] }, { From a0cfbae6fd0f98183b97e20a469a49e13d49dfee Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 3 Jul 2019 12:35:07 +0100 Subject: [PATCH 05/10] changed 2_4 --- python_basic_2_4.ipynb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python_basic_2_4.ipynb b/python_basic_2_4.ipynb index aeb347f..5ff3ed0 100644 --- a/python_basic_2_4.ipynb +++ b/python_basic_2_4.ipynb @@ -186,10 +186,9 @@ "### A big thank you!\n", "\n", "### Remember...\n", - "- Our course webpage: http://pycam.github.io\n", + "- Our course webpage: http://alanwilter.github.io/pycam\n", "- The Python website: https://www.python.org/ \n", - "- To fill the course survey ;-)\n", - "- To come to our next course 'Working with Python: functions and modules' and register at https://training.csx.cam.ac.uk/" + "- To come to our next course 'Data science in Python'" ] }, { @@ -266,7 +265,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.7.3" } }, "nbformat": 4, From 37b0106c29b5e06e933894ce3f2bc7f0811131ae Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 3 Jul 2019 12:44:10 +0100 Subject: [PATCH 06/10] use tsv ext --- solutions/pybasic_ex2_4_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/pybasic_ex2_4_1.py b/solutions/pybasic_ex2_4_1.py index 0bef69b..664b685 100644 --- a/solutions/pybasic_ex2_4_1.py +++ b/solutions/pybasic_ex2_4_1.py @@ -3,7 +3,7 @@ # stores it into a dictionary; and writes the results into a new tab separated file. gene_file = ('data/genes.txt') -output_file = "gene_lengths.txt" +output_file = "gene_lengths.tsv" results = [] # Read a tab delimited file which has 4 columns: gene, chrom, start and end. From 1c92f5b61b67109aca89d545381121e031f36b2e Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 3 Jul 2019 12:54:29 +0100 Subject: [PATCH 07/10] simplified --- solutions/pybasic_ex2_4_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/pybasic_ex2_4_2.py b/solutions/pybasic_ex2_4_2.py index a9cee66..6e3fe06 100644 --- a/solutions/pybasic_ex2_4_2.py +++ b/solutions/pybasic_ex2_4_2.py @@ -20,7 +20,7 @@ # Calculate the frequency of each word and store the result into a dictionary results = {} for w in unique_words: - results[w.lower()] = words.count(w) + results[w] = words.count(w) # Print each unique word along with its frequency for r in results: From f7378af3b38f743304cf8f4c1ba3c8265926d5bc Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 3 Jul 2019 14:14:21 +0100 Subject: [PATCH 08/10] improved --- solutions/pybasic_ex2_4_3.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/solutions/pybasic_ex2_4_3.py b/solutions/pybasic_ex2_4_3.py index d5a7839..84f4c74 100644 --- a/solutions/pybasic_ex2_4_3.py +++ b/solutions/pybasic_ex2_4_3.py @@ -33,6 +33,13 @@ print("The shortest gene is", shortest_gene, "which is", shortest, "bases long.") print("The longest gene is", longest_gene, "which is", longest, "bases long.") +# check if there's more than one +for g in genes: + if g['length'] == longest: + print('Longest ones: {}'.format(g['sys_name'])) + if g['length'] == shortest: + print('Shortest ones: {}'.format(g['sys_name'])) + # How many genes per chromosome? Print the number of genes per chromosome. unique_chrom = set(chromosomes) From 05309cc19515639151d99ef48558db916d2f0660 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 3 Jul 2019 14:24:57 +0100 Subject: [PATCH 09/10] Removed Watson/Crick strand part --- python_basic_2_4.ipynb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/python_basic_2_4.ipynb b/python_basic_2_4.ipynb index 5ff3ed0..3f5392b 100644 --- a/python_basic_2_4.ipynb +++ b/python_basic_2_4.ipynb @@ -233,12 +233,7 @@ "- How many genes are there in *S.cerevisiae*?\n", "- Which is the longest and which is the shortest gene?\n", "- How many genes per chromosome? Print the number of genes per chromosome.\n", - "- For each chromosome, what is the longest and what is the shortest gene?\n", - "- For each chromosome, how many genes on the Watson strand and how many genes on the Crick strand?\n", - "\n", - "**bonus** \n", - "\n", - "- What is the chromosome with the highest gene density? You can calculate the length of each chromosome assuming that they start at 1 and they end at the end (if on the Watson strand) or at the start (if on the Crick strand) of their last gene. Then you can calculate the length of all the genes on each chromosome and the ratio between coding vs. noncoding regions." + "- For each chromosome, what is the longest and what is the shortest gene?" ] }, { From 44181e7aaf5be3f93df6a3d25574abcf0ba579e8 Mon Sep 17 00:00:00 2001 From: Alan <3899850+alanwilter@users.noreply.github.com> Date: Wed, 3 Jul 2019 14:32:49 +0100 Subject: [PATCH 10/10] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 10cbf8d..8c6b5ad 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ Materials for the course run by the Graduate School of Life Sciences, University of Cambridge. - Course website: http://alanwilter.github.io/pycam/ -- Booking website: http://www.training.cam.ac.uk/ - If you wish to run the course on your personal computer, here are the steps to follow to get up and running.