What do the following regular expressions compute when using
What do the following regular expressions compute when using Perl?
(vi) $protein =~ /$motif/
(vii) $dna =~ s/\\s//g
(viii) $complement = tr/acgt/tgca/
(ix) $rna =~ s/T/U/g
(x) $codon =~ /GA[TC]/i
Solution
(vi) $protein =~ /$motif/
It searches / compares if value of variable \'protein\' is equal to value of variable \'motif\'.
Returns true if the two values are equal , else false.
(vii) $dna =~ s/\\s//g
It replaces all the multiple whitespaces with a single space globally (at all occurences) in the value stored in variable \'dna\'.
(viii) $complement = tr/acgt/tgca/
It translates every character of 1st string (acgt) to the character at the same postion in the 2nd string (tgca) for the value of the variable \'complement\'.
(ix) $rna =~ s/T/U/g
It replaces/substitutes all the occurences of \'T\' with \'U\' for the value of the variable \'rna\'.
(x) $codon =~ /GA[TC]/i
It matches/ checks if the variable \'codon\' contains a pattern GA followed by either T or C. Also it ignores the case.
eg codon can match the following cases :
GATC , GATc , GAc , gaT ...
