dputhier / libgtftk

gtftk C Library and program

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segfault when accessing keys

dputhier opened this issue · comments

With the latest version that expose get_type, we have an issue that is not related to get_type that impact the whole lib:

  from cffi import FFI
  import pygtftk.utils
  import pygtftk.utils
  from pygtftk.utils import GTFtkError
  from pygtftk.utils import write_properly
  ffi = FFI()
  from  pygtftk.utils import get_example_file
  from pygtftk.gtf_interface import GTF
  a_file = get_example_file()[0]
  a_gtf = GTF(a_file)
  ptr=a_gtf._data.data[0]
  rank = ptr.rank
  nb_key = ptr.attributes.nb
  chrom = ffi.string(ptr.field[0]).decode()
  src = ffi.string(ptr.field[1]).decode()
  ft_type = ffi.string(ptr.field[2]).decode()
  start = int(ffi.string(ptr.field[3]).decode())
  end = int(ffi.string(ptr.field[4]).decode())
  score = ffi.string(ptr.field[5]).decode()
  strand = ffi.string(ptr.field[6]).decode()
  frame = ffi.string(ptr.field[7]).decode()

  # Now we have issue with attributes:
  ptr.attributes.attr[0].key
  ffi.string(ptr.attributes.attr[0].key).decode() # SEGFAULT