A tiny Python package that canonicalizes GL Strings by smart sorting:
- recursively sorts within delimiter levels in precedence:
^,|,+,~,/ - orders blocks by gene/locus (left of
*) - orders alleles numerically (not lexically) within a locus (e.g.,
A*01:11beforeA*01:103) - strips suffixes for numeric comparison (e.g.,
01:01Ncompares as01:01)
This is a Python port of SmartSort.pm (2012-11-14).
From the project directory:
python -m pip install -U pip
python -m pip install -e .from gl_smartsort import smart_sort
print(smart_sort("A*01:103+A*01:11"))
# A*01:11+A*01:103Sort a single GL string:
gl-smartsort "B*07:02^A*02:01"Or sort from stdin (one per line):
cat gl.txt | gl-smartsortMIT