Created
June 9, 2016 09:16
-
-
Save Tabea-K/813b436784548af1cea44590c236f8de to your computer and use it in GitHub Desktop.
Sorts a BED file karyotypically. After sorting, it checks if the input and output files have the same content.
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # | |
| # Sorts a BED file karyotypically | |
| # File created by Tabea Kischka at Thu Jun 9 11:15:44 CEST 2016 | |
| INFILE="$1" | |
| OUTFILE="$2" | |
| cat "$INFILE" | sed 's/chrM/chr0/' | sort -k1,1V -k2,2n -k3,3n | sed 's/chr0/chrM/' > "$OUTFILE" | |
| echo "Done with sorting." | |
| echo "Now checking if both files are still the same." | |
| INFILEMD5=$(sort "$INFILE" | md5) | |
| OUTFILEMD5=$(sort "$OUTFILE" | md5) | |
| if [ "$INFILEMD5" = "$OUTFILEMD5" ] | |
| then | |
| echo "Sorting went fine!" | |
| else | |
| echo "Sorting failed!" | |
| mv "$OUTFILE" "${OUTFILE}.failed" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment