Click here to Skip to main content
15,867,686 members
Articles / General Programming / Algorithms

AzharDNA New Bioinformatics Program (DNA Translation)

Rate me:
Please Sign up or sign in to vote.
4.21/5 (7 votes)
4 Mar 2014CPOL2 min read 27.2K   541   13   12
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.

C#
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.

C#
//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:

C#
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.

C#
double images = Main_Operations.How_Many_Images(seq); 

In the loop:

C#
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:

C#
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Agriculture Genetic Engineering Research Institute
Egypt Egypt
I have adored bioinformatics since my second year in college and then I specialized in this field in my final year in biotechnology department, I have learned both C# and Perl Languages to build open soft-wares contain specialized tools in this particular science.
I'm trying to enhance my knowledge in this beautiful field by both reading and writing articles , also I hope to gain both master and doctoral degree in it.
If you have any scholarship, source , opportunity , project or idea which can help me to reach my goal don't hesitate to contact me on :
E-Mail:samman_mahmoud@yahoo.com
Facebook:Samman Mahmoud
Tel: +20118904500

Comments and Discussions

 
QuestionAwesome Pin
Angel E Calvas5-Mar-14 8:39
Angel E Calvas5-Mar-14 8:39 
GeneralNot professional coding, but interesting topic Pin
John Brett5-Mar-14 1:08
John Brett5-Mar-14 1:08 
GeneralMy vote of 1 Pin
JP_Rocks21-Jul-11 23:44
JP_Rocks21-Jul-11 23:44 
QuestionVirus VERIFIED Pin
Dave Kreskowiak21-Jul-11 9:17
mveDave Kreskowiak21-Jul-11 9:17 
QuestionVIRUS Pin
BigTimber@home20-Jul-11 3:01
professionalBigTimber@home20-Jul-11 3:01 
Attempting download of the setup for this post raised a virus alert.
AnswerRe: VIRUS Pin
Al-Samman Mahmoud20-Jul-11 4:26
Al-Samman Mahmoud20-Jul-11 4:26 
GeneralRe: VIRUS Pin
Mehran Taherimoud20-Jul-11 13:40
Mehran Taherimoud20-Jul-11 13:40 
GeneralRe: VIRUS Pin
Al-Samman Mahmoud21-Jul-11 3:34
Al-Samman Mahmoud21-Jul-11 3:34 
GeneralRe: VIRUS Pin
embroidery24-Jul-11 23:26
embroidery24-Jul-11 23:26 
GeneralRe: VIRUS Pin
Al-Samman Mahmoud25-Jul-11 6:35
Al-Samman Mahmoud25-Jul-11 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.