{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exercises: reading and writing files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 3.1\n", "Write a function that reads the first 10 lines of the file `Homo_sapiens.GRCh38.99.MT.gtf` and writes them to another file." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "## Exercise 3.2\n", "Using the same `Homo_sapiens.GRCh38.99.MT.gtf` GFF file you used in the previous exercise, report (print to terminal) all of the feature entries for genes on the mitochondrial chromosome (`MT`) between coordinates 7500 and 10000 on the forward strand. \n", "The complete GFF file format description can be found here, but here is a succint description: \n", "* Column 1: chromosome\n", "* Column 2: data source\n", "* Column 3: feature type\n", "* Column 4: feature start coordinate\n", "* Column 5: feature end coordinate\n", "* Column 6: score\n", "* Column 7: strand\n", "\n", "> hint: use the `split()` method; what is the separator between fields ?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "## Exercise 3.3\n", "Write the sequences of every exon of the mitochondrial chromosome between coordinates 7500 and 12500 to a file, in the fasta format. \n", "In the output fasta file, identify the exons using the name of their gene, as well as their start and end positions.\n", "\n", "For instance, for an exon of gene ENSG000002, going from position 42 to 1337 : `>ENSG000002:42-1337`\n", "\n", "Use the same GFF file you used in the previous exercise, \n", "as well as the fasta file `Homo_sapiens.GRCh38.dna.chromosome.MT.fa`, which contains the sequence of the mitochondrial chromosome." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }