#!/usr/bin/env bash #PBS -N FMBY2_cnv_prep #PBS -j oe #PBS -l ncpus=8 #PBS -l nodes=1 #PBS -l mem=30G ## AZFc_u3==0 . $script_dir/conf/conf.cfg cd $cnv_dir ls *_F_QC_plot.pdf |sed 's/_F_QC_plot.pdf//' > F.sam.list ls *_M_QC_plot.pdf |sed 's/_M_QC_plot.pdf//' > M.sam.list perl $exe_dir/com_cov_norm.pl FMBY2.exon.cov.xls if [ -s F.sam.list ] then nFsam=`cat F.sam.list |wc -l ` echo $nFsam if [ $nFsam -lt 10 ] then cp $dat_dir/F_CNV/*.pcov . cat F.sam.list $dat_dir/F_CNV/F.ref.list |head -n 10 > F.ref.list else cp F.sam.list F.ref.list fi else rm F.sam.list fi # for male CNV REF sample list if [ -s M.sam.list ] then perl $exe_dir/prep_cnv_Mref.pl FMBY2.M.XY.sam.xls . M.sam.list grep REF $dat_dir/M_CNV/FMBY2.chr.cov.xls |cat FMBY2.M.XY.sam.xls - > FMBY2.chr.cov.xls nMsam=`cat FMBY2.M.XY.sam.xls |wc -l ` if [ $nMsam -lt 16 ] then grep -v REF $dat_dir/M_CNV/FMBY2.chr.cov.xls |cat FMBY2.chr.cov.xls - |head -n 16 > FMBY2.chr.cov.xls.1 mv FMBY2.chr.cov.xls.1 FMBY2.chr.cov.xls for sam in `cut -f1 FMBY2.chr.cov.xls|grep Control ` do echo $sam cp $dat_dir/M_CNV/$sam.pcov . done fi test -f M.ref.list || Rscript $exe_dir/get_mby2_ref.r FMBY2.chr.cov.xls 6 awk '$4>0.1{print $1}' FMBY2.chr.cov.xls |cat - M.ref.list |sort |uniq -c |awk '$1==2{print $2}' > M.ref.list.1 perl $exe_dir/com_cov_norm.pl FMBY2.AZF.cov2.xls . M.ref.list.1 Rscript $exe_dir/get_AZF_ref.r FMBY2.AZF.cov2.xls M.ref.list.2 20 && rm FMBY2.AZF.cov2.xls mv M.ref.list M.ref.list.cluster sort M.ref.list.2 |head -n 15 > M.ref.list else rm M.sam.list fi exit perl $exe_dir/com_cov_norm.pl FMBY2.exon.cov.xls perl $exe_dir/prep_cnv_Mref.pl FMBY2.chr.cov.xls #cat $dat_dir/FMBY2.chr.cov.xls >> FMBY2.chr.cov.xls test -f ref.list || Rscript $exe_dir/get_mby2_ref.r FMBY2.chr.cov.xls 6 #grep -v 'REFDEL' ref.list > ref.list.1 awk '$4>0.1{print $1}' FMBY2.chr.cov.xls |cat - ref.list |sort |uniq -c |awk '$1==2{print $2}' > ref.list.1 #cp $dat_dir/FMBY2Control*.pcov . perl $exe_dir/com_cov_norm.pl FMBY2.AZF.cov2.xls . ref.list.1 Rscript $exe_dir/get_AZF_ref.r FMBY2.AZF.cov2.xls ref.list.2 20 && rm FMBY2.AZF.cov2.xls perl $exe_dir/com_cov_norm.pl FMBY2.AZF.cov.xls . ref.list.2 mv ref.list ref.list.cluster sort ref.list.2 |head -n 15 > ref.list