Last active
May 14, 2018 09:46
-
-
Save mattravenhall/6da4802248ca37c35b4dbe6976b86ddb to your computer and use it in GitHub Desktop.
Often you'll need to pass a standard form genomic location (chr:bpA-bpB) but actually use the components. Splitting in bash is a pain, this does that for you. Assigning chr, bpA, and bpB to those variable names.
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
# Here the function assumes you're passing a standard form genomic position (chr:bpA-bpB) as the first argument. | |
function splitRegion { | |
IFS=':' read -ra REGION <<< "$1" | |
chr="${REGION[0]}" | |
IFS='-' read -ra LOCATION <<< "{REGION[1]}" | |
bpA="${LOCATION[0]}" | |
bpB="${LOCATION[1]}" | |
} | |
splitRegion $1 | |
# chr, bpA, and bpB are now assigned. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment