Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#!/bin/bash
# set some global variables for convenience
[ -d "$HOME/Documents/conf/FamilyR13" ] && CONF="$HOME/Documents/conf" || CONF=/confidential
export SVCOMPARE="$CONF/FamilyR13/DATA/10x/sv_compare"
export FILTERED_VCFS="$SVCOMPARE/17-08_hg38/filtered_vcfs-BK/"
#export PBBAM="$CONF/iGenVar/Chromothripsis/PacBio-Chromothripsis/aligned_bam/17-08/m64080_191203_205633.minimap2.GRCh38.sorted.bam"
export PBBAM="$CONF/tGenVar/tech/pb/bamIndex/pb.17_08.hg38.bam"
export PBBAM_IDX="$CONF/tGenVar/tech/pb/bamIndex/pb.17_08.hg38.bam.bai"
export REFHG38="$CONF/FamilyR13/DATA/REF/GRCh38_hengli_recommended/GCA_000001405.15_GRCh38_no_alt_analysis_set.fna"
export REFT2T="$CONF/tGenVar/ref/t2t_v1.1/chm13.draft_v1.1.fasta"
export T2T="$CONF/tGenVar/tech/pb/bam_MDtag_t2tv1_1/pb.17_08.t2tv1_1.bam"
export T2T_IDX="$CONF/tGenVar/tech/pb/bam_MDtag_t2tv1_1/pb.17_08.t2tv1_1.bam.bai"
export ILL_HG38="$CONF/tGenVar/tech/illumina/bam_hg38/ill.17_08.hg38.bam"
#export T2T="$CONF/iGenVar/Chromothripsis/PacBio-Chromothripsis/aligned_bam/17-08/m64080_191203_205633.minimap2.T2T.sorted.bam"
#export T2T_IDX="$CONF/tGenVar/tech/pb/bam_t2t/pb.17_08.t2t.bam.bai"
VCFSSUFFIX="_sorted_filtered.vcf.gz"
getmethod() {
METHOD=$(echo $1 | awk -F_ '{print $1}')
[[ $METHOD =~ "audano" ]] && METHOD="audano"
echo "$METHOD"
}
getvar() {
# get method
METHOD="$(getmethod $1)"
# get variant line
SVSUFFIX=${1#*_}
zgrep "${METHOD}_${SVSUFFIX}" "${FILTERED_VCFS}/${METHOD}${VCFSSUFFIX}"
}
getpos() {
getvar $1 | cut -f1,2 | tr "\t" ":"
}
find_in_bam() {
# find_in_bam read_id bamfile [bamIndex] chromosome
if [[ "$3" =~ .*bai ]]
then
samtools view "$2" -X "$3" "$4" -@8 | grep "$1"
else
samtools view "$2" "$3" -@8 | grep "$1"
fi
}
hg38_read() {
find_in_bam "${1}" "${PBBAM}" "${PBBAM_IDX}" "${2}" | head -n1
}
t2t_read() {
find_in_bam "${1}" "${T2T}" "${T2T_IDX}" "${2}" | head -n1
}