-
Notifications
You must be signed in to change notification settings - Fork 0
/
processMapping.sh
5 lines (3 loc) · 1.59 KB
/
processMapping.sh
1
2
3
4
5
while read idx name; do grep OrphaCode ../data/categories/en_product3_$idx.xml | cut -f2 -d'>' | cut -f1 -d'<' | awk -v name="$name" '{print $1"\t"name}'; done < ../data/categories/legend.dat > ../data/categories/cats.dat
grep -A3 '<Disorder id' ../data/en_product7.xml | LC_ALL=C sed -e 's/^[[:space:]]*<OrphaNumber>\([0-9]*\)<\/OrphaNumber>/\1/' -e 's/^[[:space:]]*<Name lang="en">\([^<]*\)<\/Name>/\1/' -e 't' -e 'd' | awk 'NR/2==int(NR/2){print;next} {printf $0"\t"}' | awk 'NR==FNR{cats[$1]=1;next} !($1 in cats)' <(grep -A2 '<Disorder id\|<DisorderType' ../data/en_product7.xml | grep -B6 'Category</Name>\|Clinical group</Name>' | grep -A1 '<Disorder id' | grep '<OrphaNumber>' | cut -f2 -d'>' | cut -f1 -d '<') - | awk -F'\t' 'NR==FNR{if(!($1 in dis))dis[$1]=$2;next} ($2 in dis){code[$2]=(($2 in code)?code[$2]"|"$1:$1)} END{for(c in code)print c"\t"code[c]"\t"dis[c]}' - ../data/mapping.txt | awk -F'\t' 'NR==FNR{cat[$1]=$2;next} !(substr($2,1,1) in cat){print $0"\tMiscellaneous";next} $2~/^D/{split($2,a,"|");val=substr(a[1],2)+0;if(val>=50){print $0"\t"(val<80?"Blood":"Other Immune");next}} {print $0"\t"cat[substr($2,1,1)]}' ../data/legend.dat - > ../results/diseases.txt
cut -f14799-14864,14893-15076 ukb.txt | sed 1d | awk 'NR==FNR{cat[$1]=$2;next} {delete foundCat;for(idx=1;idx<=NF;idx++)if(substr($idx,1,1) in cat){idxCat=cat[substr($idx,1,1)];if($idx~/^D/){val=substr($idx,2)+0;if(val>=50)idxCat=(val<80?"Blood":"Other Immune")};foundCat[idxCat]=1};for(f in foundCat)sumCat[f]++} END{for(s in sumCat)print s"\t"sumCat[s]"\t"sumCat[s]/NR}' ../data/legend.dat - | sort -t$'\t' -rgk3,3 > ../results/icd.dist