> -----Original Message-----
> From: Barney Boisvert [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 15, 2005 2:07 AM
> To: CF-Talk
> Subject: Re: reverse compliment a sequence
> 
> Highly recommend against that.  I intentionally used the less 
> familiar and more complex Java object, because it will be 
> significantly more performant as the string of DNA gets longer.

Point taken.


> The designers of the Java language assumed that people who 
> really care about efficiency will be intelligent enough to 
> use the proper type (String or StringBuffer) based on what 
> they're doing.  By and large, I don't recommend mixing 
> arbitrary Java into your CFML code, but the use of 
> StringBuffers when you have massive string concatenation is 
> definitely something to consider.

I wish that intelligence and laziness were mutually exclusive!

> Smart Java compilers may convert string concatenation into 
> StringBuffers automatically to aid the developer.  I have no 
> idea if CF is that smart, so I explicitly tell CF what I 
> want.  Note that I'm talking about non-linear concatenation; 
> linear concatenation is always done using StringBuffers, 
> because there isn't actually a concatenation operator, every 
> compiler will automatically convert it to some StringBuffer 
> operations, from what I understand.

Yes, that makes perfect sense.  In that case it also still makes for a nice,
scalable UDF if my plain vanilla concatenation is swapped out for your Java
version.  I guess we wouldn't be able to tell how slow the concatenation
method is without running it under some real load, but I'm sure the Java
solution would handily beat it at a certain point.

> On 6/14/05, Andrew Tyrone <[EMAIL PROTECTED]> wrote:
> > 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>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209515
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