-
-
Save IdoBar/565ba822982c8562721e488bbb7fc7a6 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