-
Notifications
You must be signed in to change notification settings - Fork 0
Topic 3 assignment
Write a python script that will accomplish the following:
- Take in a fasta file containing several sequences of varying length. File to be provided below.
- For each sequence in the file, calculate the GC content.
- For each sequence in the file, determine if the GC content is higher than 40%.
- Based on this criterion, write out two files: sequences with GC content higher than 40% and sequences with GC content less than or equal to 40%.
- Provide output to the screen to let the user know what's happening.
gc_fasta.fa
>seq_1
ACATACCATGAGACTTCCAGGCACCTCGCCGCGAAGGCCAGCCTTCGGGCAGCACGAGGACCGTCA
>seq_2
TCAAGACAACAATTTAAGATTTGTTTATGATTTTGAATGTATGTTAATAGAAAGTTAACTTTAGGCCAAAAATTCAGAGATTCTAATT
>seq_3
CAACGACTATCGCGATGCCCGACCCACAAAGCGCGTACCTAGTGTCGGCGACGTCCCAGC
>seq_4
TCAAGAGATACAATAAATAGAATCTGTAAAAGATATATTAATTGTAGAATAACAATAATCCAGTGTCAA
>seq_5
GCGAGGCCCTCTGGTCCGCGCGGTCGAGTGGCCCCATGGCGGCGTGAGCCATGGGCACACGGACGCGGATCT
>seq_6
AGTAATATTTTTTTGTTTTTTCGAGAATGCCTCAATTAGTTGAATAGTATGTATATTCAGTTGAACCATAAATATAGTGTGATTTTTTCTTAAGTTGT
>seq_7
CGTTGGTCCCCCTCCCCGGTGAGCCGGTCGCCGCGCCCGGCGCCGTCGCCGCCGCCAACGGGCGG
>seq_8
TTAATGTATCAATATTAAAACATTTATATTCAAGTTATACGTAGCGAATACTTCTAACAGTTACTTGTTAAATACCAGACAAATACCGTTTAACTATAAA
>seq_9
GCCAGTCTCCCCCGGGTTTCTTGCCGCCGACGGGTAGTCATTCAAGCCGGAGCGAGGCTGCCCCCAGACCCCGACCAGCTGGAAGGCCGGGGGCC
>seq_10
TGGGTCAAGAGAGTAGTAAAATTGAGCCCTTAAAATTAGGTAGCCCTTAAATTGTCGTATGAGACGGATACATTT
Potential algorithm and helpful hints:
-
Take in a fasta file given to you in the exercise. (See week 1.)
-
Initiate lists for sequences belonging to each category, 40+ and <=40.
-
Initiate a for loop to read each sequence in the file.
We haven't covered this in class. https://www.w3schools.com/python/python_for_loops.asp
-
Calculate GC content (as a percentage) for each sequence
Using the built-in length function might be helpful here. https://www.w3schools.com/python/ref_func_len.asp
-
Use if, else statements to evaluate GC content. (append() will be helpful here.)
-
Write out the lists to separate files, depending on the GC content.
-
Upload your code to blackboard at least 24 hour prior to the next class.
-
Also upload your code to your github repository.