Difference between revisions of "CSC231 Final Exam Solutoins 2012"
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] 14:37, 20 December 2012 (EST) | --[[User:Thiebaut|D. Thiebaut]] 14:37, 20 December 2012 (EST) | ||
---- | ---- | ||
− | < | + | <onlydft> |
This is just a sketch of the solution for the exam, but enough to give you an idea of what you had to do. | This is just a sketch of the solution for the exam, but enough to give you an idea of what you had to do. | ||
Line 513: | Line 513: | ||
Nobody saw that you could use a look-up table for this question! Would have made your program so much simpler!!! | Nobody saw that you could use a look-up table for this question! Would have made your program so much simpler!!! | ||
− | table | + | table equ $ |
db 'A','A','A','A', 0x00 | db 'A','A','A','A', 0x00 | ||
db 'A','A','A','C', 0x01 | db 'A','A','A','C', 0x01 | ||
''etc...'' | ''etc...'' | ||
+ | |||
+ | You look at all patterns of 4 'A', 'C', 'G', and 'T' characters and figure out their compressed hexadecimal equivalent (a quick Python hack can give you that), and you will get 256 patterns. Sort them in the right order, and your program simply takes groups of 4 characters from the string, puts them in eax, scans the table (every 5 bytes) for 32-bit values equal to eax, and when found, takes the 5th byte and prints it in hex. | ||
+ | |||
+ | To make sure the program deals correctly with strings whose length is not a multiple of 4 bytes, then always add "AAA" at the end of the DNA string and that should do the trick! | ||
But the great majority got at least 90% of the binary pattern to print out... Good! | But the great majority got at least 90% of the binary pattern to print out... Good! | ||
− | </ | + | </onlydft> |
<br /> | <br /> |