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

Sea Butterfly!

Neih hou!  Don't roll you eyes wondering what it is! "Neih hou" is how you say "hello" in Cantonese. Guess what, I am in Hong Kong and therefore the language Cantonese. I came to Hong Kong this summer as an intern before officially joining as a PhD Student. This is my second experience abroad, far away from home, new language, new culture, I expected me to have a "really" bad cultural shock, but, actually I experienced only 50% of what I expected. For a girl who have used the marina beach only for eating "sundal", bikini in beach was a shock (FEEL FREE TO JUDGE ME!). The first time, I went to the big wave beach here, I was the only one who was totally covered, when everyone was enjoying their Beer, I was slowly sipping my lemon juice (THE ODD ONE OUT!). I realized how beautifully different the world outside is! There is no single standard for right or wrong, it varies in different countries, in different regions around the world. And it ...

The Butterfly flew for the first time!

Hi dear sweet lovely reader, Didn't meet you for a long time... Just after complaining about the stipend problem in the last post, I actually wanted to write a lot here, but, couldn't find time (Such a lazy girl, I am!). As you might be knowing, the author (me) is the butterfly here :P And, I flew for the first time!! YEAH! I FLEW! I flew like a butterfly! It was an awesome experience flying for the very first time! (ow, no! I dint put a trans-gene in my body and fly after getting  a pair of wings, but with a passport and VISA). I'm this girl, full of dreams wishing to do "this", "that" and "all kind of stuffs that one can do". And, one among those dreams was to fly one day! TO FLY FREE!(I mean, not free of cost :P, but liberation) I always wanted to fly in those big, big airplanes, but, I always have avoided that mode of transport. Reason? Obviously, it would burn a big hole in my dad's pocket (actually he can afford if I wan...