Skip to content

Commit

Permalink
Complementing a Strand of DNA
Browse files Browse the repository at this point in the history
Solution to Rosalind Problem 003: Complementing a Strand of DNA
  • Loading branch information
jschendel committed Sep 1, 2013
1 parent 6611468 commit f69d571
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 003_REVC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Complementing a Strand of DNA
Rosalind ID: REVC
Rosalind #: 003
URL: http://rosalind.info/problems/revc/
'''

from string import maketrans

input_file = open('data/rosalind_revc.txt')
dna = input_file.read()
input_file.close()

nucleotide = 'ATCG'
complement = 'TAGC'
transtab = maketrans(nucleotide, complement)

dna_reverse_complement = dna.translate(transtab)[::-1].lstrip()

output_file = open('output/003_REVC.txt', 'w')
output_file.write(dna_reverse_complement)
output_file.close()
1 change: 1 addition & 0 deletions data/rosalind_revc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GTATTAAGAAGCCTACTGACATAAGATGAGACCTGCGATCCTAAAAGACGGTTAACACGTCACATACCGATCAATCGAACTGTTCAGCGCAACACTATTCCTCCCAAAGGTCGCGGGGACCCCCCAACCATTAGTATGGCTGGTTGATACCACACCTAATTTACTCAGTTTATCCAACCTTTAGAACTCCCCTTTACTTTCTACTGTATTGCCACGAAACAGCACCTATCTACGAACGAGTTCTAAGGGGCCTATATCGGTAGGTGTTTTTTAATACGGTAACGCATCATCGCTACGAAAGATCCCCCAATTAAAGGACAGACAAAACTAGTAGCGTGTTGTCGTTGAAAATATGTCAGCAATATATGGTAACCGAGCTAGGACTCATACTGCGCATTGTTAACTGTCGAATTGGTTAACCACGGCTCACTATCTGCGGGAACGCAGAAGGTCCCCTAAAGTAATCAGTGACGAGCTCAAGGTATAAATTCATGCCAATGTTCTTGGGTGCAAGGCAGGCCCGTCCGGGCCAAACAAGTGCAAGTTTACATAACTGGCCTTAATCCGATAATCACCTGCTTTCGATACGGGGTTAGGAAAAAGAAGCCCGGAGCCTTAGATCCCTAAAATGCGCACTTCTCAGGGGGGTATCGTAGGCGACACTCAGACTGCCGTGTCTTACGCCGCCGCGGGTCGATTAGTCTAAGTGATCGGTACGCAAGGCGATGTCGCACAAAGTGCAAGACGAGGTGAGCAGTAGCTACAGTGCATGCATGGCCGCTCCCGCCAGCTAATCGATTGGCCACCGTAGAATTTGTCCTGTTTCGTCGGTTACACATTTTCACCAGTACGATTAAGACCTCGGTTAACCACTTGTAGATTTTTTGCTTTGGACTAGG
1 change: 1 addition & 0 deletions output/003_REVC.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CCTAGTCCAAAGCAAAAAATCTACAAGTGGTTAACCGAGGTCTTAATCGTACTGGTGAAAATGTGTAACCGACGAAACAGGACAAATTCTACGGTGGCCAATCGATTAGCTGGCGGGAGCGGCCATGCATGCACTGTAGCTACTGCTCACCTCGTCTTGCACTTTGTGCGACATCGCCTTGCGTACCGATCACTTAGACTAATCGACCCGCGGCGGCGTAAGACACGGCAGTCTGAGTGTCGCCTACGATACCCCCCTGAGAAGTGCGCATTTTAGGGATCTAAGGCTCCGGGCTTCTTTTTCCTAACCCCGTATCGAAAGCAGGTGATTATCGGATTAAGGCCAGTTATGTAAACTTGCACTTGTTTGGCCCGGACGGGCCTGCCTTGCACCCAAGAACATTGGCATGAATTTATACCTTGAGCTCGTCACTGATTACTTTAGGGGACCTTCTGCGTTCCCGCAGATAGTGAGCCGTGGTTAACCAATTCGACAGTTAACAATGCGCAGTATGAGTCCTAGCTCGGTTACCATATATTGCTGACATATTTTCAACGACAACACGCTACTAGTTTTGTCTGTCCTTTAATTGGGGGATCTTTCGTAGCGATGATGCGTTACCGTATTAAAAAACACCTACCGATATAGGCCCCTTAGAACTCGTTCGTAGATAGGTGCTGTTTCGTGGCAATACAGTAGAAAGTAAAGGGGAGTTCTAAAGGTTGGATAAACTGAGTAAATTAGGTGTGGTATCAACCAGCCATACTAATGGTTGGGGGGTCCCCGCGACCTTTGGGAGGAATAGTGTTGCGCTGAACAGTTCGATTGATCGGTATGTGACGTGTTAACCGTCTTTTAGGATCGCAGGTCTCATCTTATGTCAGTAGGCTTCTTAATAC

0 comments on commit f69d571

Please sign in to comment.