Skip to content

nmdp-bioinformatics/gl-smartsort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gl-smartsort

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:11 before A*01:103)
  • strips suffixes for numeric comparison (e.g., 01:01N compares as 01:01)

This is a Python port of SmartSort.pm (2012-11-14).

Install (local)

From the project directory:

python -m pip install -U pip
python -m pip install -e .

Usage (Python)

from gl_smartsort import smart_sort

print(smart_sort("A*01:103+A*01:11"))
# A*01:11+A*01:103

Usage (CLI)

Sort a single GL string:

gl-smartsort "B*07:02^A*02:01"

Or sort from stdin (one per line):

cat gl.txt | gl-smartsort

License

MIT

About

lightweight module for putting GL Strings into a canonical form

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages