Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

AzharDNA New Bioinformatics Program (DNA Translation)

0.00/5 (No votes)
4 Mar 2014 1  
Basic tool for the translation of DNA

Introduction

In molecular biology and genetics, translation is the third stage of protein biosynthesis (part of the overall process of gene expression). In translation, messenger RNA (mRNA) produced by transcription is decoded by the ribosome to produce a specific amino acid chain, or polypeptide, that will later fold into an active protein. In Bacteria, translation occurs in the cell's cytoplasm, where the large and small subunits of the ribosome are located, and bind to the mRNA. In Eukaryotes, translation occurs across the membrane of the endoplasmic reticulum in a process called vectorial synthesis. The ribosome facilitates decoding by inducing the binding of tRNAs with complementary anticodon sequences to that of the mRNA. The tRNAs carry specific amino acids that are chained together into a polypeptide as the mRNA passes through and is "read" by the ribosome in a fashion reminiscent to that of a stock ticker and ticker tape.

Background

Every amino acid is encoded by triple nucleotide code like M(Methionine) is encoded by (atg)triple code and there are 64 combinations encoded for 21 amino acids.

Translation Method

This method is responsible for cutting the DNA into number of triple code every triple code is consisted of three nucleotides then the code will ask the database about the amino acid that is encoded by this specific triple code and we must know there are many triples code for one amino acid but there just one amino acid for every triple code the method will require both the sequence and the database connection and it will return series of amino acids.

public static string Translate(string seq, SqlConnection DnaPro)
{
    string Translation = "";
    using (SqlConnection cn = new SqlConnection(DnaPro.ConnectionString))
    {
        cn.Open();

        for (int x = 0; x < seq.Length / 3; x++)
        {
            int g = x * 3;
            string h = seq.Substring(g, 3);
            string cm = "select aminoacid from dnapro where dna='" + h + "'";
            SqlCommand cmd = new SqlCommand(cm, cn);
            Translation += cmd.ExecuteScalar();
        }

        return (string)Translation;
    }
}

Sequence Frames and the Probabilities of Translation

What if the first nucleotide in sequence was not the first nucleotide in translation and also what the two first nucleotides will not integrate into the translation process, this will leave you with three probabilities for the sequence which will be translated, and over all this what if the translation process will began from the opposite direction this will leave with three other probabilities (frames) and this mean that there are six frames (probabilities) for the main sequence which will enter the process of translation.

//One DIRECTION
 string frame1 = Translation.Translate(seq, DNAPro.Connection);
 string frame2 = Translation.Translate(seq.Substring(1), DNAPro.Connection);
 string frame3 = Translation.Translate(seq.Substring(2), DNAPro.Connection);
 //Opposite DIRECTION
 string Revseq = Main_Operations.Reversion(seq);
 string frame4 = Translation.Translate(Revseq, DNAPro.Connection);
 string frame5 = Translation.Translate(Revseq.Substring(1), DNAPro.Connection);
 string frame6 = Translation.Translate(Revseq.Substring(2), DNAPro.Connection);

Drawing the Result on Form

First define where every frame will be painted on the picture box or its position:

Translation.Frame1_Pos = 100;
Translation.Frame2_Pos = 110;
Translation.Frame3_Pos = 120;
Translation.Frame4_Pos = 155;
Translation.Frame5_Pos = 165;
Translation.Frame6_Pos = 175;

Then we will calculate the sequence which will be in this image depending on that every image has to contain 50 nucleotides.

double images = Main_Operations.How_Many_Images(seq); 

In the loop:

for (int image_No = 0; image_No < images; image_No++)
{
    //creating Bitmap image with specific dimensions 
    Image image = new Bitmap(500, 200);
    Graphics pic = Graphics.FromImage(image);
    //painting the reverse sequence
    string RevSeq = Main_Operations.Reversion(seq);
    Main_Operations.draw_Seq_On_Image(seq, image_No, pic, 85);
    Main_Operations.draw_Seq_On_Image(Revseq, image_No, pic, 145);
    Main_Operations.draw_SeqCount_On_Image(seq, Revseq, image_No, pic);
    //painting frames
    Translation.Draw_Trans_Result_Image(seq, Revseq, image_No, pic, 
                frame1, frame2, frame3, frame4, frame5, frame6, 70);
    //Processes
    //to paint the images at specific positions on form
    Draw_Box_With_This_Image(image_No, image);
}

public void Draw_Box_With_This_Image(int im, Image image)
{
    PictureBox p = new PictureBox();
    p.Location = new Point(0, im * 200);
    p.Image = image;
    p.Size = image.Size;
    Controls.Add(p);
}

Here is the method that will paint the frames on the image:

public static void Draw_Trans_Result_Image(string seq, string Revseq, 
   int image_No, System.Drawing.Graphics pic, string frame1, 
   string frame2, string frame3, string frame4, string frame5, 
   string frame6, int level)
{
    //painting Of the sequence of DNA Nu which are exists in this image.
    string subframe1 = "";
    string subframe2 = "";
    string subframe3 = "";
    string subframe4 = "";
    string subframe5 = "";
    string subframe6 = "";
    double MyNumber = Main_Operations.How_Many_Images(seq)-1;
    if (image_No < MyNumber )
    {
        subframe1 = frame1.Substring(image_No * 16 + image_No / 2, 16);
        subframe2 = frame2.Substring(image_No * 16 + image_No / 2, 16);
        subframe3 = frame3.Substring(image_No * 16 + image_No / 2, 16);
        subframe4 = frame4.Substring(image_No * 16 + image_No / 2, 16);
        subframe5 = frame5.Substring(image_No * 16 + image_No / 2, 16);
        subframe6 = frame6.Substring(image_No * 16 + image_No / 2, 16);
    }
    else
    {
        subframe1 = frame1.Substring(frame1.Length - frame1.Length % 16 + image_No / 2);
        subframe2 = frame2.Substring(frame2.Length - frame2.Length % 16 + image_No / 2);
        subframe3 = frame3.Substring(frame3.Length - frame3.Length % 16 + image_No / 2);
        subframe4 = frame4.Substring(frame4.Length - frame4.Length % 16 + image_No / 2);
        subframe5 = frame5.Substring(frame5.Length - frame5.Length % 16 + image_No / 2);
        subframe6 = frame6.Substring(frame6.Length - frame6.Length % 16 + image_No / 2);
    }

    for (int t = 0; t < seq.Length; t++)
    {
        if (t == 2 || (t - 2) % 3 == 0)
        {
            if (subframe1.Length > (t - 2) / 3)
                pic.DrawString(subframe1[(t - 2) / 3].ToString(), 
                  new Font("italic", 8, FontStyle.Bold), 
                  Brushes.DarkOrange, new PointF(t * 8 + 15, Frame1_Pos));
            if (subframe2.Length > (t - 2) / 3)
                pic.DrawString(subframe2[(t - 2) / 3].ToString(), 
                  new Font("italic", 8, FontStyle.Bold), 
                  Brushes.Purple, new PointF(t * 8 + 8 + 15, Frame2_Pos));
            if (subframe3.Length > (t - 2) / 3)
                pic.DrawString(subframe3[(t - 2) / 3].ToString(), 
                  new Font("italic", 8, FontStyle.Bold), 
                  Brushes.Blue, new PointF(t * 8 + 15 + 15, Frame3_Pos));
            if (subframe4.Length > (t - 2) / 3)
                pic.DrawString(subframe4[(t - 2) / 3].ToString(), 
                  new Font("italic", 8, FontStyle.Bold), 
                  Brushes.Red, new PointF(t * 8 + 15, Frame4_Pos));
            if (subframe5.Length > (t - 2) / 3)
                pic.DrawString(subframe5[(t - 2) / 3].ToString(), 
                  new Font("italic", 8, FontStyle.Bold), 
                  Brushes.Green, new PointF(t * 8 + 8 + 15, Frame5_Pos));
            if (subframe6.Length > (t - 2) / 3)
                pic.DrawString(subframe6[(t - 2) / 3].ToString(), 
                  new Font("italic", 8, FontStyle.Bold), 
                  Brushes.Brown, new PointF(t * 8 + 15 + 15, Frame6_Pos));
        }
    }
}

Note

I know that it's annoying when I used PictureBox to display the translation result and really I wanted to paint the result on a RichTextBox, and it will be very helpful if anyone can help me with this method. And I am very sorry that my code is not professional enough but what I can do is better than what I can't.

History

This code is related to the AzharDNA new bioinformatics program (basic tool for DNA translation).

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here