Skip to content

AttributeError: 'array.array' object has no attribute 'tostring' #207

@oliverartz

Description

@oliverartz

Dear developer,

I have been trying to simulate some in silico tumors using BAMSurgeon. After installing (check_dependencies.py not throwing any errors) and generating random sites using randomsites.py, I tried introducing SNVs with addsnv.py. I am running the following command

python3 -O /home/artzo/bin/bamsurgeon/bin/addsnv.py \
-v random_SNV_1k.txt \
-f [BAM FILE] \
-r [GENOME FILE] \
-o [OUTPUT FILE] \
--aligner mem \
--picardjar [PATH TO PICARD.JAR] \
--tagreads \
--seed 2010 \
-p 12 \
--insane 

I redacted the file paths in the above command. I got some errors regarding sanity checks, so I decided to use --insane. The script runs for about 20 min generating temporary files and a surprisingly small output BAM. The error.log is rather lengthy (>75k lines) and ends with

INFO 2022-06-20 14:41:34,076 loading donor reads into dictionary...

INFO 2022-06-20 14:41:34,774 secondary reads count:0
INFO 2022-06-20 14:41:34,774 supplementary reads count:0
INFO 2022-06-20 14:41:34,774 loaded 229926 reads, (144 excluded, 0 null or secondary or supplementary--> ignored)

Traceback (most recent call last):
  File "/home/artzo/bin/bamsurgeon/bin/addsnv.py", line 479, in <module>
    run()
  File "/home/artzo/bin/bamsurgeon/bin/addsnv.py", line 476, in run
    main(args)
  File "/home/artzo/bin/bamsurgeon/bin/addsnv.py", line 422, in main
    rr.replace_reads(args.bamFileName, outbam_mutsfile, args.outBamFile, keepqual=True, seed=args.seed)
  File "/lila/home/artzo/bin/bamsurgeon/bin/bamsurgeon/replace_reads.py", line 165, in replace_reads
    rdict[extqname].qual = read.qual
  File "pysam/calignedsegment.pyx", line 2182, in pysam.calignedsegment.AlignedSegment.qual.__get__
  File "pysam/cutils.pyx", line 45, in pysam.cutils.array_to_qualitystring
AttributeError: 'array.array' object has no attribute 'tostring'

I have read that the tostring issue might be due to incompatibilities with Python 3.9 (which I am using). However, tostring was deprecated in Python 3.2 and I find it hard to believe that all other users are using Python < 3.2. So, I was wondering whether a different issue might be at play here. I would greatly appreciate your help!

Thank you very much for the development and support of BAMSurgeon!
Best,
Oliver

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions