Posted to microsoft.public.excel.programming
|
|
A function of reverse complement
I guess my objective in this case is more to show the OP what steps are to be
taken. To demonstrate as a learning tool, I would have done the replacements
as 4 steps (as the OP had done originally), a 5th line to to the UCase, a 6th
for the StrReverse, and a 7th to assign to the function output. I don't know
whether in the real world that is slower or faster than combining everything
into one statement.
On Mon, 17 Jan 2005 14:37:08 -0500, "Tom Ogilvy" wrote:
If the objective is to pack everything together, why stop there
Public Function ReverseComplement(sInput As String)
ReverseComplement = _
StrReverse(UCase(Replace(Replace(Replace(Replace( _
sInput, "A", "u"), "C", "g"), "G", "c"), "U", "a")))
End Function
---
Regards,
Tom Ogilvy
"Myrna Larson" wrote in message
.. .
Nice one, JE! I think he also wants the characters in reverse order, so
perhaps this slight modification will take care of that:
Public Function ReverseComplement(sInput As String)
Dim sTemp As String
sTemp = UCase(Replace(Replace(Replace(Replace( _
sInput, "A", "u"), "C", "g"), "G", "c"), "U", "a"))
ReverseComplement = StrReverse(sTemp)
End Function
On Mon, 17 Jan 2005 11:43:12 -0700, JE McGimpsey
wrote:
Perhaps
Public Function ReverseComplement(sInput As String)
Dim sTemp As String
sTemp = UCase(Replace(Replace(Replace(Replace( _
sInput, "A", "u"), "C", "g"), "G", "c"), "U", "a"))
ReverseComplement = sTemp
End Function
In article ,
M H wrote:
I've written an excel function aim to change a RNA sequence to its
reverse complement (e.g. from "ACGUUGUA" to "UACAACGU") as:
Function ReverseComplement(Rcell As Range, Optional IsText As Boolean)
Dim i As Integer
Dim strReverseSeq As String
Dim strSenseSeq As String
strSenseSeq = Trim(Rcell)
For i = 1 To Len(strSenseSeq)
strReverseSeq = Mid(strSenseSeq, i, 1) & _ strReverseSeq
Next i
If IsText = False Then
ReverseComplement = CLng(strReverseSeq)
Else
ReverseComplement = strReverseSeq
End If
strSeqA1 = Replace(strReverseSeq, "A", "1")
strSeqC2 = Replace(strSeqA1, "C", "2")
strSeqG3 = Replace(strSeqC2, "G", "3")
strSeqT4 = Replace(strSeqG3, "U", "4")
strSeq1T = Replace(strSeqT4, "1", "U")
strSeq2G = Replace(strSeq1T, "2", "G")
strSeq3C = Replace(strSeq2G, "3", "C")
strSeq4A = Replace(strSeq3C, "4", "A")
End Function
The first half works fine, which reverse the sequence, but the second
part doesn't work, which cannot make the comoplements Please help for
debug. Much thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
|