combined-pvalues icon indicating copy to clipboard operation
combined-pvalues copied to clipboard

Python 3.7.3 issuing a TypeError for acf.py

Open parcbioinfo opened this issue 6 years ago • 5 comments

Trying to run comb-p on python 3.7.3. After converting the code from 2 to 3.7 I could finally get it running up to this point where I get a TypeError on the use of ">". However the line in acf.py (32) where the error is issued does not contain any ">". Do you know how to handle this issue?

comb-p acf -d 1:500:100 -c 5 MethylationComparison.bed >acf.txt Traceback (most recent call last): File "comb-p", line 4, in import('pkg_resources').run_script('cpv==0.48', 'comb-p') File "site-packages/pkg_resources/init.py", line 666, in run_script self.require(requires)[0].run_script(script_name, ns) File "site-packages/pkg_resources/init.py", line 1446, in run_script exec(code, namespace, namespace) File "site-packages/cpv-0.48-py3.7.egg/EGG-INFO/scripts/comb-p", line 38, in main() File "site-packages/cpv-0.48-py3.7.egg/EGG-INFO/scripts/comb-p", line 35, in main module.main() File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 170, in main return run(args) File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 140, in run args.full)) File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 95, in acf for chrom_acf in map(_acf_by_chrom, arg_list): File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 32, in _acf_by_chrom max_lag = max(a[1] for a in acfs) TypeError: '>' not supported between instances of 'int' and 'NoneType'

parcbioinfo avatar Apr 03 '19 23:04 parcbioinfo

try:

max_lag = max(a[1] for a in acfs if a[1] is not None)

please open a PR when you have it working on python 3

brentp avatar Apr 03 '19 23:04 brentp

Thanks! That seems to have worked but now I am getting another TypeError. Let me explain the context. When I first tried to run the program I've got "module not found" errors in many of the algorithms. One of them was regarding the use of "zip". So, after doing some digging I changed the import line (2nd line below) to this: from itertools import groupby, zip_longest as zip, chain #from itertools import groupby, zip, chain It worked. However now I get the following error (after I changed line 32 as you suggested): comb-p acf -d 1:300:100 -c 5 MethylationComparison.bed >acf.txt Traceback (most recent call last): File "comb-p", line 4, in <module> __import__('pkg_resources').run_script('cpv==0.48', 'comb-p') File "site-packages/pkg_resources/__init__.py", line 666, in run_script self.require(requires)[0].run_script(script_name, ns) File "site-packages/pkg_resources/__init__.py", line 1446, in run_script exec(code, namespace, namespace) File "site-packages/cpv-0.48-py3.7.egg/EGG-INFO/scripts/comb-p", line 38, in <module> main() File "site-packages/cpv-0.48-py3.7.egg/EGG-INFO/scripts/comb-p", line 35, in main module.main() File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 172, in main return run(args) File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 142, in run args.full)) File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 100, in acf acfs = merge_acfs(unmerged_acfs) File "site-packages/cpv-0.48-py3.7.egg/cpv/acf.py", line 67, in merge_acfs zip(merged, um): TypeError: zip_longest argument #1 must support iteration

parcbioinfo avatar Apr 04 '19 17:04 parcbioinfo

I would use:

try:
    from itertools import izip as zip # and other imports
except:
    pass

brentp avatar Apr 04 '19 17:04 brentp

I still get the same error with that: TypeError: zip argument #1 must support iteration I have modified slightly line 67 from for (glag_min, glag_max, gxys), (ulag_min, ulag_max, uxys) in zip(merged, um): to for (glag_min, glag_max, gxys), (ulag_min, ulag_max, uxys) in zip(itertools.repeat(merged), um): but now I get the same error with the second argument: TypeError: zip argument #2 must support iteration If I use the same itertools.repeat function on "um", I get: TypeError: cannot unpack non-iterable int object

parcbioinfo avatar Apr 04 '19 19:04 parcbioinfo

I've decided to install it with python 3 rather than 3.7.3. It's working so far. Thanks

parcbioinfo avatar Apr 05 '19 20:04 parcbioinfo