zstephens / neat-genreads

NEAT read simulation tools
Other
95 stars 27 forks source link

Circular dependency import #47

Closed astewart-twist closed 6 years ago

astewart-twist commented 6 years ago

I think you have a circular dependency in your imports.

Using a fresh clone of the repo:

python genReads.py -r test.fasta -R 101 -o simulated_data
Traceback (most recent call last):
  File "genReads.py", line 38, in <module>
    from SequenceContainer      import SequenceContainer, ReadContainer, parseInputMutationModel
  File "/neat-genreads/py/SequenceContainer.py", line 10, in <module>
    from cigar import CigarString
ImportError: cannot import name CigarString

Also, any plan to make this an actual package with a setup.py, etc ?

zstephens commented 6 years ago

Hmm, I'm unable to replicate this:

git clonehttps://github.com/zstephens/neat-genreads.git cd neat-genreads/ python genReads.py -r hg19.fa -R 101 -o simulated_data Using default sequencing error model. Using default gc-bias model. found index hg19.fa.fai reading chr1...` etc..

Can you confirm what version of python you're running on, any maybe what system? That might help debug further.

astewart-twist commented 6 years ago

Sure.

Python:

Python 2.7.14

System:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
NAME="Ubuntu"
VERSION="16.04.4 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.4 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
zstephens commented 6 years ago

Is is possible you have this package installed? https://pypi.org/project/cigar/

If you do, I could imagine the line in neat-genreads/py/SequenceContainer.py: from cigar import CigarString might be trying to import from that package instead of genreads' own cigar.py.

Either way, I believe I can prevent this by prepending sys.path with neat-genreads/py/, or worst case scenario just renaming cigar.py to something less generic.

astewart-twist commented 6 years ago

Bingo. Good catch!