Re: Lost in loops
- From: "Fred Kleinschmidt" <fred.l.kleinmschmidt@xxxxxxxxxx>
- Date: Tue, 24 Jan 2006 20:23:42 GMT
<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
.
- Follow-Ups:
- Re: Lost in loops
- From: annascalise
- Re: Lost in loops
- References:
- Lost in loops
- From: annascalise
- Lost in loops
- Prev by Date: Re: Manipulating large arrays very fast
- Next by Date: Scanning Strings to replace with links.
- Previous by thread: Re: Lost in loops
- Next by thread: Re: Lost in loops
- Index(es):
Relevant Pages
|