Overview
In this example, you will learn how to chagne the whole sequence into lower case, find all atg and capitalize them into ATG so that we can visually see them.
Example Code
Output
gcacagggtgaacgtaacgatggctgatcgtataagtgtgactatggccgacactgatagagtcaacttgaccatgcacagggtgaacgtaacg
gcacagggtgaacgtaacgATGgctgatcgtataagtgtgactATGgccgacactgatagagtcaacttgaccATGcacagggtgaacgtaacg
Decode
>>Line 10: $sequence= lc($sequence) ;
lc(STRING) is a perl build in function that will transform the whole STRING into lower case.
uc(STRING) is a perl function that will capitalize the whole STRING.
>>Line 16: $sequence=~s/atg/ATG/g;
~s/REGEX/REPLACEMENT/g is a substitution operator. In our example, $sequence=~s/atg/ATG/g , this command search $sequence for all occurrences of atg and replace them into ATG.
Note: g means global. Without g, the command $seqeunce=~s/atg/ATG will only search for the first occurrence of atg and replace it with ATG.
Exercise Three
>> $sequence="gcacagggtgaacgtaacgatggctgatcgtataagtgtgactatggccgacactgatagagtcaacttgaccatgcacagggtgaacgtaacg ";
Write a program to change the above sequece into capital letters and find stop codon (TGA) to change them into lower case and then print the result.