I've a table of blast results with ~5hits/query protein:

```
Protein     Class
ProtA       1
ProtA       1
ProtA       1
ProtA       0
ProtA       1
ProtB       1
ProtB       1
ProtB       0
ProtB       0
ProtB       1
```

I would like to convert this into a feature vector matrix like this:

```
Protein     Class1     Class2     Class3     Class4     Class5
ProtA       1          1          1          0          1
ProtB       1          1          0          0          1
```

Can someone suggest me an efficient way to do this, since I've ~2300k hits in the file.
<p>Using awk grouping</p>

<pre>
awk -F&quot;\t&quot; &#39;{if(a[$1])a[$1]=a[$1]&quot;\t&quot;$2; else a[$1]=$2;}END{for (i in a)print i, a[i];}&#39; OFS=&quot;\t&quot; YOUR_FILE</pre>

<p>outputs</p>

<pre>
ProtB     1    1    0    0    1
ProtA     1    1    1    0    1</pre>

<p>I excluded the first/header line in the input. You can sort the rows if you want in any particular order.</p>

<p>Modified from: http://www.theunixschool.com/2012/06/awk-10-examples-to-group-data-in-csv-or.html</p>
