Skip to content

argparse bug when running consolidate #78

Open

Description

@racng

After succesfully running demultiplex and unitag, I tried running consolidate step with the following command:

SAMPLE=test
guideseq.py consolidate \
    --read1 $WORKDIR/umitagged/${SAMPLE}.r1.umitagged.fastq \
    --read2 $WORKDIR/umitagged/${SAMPLE}.r2.umitagged.fastq \
    --outfolder $WORKDIR 

I got the following error

[09/27 07:33:18PM][INFO][guideseq_cmd] Consolidating reads...
[09/27 07:33:18PM][ERROR][guideseq_cmd] Error umitagging
[09/27 07:33:18PM][ERROR][guideseq_cmd] Traceback (most recent call last):
  File "/users/rng/mambaforge/envs/guideseq/lib/python3.7/site-packages/guideseq/guideseq_cmd.py", line 186, in consolidate
    consolidate.consolidate(self.umitagged[sample]['read1'], self.consolidated[sample]['read1'], min_qual, min_freq)
  File "/users/rng/mambaforge/envs/guideseq/lib/python3.7/site-packages/umi/consolidate.py", line 92, in consolidate
    consolidation_sucess, cons_seq, cons_qual = zip(*[consolidate_position(bases, quals, min_qual, min_freq) for bases, quals in zip(read_bases, read_quals)])
  File "/users/rng/mambaforge/envs/guideseq/lib/python3.7/site-packages/umi/consolidate.py", line 92, in <listcomp>
    consolidation_sucess, cons_seq, cons_qual = zip(*[consolidate_position(bases, quals, min_qual, min_freq) for bases, quals in zip(read_bases, read_quals)])
  File "/users/rng/mambaforge/envs/guideseq/lib/python3.7/site-packages/umi/consolidate.py", line 49, in consolidate_position
    if qq > min_qual:
TypeError: '>' not supported between instances of 'int' and 'NoneType'

I then investigated this by calling consolidate from umi.consolidate directly in a python environment and didn't run into an error.

I then looked into the guideseq.py script that handles command line arguments. I modified the script to print out the values of min_qual and min_freq before it runs g.consolidate(...). Turns out both values are None.
In the following lines, the conditional is evaluated as True, even when these optional arguments are not provided.

        if 'min_quality' in args:
            min_qual = args.min_quality
        else:
            min_qual = CONSOLIDATE_MIN_QUAL

        if 'min_frequency' in args:
            min_freq = args.min_frequency
        else:
            min_freq = CONSOLIDATE_MIN_FREQ

The program works after I have changed these lines to the following:

        if args.min_quality is not None:
            min_qual = args.min_quality
        else:
            min_qual = CONSOLIDATE_MIN_QUAL

        if args.min_frequency is not None:
            min_freq = args.min_frequency
        else:
            min_freq = CONSOLIDATE_MIN_FREQ

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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