multiple line parsing help

Hey everyone,

I'm having trouble figuring out how to reformat the following (large) file:

>Cluster 1
0 563nt, >FX2FH6V05GB01A... *
1 405nt, >FX2FH6V05F7LOL... at +/98%
>Cluster 2
0 551nt, >FX2FH6V05FTLO0... at +/98%
1 561nt, >FX2FH6V05F5F1E... *
2 343nt, >FX2FH6V05GBHRK... at +/98%

I need to reformat it so that the string in front of the asterisk is first on a line, followed by that string repeated, and the all of the other strings in the cluster. For example:
FX2FH6V05GB01A FX2FH6V05GB01A, FX2FH6V05F7LOL
FX2FH6V05F5F1E FX2FH6V05F5F1E, FX2FH6V05FTLO0, FX2FH6V05GBHRK

Some of the clusters are very large, and the string followed by the asterisk can be anywhere within that cluster. I can probably figure out how to flatten everything, but I'm not sure how to reorder the strings so that the one with the asterisk comes first.

Many thanks in advance for your advice.

Try...

awk '/>Cluster/{c=$2;next}
     {z=substr($3,2,14);if($NF=="*")b[c]=z;else a[c]=a[c] "," z}
     END{for(c in b)print b[c] " " b[c] a[c]}' file1

Result...

FX2FH6V05GB01A FX2FH6V05GB01A,FX2FH6V05F7LOL
FX2FH6V05F5F1E FX2FH6V05F5F1E,FX2FH6V05FTLO0,FX2FH6V05GBHRK

Thanks Ygor!

You solved a problem in a few minutes that I've been struggling with for a week. The parser works great.