diff --git a/README.md b/README.md index 24febdb..8c6b5ad 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,14 @@ Materials for the course run by the Graduate School of Life Sciences, University of Cambridge. -- Course website: http://pycam.github.io/ -- Booking website: http://www.training.cam.ac.uk/ - +- Course website: http://alanwilter.github.io/pycam/ If you wish to run the course on your personal computer, here are the steps to follow to get up and running. ## 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 +32,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 +45,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 ``` 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": { 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 )." ] }, { diff --git a/python_basic_2_4.ipynb b/python_basic_2_4.ipynb index aeb347f..3f5392b 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'" ] }, { @@ -234,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?" ] }, { @@ -266,7 +260,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.7.3" } }, "nbformat": 4, 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])" ] 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. 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: 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)