Much thanks to JE's original idea, precise and concise, and Myrna's
essential amendment. Actually I realize my stupidity of missing one
line as Tom suggested when I was on the bed, and I'm really amazed to
see the how several brains led to the one-line code!
This is finally what I've to achieve, with including the degenerate
alphabets and distinguishing DNA from RNA:
Public Function RevCompl(sInput As String)
Dim sTemp As String
sUInput = UCase(sInput)
sTemp1 = Replace(sUInput, "T", "")
'If it is DNA
If Len(sTemp1) < Len(sUInput) Then
sTemp = Replace(Replace(Replace(Replace(Replace(Replace( _
Replace(Replace(Replace(Replace(Replace(Replace( _
sUInput, "R", "y"), "M", "k"), "Y", "r"), "K", "m"), _
"H", "d"), "D", "h"), "B", "v"), "V", "b"), _
"A", "t"), "C", "g"), "G", "c"), "T", "a")
'if it is RNA
Else
sTemp = Replace(Replace(Replace(Replace(Replace(Replace( _
Replace(Replace(Replace(Replace(Replace(Replace( _
sUInput, "R", "y"), "M", "k"), "Y", "r"), "K", "m"), _
"H", "d"), "D", "h"), "B", "v"), "V", "b"), _
"A", "u"), "C", "g"), "G", "c"), "U", "a")
End If
RevCompl = StrReverse(UCase(sTemp))
End Function
rgds,
Maurice
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!