INNER CODE UNIT · Python
extract_subchain
hillerlab/TOGA · CESAR_wrapper.py:688
def extract_subchain(chain_str, search_locus):
"""Extract subchain containing only the search locus."""
# convert python types to C types
c_chain = ctypes.c_char_p(chain_str.encode())
c_mode = ctypes.c_char_p("q".encode())
c_search = ctypes.c_char_p(search_locus.encode())
# call the library finally
ex_out_raw = ex_lib.extract_subchain(c_chain, c_mode, c_search)
ex_out = []
for elem in ex_out_raw:
line = elem.decode("utf-8")
if line == "END":
break
ex_out.append(line)
blocks = [[int(x) for x in elem.split()] for elem in ex_out]
if len(blocks) == 0: # die an show chain id