Created
September 7, 2023 08:04
-
-
Save tbrittoborges/05dcb7bb1a0389f8d00f9da60e80f56b to your computer and use it in GitHub Desktop.
Sort and index gtf file for vizualization. Requires htslib.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <input_gtf_file>" | |
exit 1 | |
fi | |
input_gtf="$1" | |
output_prefix="output" | |
sorted_gtf="${output_prefix}.sorted.gtf" | |
sorted_gtf_gz="${sorted_gtf}.gz" | |
module load htslib | |
# Sort the input GTF file | |
sort -k1,1 -k4,4n -s "$input_gtf" > "$sorted_gtf" | |
# Compress the sorted GTF file | |
bgzip -c "$sorted_gtf" > "$sorted_gtf_gz" | |
# Index the compressed GTF file | |
tabix "$sorted_gtf_gz" | |
# Remove intermediate files | |
rm "$sorted_gtf" | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment