Re: Lost in loops




<annascalise@xxxxxxxxx> wrote in message
news:1138127254.218872.323480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I am really stuck with my program that will compare two strings and
> assign scores between pairs of letters.
>
> my sequences are read in ok
>
> seq1 = ATCGTCGTA
> seq2 = TCGTACTAA
>
> a second file formatted as so...
>
> A A 1
> T T 1
> C C 1
> G G 1
>
> is now in a 2D char array
>
> I just cannot think how on earth to get my values out of my array, i
> know if I get past this milestone I will be fine (I do not have much
> java experience or knowledge at my disposal - in fact it all i can do
> to understand the code I have wrote)
>
> thanks,
>
> Anna
>
><snip>

You don't say what you mean by "compare two strings", or what "assing a
score" means.
Do you mean that if seq1[i] is A and seq2[i] is G, then you assign score[i]
to be equal to the score (taken from the second file) assigned to the
sequence "AG" ?

Her's a simplistic way:
If you only have 4 different letters (A,T,C,G) then think about assigning 1,
2, 3, 4 to the different letters, and place in an int array, so seq1 becomes
iseq1={1,2,3,4,2,3,4,2,1}, etc. Then add iseq1[i] + 10*iseq2[1] and
compare to a score table created from the letter pairs:
AA becomes 11, so score[11] is set to 1
TT becomes 22, so score[22] is set to 1
AT becomes 21, so score[21] is set to n, where n is from the second file's
line "A T n"

Refine this using powers of 2 if there are more than 10 different letters.

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project


.



Relevant Pages

  • Re: Lost in loops
    ... >> I am really stuck with my program that will compare two strings and ... >> assign scores between pairs of letters. ... >> is now in a 2D char array ...
    (comp.lang.java.programmer)
  • Re: Lost in loops
    ... > I am really stuck with my program that will compare two strings and ... > assign scores between pairs of letters. ... > is now in a 2D char array ...
    (comp.lang.java.programmer)
  • string comparison?
    ... Remove the common words: ... Compare the remaining letters in both strings, ...
    (microsoft.public.vb.general.discussion)
  • Re: A note on computing thugs and coding bums
    ... Here's my response including a bug fix. ... to make "modern strings" possible was designed and first implemented ... contents to strings, to compare them, and to duplicate them. ... while the Pike code will NEVER work...for international strings. ...
    (comp.programming)
  • Re: Ascan with a Substr
    ... the above suggestion: ... operator to compare the strings. ... code block you originally used was just right, ...
    (comp.lang.clipper)