annotate admixture/transpose.awk @ 0:3e19d0dfcf3e draft

Uploaded
author dereeper
date Mon, 23 Mar 2015 05:57:27 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/gawk -f
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
2
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
3 BEGIN {
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
4 max_x =0;
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
5 max_y =0;
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
6 }
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
7
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
8 {
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
9 max_y++;
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
10 for( i=1; i<=NF; i++ )
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
11 {
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
12 if (i>max_x) max_x=i;
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
13 A[i,max_y] = $i;
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
14 }
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
15 }
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
16
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
17 END {
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
18 for ( x=1; x<=max_x; x++ )
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
19 {
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
20 for ( y=1; y<=max_y; y++ )
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
21 {
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
22 if ( (x,y) in A ) printf "%s",A[x,y];
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
23 if ( y!=max_y ) printf " ";
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
24 }
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
25 printf "\n";
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
26 }
3e19d0dfcf3e Uploaded
dereeper
parents:
diff changeset
27 }