view admixture/.svn/text-base/transpose.awk.svn-base @ 23:a1ab979f4551 draft

Uploaded
author dereeper
date Mon, 23 Mar 2015 05:52:17 -0400
parents 13cff72ec2d3
children
line wrap: on
line source

#!/usr/bin/gawk -f

BEGIN {
    max_x =0;
    max_y =0;
}

{
    max_y++;
    for( i=1; i<=NF; i++ )
    {
        if (i>max_x) max_x=i;
        A[i,max_y] = $i;
    }
}

END {
    for ( x=1; x<=max_x; x++ )
    {
        for ( y=1; y<=max_y; y++ )
        {
            if ( (x,y) in A ) printf "%s",A[x,y];
            if ( y!=max_y ) printf " ";
        }
        printf "\n";
    }
}