annotate admixture/transpose.awk @ 14:1b672da89d00 draft

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