-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureMerge.sh
More file actions
executable file
·60 lines (42 loc) · 1.7 KB
/
FeatureMerge.sh
File metadata and controls
executable file
·60 lines (42 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -o pipefail
### Script to merge intervals containing features of interest from Genome Annotation File
####################################
########### DEPENDENCIES ###########
####################################
module load BEDOPS/2.4.30
module load BEDTools/2.29.2-GCC-8.2.0-2.31.1
####################################
##### USER-SUPPLIED VARIABLES ######
####################################
# Genome Annotation File
GEN_ANN="/scratch/eld72413/Ha412HOv2.0/Ha412HOv2.0-20181130.gff3"
#GEN_ANN="/scratch/eld72413/Ha412HOv2.0/Ha412HOv2.0-20181130.gtf"
# What feature to capture? (Gene, Exon, etc)
FEATURE="gene"
#FEATURE="exon"
# Maximum distance between features (in bp) to be merged?
INT_DIST=500000
# Where do you want output files?
OUTPUTDIR="/scratch/eld72413/Salty_Nut/CultivatedOnly/SNPcalling"
# Name for final output .bed file (no .bed extension here)
OUT_NAME="GFF_Gene_Regions"
####################################
########## INTERVALS CODE ##########
####################################
# GFF3 or GTF file?
ANN_ext="$(basename ${GEN_ANN##*.})"
if [[ "$ANN_ext" == "gff3" ]]; then
echo "Merging $FEATURE regions within $INT_DIST from GFF3 file"
gff2bed < ${GEN_ANN} > ${OUTPUTDIR}/BED_Convert.bed
elif [[ "$ANN_ext" == "gtf" ]]; then
echo "Merging $FEATURE regions within $INT_DIST from GTF file"
gtf2bed < ${GEN_ANN} > ${OUTPUTDIR}/BED_Convert.bed
else
echo "The genome annotation file does not appear to be a recognized file format, exiting..."
#exit 1
fi
#echo "$COMMAND < ${GEN_ANN}" | head
awk -v var="${FEATURE}" '{if ($8 == var) {print $0}}' ${OUTPUTDIR}/BED_Convert.bed | \
bedtools merge -i stdin -d ${INT_DIST} > ${OUTPUTDIR}/${OUT_NAME}.bed
rm ${OUTPUTDIR}/BED_Convert.bed