glstring

examples using the GlString class


In [1]:
from glstring.glstring import *

gls = ("HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03^"
 "HLA-B*08:01+HLA-B*44:01/HLA-B*44:02^"
 "HLA-C*01:02^"
 "HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92")

ver = "3.23.0"

print('gls =', gls)
print('ver =', ver)


gls = HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03^HLA-B*08:01+HLA-B*44:01/HLA-B*44:02^HLA-C*01:02^HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92
ver = 3.23.0

In [2]:
g = GlString(gls, ver)
print(g.gls)


HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03^HLA-B*08:01+HLA-B*44:01/HLA-B*44:02^HLA-C*01:02^HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92

In [3]:
print(g.ver)


3.23.0

In [4]:
g.locus_blocks()


Out[4]:
[GlString('HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03', '3.23.0'),
 GlString('HLA-B*08:01+HLA-B*44:01/HLA-B*44:02', '3.23.0'),
 GlString('HLA-C*01:02', '3.23.0'),
 GlString('HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92', '3.23.0')]

In [5]:
for locus_block in g.locus_blocks():
    print(locus_block.gls)


HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03
HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
HLA-C*01:02
HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92

In [6]:
g.locus_blocks()[0].gls


Out[6]:
'HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03'

In [7]:
g.locus_blocks()[0].ver


Out[7]:
'3.23.0'

In [8]:
g.genotypes()


Out[8]:
[GlString('HLA-A*01:01/HLA-A*01:02+HLA-A*24:02', '3.23.0'),
 GlString('HLA-A*01:03+HLA-A*24:03', '3.23.0'),
 GlString('HLA-B*08:01+HLA-B*44:01/HLA-B*44:02', '3.23.0'),
 GlString('HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92', '3.23.0')]

In [9]:
for genotype in g.genotypes():
    print(genotype.gls)


HLA-A*01:01/HLA-A*01:02+HLA-A*24:02
HLA-A*01:03+HLA-A*24:03
HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92

In [10]:
for locus_block in g.locus_blocks():
    print('-' * 40)
    print(locus_block.gls)
    for genotype in locus_block.genotypes():
        print('  >', genotype.gls)


----------------------------------------
HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03
  > HLA-A*01:01/HLA-A*01:02+HLA-A*24:02
  > HLA-A*01:03+HLA-A*24:03
----------------------------------------
HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
  > HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
----------------------------------------
HLA-C*01:02
----------------------------------------
HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92
  > HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92

In [11]:
for locus_block in g.locus_blocks():
    print('-'*40)
    print(locus_block.gls)
    for genotype in locus_block.genotypes():
        print('>', genotype.gls)
        for genotype_block in genotype.genotype_blocks():
            print('  >', genotype_block.gls)


----------------------------------------
HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03
> HLA-A*01:01/HLA-A*01:02+HLA-A*24:02
  > HLA-A*01:01/HLA-A*01:02
  > HLA-A*24:02
> HLA-A*01:03+HLA-A*24:03
  > HLA-A*01:03
  > HLA-A*24:03
----------------------------------------
HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
> HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
  > HLA-B*08:01
  > HLA-B*44:01/HLA-B*44:02
----------------------------------------
HLA-C*01:02
----------------------------------------
HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92
> HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92
  > HLA-DRB5*01:01~HLA-DRB1*03:01
  > HLA-DRB1*04:07:01/HLA-DRB1*04:92

In [12]:
for locus_block in g.locus_blocks():
    print('-'*40)
    print(locus_block.gls)
    for genotype_list in locus_block.genotype_lists():
        print('->', genotype_list.gls)
        for genotype_list_block in genotype_list.genotype_list_blocks():
            print('-->', genotype_list_block.gls)


----------------------------------------
HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03
-> HLA-A*01:01/HLA-A*01:02+HLA-A*24:02|HLA-A*01:03+HLA-A*24:03
--> HLA-A*01:01/HLA-A*01:02+HLA-A*24:02
--> HLA-A*01:03+HLA-A*24:03
----------------------------------------
HLA-B*08:01+HLA-B*44:01/HLA-B*44:02
----------------------------------------
HLA-C*01:02
----------------------------------------
HLA-DRB5*01:01~HLA-DRB1*03:01+HLA-DRB1*04:07:01/HLA-DRB1*04:92

In [ ]:


In [ ]: