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

Bug with last version of python2.7 #11

Open
lelouar opened this issue Mar 16, 2021 · 3 comments
Open

Bug with last version of python2.7 #11

lelouar opened this issue Mar 16, 2021 · 3 comments

Comments

@lelouar
Copy link

lelouar commented Mar 16, 2021

Hi,

I've tried to test your soft but have an error during process. Only *_stats.tab are created at the end of process.

I install pymasc via pip install.

Here the command I used:
pymasc -p 10 -e * -i I -n test2 -o test2masc processed_data/ce11/NGS/ChIPseq/bam/H3k4me1_WThexCtrl_rep1.bwa_aln.sort.bam

and logs:

[2021-03-16 11:51:30,003 | INFO] PyMaSC.pymasc : PyMaSC version 0.3.2 with Python2.7.18
[2021-03-16 11:51:30,004 | INFO] PyMaSC.pymasc : Make output directory: test2masc
[2021-03-16 11:51:30,103 | INFO] PyMaSC.pymasc : Check read length: Get median from read length distribution
[2021-03-16 11:51:30,103 | INFO] PyMaSC.handler.masc : Check read length... : processed_data/ce11/NGS/ChIPseq/bam/H3k4me1_WThexCtrl_rep1.bwa_aln.sort.bam
[2021-03-16 11:52:47,362 | INFO] PyMaSC.core.readlen : Scan 6,336,378 reads, 1,038,711 reads were unmapped and 4,775,493 reads >= MAPQ 1.
[2021-03-16 11:52:47,362 | INFO] PyMaSC.core.readlen : 6,336,378 reads were paired: 3,168,189 reads were 1st and 3,168,189 reads were last segment.
[2021-03-16 11:52:47,362 | INFO] PyMaSC.core.readlen : Note that only 1st reads in the templates will be used for calculation.
[2021-03-16 11:52:47,362 | INFO] PyMaSC.core.readlen : Estimated read length = 150
[2021-03-16 11:52:47,362 | INFO] PyMaSC.pymasc : Calculate cross-correlation between 0 to 1000 base shiftwith reads MAOQ >= 1
[2021-03-16 11:52:47,362 | INFO] PyMaSC.pymasc : Process processed_data/ce11/NGS/ChIPseq/bam/H3k4me1_WThexCtrl_rep1.bwa_aln.sort.bam
[2021-03-16 11:52:47,398 | INFO] PyMaSC.bacore.mscc : Loading II reads to bit array...
[2021-03-16 11:52:47,398 | INFO] PyMaSC.bacore.mscc : Loading III reads to bit array...
[2021-03-16 11:52:47,398 | INFO] PyMaSC.bacore.mscc : Loading IV reads to bit array...
[2021-03-16 11:52:47,399 | INFO] PyMaSC.bacore.mscc : Loading V reads to bit array...
[2021-03-16 11:52:47,399 | INFO] PyMaSC.bacore.mscc : Loading MtDNA reads to bit array...
[2021-03-16 11:52:47,400 | INFO] PyMaSC.bacore.mscc : Loading X reads to bit array...
[2021-03-16 11:52:47,400 | INFO] PyMaSC.bacore.mscc : Loading I reads to bit array...
[2021-03-16 11:52:47,742 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for MtDNA...
[2021-03-16 11:52:49,955 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for II...
[2021-03-16 11:52:50,131 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for IV...
[2021-03-16 11:52:50,200 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for III...
[2021-03-16 11:52:50,252 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for X...
[2021-03-16 11:52:50,453 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for I...
[2021-03-16 11:52:50,564 | INFO] PyMaSC.bacore.mscc : Calculate cross-correlation for V...
[2021-03-16 11:52:54,707 | WARNING] PyMaSC.handler.result : Whole genome Forward/Reverse read count imbalance.
[2021-03-16 11:52:54,707 | WARNING] PyMaSC.handler.result : +/- = 998928 / 1003500, Chi-squared test p-val = 0.0223354912445 <= 0.05
[2021-03-16 11:52:54,877 | INFO] PyMaSC.output.stats : Output 'test2masc/test2_stats.tab'
[2021-03-16 11:52:54,878 | INFO] PyMaSC.output.table : Output 'test2masc/test2_nreads.tab'
Traceback (most recent call last):
File "/nfs/work/gen2i/technique/tools/bin/pymasc", line 8, in
sys.exit(main())
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/init.py", line 20, in _inner
main_func()
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/pymasc.py", line 98, in main
output_results(args, output_basename, result_handler)
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/pymasc.py", line 189, in output_results
output_nreads_table(output_basename, result_handler)
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/utils/output.py", line 10, in _io_func
return func(*args, **kwargs)
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/output/table.py", line 179, in output_nreads_table
with NReadsIO(outfile, 'w') as tab:
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/output/table.py", line 36, in enter
self.open()
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/output/table.py", line 33, in open
self.fp = open(self.path, self.mode, newline='')
TypeError: 'newline' is an invalid keyword argument for this function

I will try with python 3.9.2 version but I'm waiting for the admin of HPC I use to install a devel lib to be able to correctly compile python.

Many thanks,
cheers

@ronin-gw
Copy link
Owner

ronin-gw commented Mar 16, 2021

Thanks for for your reporting. I will fix it in the future release.
If you want to run PyMaSC now, you can try to edit /nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/output/table.py to apply the following changes. I think this fixes your issue.

from __future__ import print_function

import logging
from functools import partial
import csv
from itertools import chain
from collections import defaultdict
from copy import copy
+ import io

import numpy as np

from PyMaSC.utils.output import catch_IOError
class TableIO(object):
    DIALECT = "excel-tab"

    def __init__(self, path, mode='r'):
        self.path = path
        self.mode = mode
        self.fp = None

        if mode not in ('r', 'w'):
            raise NotImplemented

    def open(self):
-        self.fp = open(self.path, self.mode, newline='')
+        self.fp = io.open(self.path, self.mode, newline='')

@lelouar
Copy link
Author

lelouar commented Mar 16, 2021

I modified table.py file but another error came :

[...]
[2021-03-16 14:31:34,661 | INFO] PyMaSC.output.table : Output 'test2masc/test2_nreads.tab'
Traceback (most recent call last):
File "/nfs/work/gen2i/technique/tools/bin/pymasc", line 8, in
sys.exit(main())
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/init.py", line 20, in _inner
main_func()
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/pymasc.py", line 98, in main
output_results(args, output_basename, result_handler)
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/pymasc.py", line 189, in output_results
output_nreads_table(output_basename, result_handler)
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/utils/output.py", line 10, in _io_func
return func(*args, **kwargs)
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/output/table.py", line 185, in output_nreads_table
_make_dict_with_whole(ccr.mappable_ref2reverse_sum, "masc", "reverse_sum")
File "/nfs/work/gen2i/technique/tools/lib/python2.7/site-packages/PyMaSC/output/table.py", line 135, in write
tab.writerow(("shift", ) + tuple(header))
TypeError: write() argument 1 must be unicode, not str

cheers

@lelouar
Copy link
Author

lelouar commented Mar 16, 2021

Hi,

I've tried with a fresh compiled python 3.7.10 and it works (however, I had to use "python3 -m pip install pymasc --no-binary pymasc" to recompile the cython part to be able to use it)

Cheers

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

2 participants