Skip to main content

Perl programming #3

Hi,
You read the first two posts about perl? Missed? Don't worry, go and read here ( perl #1 #2 )

From today, we can learn few programs that would help biology students! Ya, as a biotechnology student I use perl programs for dealing with DNA , RNA and Proteins.

So, I know just something about perl (very limited) for processing sequences! Okay, let's learn some basic programs.

Program to convert DNA sequence to protein sequence:

print "enter a dna sequence file\n";
$dnafile=<>;
chomp($dnafile);
unless(open(DNAFILENAME,$dnafile))
{
print "file not found\n";
}
$dnafile=<DNAFILENAME>;
$dna=join("",$dnafile);
$dna=~s/\s//g;
$dna=uc($dna);
print "DNA seq. is\n",$dna;
$dna=~tr/T/U/;
print "mRNA seq. is\n", $dna,"\n";
my(%genetic_code)=
(
'UUU'=>'F',
'UUC'=>'F',
'UUG'=>'L',
'UUA'=>'L',
'UCU'=>'L',
'UCC'=>'S',
'UCG'=>'S',
'UCA'=>'S',
'UGU'=>'C',
'UGC'=>'C',
'UGG'=>'T',
'UGA'=>'Stop',
'UAU'=>'Y',
'UAC'=>'Y',
'UAG'=>'Stop',
'UAA'=>'Stop',
'CUU'=>'L',
'CUC'=>'L',
'CUG'=>'L',
'CUA'=>'L',
'CCU'=>'P',
'CCC'=>'P',
'CCG'=>'P',
'CCA'=>'P',
'CGU'=>'A',
'CGC'=>'A',
'CGG'=>'A',
'CGA'=>'A',
'CAU'=>'H',
'CAC'=>'H',
'CAG'=>'Q',
'CAA'=>'Q',
'GUU'=>'V',
'GUC'=>'V',
'GUG'=>'V',
'GUA'=>'V',
'GCU'=>'A',
'GCC'=>'A',
'GCG'=>'A',
'GCA'=>'A',
'GGU'=>'G',
'GGC'=>'G',
'GGG'=>'G',
'GGA'=>'G',
'GAU'=>'A',
'GAC'=>'A',
'GAG'=>'E',
'GAA'=>'E',
'AUU'=>'I',
'AUC'=>'I',
'AUG'=>'I',
'AUA'=>'I',
'ACU'=>'T',
'ACC'=>'T',
'ACG'=>'T',
'ACA'=>'T',
'AGU'=>'S',
'AGC'=>'S',
'AGG'=>'R',
'AGA'=>'R',
'AAU'=>'N',
'AAC'=>'N',
'AAG'=>'K',
'AAA'=>'K',
);
for($i=0;$i<(length($dna)-2);$i+=3)
{
$codon=substr($dna,$i,3);
$protein.=$genetic_code{$codon};
}
print "the protein sequence is\n",$protein,"\n";
open (PROTEIN, ">protein.txt");
print PROTEIN $protein;
close PROTEIN;
exit;

O/P of the above perl code
"Hashing" here we are using "Genetic code" where we specified the one letter aminoacid code for the codon

"length" this command is used in the perl for finding the number of letters in the pattern
"substr" is used for getting a substring from the given string. You can specify the string from which the substring must be taken and the number of letters of the string that must be taken as substring can also be selected.

$codon=substr($dna,$i,3);

Here, we are selecting the substring from the main string stored in "$dna" and as we are going to take as codon, so, we are taking 3 letters here as substring.

In the following line,
 
 $protein.=$genetic_code{$codon};

we are converting the three letter codon into one letter amino acid code and saving it in $protein. 
We are using ".= " which appends the value when each time the for loop is executed, so that, we get the complete aminoacid sequence, rather than a single amino acid - check with out giving the "dot", you could understand it better. 

In the following lines, we are saving the output sequence in a text file, we are creating the file protein.txt. In the next line, we are printing the output in the created file, in the next line, we  are closing the file.

open (PROTEIN, ">protein.txt");
print PROTEIN $protein;
close PROTEIN;

I explained in my own way, hope i explained in a better way.
Got the concept? Any doubts??? Then, comment.
 

Comments

Popular posts from this blog

Lowry Assay Principle and procedure

Though there are several protein assays available, the most preferred one in many laboratories is "Lowry assay". It is effective in the concentration range of 0.01 mg/ml to 1 mg/ml. And, as an additional info, the paper published describing the procedure and principle of Lowry Assay is the most cited paper in the scientific history. (Feeling like, "Wow! I want to publish one to compete with Oliver.H. Lowry"???  :P) Why Lowry?   Though there are several other protein assays, mostly Lowry assay is used in many laboratories. The reasons for preferring Lowry are: sensitivity of the assay, highly reproducible, cost effective, easy to perform. Biuret assay is generally used for higher protein concentrations like tissue samples but, Lowry for less concentrated samples and hence used in most of the molecular biology laboratories where there will be need for assaying comparatively less concentrated protein samples (in most cases where we attempt to produce enzymes). Oth...

Fire in the lab!!! BE CAREFUL!!!! A Lesson learnt!

   That day, we were working in our lab under laminar air flow chamber. we were streaking our plates with E.coli. For sterilizing the loop, we were using 70% ethanol. We also sterilized the L rod which we used for spreading , using the same Ethanol.  One by one, we started streaking and spreading. I completed my turn, and sterilized the L rod by dipping in ethanol once and shown in flame, and placed it in a tray.Mam instructed, " Ethanol will catch fire , if you place the hot rod over it" . One of my friend, did spreading after my turn, she too dipped the rod in ethanol, flamed the rod and instead of placing in the tray she misplaced the hot rod in the ethanol plate!!!! " oooo... fire fire..." immediately ethanol caught fire..!!! My friend who misplaced., she started crying... Mam shouted, " hey girls, guys run out of the lab...," as the tube which carries LPG for the flame was very close to fire. Suddenly, our lab technician acte...

Galaataa at Chemical engg lab!!! :D :D Bang!!!

Venturi meter  Oooo.. Pipes, Flows, Fluid flow rate... A different class of chemical engineering, which i never expected in Biotechnology. Thought that mechanical guys alone read on & deal on this thermodynamics!!! But, I too dealt with this thermodynamics. The chemical engineering lab which includes exercises like, 1) Venturi meter 2) Orifice Meter 3) Rota meter 4) Packed bed 5) Fluidised bed... The list goes on and ends with number 14! But, I do remember only these topics. Completed with the exercise, " FLUID FLOW THROUGH A STRAIGHT CIRCULAR PIPE " in the last lab on thursday!. Here we go with that lab experience.  Noted the reading from manometer and stop clock successfully with my two batch mates! Some data we searched for calculation : 1) Density of Mercury : 13,600 Kg/m^3  2) Viscosity of Water  : 0.001 Kg/(m-s) 3) We were in need of the area of the collecting tank .... A terrible attempt by me, for measuring the width & breadth. ...