Question

In: Computer Science

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

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 =
=> GGCAAT
>> dna2
=> GGCAAT
>> dna1
=> ATTGCC
>> dna2.reverse_complement => ATTGCC

DNA.new('ATTGCC') dna1.reverse_complement

>> dna1.reverse_complement.reverse_complement == dna1 => true

Solutions

Expert Solution

Python code for above problem

class DNA:
   def __init__(self,dna):
       self.dna=dna
   def reverse_complement(self):
       new_dna=""
       for i in range(len(self.dna)):
           ch=self.dna[i]
           if(ch=='A'):
               new_dna+="T"
           elif(ch=='T'):
               new_dna+="A"
           elif(ch=='G'):
               new_dna+="C"
           else:
               new_dna+="G"
       return DNA(new_dna)
   def __str__(self):
       return self.dna

dna1=DNA("ATTGCC")
print(dna1.reverse_complement().__str__()=="TAACGG")   # prints True
print(dna1.reverse_complement().reverse_complement().__str__()=="ATTGCC")   # prints True

Mention in comments if any mistakes or errors are found. Thank you.


Related Solutions

A DNA string is a sequence of the bases a, c, g, and t in any...
A DNA string is a sequence of the bases a, c, g, and t in any order, whose length is usually a multiple of three. In reality, it is not necessarily a multiple of three, but we will simplify it as such for discussion. For example, aacgtttgtaaccagaactgt is a DNA string with a length of 21 bases. Recall that a sequence of three consecutive letters is called a codon. Assuming the first codon starts at position 1, the codons are...
1. Compute for the A + C : T + G ratios of the given DNA...
1. Compute for the A + C : T + G ratios of the given DNA strand in "A" 5' A A C C T A C T C C T G C G T G G G T G T C T T 3' 3' T T G G A T G A G G A C G C A C C C A C A G A A 5' 2. What happens if any of the protein for...
3` - T A T A G A G C A A T T G C...
3` - T A T A G A G C A A T T G C T A C G T G T A T C C C G A G A C T C C G T A A – 5` 5` - A T A T C T C G T T A A C G A T G C A C A T A G G G C T C T G A G G C A...
RUBY Write a DNA class that gets initialized with a string of nucleotide characters. An instance...
RUBY Write 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...
Write a C++ program which reads a string, less than 10 characters long. This string represents...
Write a C++ program which reads a string, less than 10 characters long. This string represents an integer expressed in roman numbers. Let a function convert the number from roman to arabic form (i.e., our standard digits). Let then the main program writes out both forms. The roman numbers are written according to: M = 1000, D = 500, C =100, L=50, X=10, V=5, I=1. Examples: LXXXVII = 87 CCXIX = 219 MCCCLIV = 1354 MMDCLXXIII = 2673
In c++, using stack structure, write a program that will take a sequence of characters (string)...
In c++, using stack structure, write a program that will take a sequence of characters (string) and determine whether it is a palindrome. Use the linked version of the stack.
The macroeconomy of the TELLA is represented by the following model. Goods Market Y=C+I+G+X-M C=200+0.7(T-T) T=0.2YI=100-10r...
The macroeconomy of the TELLA is represented by the following model. Goods Market Y=C+I+G+X-M C=200+0.7(T-T) T=0.2YI=100-10r G=150 EX=200 IM=0.1Y Money Market Md=1000-6666r Ms = [(C/D+1)/(C/D+R/D)]H Where C/D=0.2; R/D=0.2 and H=200 Use this model to answer the following questions: 1) The value of the money multiplier in this model is: A) 2.0 B) 2.5 C) 3.0 D) 3.5 E) 4.0 2) The value of the expenditure multiplier in this model is: A)1.54 B)4.23 C)2.51 D)1.85 E) 3.50 3) The value of...
Describe DNA denaturation, renaturation (annealing) and how base composition (A & T v. C & G)...
Describe DNA denaturation, renaturation (annealing) and how base composition (A & T v. C & G) affects DNA stability
Given a string of at least 3 characters as input, if the length of the string...
Given a string of at least 3 characters as input, if the length of the string is odd return the character in the middle as a string. If the string is even return the two characters at the midpoint. -------------------------------------------------------------- public class Class1 { public static String midString(String str) {     //Enter code here } }
in looking at the structure of DNA, we learned that a strand of DNA possesses an...
in looking at the structure of DNA, we learned that a strand of DNA possesses an inherent polarity; it has a 5’ end and a 3’ end and that the two strands in a DNA duplex have opposite polarities – they run antiparallel to on another. But why? … why are the two strands always and only antiparallel? (think of the H-bonds that hold the two strands together by complementary base pairing)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT