Last active
December 2, 2020 19:29
-
-
Save Vini2/2b12d66b199a99ddb75d9d36bcee381a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the file and get the DNA string | |
file = open("sample_dna.txt", "r") | |
dna = file.read() | |
# Print the original DNA string | |
print "DNA String: ", dna | |
# Create dictionary of complementing nucleobase pairs | |
comp_pairs = {"A" : "T", "T" : "A", "G" : "C", "C" : "G"} | |
complementing_strand = "" | |
# Generate the complementing strand | |
for i in range (len(dna)-1, -1, -1): | |
complementing_strand += comp_pairs[dna[i]] | |
# Print the complementing strand | |
print "Complement: ", complementing_strand | |
# End of program |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Complementing a Strand of DNA
Solution for problem at ROSALIND.info