Connor Deduplication - AttributeError: 'module' object has no attribute 'AlignmentFile'
0
0
Entering edit mode
6.8 years ago

I'm attempting to use Connor to deduplicate some bam files in my variant calling pipeline, but so far whenever I attempt to run Connor I get the following error message:

2017-07-17 10:32:28|ERROR|An unexpected error occurred
2017-07-17 10:32:28|ERROR|Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/connor/connor.py", line 498, in main
    command_validator.preflight(args, log)
  File "/usr/local/lib/python2.7/dist-packages/connor/command_validator.py", line 190, in preflight
    validate(args, log)
  File "/usr/local/lib/python2.7/dist-packages/connor/command_validator.py", line 76, in _check_input_bam_valid
    bamfile = samtools.alignment_file(args.input_bam, 'rb')
  File "/usr/local/lib/python2.7/dist-packages/connor/samtools.py", line 527, in alignment_file
    return pysam.AlignmentFile(filename, mode, template)
AttributeError: 'module' object has no attribute 'AlignmentFile'

I installed Connor using pip, and have since tried updating pysam (which in turn required installation of liblzma-dev via apt-get), but I'm still getting the same error.

I've also tried using sorted, indexed bam files but that doesn't help either.

If anyone has any suggestions it would be much appreciated.

deduplication barcoding alignment connor • 3.2k views
ADD COMMENT
0
Entering edit mode

What's your pysam version? It's probably that.

It's possible that Connor imports an older pysam module (while you installed the latest).

ADD REPLY
0
Entering edit mode

According to pip, I'm using v 0.11.2.2

Connor says it requires pysam>=0.8.4,<0.9.1, how would I go about changing the pysam version?

ADD REPLY
0
Entering edit mode

Do you know a bit of Python?

ADD REPLY
0
Entering edit mode

I managed to switch to pysam 0.8.4 with pip, but I'm still getting the same error message when I try to run Connor

ADD REPLY
0
Entering edit mode

I managed to switch to pysam 0.8.4 with pip

That's insufficient.
Pysam made some changes (I believe around 0.10.0) which make it non-compatible to older versions.

But it's not impossible to fix.

Sooo... do you know a bit of Python?

ADD REPLY
0
Entering edit mode

Ah, fair enough. Yes I know some python.

ADD REPLY
0
Entering edit mode

Cool. Let's start with checking which version of pysam is used by connor.
Look for the import statement import pysam and add print(pysam.__version__) afterwards.

ADD REPLY
0
Entering edit mode

Connor is using pysam 0.7.5

ADD REPLY
0
Entering edit mode

What a bastard. Okay - so it uses an outdated pysam.
Let's figure out where it comes from. If you just add the following:
print(pysam)
That will tell you the path it used to import from.

Also, let's have a look at your sys.path
import sys
print(sys.path)

That tells the python interpreter where it can get its modules. We'll need to hack it slightly to make sure Connor imports the correct pysam.

ADD REPLY

Login before adding your answer.

Traffic: 1679 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6