Skip to content

Commit

Permalink
Merge pull request #179 from RoanKanninga/master
Browse files Browse the repository at this point in the history
small fixes to make bed file script
  • Loading branch information
marieke-bijlsma authored Nov 3, 2017
2 parents 5cbed12 + 4958f14 commit d89ae0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 36 deletions.
18 changes: 10 additions & 8 deletions makeBedForDiagnostics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Options:
-h Show this help.
-b Name of the BED file
-n Name of the new BED file
-e Making BED file for exomekit [default=false]
-e Making BED file for exomekit true/false [default=false]
===============================================================================================================
EOH
trap - EXIT
Expand All @@ -26,7 +26,7 @@ EOH

while getopts "b:d:e:h" opt;
do
case $opt in h)showHelp;; b)bedfile="${OPTARG}";; d)name="${OPTARG}";; e)exome="${OPTARG}";;
case $opt in h)showHelp;; b)bedfile="${OPTARG}";; n)name="${OPTARG}";; e)exome="${OPTARG}";;
esac
done

Expand All @@ -50,8 +50,6 @@ fi
if [[ -z "${exome:-}" ]]
then
exome="false"
else
exome="true"
fi


Expand Down Expand Up @@ -87,11 +85,15 @@ cd human_g1k_v37/

if [[ "${exome}" == 'true' ]]
then
echo 'Creating bedfiles for a new exomekit ${name}'
echo "Creating bedfiles for a new exomekit ${name}"
sh ${EBROOTNGSMINUTILS}/prepare_NGS_Bedfiles.sh -n captured
else
elif [[ "${exome}" == 'false' ]]
then
echo "Creating bedfiles for a new kit ${name}"
sh ${EBROOTNGSMINUTILS}/prepare_NGS_Bedfiles.sh -n captured -c true -d targeted
else
echo "please fill in true or false"
exit 1
fi

##
Expand All @@ -105,13 +107,13 @@ rename "captured" "${name}" "captured."*

#perbase
cd "${umcgDir}/CoveragePerBase/"
mkdir "${name}"
mkdir -p "${name}"
cd "${name}"
ln -sf "../../${name}"/

#pertarget
cd "${umcgDir}/CoveragePerTarget/"
mkdir "${name}"
mkdir -p "${name}"
cd "${name}"
ln -sf "../../${name}"/

Expand Down
39 changes: 11 additions & 28 deletions prepare_NGS_Bedfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ then

sort -V -k1 -k2 -k3 ${TMP}/${NAME}.per_base.bed | uniq > ${baits}.uniq.per_base.bed.tmp
sort -V ${baits}.uniq.per_base.bed.tmp > ${baits}.uniq.per_base.bed
#rm ${baits}.uniq.per_base.bed.tmp
#rm ${TMP}/${NAME}.per_base.bed

echo "per base done: ${baits}.uniq.per_base.bed"
else
Expand Down Expand Up @@ -276,18 +274,18 @@ then
batchIntervallistDir=${MAP}
chrXNONPARBed=${baits}.batch-Xnp.bed
chrXPARBed=${baits}.batch-Xp.bed

##Lastline is always phiX, we want to know whi
LASTLINE=$(tail -n1 ${baits}.bed)
if [[ $LASTLINE == *"NC_"* ]]
FIRSTLINE=$(head -1 ${baits}.merged.bed)
if [[ "${FIRSTLINE}" == *"NC_"* ]]
then
chromo=$(echo "${LASTLINE}" | awk '{FS=" "}{print $1}')
position=$(echo "${LASTLINE}" | awk '{FS=" "}{print $2}')
chromo=$(echo "${FIRSTLINE}" | awk '{FS=" "}{print $1}')
position=$(echo "${FIRSTLINE}" | awk '{FS=" "}{print $2}')
else
chromo=$(tail -n2 ${baits}.bed | head -1 | awk '{FS=" "}{print $1}')
position=$(tail -n2 ${baits}.bed | head -1 | awk '{FS=" "}{print $2}')

chromo=$(head -2 ${baits}.merged.bed | tail -1 | awk '{FS=" "}{print $1}')
position=$(head -2 ${baits}.merged.bed | tail -1 | awk '{FS=" "}{print $2}')
fi

awk '{
if ($1 == "X"){
if (($2 == 1) && ($3 == 155270560)){
Expand All @@ -308,18 +306,8 @@ then
print $0 >> "captured.batch-"$1".bed"
}
}' ${baits}.merged.bed
### Check where to put the phiXref
if [ "${chromo}" == "X" ]
then
if [[ ${position} -gt 60001 && ${position} -lt 2699520 ]] || [[ $position -gt 154931044 && $position -lt 155260560 ]]
then
echo -e "NC_001422.1\t1\t5386\tphiX174" >> captured.batch-Xp.bed
else
echo -e "NC_001422.1\t1\t5386\tphiX174" >> captured.batch-Xnp.bed
fi
else
echo -e "NC_001422.1\t1\t5386\tphiX174" >> captured.batch-${chromo}.bed
fi

echo -e "NC_001422.1\t1\t5386\tphiX174" >> captured.batch-${chromo}.bed
fi
else
if [ -f ${baits}.batch-1.bed ]
Expand Down Expand Up @@ -383,8 +371,7 @@ else
echo "PAR DONE"
BATCH_ALL=$((BATCHCOUNT + batchCount_X))
#move the X chromosome folders
lengthR=`less ${phiXRef} | wc -l`
echo "lengthR: $lengthR"
lengthR=$(less ${phiXRef} | wc -l)
lengthRef=$(( ${lengthR} + 2 ))
if [ ${lengthOFChrXNP1} -ne ${lengthOFChrXNP2} ]
then
Expand All @@ -395,11 +382,9 @@ else
echo "ba=$ba bi=$bi"
if [[ ${i} -lt 10 ]]
then
echo "$i is minder dan 10"
mv ${batchIntervallistDir}/temp_000${i}_of_${batchCount_X}/scattered.intervals ${ba}.interval_list
tail -n+${lengthRef} ${ba}.interval_list > ${ba}.bed
else
echo "$i is meer dan 10"
mv ${batchIntervallistDir}/temp_00${i}_of_${batchCount_X}/scattered.intervals ${ba}.interval_list
tail -n+${lengthRef} ${ba}.interval_list > ${ba}.bed
fi
Expand Down Expand Up @@ -493,5 +478,3 @@ then
echo -e 'Y\t1\t2\t+\tFake' > ${MAP}/captured.femaleY.bed
fi
fi

#for f in ${MAP}/*_baits_*; do cp $f ${f/_baits_/_exons_}; done

0 comments on commit d89ae0f

Please sign in to comment.