Skip to content

Type error when counting variants (Overlap SeqLib) : TypeError: 'str' object does not support item assignment #78

Description

@ppreshant

I'm running enrich2 on paired end reads from a small run of amplicon-EZ with the alignment option turned off. This is the error I see and is very unintuitive where it is coming from. Here's my command for the CLI run: pixi run enrich_cmd della_pairedEnd.json ratios complete

Tried

I tried these things but doesn't affect the error message at all

  • use aligner : true
  • turn off trim within overlap and report filtered reads" by setting to false
  • Changing the normalization to wt and full instead.

Setup method

I have a feeling this could be a python version issue but here's how I made my pixi environment

  • Copied the dependancies from the enrich2_env.yml on github.
  • I did a pixi install using this toml
  • Here's the final pixi.toml after installing enrich2 from pypi.
[workspace]
authors = ["Prashant Kalvapalle <ppresh.ant@gmail.com>"]
channels = ["conda-forge", "bioconda"]
name = "enrich2_library"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[dependencies]
python = "3.*"
numpy = "*"
scipy = "*"
pandas = "*"
pytables = "*"
statsmodels = "*"
matplotlib = "*"
fastp = ">=1.3.6,<2"
cutadapt = ">=5.2,<6"

[pypi-dependencies]
enrich2 = ">=2.0.2, <3"

Error message

pixi run enrich_cmd della_pairedEnd.json ratios complete
2026-08-26 18:50:17,840 [enrich2.main] Detected an Experiment config file
2026-08-26 18:50:17,841 [enrich2.experiment.Experiment - DELLA_low_depth] Creating new HDF5 data store "results/DELLA_low_depth_exp.h5"
2026-08-26 18:50:19,433 [enrich2.selection.Selection - Input] Creating new HDF5 data store "results/Input_sel.h5"
2026-08-26 18:50:19,439 [enrich2.overlap.OverlapSeqLib - Input_before_enrichment] Creating new HDF5 data store "results/Input_before_enrichment_lib.h5"
2026-08-26 18:50:19,445 [enrich2.overlap.OverlapSeqLib - Enriched] Creating new HDF5 data store "results/Enriched_lib.h5"
2026-08-26 18:50:19,451 [enrich2.selection.Selection - Input] Counting for each time point (variants)
2026-08-26 18:50:19,469 [enrich2.overlap.OverlapSeqLib - Input_before_enrichment] Counting variants
Traceback (most recent call last):
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/bin/enrich_cmd", line 10, in <module>
    sys.exit(main_cmd())
             ^^^^^^^^^^
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/main.py", line 225, in main_cmd
    obj.calculate()
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/experiment.py", line 156, in calculate
    s.calculate()
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/selection.py", line 425, in calculate
    self.merge_counts_unfiltered(label)
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/selection.py", line 295, in merge_counts_unfiltered
    lib.calculate()
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/overlap.py", line 326, in calculate
    self.counts_from_reads()
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/overlap.py", line 277, in counts_from_reads
    merge = self.merge_reads(fwd, rev)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/enrich2/overlap.py", line 214, in merge_reads
    merge.sequence[a] = "X"  # unresolvable
    ~~~~~~~~~~~~~~^^^
TypeError: 'str' object does not support item assignment
/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/tables/file.py:130: UnclosedFileWarning: Closing remaining open file: results/Input_sel.h5
  warnings.warn(UnclosedFileWarning(msg))
/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/tables/file.py:130: UnclosedFileWarning: Closing remaining open file: results/DELLA_low_depth_exp.h5
  warnings.warn(UnclosedFileWarning(msg))
/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/tables/file.py:130: UnclosedFileWarning: Closing remaining open file: results/Enriched_lib.h5
  warnings.warn(UnclosedFileWarning(msg))
/home/prashantk/bioinformatics/enrich2_library/.pixi/envs/default/lib/python3.12/site-packages/tables/file.py:130: UnclosedFileWarning: Closing remaining open file: results/Input_before_enrichment_lib.h5

Here's the json file if it is helpful

{
  "name": "DELLA_low_depth",
  "output directory": "results/",

  "conditions": [
    {
      "name": "All",

      "selections": [
        {
          "name": "Input",

          "libraries": [
            {
              "name": "Input_before_enrichment",
              "timepoint": 0,
              "report filtered reads": true,

              "overlap": {
                "forward start": 1,
                "length": 290,
                "max mismatches": 100,
                "reverse start": 1,
                "trim": true
              },


              "fastq": {
                "forward reads": "fastq/GS2431UQ5AF_R1_001.fastq.gz", 
                "reverse reads": "fastq/GS2431UQ5AF_R2_001.fastq.gz",

                "filters": {
                  "min quality": 20
                }
              },

              "variants": {
                "min count": 0,
                "use aligner": false,
                "wild type": {
                  "sequence": "GTTAAAAAAGAGGAAGACGGCGGGGGTAATATGGATGATGAATTGCTGGCCGTGTTGGGTTACAAAGTTAGATCAAGTGAGATGGCCGAAGTGGCACTTAAGCTTGAACAACTGGAAACTATGATGAGCAACGTCCAGGAAGATGGTCTTTCCCACTTAGCGACGGACACTGTGCATTACAACCCTTCTGAGTTATACAGTTGGCTAGACAACATGCTTAGCGAGCTGAATCCCCCGC",
                  "coding": false,
                  "reference offset": 0
                }
              }
            },

            {
              "name": "Enriched",
              "timepoint": 2,
              "report filtered reads": true,

              "overlap": {
                "forward start": 1,
                "length": 290,
                "max mismatches": 100,
                "reverse start": 1,
                "trim": true
              },

              "fastq": {
                "forward reads": "fastq/GS2436UQ5AF_R1_001.fastq.gz",
                "reverse reads": "fastq/GS2436UQ5AF_R2_001.fastq.gz",

                "filters": {
                  "min quality": 20
                }
              },

              "variants": {
                "min count": 0,
                "use aligner": false,
                "wild type": {
                  "sequence": "GTTAAAAAAGAGGAAGACGGCGGGGGTAATATGGATGATGAATTGCTGGCCGTGTTGGGTTACAAAGTTAGATCAAGTGAGATGGCCGAAGTGGCACTTAAGCTTGAACAACTGGAAACTATGATGAGCAACGTCCAGGAAGATGGTCTTTCCCACTTAGCGACGGACACTGTGCATTACAACCCTTCTGAGTTATACAGTTGGCTAGACAACATGCTTAGCGAGCTGAATCCCCCGC",
                  "coding": false,
                  "reference offset": 0
                }
              }
            }

            
          ]
        }
      ]
    }
  ]
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions