-
Notifications
You must be signed in to change notification settings - Fork 0
/
rvco.py
49 lines (44 loc) · 1.38 KB
/
rvco.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Complementing a Strand of DNA
# https://rosalind.info/problems/rvco/
from Bio import SeqIO
from Bio.Seq import Seq
import io
fasta_str = """
>Rosalind_0732
GCGATGCTTTCGTTCGGGGCTGTCACTTGGGCATTGGTGCAAGATTTAGTTTAACATCGT
CAAGAGTCTTATTTACGAGATACGATGCGT
>Rosalind_8154
CCGATTCATGCATGGGTCTTCGAGGGGATCGCATTGCAATGCTCGGGAATAACACAGTGT
TTTAAATTTGGTTTCGCTGTATAGGGGGGCAATAGGTCAT
>Rosalind_2098
GGGAGAGTGTAAGATTTATTGCTCGCATCCGGCCCTCTCACCAGGTAAGTCTACACGGGC
AGCCACGGTGGGTTGCGGTTGGAACTTC
>Rosalind_1885
GAAGCTCCCATAGCATTTGAAGTCGACGCTTTTGGGTAAGCGCTAAAGCTTTAGCGCTTA
CCCAAAAGCGTCGACTTCAAATGCTATGGGAGCTTC
>Rosalind_4221
GGAACGAGTGGCTTTGTAAGGAATGAGTGCACATATGTGTAGGCTAACCGATTTATTCAG
CTCTCTTCCCCGCGATCCTAGGCACGTGGCTAATTG
>Rosalind_7971
AGCCATCCTATCGAGCAGGGCAGGACGCCAATGAAGAGGACAGCAACCGCCCATTGCGAC
GTCGGTGGAAGTTACTGGAG
>Rosalind_0478
CGGTTGTATGTGCGGCTACCGAGTAGCATCAACTTGGGTGCTAGCACCCAAGTTGATGCT
ACTCGGTAGCCGCACATACAACCG
>Rosalind_4754
TAGGTCCAGTAACAAACGTTACGTTTGAGCCCATAAGGCGAGCGATGACAGGAGCATAGC
CCTCCGGAAGAGAGGACGCCGAAGGGTATATCCG
>Rosalind_4106
TCGAATTGAACGCCATCAGCTCCGCGTCGGATGCGGAATGCATTCGATCGAATGCATTCC
GCATCCGACGCGGAGCTGATGGCGTTCAATTCGA
>Rosalind_4627
GGGGTTCATCACGTGAGAGCTCCAAGGCGTAACCTGTTTCGAAACAGGTTACGCCTTGGA
GCTCTCACGTGATGAACCCC
"""
records = list(SeqIO.parse(io.StringIO(fasta_str), "fasta"))
count = 0
for record in records:
seq = record.seq
if seq == seq.reverse_complement():
count += 1
print(count)