444,089 Members | 2,432 Online
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

# comparison of two dna sequences

 P: 4 Hi, I would ike to compare two dna sequences. let's say seq_a= TGGAGGCAATGGCGGCCAGCACTTCCCTGCCTGACCCTGGAGACTTTGAC CGGAACGTG CCCCGGATCTGTGGGGTGTGTGGAGACCGAGCCACTGGCTTTCACTTCAA TGCTATGACC TGTGAAGGCTGCAAAGGCTTCTTCAGGCGAAGCATGAAGCGGAAGGCACT ATTCACCTGC CCCTTCAACGGGGACTGCCGCATCACCAAGGACAACCGACGCCACTGCCA GGCCTGCCGG and seq_b=GACTCCTCCTCCTCCTGCTCAGATCACTGTATCACCTCTTCAGA CATGATGGAC---TCGTCCTTCTCCCTGCTGAATGAAAAATCAGATGACTCT---------------GTGCTAGAG CTGTCCCAA-------------------------------------------------------------------------------------GACCTCACCTCTGAGGACCAGATCGTACTGCTGAAGTCAAGTGCCATTGA GGTCATCATGTTGCGCTCCAATGAGTCCTTCACC how can I find differences in term of codons and position? Sep 21 '11 #1
6 Replies

 100+ P: 332 How does your program look so far? What output do you expect based on your two sequences. There are different ways to present a solution. So more details are required. Sep 21 '11 #2

 P: 4 Hi, right now I done the script to find mismatches between those sequences as follow: def sequence_compare(seq_a, seq_b): len1= len(seq_a) len2= len(seq_b) mismatches = [] for pos in range (0,min(len1,len2)) : if seq_a[pos] != seq_b[pos]: mismatches.append(pos) return mismatches sequence_compare(seq_a,seq_b) Thus eventually this gives me the right position of the mismatches between those two sequence. But at this point I get lost, because I want to know which codons are involved in comparison. i.e I know that there is a mismatch at the position 19 but which codons is involved so far?, and what the related amino acid? thanks Sep 22 '11 #3

 100+ P: 332 Maybe something like this would help: Expand|Select|Wrap|Line Numbers def sequence_compare(seq_a, seq_b):         len1= len(seq_a)         len2= len(seq_b)         mismatches = []         for pos in range (0,min(len1,len2)) :               if seq_a[pos] != seq_b[pos]:                   mismatches.append('|')               else:                   mismatches.append(' ')         print (seq_a)         print (mismatches)         print (seg_b) sequence_compare(seq_a,seq_b)   Would print and show the differences.   ACTGGCT  |  | | ATTGACA   Sep 22 '11 #4

 P: 4 ok cool I am gona try immediately... thanks! Sep 22 '11 #5

 P: 4 ok it works quite nicely but what about if I want in addition to this I want to know the amino acid related to that specific codons change? thanks Sep 22 '11 #6

 100+ P: 332 I guess it all depends on how you want to visualize the output. Maybe add something similar to what I proposed earlier but instead of appending pipe and space characters, add a new list with the related amino acid. Sep 22 '11 #7