
indir=$1

cd $indir

awk '{if(NR>1){print $4}}' fusion_results.txt > site.txt;

awk -F "-" '{print $2"-"$1}' site.txt > site1.txt;

cat site1.txt >> site.txt;

for i in `cat site.txt`;do grep ${i} single_fusion_breakpoints_readsID.txt;done > site_reads_temp.txt;
for i in `cat site.txt`;do grep ${i} fusion_breakpoints_readsID.txt;done >> site_reads_temp.txt;

awk '{print $1"\t"$3}' site_reads_temp.txt | awk -F "_" '{print $1}' > site_reads.txt;

reads_file=`ls ../1.QC/*reads.txt`

awk 'NR==FNR{a[$1]=$4"\t"$8;next}{print $1"\t"$2"\t"a[$2]}' $reads_file site_reads.txt > fusion_breakpoints_brief_readsID_primer.txt;

#combine
awk '{print $1"@"$3"@"$4}' fusion_breakpoints_brief_readsID_primer.txt > fusion_breakpoints_primer.txt;

cat fusion_breakpoints_primer.txt | sort | uniq > fusion_breakpoints_primer_temp.txt;
awk -F "@" '{print $1"\t"$2"\t"$3}' fusion_breakpoints_primer_temp.txt > fusion_breakpoints_primer.txt
