Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# How to calculate occurrences in a Multimap?

michael stoker
Ranch Hand
Posts: 39
Hi everyone,

I'm new to Java and i'm facing some problems with Multimap tools.
I've got a text file that i parsed to collect some datas. In every single line, i collect the sequence Id, the gene names and its corresponding alleles and optionnaly the comments about the sequences (if there's one).

The aim of my work is first to sort the alleles out according to their corresponding genes (which is easy with the MultiMap by taking as a parameter an Arraylist which contains the list of all the alleles).

There is an example of my text file (i just made it more simple so its easier to understand):

So i need to get something like that :

which i could do it.

The problem starts here: For every different allele, i need to calculate:
-the number of the total sequences in which the allele appears
-the number of the redundant sequences
-the number of the non-redundants sequences
-the number of the sequences which contain a comment

To sum up, when i finished to read the file, i need to be able to say for every allele, how many sequences are associated to this allele and among those sequences, i need to be able to say how many are redundant and how many are not as well as how many contain a comment.
All this, while keeping the order defined first, which means the alleles sorted out according to their corresponding genes.

For example, for the allele 1 of the Gene A, i need to get as an output, something like this:

What would you propose as solutions to my problem please?

Any help will be really appreciated.

Ps: sorry for my english, i'm french

Martin Vanyavchich
Ranch Hand
Posts: 241
I don't know how many of these files you have and how many genes and sequences we're talking about. I would put all this data into a SQL database and do the sorting and counting there. Btw. how do you know if an allele is redundant or not?

... oh and about you beeing French, I totaly forgive you

michael stoker
Ranch Hand
Posts: 39