hoffmangroup / segtools

Package for analysis of genomic segmentations.
http://pmgenomics.ca/hoffmanlab/proj/segtools
GNU General Public License v2.0
0 stars 0 forks source link

segtools-relabel error: No field of name strand #61

Open paul-sud opened 3 years ago

paul-sud commented 3 years ago

When running segtools-relabel I am seeing the following error:

Traceback (most recent call last):
  File "/Users/paul/opt/anaconda3/envs/segway-py2/bin/segtools-relabel", line 12, in <module>
    sys.exit(main())
  File "/Users/paul/opt/anaconda3/envs/segway-py2/lib/python2.7/site-packages/segtools/relabel.py", line 133, in main
    relabel(*args, **kwargs)
  File "/Users/paul/opt/anaconda3/envs/segway-py2/lib/python2.7/site-packages/segtools/relabel.py", line 90, in relabel
    (segment['strand'] == prev_segment['strand'])
ValueError: no field of name strand

Indexing into the NumPy array with an incorrect name, in this case strand, raises a ValueError for me in NumPy 1.16.5 . I think the relabeling expects an IndexError in a couple places, see the following: https://github.com/hoffmangroup/segtools/blob/2879994035712c4f34348dc145f99accccacfa01/segtools/relabel.py#L35 https://github.com/hoffmangroup/segtools/blob/2879994035712c4f34348dc145f99accccacfa01/segtools/relabel.py#L88

This NumPy issue looks relevant too: https://github.com/numpy/numpy/issues/8519

EricR86 commented 3 years ago

Hi Paul,

Thanks for the report. From the surface, it does look like it might be a NumPy version and by proxy a python version issue we probably need to tackle in the near future. You could maybe try putting the strand field manually in your segmentations to avoid the exception altogether though I'm not sure if this would suffice.

paul-sud commented 3 years ago

Thanks for the response. Fortunately for my use case it was fairly simple to write our own relabeling since adjacent segments don't share labels, no need to merge.