How to resolve ‘Can’t perform this operation for unregistered loader type’

Problem

Recently I started to add unit tests using setuptools to one of my packages.

In order to do this, I added a test directory containing MyUnitTest.py. setup.py was properly setup using the

test_suite="tests"

option.

However, when running

python setup.py test

I got this error message:

running test
running egg_info
writing MyPackage.egg-info/PKG-INFO
writing top-level names to MyPackage.egg-info/top_level.txt
writing dependency_links to MyPackage.egg-info/dependency_links.txt
reading manifest file 'MyPackage.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MyPackage.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 29, in <module>
    'Topic :: Scientific/Engineering :: Information Analysis'
  File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 135, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 116, in with_project_on_sys_path
    func()
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 160, in run_tests
    testLoader = cks
  File "/usr/lib/python3.4/unittest/main.py", line 92, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python3.4/unittest/main.py", line 139, in parseArgs
    self.createTests()
  File "/usr/lib/python3.4/unittest/main.py", line 146, in createTests
    self.module)
  File "/usr/lib/python3.4/unittest/loader.py", line 146, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.4/unittest/loader.py", line 146, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python3.4/unittest/loader.py", line 117, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/usr/lib/python3/dist-packages/setuptools/command/test.py", line 26, in loadTestsFromModule
    for file in resource_listdir(module.__name__, ''):
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 954, in resource_listdir
    resource_name
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1378, in resource_listdir
    return self._listdir(self._fn(self.module_path,resource_name))
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1415, in _listdir
    "Can't perform this operation for unregistered loader type"
NotImplementedError: Can't perform this operation for unregistered loader type

Read more

A GeneOntology OBO v1.4 parser in Python

The GeneOntology Consortium provides bulk data download for the GO terms in the OBO v1.2 format.

If you Google GO OBO parser, there is something missing. You can easily find parsers in Perl, parsers in Java, but not even BioPython has a parser in Python. The format itself, however seems like it’s tailor-made for Python’s generator concept. Only a few SLOCs are needed to get it work without storing everything in RAM.

I used this parser in a prototype project that allows to search GO interactively (it’s fast). I’m not sure when/if I’ll publish that, but here is the parser code.

Read more

A simple tool for FASTA statistics

The issue

It is surprisingly difficult to compute simple statistics of FASTA files using existing software. I recently needed to compute the nucleotide count and relative GC frequency of a single sequence in FASTA format, but unless you install dependency-heavy native software like FASTX or you develop it by yourself using BioPython or similar, there doesn’t seem to be a simple, dependency-free solution for this simple set of problem.

Read more