---
# System prepended metadata

title: Python Exercise 3 - 2021/03/08
tags: [python2021]

---

# Python Exercise 3 - 2021/03/08
###### tags: `python2021`
* 繳交格式： 
    * 以學號命名的zip壓縮檔         
    ![](https://i.imgur.com/4tY8uY7.png)
    * 程式作業 (1~4) 取名為：ex3-1.py, ex3-2.py, ex3-3.py......，不符合者視為缺交。
    * 本次要求：所有的檔案路徑都要用相對路徑
---

# Exercise 3-1: Read a FASTA file (structured text)
The link below is human insulin’s genomic sequence in FASTA format. Download the file, then write a .py script that reads the file and print the first line.

Link: https://drive.google.com/file/d/16yxmefi6UuBHSoafi9DlHo1GV457zWdW/view?usp=sharing

:::info
Hint: 
The line separator in the .fa file is ‘**\n**’
:::


---
# Exercise 3-2: Re-format read text content
The file in 3-1 is in FASTA format. Write a script that re-format the FASTA sequence into a single-line text file (with not text description) and save it as **Ex_3-2.txt**



---
# Exercise 3-3: Extract infromation from file
The insulin gene has 3 exons. Write a script that reads the txt file from 3-2 and then save the 3 exons into separate files **(exon_1.txt, exon_2.txt, exon_3.txt)**.

:::info
**Exon locations:**
Exon 1: 1~42
Exon 2: 222~425
Exon 3: 1213~1432
:::



---
# Exercise 3-4
Write a script that reads the txt files from 3-3, connect the exons, and save the resulting sequence in FASTA format (70 nucleotides each line) as **insulin.fa**.
:::warning
1st line of the FASTA file must be: 
**\>Human Insulin mRNA**
...
:::
