USING RUBY LANGUAGE PLEASE PART 1 A DNA strand is represented by a string of the characters A, C,…

USING RUBY LANGUAGE PLEASE

PART 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. Create a DNA class that gets

initialized with a string of nucleotide characters. An instance of DNA responds to the to_s,

length, hamming_distance, contains, positions, and frequencies 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. a.contains(b) returns true if b appears as a substring in a,

and returns false otherwise. a.positions(n) returns an array of the (zero-based) positions in which

the nucleotide n occurs in increasing order. Frequencies returns a hash that maps each of the four

nucleotides to the number of times it occurs in the DNA instance.

>> dna1 = DNA.new(‘ATTGCC’)

=> ATTGCC

>> dna1.length

=> 6

>> puts dna1

ATTGCC

>> dna1.contains(‘TGC’)

true

>> dna1.contains(DNA.new(‘AT’))

true

>> dna1.contains(‘GG’)

false

>> dna1.positions(‘T’)

[1, 2]

>> 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 ‘

>> dna1.frequencies

{“A”=>1, “T”=>2, “G”=>1, “C”=>2}

PART 2

A DNA strand is represented by a string of the characters A, C, G, and T, each of which

represents a nucleotide. Each nucleotide has its complement as indicated by this Ruby hash:

NUCLEOTIDE_COMPLEMENT = {

‘A’ => ‘T’, ‘T’ => ‘A’, ‘C’ => ‘G’, ‘G’ => ‘C’

}

The reverse-complement of a DNA string is a new string in which each nucleotide is replaced by

its complement and the string is reversed. Reverse-complements are important in bioinformatics

since a strand of DNA can be read in forward direction or, equivalently, its complementary

strand can be read in its forward direction, which is reverse of the original string’s direction. Add

the reverse_complement method to your DNA class. In response to reverse_complement, it

returns a new DNA instance representing its reverse-complement. Note also that a == b if and

only if DNA instances a and b represent the same DNA strand.

>> dna1

=> “ATTGCC”

>> dna2 = dna1.reverse_complement

=> “GGCAAT”

>> dna2.reverse_complement

=> “ATTGCC”

>> dna1.reverse_complement.reverse_complement == dna1

=> true

omplement.reverse_complement == dna1 => true

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!