geniomhe-oop-dnapp/README.md

1.4 KiB

DNA++

Instructions

  1. Create a base class Sequence that represents a generic sequence. Include the following attributes and methods:
    1. Attributes:
      1. sequence: A string representing the sequence itself.
    2. Methods:
      1. __init__(self, sequence): Initialize the sequence.
      2. get_length(self): Return the length of the sequence.
      3. get_sequence(self): Return the sequence as a string.
  2. Create a subclass DNASequence that inherits from the Sequence class. Add the following methods:
    1. get_complement(self): Return the complementary DNA sequence. A pairs with T, and C pairs with G.
    2. transcribe_to_rna(self): Return the RNA sequence by replacing all T's with U's.
  3. Create another subclass ProteinSequence that inherits from the Sequence class. Add a method translate_to_protein(self) that translates the DNA sequence into a protein sequence using the genetic code (you can use a dictionary to map codons to amino acids).
  4. Provide an example DNA sequence and demonstrate the functionality of your program by:
    1. Creating a DNA sequence object.
    2. Getting its complement and transcribed RNA sequence.
    3. Translating it into a protein sequence.

Hints:

  • You can create a dictionary to represent the genetic code, where keys are codons (triplets of nucleotides), and values are the corresponding amino acids.
  • The complement of a DNA sequence can be found by replacing A with T, T with A, C with G, and G with C.