RE: reverse compliment a sequence
> I wish that intelligence and laziness were mutually exclusive! To hell with that! Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| 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:209627 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
RE: reverse compliment a sequence
You learn something new every day. Thanks for the explanation, i thought it worked like the TR (translate) function in unix. /t >-Original Message- Subject: reverse compliment a sequence >From: Barney Boisvert <[EMAIL PROTECTED]> >Date: Tue, 14 Jun 2005 12:33:28 -0700 >Thread: >http://www.houseoffusion.com/cf_lists/index.cfm/method=messages >&threadid=40706&forumid=4#209461 > >ReplaceList is the same as a series of replace operations. so first >it replaces the C with a G leaving AGTG, then G with C leaving ACTC, >then A with T leaving TCTC, and finally T with A leaving ACAC. > >replaceList("ACTG", "A,T,Z,G,C,Z", "Z,A,T,Z,G,C") should work > >cheers, >barneyb > >On 6/14/05, RADEMAKERS Tanguy <[EMAIL PROTECTED]> wrote: >> Well, i was going to suggest using >> >> #ReplaceList("ACTG","C,G,A,T","G,C,T,A")# >> >> but on my system that replaces "ACTG" with "ACAC" >> >> i'm confused? > >-- >Barney Boisvert >[EMAIL PROTECTED] >360.319.6145 >http://www.barneyb.com/ > >Got Gmail? I have 50 invites. ~| 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:209532 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
Re: reverse compliment a sequence
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Barney Boisvert wrote: > It ought to do what it's documented to do, which is replace each > instance of the first list's items with the corresponding item from > the second list. It does that very well. Which can be interpreted two ways. One is the intuitive one, which is like a string- rather than character-based version of tr///, where the input string is scanned for the span of characters closest to the beginning of the string that matches one of the elements in the domain list. This span of characters is replaced with its corresponding entry in the range list. It then does the same thing with the remainder of the string following the span that's just been replaced. Wash, rinse, repeat. This is a useful function. Then there's the counterintuitive one, which is how ReplaceList() works: function ReplaceList(text, rangeList, domainList) { var i = 0; var range = ListToArray(rangeList); var domain = ListToArray(domainList); for (i = 1; i lte ArrayLen(range); i = i + 1) { text = Replace(text, range[i], domain[i], "ALL"); } return text; } Which is, quite frankly, next to useless and violates the Principle of Least Surprise. That, in itself, is a bug. > Whether that particular function is useful at all is up for debate > (I'm on the 'no' side). Ditto. K. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCsAY/mSWF0pzlQ04RAq7bAJ9U5KMiBh4XHetuOjPYG/tx8kmY3ACfXkhR HIqMjKBhjyUB1uKuWCYFBXA= =dDma -END PGP SIGNATURE- ~| 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:209524 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: reverse compliment a sequence
> -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: > > > > > > > > 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; > > > > } > > > > > > > > #RevCompDNA("actg")# ~| 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
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. Java has a String "system", for lack of a better term, that is optimized for speed and memory utilization with static strings, at the expense of speed when manipulating strings. In particular, string operations such as len, mid, left, right, etc. are designed to be fast. Operations such as replace and concatenation are designed to be somewhat slower in order to make the first group faster. It's a tradeoff, but one that makes sense the vast majority of the time. StringBuffers (the object I used), on the other hand, are designed in "normal" fashion, without any particular optimizations for certain operations. Consequently they're a little slower for some operations than standard Strings, but they're much faster for other operations (in particular, concatenation). 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. 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. cheers, barneyb 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: > > > > 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; > > } > > > > #RevCompDNA("actg")# > > > Andy -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209513 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
RE: reverse compliment a sequence
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: 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; } #RevCompDNA("actg")# 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
Re: reverse compliment a sequence
It ought to do what it's documented to do, which is replace each instance of the first list's items with the corresponding item from the second list. It does that very well. Whether that particular function is useful at all is up for debate (I'm on the 'no' side). But it's far from the only "weird" in the CF function library. For example, there's a ceiling() function (which is quite useful), but not a floor() function. There's int() and fix(), and int() does what the floor() function usually does, and fix() does some integer truncation. There are certainly other examples. cheers, barneyb On 6/14/05, Keith Gaughan <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Ray Champagne wrote: > > > that seemed harsh... > > It's not. It *ought* to work something like string-based version of > tr/// in Perl, but doesn't. -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209499 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
Re: reverse compliment a sequence
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ray Champagne wrote: > that seemed harsh... It's not. It *ought* to work something like string-based version of tr/// in Perl, but doesn't. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCr3aamSWF0pzlQ04RAkc0AKDd+da4PHIlMeFMNaPcZvLkpMlN3QCg2NaO cwTneqWUdy/vDqDgkQT5XM8= =nLXp -END PGP SIGNATURE- ~| 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:209494 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
Re: reverse compliment a sequence
that seemed harsh... Keith Gaughan wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > RADEMAKERS Tanguy wrote: > > >>Well, i was going to suggest using >> >>#ReplaceList("ACTG","C,G,A,T","G,C,T,A")# >> >>but on my system that replaces "ACTG" with "ACAC" >> >>i'm confused? > > > That's 'cause it's riddled with bugs. It ought to work but doesn't. > > K. > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.1 (MingW32) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFCr3EUmSWF0pzlQ04RAsRAAKCg0WNSB+riLkETGI7xqvNCm/hyPwCgh4L2 > /ufYlQwtcqARjrTJ1K0CuX8= > =cHSn > -END PGP SIGNATURE- > > ~| 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:209493 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 RADEMAKERS Tanguy wrote: > Well, i was going to suggest using > > #ReplaceList("ACTG","C,G,A,T","G,C,T,A")# > > but on my system that replaces "ACTG" with "ACAC" > > i'm confused? That's 'cause it's riddled with bugs. It ought to work but doesn't. K. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCr3EUmSWF0pzlQ04RAsRAAKCg0WNSB+riLkETGI7xqvNCm/hyPwCgh4L2 /ufYlQwtcqARjrTJ1K0CuX8= =cHSn -END PGP SIGNATURE- ~| 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:209492 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Richard Colman wrote: > 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? The following does something simple like Perl's tr///. function Translate(text, from, to) { var iText = 0; var iTrans = 0; var result = ""; var ch = ""; for (iText = 1; iText lte Len(text); iText = iText + 1) { ch = Mid(text, iText, 1); iTrans = Instr(ch, from); if (iTrans gt 0) ch = Mid(to, iTrans , 1); result = result & ch; } return result; } No error checking, quick hack, but it ought to work. K. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCr3BHmSWF0pzlQ04RAgFfAKDpvYJobImfGyDR6w+exZwaZTHNpACgui2H ZhrBxlGpnk8SjQGAs7rtv9I= =GVFZ -END PGP SIGNATURE- ~| 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:209491 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
RE: reverse compliment a sequence
> -Original Message- > From: Ben Doom [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 14, 2005 4:07 PM > To: CF-Talk > Subject: Re: reverse compliment a sequence > > Jeff Congdon wrote: > > The replace idea below will work as long as those temporary values don't > > exist anywhere in the original string, which seems a risky assumption. > > Not knowing the original values though, I can't speak for that. > > Since he's looking for a DNA sequence compliment, we know that the only > chars present will be a,t,g,c -- the four types in DNA. Maybe not > common knowledge, though. In this case I would probably use the digits 1-4 as placeholders - it makes really clear which characters are placeholders and which aren't. Of course a potentially confusing, potentially elegant solution is to uppercase the original value, replace with lower case letters (which would allow for only four replaces) and then uppercase the whole mess again. Jim Davis ~| 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:209479 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
RE: reverse compliment a sequence
How about this. newlist = ""; string = "A,C,G,C,T,A,C,T"; for(i=1; i LTE listlen(string);i=i+1) { idx = listgetat(string,i); switch(idx) { case 'A': newlist = listAppend(newlist,'T'); break; case 'T': newlist = listAppend(newlist,'A'); break; case 'C': newlist = listAppend(newlist,'G'); break; case 'G': newlist = listAppend(newlist,'C'); break; default: break; } } writeoutput(string & ""); writeoutput(newlist); ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209478 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
Re: reverse compliment a sequence
Ben Doom wrote: >Jeff Congdon wrote: > > >>The replace idea below will work as long as those temporary values don't >>exist anywhere in the original string, which seems a risky assumption. >>Not knowing the original values though, I can't speak for that. >> >> > >Since he's looking for a DNA sequence compliment, we know that the only >chars present will be a,t,g,c -- the four types in DNA. Maybe not >common knowledge, though. > > haha, I skipped that section of Ben Forta's Advanced CF book ;) Without that knowledge, my replies are toward a solution that will work with any string, and any replacable letters. -Jeff ~| 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:209477 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
RE: reverse compliment a sequence
Replace is case sensitve, so if it's all one case in the original string you can do some variation of this: #Ucase(DNA)# ~| 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:209476 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: reverse compliment a sequence
Should work. -- Damien McKenna - Web Developer - [EMAIL PROTECTED] The Limu Company - http://www.thelimucompany.com/ - 407-804-1014 #include ~| 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:209473 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
Re: reverse compliment a sequence
Jeff Congdon wrote: > The replace idea below will work as long as those temporary values don't > exist anywhere in the original string, which seems a risky assumption. > Not knowing the original values though, I can't speak for that. Since he's looking for a DNA sequence compliment, we know that the only chars present will be a,t,g,c -- the four types in DNA. Maybe not common knowledge, though. Frequently, I use chr(7) == 'bell' because the bell symbol is generally untypable. :-) --Ben ~| 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:209472 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
DNA is composed of only those 4 nucleotides, so any other values can't occur within the string. Hence the temp value solution works. If not, then you'd have to do the live replace method that your or I proposed. I suspect my solution would be significantly faster, particularly over longer strings, but it's the same idea. cheers, barneyb On 6/14/05, Jeff Congdon <[EMAIL PROTECTED]> wrote: > Yes sorry, I meant the replace idea outlined in the quoted section of my > email ;) > > The replace idea below will work as long as those temporary values don't > exist anywhere in the original string, which seems a risky assumption. > Not knowing the original values though, I can't speak for that. > > -Jeff -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209471 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
4 temp values is overkill. You only need 2 (one for the a<->z and one for the g<->c; you can actually use the same char for both). atgcacgt a->z : ztgczcgt t->a : zagczcga z->t : tagctcga g->z : tazctcza c->g : tazgtgza t->c : tacgtgca atgcacgt tacgtgca So, you get the correct compliment. --Ben Dawson, Michael wrote: > Replace() will work if you use *four* temporary values. > > Replace 'a' with '1' > Replace 'c' with '2' > Replace 'g' with '3' > Replace 't' with '4' > > Then > > Replace '1' with 't' > Replace '2' with 'g' > Replace '3' with 'c' > Replace '4' with 'a' > > Then, you mix in some love and you have a dino-baby. > > M!ke > > -Original Message- > From: Jeff Congdon [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 14, 2005 2:41 PM > To: CF-Talk > Subject: Re: reverse compliment a sequence > > the replace idea won't work. it will replace all 'a' with 'z', then > replace all 'z' with 't' > > this leads to all 'a' being replaced with 't', not with all 'a' being > replaced with 't'. > > ~| 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:209470 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
Re: reverse compliment a sequence
Yes sorry, I meant the replace idea outlined in the quoted section of my email ;) The replace idea below will work as long as those temporary values don't exist anywhere in the original string, which seems a risky assumption. Not knowing the original values though, I can't speak for that. -Jeff Dawson, Michael wrote: >Replace() will work if you use *four* temporary values. > >Replace 'a' with '1' >Replace 'c' with '2' >Replace 'g' with '3' >Replace 't' with '4' > >Then > >Replace '1' with 't' >Replace '2' with 'g' >Replace '3' with 'c' >Replace '4' with 'a' > >Then, you mix in some love and you have a dino-baby. > >M!ke > >-Original Message- >From: Jeff Congdon [mailto:[EMAIL PROTECTED] >Sent: Tuesday, June 14, 2005 2:41 PM >To: CF-Talk >Subject: Re: reverse compliment a sequence > >the replace idea won't work. it will replace all 'a' with 'z', then >replace all 'z' with 't' > >this leads to all 'a' being replaced with 't', not with all 'a' being >replaced with 't'. > > ~| 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:209469 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
Amen to that. Single replaces are always better. Easier to read, far more indicitive of what's really happening, and probably very close to equally performant. cheers, barneyb On 6/14/05, Jim Davis <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: Barney Boisvert [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, June 14, 2005 3:33 PM > > To: CF-Talk > > Subject: Re: reverse compliment a sequence > > > > ReplaceList is the same as a series of replace operations. so first > > it replaces the C with a G leaving AGTG, then G with C leaving ACTC, > > then A with T leaving TCTC, and finally T with A leaving ACAC. > > 'Xactly - so while you could condense one of the multiple-replace options > down to one line it's probably not worth it as the code will be all but > unintelligible. > > Personally I find "replacelist" to be really obtuse. ;^) > > Jim Davis > > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209468 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
Re: reverse compliment a sequence
> the replace idea won't work. it will replace all 'a' with 'z', then > replace all 'z' with 't' Right. That's how it's supposed to work. > this leads to all 'a' being replaced with 't', not with all 'a' being > replaced with 't'. Huh? --Ben ~| 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:209467 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: reverse compliment a sequence
Replace() will work if you use *four* temporary values. Replace 'a' with '1' Replace 'c' with '2' Replace 'g' with '3' Replace 't' with '4' Then Replace '1' with 't' Replace '2' with 'g' Replace '3' with 'c' Replace '4' with 'a' Then, you mix in some love and you have a dino-baby. M!ke -Original Message- From: Jeff Congdon [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 2:41 PM To: CF-Talk Subject: Re: reverse compliment a sequence the replace idea won't work. it will replace all 'a' with 'z', then replace all 'z' with 't' this leads to all 'a' being replaced with 't', not with all 'a' being replaced with 't'. ~| 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:209466 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
the replace idea won't work. it will replace all 'a' with 'z', then replace all 'z' with 't' this leads to all 'a' being replaced with 't', not with all 'a' being replaced with 't'. without instantiating java... Probably not the most efficient, but it should get you there. -Jeff Barney Boisvert wrote: >I didn't say it was perfect. ;) The replace stuff is a lot better, most >likely. > >I used a StringBuffer because string manipulation in Java is quite >slow, and by using a buffer I'd circumvent the issue almost >completely. > >cheers, >barneyb > >On 6/14/05, Matthew Small <[EMAIL PROTECTED]> wrote: > > >>That seems like a lot of work. Why instantiate java? >> >> >>dna = "actg"; >>newdna = dna; >>newdna = replace(newdna,"a","z"); >>newdna = replace(newdna,"t","a"); >>newdna = replace(newdna,"z","t"); >>newdna = replace(newdna,"c","z"); >>newdna = replace(newdna,"g","c"); >>newdna = replace(newdna,"z","g"); >> >> >> > > > > ~| 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:209464 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
RE: reverse compliment a sequence
> -Original Message- > From: Barney Boisvert [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 14, 2005 3:33 PM > To: CF-Talk > Subject: Re: reverse compliment a sequence > > ReplaceList is the same as a series of replace operations. so first > it replaces the C with a G leaving AGTG, then G with C leaving ACTC, > then A with T leaving TCTC, and finally T with A leaving ACAC. 'Xactly - so while you could condense one of the multiple-replace options down to one line it's probably not worth it as the code will be all but unintelligible. Personally I find "replacelist" to be really obtuse. ;^) Jim Davis ~| 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:209462 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reverse compliment a sequence
ReplaceList is the same as a series of replace operations. so first it replaces the C with a G leaving AGTG, then G with C leaving ACTC, then A with T leaving TCTC, and finally T with A leaving ACAC. replaceList("ACTG", "A,T,Z,G,C,Z", "Z,A,T,Z,G,C") should work cheers, barneyb On 6/14/05, RADEMAKERS Tanguy <[EMAIL PROTECTED]> wrote: > Well, i was going to suggest using > > #ReplaceList("ACTG","C,G,A,T","G,C,T,A")# > > but on my system that replaces "ACTG" with "ACAC" > > i'm confused? -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209461 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
Re: reverse compliment a sequence
I didn't say it was perfect. ;) The replace stuff is a lot better, most likely. I used a StringBuffer because string manipulation in Java is quite slow, and by using a buffer I'd circumvent the issue almost completely. cheers, barneyb On 6/14/05, Matthew Small <[EMAIL PROTECTED]> wrote: > That seems like a lot of work. Why instantiate java? > > > dna = "actg"; > newdna = dna; > newdna = replace(newdna,"a","z"); > newdna = replace(newdna,"t","a"); > newdna = replace(newdna,"z","t"); > newdna = replace(newdna,"c","z"); > newdna = replace(newdna,"g","c"); > newdna = replace(newdna,"z","g"); > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209458 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
RE: reverse compliment a sequence
That seems like a lot of work. Why instantiate java? dna = "actg"; newdna = dna; newdna = replace(newdna,"a","z"); newdna = replace(newdna,"t","a"); newdna = replace(newdna,"z","t"); newdna = replace(newdna,"c","z"); newdna = replace(newdna,"g","c"); newdna = replace(newdna,"z","g"); Matthew Small Web Developer American City Business Journals 704-973-1045 [EMAIL PROTECTED] -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 2:54 PM To: CF-Talk Subject: Re: reverse compliment a sequence #result.toString()# cheers, barneyb On 6/14/05, Richard Colman <[EMAIL PROTECTED]> wrote: > 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? > > > Richard Colman > Institute for Genomics and Bioinformatics > 949-824-1816, 701-5330 > [EMAIL PROTECTED] > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209452 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
Re: reverse compliment a sequence
Offhand, using a placeholder and a series of replace()'s will work: replace(text, 'g', '|', 'all') replace(text, 'c', 'g', 'all') replace(text, '|', 'c', 'all') replace(text, 'a', '|', 'all') replace(text, 't', 'a', 'all') replace(text, '|', 't', 'all') replacelist() may work. I'm not sure if it's serial for each item in the list or parallel, and I'm too lazy to investigate. :-) --Ben Richard Colman wrote: > 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? > > > Richard Colman > Institute for Genomics and Bioinformatics > 949-824-1816, 701-5330 > [EMAIL PROTECTED] > > > > ~| 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:209451 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
RE: reverse compliment a sequence
Well, it needs to be done a character at a time, so, I am not entirely sure that replace ("ACTG","TGAC", "all") would work in all cases. However, Barney's solution is quite elegant! TNX to both of you for helping with a common genomics transformation. Rick. -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 11:56 AM To: CF-Talk Subject: Re: 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" At first sight, simply replace ("ACTG","TGAC", "all") should do it, but I suspect the problem to be a little more complex, can you give us more detail (may be a link) about what a "nucleotide sequence" may look like? -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| 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:209450 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
Re: 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" At first sight, simply replace ("ACTG","TGAC", "all") should do it, but I suspect the problem to be a little more complex, can you give us more detail (may be a link) about what a "nucleotide sequence" may look like? -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209448 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
Re: reverse compliment a sequence
#result.toString()# cheers, barneyb On 6/14/05, Richard Colman <[EMAIL PROTECTED]> wrote: > 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? > > > Richard Colman > Institute for Genomics and Bioinformatics > 949-824-1816, 701-5330 > [EMAIL PROTECTED] > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| 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:209447 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54