Created
August 31, 2015 08:54
-
-
Save cth/da414cdfc739f105aedf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#$ -S /bin/bash | |
#$ -cwd | |
# Christian Theil HAve, 2015 | |
# Modify this to be the final report directory of interest | |
# Note that final reports must contain LRR and BAF | |
FINAL_REPORTS_DIR=target_final_reports | |
# This is where | |
BAF_LRR_CSV_DIR=`pwd`/baf_lrr_csv | |
function nth() { | |
target=$1 | |
shift | |
idx=1 | |
for symbol in $@; do | |
if [ $symbol == $target ]; then | |
echo $idx | |
return | |
fi | |
idx=$(($idx+1)) | |
done | |
} | |
rm -f samples_csv.list | |
# Create .csv files for each final report | |
for fr in $FINAL_REPORTS_DIR/* | |
do | |
hdr_line=`tail -n+11 $fr | head -n1|tr '\t' ','` | |
#echo $hdr_line | |
IFS=, | |
baf_idx=`nth "B Allele Freq" $hdr_line` | |
lrr_idx=`nth "Log R Ratio" $hdr_line` | |
sample_idx=`nth "Sample ID" $hdr_line` | |
IFS= | |
sample_id=$(tail -n+12 $fr | head -n1 |awk -F $'\t' "BEGIN {OFS = FS} {print \$${sample_idx}}") | |
particid=`grep -w $sample_id BarcodesToParticidAllChips.txt | cut -d, -f2` | |
if [ `grep -c -w "$particid" /eva/data/clean/target/chip_data/Target_and_GBparents_clean_V1.fam` = 1 ]; then | |
echo "Processing sample $sample_id ($particid) from $fr" | |
tail -n+12 $fr | awk -F $'\t' "BEGIN {OFS = FS} {print \$${baf_idx} \",\" \$${lrr_idx}}" > $BAF_LRR_CSV_DIR/$particid.csv | |
echo "$BAF_LRR_CSV_DIR/$particid.csv" >> samples_csv.list | |
else | |
echo "Skipping sample $sample_id ($particid) from $fr" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment