Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.pascal.borland    |    Borland Pascal was actually pretty neat    |    2,978 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 1,917 of 2,978    |
|    Bart to All    |
|    Re: Decoding RNA codons: fastest method     |
|    10 Oct 05 22:02:10    |
      From: broersma.juda_ANTISPAM_@tiscali.nl              Op Sun, 9 Oct 2005 22:49:21 +0100 schreef Dr John Stockton              >>function CodonHash(const ACodon: tCodon): Longint;       >>begin       >> Result := (Ord(ACodon[1]) shl 16) + (Ord(ACodon[2]) shl 8) +       >>Ord(ACodon[3]);       >>end;       >       [snip]       >It looks like Delphi; I don't recall Return in Pascal.       Yep, I recoded it in Delphi, my TP6 won't run under WinME on my       machine...              >This should be       >quicker, and gives the same but with a leading 3.       >       > function CodonHash(const ACodon: tCodon): Longint;       > begin CodonHash := Longint(ACodon) end;       Tried that: it gives me a compile error: invalid typecast       Tried move(ACodon,Result,3) --> gives same result (as expected) but is       slower.                     >Or, since the codons are made of ACGU only, encode each letter as 2 bits       >and store in a byte; you can then look the translation up in a small       >array of enumerated or string (fill unused entries with 0 or '').       Gonna give that a try                     >Since a letter needs only 5 bits, you could try encoding three in a byte       >as (X1*2+X2)*2+X3; there *may* be no duplicates. In fact, only 3 bits       >vary in ACGU : ...X.XX. : so (X1*32+X2)*32+X3 looks safe, using word       >arithmetic.       Will try that too                     >Arrange your numbers in order, and use a binary search; for 64 entries,       >that's about 6 comparisons rather than average 32.       My nested case scenario probably requires less comparisons on average,       so maybe its hard to get faster?              Bart       --       Bart Broersma       broersma.juda_ANTISPAM_@tiscali.nl       (ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca