#warning windows double quotes perl -lanE "print $F[0],qq(\t)x($F[3]=~/Pro/?1:$F[3]=~/Bact/?2:3),$F[4 +]" genetable.txt ENSG00000088992 0.31 ENSG00000105374 0.37 ENSG00000005810 0.29 ENSG00000088992 0.27 ENSG00000109016 -0.37 ENSG00000069248 0.32 ENSG00000005810 -0.29 ENSG00000105374 -0.27 ENSG00000105374 -0.27 ENSG00000105374 -0.30 ENSG00000133107 0.35
L*
update if also want the headers printed you can use them to match:
perl -lanE "BEGIN{@h=qw(Gene Prot_Ente Bact_Bact Firm_Lach);print join + qq(\t),@h} print $F[0],qq(\t)x($F[3]=~/$h[1]/?1:$F[3]=~/$h[2]/?2:3),$ +F[4]" genetable.txt Gene Prot_Ente Bact_Bact Firm_Lach ENSG00000088992 0.31 ENSG00000105374 0.37 ENSG00000005810 0.29 ENSG00000088992 0.27 ENSG00000109016 -0.37 ENSG00000069248 0.32 ENSG00000005810 -0.29 ENSG00000105374 -0.27 ENSG00000105374 -0.27 ENSG00000105374 -0.30 ENSG00000133107 0.35
In reply to Re: creating a matrix like format -- oneliner
by Discipulus
in thread creating a matrix like format
by perl_user123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |