Skip to content

Instantly share code, notes, and snippets.

@armish
Created January 14, 2016 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armish/a065b81979b60089de37 to your computer and use it in GitHub Desktop.
Save armish/a065b81979b60089de37 to your computer and use it in GitHub Desktop.
Merge multiple SSMs into a single one
#!/bin/bash
set -e
cat helpers/triplets.lst |while read patient
do
mergedFile=ssms/merged/${patient}.txt
cat helpers/ssm_header.txt > ${mergedFile}
count=0
files=$(ls ssms/filled_in/${patient}*.txt)
cat $files |grep -v "gene" |cut -f2 |sort |uniq -c |awk '{ if($1 > 1) print $2 }' |while read mutation
do
a=$(cat $files |grep "${mutation}" |cut -f3 |tr "\n" "," |sed -e 's/,$//g')
d=$(cat $files |grep "${mutation}" |cut -f4 |tr "\n" "," |sed -e 's/,$//g')
echo -ne "s${count}\t${mutation}\t${a}\t${d}\t0.999\t0.499\n" >> ${mergedFile}
let count=$count+1
done
echo "${patient} done... [`date`]"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment