Advertisement
jaect

DNA Complementary Sequence Producer

Dec 10th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Feb  5 16:02:10 2018
  4.  
  5. @author: Josh Jones
  6. """
  7. # The following details a DNA sequence and its various complements
  8.  
  9. seq = input("Enter a DNA sequence consisting of A's, T's, G's, or C's: ")
  10. seq = seq.upper()
  11. for letter in seq:
  12.     if letter != 'A' and letter != 'T' and letter != 'G' and letter != 'C':
  13.         seq = seq.replace(letter, '-')    
  14.        
  15. # Print the length and original sequence  
  16. print("Length of Sequence:", len(seq))
  17. print("Original DNA Sequence: 5`-", seq, "-3`")
  18.  
  19. # Take and print the complement
  20. complement = []
  21. seq_complement = {'A':'T', 'T':'A', 'G':'C', 'C':'G', '-':'-'}
  22.  
  23. for letter in seq:
  24.     complement.append(seq_complement[letter])
  25. print("Complement Sequence:   3`-", ''.join(complement), "-5`")
  26.  
  27. # Take and print the reverse
  28. l = list(seq)
  29. l.reverse()
  30. seq = ''.join(l)
  31. print("Reverse Sequence:      3`-", seq, "-5`")
  32.  
  33. # Reverse the complement and print
  34. l = list(complement)
  35. l.reverse()
  36. print("Reverse Complement:    5`-", ''.join(l), "-3`")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement