Functions To Get DNA and RNA Complementary Codes

For my most recent project at U of C, I had to write some script to find places where DNA and RNA might bind.

DNA (and RNA) will bind when 2 strands have a complementary sequence.  A binds with T, T bind with A, G binds with C and C binds with G. 

Basically the same thing happens with RNA.

Here are 2 functions that will quickly find the complementary sequence for DNA and RNA:

Public Function FlipRnaCode(ByVal sEnd As String) As String
    sEnd = Replace(sEnd, "U", "a", 1, -1, CompareMethod.Binary)
    sEnd = Replace(sEnd, "A", "u", 1, -1, CompareMethod.Binary)
    sEnd = Replace(sEnd, "G", "c", 1, -1, CompareMethod.Binary)
    sEnd = Replace(sEnd, "C", "g", 1, -1, CompareMethod.Binary)
    sEnd = UCase(sEnd)
    Return sEnd
End Function

Public Function FlipDnaCode(ByVal sEnd As String) As String
    sEnd = Replace(sEnd, "T", "a", 1, -1, CompareMethod.Binary)
    sEnd = Replace(sEnd, "A", "t", 1, -1, CompareMethod.Binary)
    sEnd = Replace(sEnd, "G", "c", 1, -1, CompareMethod.Binary)
    sEnd = Replace(sEnd, "C", "g", 1, -1, CompareMethod.Binary)
    sEnd = UCase(sEnd)
    Return sEnd
End Function

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s