Using Barney's elegant struct solution, we can take it one step further by
creating a UDF and getting rid of the Java by using a new variable and
appending to it:

<cfscript>

function RevCompDNA(dna) {
        
        var newdna = "";
        var t = structNew();
        
        t.c = "g";
        t.g = "c";
        t.a = "t";
        t.t = "a";

        for (i = 1; i LTE Len(arguments.dna); i=i+1) {
                
                newdna = newdna & t[mid(dna, i, 1)];
        
        }
        
        return newdna;

}

</cfscript>

<cfoutput>#RevCompDNA("actg")#</cfoutput>


Andy

> -----Original Message-----
> From: Richard Colman [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 14, 2005 2:45 PM
> To: CF-Talk
> Subject: reverse compliment a sequence
> 
> I need to to reverse compliment a nucleotide sequence, so
> 
> C become a G
> G becomes a C
> A becomes a T
> T becomes an A
> 
> I need to go through a string a character at a time and build 
> a new string.
> 
> So:
> 
> "ACTG" becomes "TGAC"
> 
> Is there an easy way to do this?
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209512
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to