Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centurion incompatible with Py3 #4

Open
bredeson opened this issue May 13, 2019 · 0 comments
Open

Centurion incompatible with Py3 #4

bredeson opened this issue May 13, 2019 · 0 comments

Comments

@bredeson
Copy link

Hi Devs,

I'm reporting this just in case you intend Centurion to be Py3-compatible.

I'm getting the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-152081d3bb39> in <module>
      1 centromeres = centromeres_calls.centromeres_calls(
      2     counts, lengths,
----> 3     resolution=10000)

~/.conda/envs/centurion/lib/python3.6/site-packages/centurion/centromeres_calls.py in centromeres_calls(counts, lengths, resolution, init, n_candidate, sigma, verbose, filter_candidates, normalize)
     21     if init is None:
     22         counts_40kb, lengths_40kb = utils.downsample_resolution(
---> 23             counts, lengths, coefficient=coef)
     24 
     25         if normalize:

~/.conda/envs/centurion/lib/python3.6/site-packages/centurion/utils.py in downsample_resolution(counts, lengths, coefficient)
     41             sub_target_counts = target_counts[target_begin_i:target_end_i,
     42                                               target_begin_j:target_end_j]
---> 43             for start in range(coefficient):
     44                 s = sub_counts[start::coefficient, start::coefficient]
     45                 sub_target_counts[:s.shape[0], :s.shape[1]] += s

TypeError: 'float' object cannot be interpreted as an integer

because centromeres_calls.centromeres_calls() attempts division without flooring:

    if sigma is None:
        sigma = 80000 / resolution

    coef = 40000 / resolution

In Py3, division (even between two integers) yields a float, which could be avoided instead by using floor division (which returns an int):

    if sigma is None:
        sigma = 80000 // resolution

    coef = 40000 // resolution

In order to make Centurion Py3-compatible, floor division should be used everywhere an integer is expected to be returned.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant