From f69d5716a51205fa357594f90cf66088a3518d9e Mon Sep 17 00:00:00 2001 From: jschendel Date: Sat, 31 Aug 2013 19:16:10 -0500 Subject: [PATCH] Complementing a Strand of DNA Solution to Rosalind Problem 003: Complementing a Strand of DNA --- 003_REVC.py | 25 +++++++++++++++++++++++++ data/rosalind_revc.txt | 1 + output/003_REVC.txt | 1 + 3 files changed, 27 insertions(+) create mode 100644 003_REVC.py create mode 100644 data/rosalind_revc.txt create mode 100644 output/003_REVC.txt diff --git a/003_REVC.py b/003_REVC.py new file mode 100644 index 0000000..a13a165 --- /dev/null +++ b/003_REVC.py @@ -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() diff --git a/data/rosalind_revc.txt b/data/rosalind_revc.txt new file mode 100644 index 0000000..79402e0 --- /dev/null +++ b/data/rosalind_revc.txt @@ -0,0 +1 @@ +GTATTAAGAAGCCTACTGACATAAGATGAGACCTGCGATCCTAAAAGACGGTTAACACGTCACATACCGATCAATCGAACTGTTCAGCGCAACACTATTCCTCCCAAAGGTCGCGGGGACCCCCCAACCATTAGTATGGCTGGTTGATACCACACCTAATTTACTCAGTTTATCCAACCTTTAGAACTCCCCTTTACTTTCTACTGTATTGCCACGAAACAGCACCTATCTACGAACGAGTTCTAAGGGGCCTATATCGGTAGGTGTTTTTTAATACGGTAACGCATCATCGCTACGAAAGATCCCCCAATTAAAGGACAGACAAAACTAGTAGCGTGTTGTCGTTGAAAATATGTCAGCAATATATGGTAACCGAGCTAGGACTCATACTGCGCATTGTTAACTGTCGAATTGGTTAACCACGGCTCACTATCTGCGGGAACGCAGAAGGTCCCCTAAAGTAATCAGTGACGAGCTCAAGGTATAAATTCATGCCAATGTTCTTGGGTGCAAGGCAGGCCCGTCCGGGCCAAACAAGTGCAAGTTTACATAACTGGCCTTAATCCGATAATCACCTGCTTTCGATACGGGGTTAGGAAAAAGAAGCCCGGAGCCTTAGATCCCTAAAATGCGCACTTCTCAGGGGGGTATCGTAGGCGACACTCAGACTGCCGTGTCTTACGCCGCCGCGGGTCGATTAGTCTAAGTGATCGGTACGCAAGGCGATGTCGCACAAAGTGCAAGACGAGGTGAGCAGTAGCTACAGTGCATGCATGGCCGCTCCCGCCAGCTAATCGATTGGCCACCGTAGAATTTGTCCTGTTTCGTCGGTTACACATTTTCACCAGTACGATTAAGACCTCGGTTAACCACTTGTAGATTTTTTGCTTTGGACTAGG diff --git a/output/003_REVC.txt b/output/003_REVC.txt new file mode 100644 index 0000000..ccd0bea --- /dev/null +++ b/output/003_REVC.txt @@ -0,0 +1 @@ +CCTAGTCCAAAGCAAAAAATCTACAAGTGGTTAACCGAGGTCTTAATCGTACTGGTGAAAATGTGTAACCGACGAAACAGGACAAATTCTACGGTGGCCAATCGATTAGCTGGCGGGAGCGGCCATGCATGCACTGTAGCTACTGCTCACCTCGTCTTGCACTTTGTGCGACATCGCCTTGCGTACCGATCACTTAGACTAATCGACCCGCGGCGGCGTAAGACACGGCAGTCTGAGTGTCGCCTACGATACCCCCCTGAGAAGTGCGCATTTTAGGGATCTAAGGCTCCGGGCTTCTTTTTCCTAACCCCGTATCGAAAGCAGGTGATTATCGGATTAAGGCCAGTTATGTAAACTTGCACTTGTTTGGCCCGGACGGGCCTGCCTTGCACCCAAGAACATTGGCATGAATTTATACCTTGAGCTCGTCACTGATTACTTTAGGGGACCTTCTGCGTTCCCGCAGATAGTGAGCCGTGGTTAACCAATTCGACAGTTAACAATGCGCAGTATGAGTCCTAGCTCGGTTACCATATATTGCTGACATATTTTCAACGACAACACGCTACTAGTTTTGTCTGTCCTTTAATTGGGGGATCTTTCGTAGCGATGATGCGTTACCGTATTAAAAAACACCTACCGATATAGGCCCCTTAGAACTCGTTCGTAGATAGGTGCTGTTTCGTGGCAATACAGTAGAAAGTAAAGGGGAGTTCTAAAGGTTGGATAAACTGAGTAAATTAGGTGTGGTATCAACCAGCCATACTAATGGTTGGGGGGTCCCCGCGACCTTTGGGAGGAATAGTGTTGCGCTGAACAGTTCGATTGATCGGTATGTGACGTGTTAACCGTCTTTTAGGATCGCAGGTCTCATCTTATGTCAGTAGGCTTCTTAATAC \ No newline at end of file