Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SNP Id Geno
- 1 a AB
- 2 a AB
- 3 a BB
- . . .
- . . .
- . . .
- 1 b AB
- 2 b BB
- 3 b AB
- . . .
- . . .
- . . .
- 1 c AA
- 2 c AB
- 3 c AA
- . . .
- . . .
- . . .
- SNP Genoa Genob Genoc . . .
- 1 AB AB AA
- 2 AB BB AB
- 3 BB AB AA
- . . . .
- . . . .
- . . . .
- sed 'G;s/^SNP.*/SNP/
- /^1 /s/ ([^ ]*) .*SNP[^[:cntrl:]]*/& Geno1/
- s/^([0-9]*) [^ ]*( [AB]*)n(.*n1 [AB ]*)/32/
- s/^([0-9]*) [^ ]*( [AB]*)(n)(.*)/4312/
- h
- $!d' file1 > file2
- awk '{if ($1==1) h=h" Geno"$2
- if ($1!="SNP") g[$1]=g[$1]" "$3}
- END {print "SNP"h; for (i in g) print i g[i]}' file1 > file2
- awk '{g[$1] = g[$1] " " $3}
- END {for (i in g) print i g[i]}' < file1 > file2
- awk '! ($1 in g) {snp[n++] = $1}
- {g[$1] = g[$1] " " $3}
- END {for (i = 0; i < n; i++) print snp[i] g[snp[i]]}' < file1 > file2
- awk 'NR == 1 {header = $1; prefix = $3; next}
- first == "" {first = "" $1}
- $1 == first {header = header " " prefix $2}
- ! ($1 in g) {snp[n++] = $1}
- {g[$1] = g[$1] " " $3}
- END {
- print header
- for (i = 0; i < n; i++) print snp[i] g[snp[i]]
- }' < file1 > file2
- perl -lane '
- next if $. == 1; # skip header
- $A[@A] = $F[1] if /^1h/; # populate new header
- push @{$h{$F[0]}}, $F[2]}{$,="t"; # OFS = tab
- print q/SNP/, map { "Geno$_" } @A; # new header print
- print $_, @{$h{$_}} for sort { $a <=> $b } keys %h; # result
- ' gene.data
- sed -e '
- 1d; # monospace lines
- s/[[:blank:]]{1,}/t/g;s/^[[:blank:]]*//;s/[[:blank:]]*$//
- H;g
- # 1 2 3 4
- s/(n(.*n){0,1})1[[:blank:]]([^[:space:]]{1,})([[:blank:]][^[:space:]]{1,})$/tGeno31n14/
- /(n[^[:space:]]{1,}[[:blank:]])[^[:space:]]{1,}[[:blank:]]([^[:space:]]{1,})$/s//12/
- y/n_/_n/
- s/_([0-9]{1,})([^_]*)_(.*_){0,1}1([[:blank:]][^_]*)/_124_3/
- y/n_/_n/
- h;$!d
- s/n*$//
- s/n(n)/1/
- s/^[[:blank:]]/SNP&/
- ' gene.data
- SNP Genoa Genob Genoc
- 1 AB AB AA
- 2 AB BB AB
- 3 BB AB AA
Add Comment
Please, Sign In to add comment