| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| PL/I has a number of built-in functions for doing this type of task. Specifically, it has: 1. the TALLY function that counts the number of occurrences of a string. 2. the SEARCH function, whch looks for a string commencing with any character of a grroup of characters. 3. the VERIFY function, which could be used in you case to find the end of a sequence of characters that belongs to your set. For example, to search for the first character that is either G, A, T, C, one could write: k = search (String, 'GATC'); Then to find out whether other characters in that group follow it, one writes: j = verify (String, 'GATC', k); which tells you the position of the character beyond that sequence. Thus you have (j-k) consecutive characters consisting of the letters G, A, T, C in any combination. Assuming that there are two or more characters in that sequence, the first two characters must be one instance of your group below, and subsequent characters must be another instance (assuming that there are at least two more), and so on. If overlapping characters are to be included, you continue with the (k+1)-th character, and so on. <tomguest@hotmail.com> wrote in message news:81a1829b-ebce-4749-864c-0e5299772782@r66g2000hsg.googlegroups.com... > Hi > > I'm wanting to create a program that will search a text file for a > specific string (and count the number of occurances). I will want to > have a loop so that I can change the string in question. > > Example > > text file - GAATTCAGTTA > > search for every 2 letter combination of G, A, T and C > > result > GG - 0 > GA - 1 > GT - 1 > GC - 0 > AG - 1 > AA - 1 > AT - 1 > AC - 0 > etc... > etc... > > The text file is going to be very very very long. Hopefully I can get > my output file to be a single line (then maybe use grep?) > > I also want to make the search string relatively long. > > I do all my work in Fortran which does not lend its self to this kind > of problem. I can get it working for small strings but not long > strings (memory problems) > > Has anyone got any ideas? > > Cheers |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.