Pergunta:
Concatenate the values in column 5,6 and 7 IF I have a match in the first 3 columns
Resposta:
perl -lane 'if($.==1){@a=@F;next} if($F[0]eq$a[0]&&$F[1]eq$a[1]&&$F[2]eq$a[2]){$a[4].="/$F[4]";$a[5].="/$F[5]";$a[6].="/$F[6]";}else{for($i=0;$i<@a;$i++){printf "\t%s",$a[$i]};print"";@a=@F}END{for($i=0;$i<@a;$i++){printf "\t%s",$a[$i]};print""}' input.bed
Saída:
chr1 69744110 69793325 . -1 -1 0
chr1 82791976 82831348 chr1 82792114/82816285/82828015 82792615/82817077/82829891 501/792/1876
chr1 88599340 88658398 . -1 -1 0
chr1 137772945 137830035 . -1 -1 0
chr1 137875312 137920590 . -1 -1 0
chr1 193433080 193446861 . -1 -1 0
chr10 26483800 26501370 chr10 26484794 26485295 501
chr10 68069913 68089436 . -1 -1 0
chr10 95098349 95113967 . -1 -1 0
chr10 97310211 97335589 . -1 -1 0
chr10 111083097 111118237 chr10 111088928 111090274 1346
chr10 117904141 117947090 chr10 117905334/117918966/117926867 117906320/117919852/117927368 986/886/501
chr11 11521339 11587607 chr11 11523970/11555497/11560639/11564617 11524747/11559868/11562128/11565370 777/4371/1489/753
Nota:
Pode haver uma solução mais curta ou mais elegante