lpantano / seqcluster

small RNA analysis from NGS data
http://seqcluster.readthedocs.io
MIT License
35 stars 17 forks source link

python setup.py test - __init__.py argument missing #32

Closed smoe closed 5 years ago

smoe commented 6 years ago

Hello, I have checked out your devel branch. Invoking tests, with python 2.7 this shows

$ python setup.py test
running test
running egg_info
writing seqcluster.egg-info/PKG-INFO
writing top-level names to seqcluster.egg-info/top_level.txt
writing dependency_links to seqcluster.egg-info/dependency_links.txt
writing entry points to seqcluster.egg-info/entry_points.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'seqcluster.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 34, in <module>
    zip_safe=False)
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/moeller/.local/lib/python2.7/site-packages/setuptools/command/test.py", line 211, in run
    self.run_tests()
  File "/home/moeller/.local/lib/python2.7/site-packages/setuptools/command/test.py", line 234, in run_tests
    **exit_kwarg
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 103, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/home/moeller/.local/lib/python2.7/site-packages/setuptools/command/test.py", line 43, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/usr/lib/python2.7/unittest/loader.py", line 103, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/home/moeller/.local/lib/python2.7/site-packages/setuptools/command/test.py", line 29, in loadTestsFromModule
    tests.append(TestLoader.loadTestsFromModule(self, module))
  File "/usr/lib/python2.7/unittest/loader.py", line 65, in loadTestsFromModule
    tests.append(self.loadTestsFromTestCase(obj))
  File "/usr/lib/python2.7/unittest/loader.py", line 56, in loadTestsFromTestCase
    loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
TypeError: __init__() takes at least 3 arguments (2 given)

while python 3.6.6 gives me

$ python3 setup.py test
running test
running egg_info
writing seqcluster.egg-info/PKG-INFO
writing dependency_links to seqcluster.egg-info/dependency_links.txt
writing entry points to seqcluster.egg-info/entry_points.txt
writing top-level names to seqcluster.egg-info/top_level.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'seqcluster.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 34, in <module>
    zip_safe=False)
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 129, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 226, in run
    self.run_tests()
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 248, in run_tests
    exit=False,
  File "/usr/lib/python3.6/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python3.6/unittest/main.py", line 141, in parseArgs
    self.createTests()
  File "/usr/lib/python3.6/unittest/main.py", line 148, in createTests
    self.module)
  File "/usr/lib/python3.6/unittest/loader.py", line 219, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.6/unittest/loader.py", line 219, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.6/unittest/loader.py", line 190, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 52, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/usr/lib/python3.6/unittest/loader.py", line 190, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 38, in loadTestsFromModule
    tests.append(TestLoader.loadTestsFromModule(self, module))
  File "/usr/lib/python3.6/unittest/loader.py", line 123, in loadTestsFromModule
    tests.append(self.loadTestsFromTestCase(obj))
  File "/usr/lib/python3.6/unittest/loader.py", line 92, in loadTestsFromTestCase
    loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
  File "/usr/lib/python3.6/unittest/suite.py", line 24, in __init__
    self.addTests(tests)
  File "/usr/lib/python3.6/unittest/suite.py", line 57, in addTests
    for test in tests:
TypeError: __init__() missing 1 required positional argument: 'exc_val'

Can you possibly reproduce that?

Cheers, Steffen

lpantano commented 6 years ago

sorry about that. I think in this repo we were working from master. I just sync the branches, can you pull and try again, please?

as well, I run the tests always with nosetest, I think I don't have it set it up properly to run with python setup.py test, can you try with nosetest and see if that works?

smoe commented 6 years ago

Sorry for my late reply. With nosetest3 there are some python3 issues surfacing. The first is

['cluster', '-m', '../../data/examples/cluster/seqs_set.ma', '-a', '../../data/examples/cluster/seqs_map.bam', '--gtf', '../../data/examples/cluster/ann_reduced.gtf', '-r', '../../data/genomes/genome.fa', '-o', 'test_out_res']
INFO Run cluster
INFO Checking parameters and files
INFO Output dir will be: test_out_res
INFO Clean bam file with highly repetitive reads with low counts. sum(counts)/n_hits > 1%
INFO error at command
Traceback (most recent call last):
  File "/usr/bin/seqcluster", line 11, in <module>
    load_entry_point('seqcluster==1.2.4a8', 'console_scripts', 'seqcluster')()
  File "/usr/lib/python3/dist-packages/seqcluster/command_line.py", line 28, in main
    cluster(kwargs["args"])
  File "/usr/lib/python3/dist-packages/seqcluster/make_clusters.py", line 44, in cluster
    bam_file, seq_obj = _clean_alignment(args)
  File "/usr/lib/python3/dist-packages/seqcluster/make_clusters.py", line 249, in _clean_alignment
    bam_file, seq_obj = clean_bam_file(args.afile, args.mask)
  File "/usr/lib/python3/dist-packages/seqcluster/detect/cluster.py", line 50, in clean_bam_file
    run("samtools index %s" % bam_in)
  File "/usr/lib/python3/dist-packages/seqcluster/libs/do.py", line 16, in run
    logger.debug(" ".join(str(x) for x in cmd) if not isinstance(cmd, basestring) else cmd)
NameError: name 'basestring' is not defined

which stackoverflow claims to be directly substitutable with "str". The other issue surfacing stackoverflow describes here https://stackoverflow.com/questions/26967509/attributeerror-io-textiowrapper-object-has-no-attribute-next-python . In short, there is no next() function with python3.

======================================================================
ERROR: test_preparedata (test.test_preparedata.TestPreparedata)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/moeller/git/debian-med/seqcluster-smoe/seqcluster/test/test_preparedata.py", line 20, in test_preparedata
    seq_l, list_s = _read_fastq_files(open("data/examples/collapse/config"), args)
  File "/home/moeller/git/debian-med/seqcluster-smoe/seqcluster/seqcluster/prepare_data.py", line 108, in _read_fastq_files
    seq = handle.next().strip()
AttributeError: '_io.TextIOWrapper' object has no attribute 'next'

======================================================================
ERROR: test_umis (test.test_preparedata.TestPreparedata)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/moeller/git/debian-med/seqcluster-smoe/seqcluster/test/test_preparedata.py", line 32, in test_umis
    umis = collapse(os.path.abspath("data/examples/umis/sample.fastq"))
  File "/home/moeller/git/debian-med/seqcluster-smoe/seqcluster/seqcluster/libs/fastq.py", line 20, in collapse
    return collapse_umi(in_file)
  File "/home/moeller/git/debian-med/seqcluster-smoe/seqcluster/seqcluster/libs/fastq.py", line 40, in collapse_umi
    seq = handle.next().strip()
AttributeError: '_io.TextIOWrapper' object has no attribute 'next'
-------------------- >> begin captured logging << --------------------
seqbuster: INFO: Find UMI tags in read names, collapsing by UMI.
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 6 tests in 2.849s

FAILED (errors=4)

I'll send a pull request with substitutes of next() with readline().

The nosetests3 still fail, but now because an executable is not found:

ERROR: Run miraligner analysis
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/moeller/git/debian-med/seqcluster-smoe/seqcluster/test/test_automated_analysis.py", line 107, in test_srnaseq_miraligner
    subprocess.check_call(cl)
  File "/usr/lib/python3.6/subprocess.py", line 286, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'seqcluster': 'seqcluster'
-------------------- >> begin captured stdout << ---------------------
seqcluster seqbuster --sps hsa --hairpin ../../data/examples/miraligner/hairpin.fa --mirna ../../data/examples/miraligner/miRNA.str --gtf ../../data/examples/miraligner/hsa.gff3 -o test_out_mirs_fasta --miraligner ../../data/examples/miraligner/sim_isomir.fa

--------------------- >> end captured stdout << ----------------------

Does that ring any bell?

Cheers,

Steffen

lpantano commented 6 years ago

hum, I think it could be related to how python3 is linking the command lines mentioned in setup.py. I'll try to take a look early next week.

thanks!

smoe commented 5 years ago

This happens when running the tests from outside the build folder. Sorry, my bad.