The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Problem 1
Â
A DNA strand is represented by a string of the characters A, C, G, and T, each of which represents a nucleotide. The hamming distance between two DNA strands of the same length is equal to the number of positions in which they differ. Hamming distance is used in bioinformatics as a measure of the similarity of two strings. Write a DNA class that gets initialized with a string of nucleotide characters. An instance of DNA responds to the to_s, length,and hamming_distance messages. Where a and b are DNA instances of the same length, the message send a.hamming_distance(b) returns the hamming distance between a and b:
=> true
>> dna1 = DNA.new('ATTGCC')
=> ATTGCC
>> dna1.length
=> 6
>> puts dna1
ATTGCC
>> dna2 = DNA.new('GTTGAC')
=> GTTGAC
>> dna1.hamming_distance(dna2) => 2
>> dna1.hamming_distance(dna1)
=> 0
>> dna1.hamming_distance(DNA.new('AT')) ArgumentError: dnas of different lengths from ass2.rb:17:in `hamming_distance' from (irb):8
from C:/Ruby22/bin/irb:11:in ''
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll