Skip to content

Error when combining multiple 5' adapter search with -g file: and ;rightmost #889

Description

@clmattson

Hi!

I'm using cutadapt 5.2 with Python 3.12.11, installed via conda (cutadapt updated today). I'm running within a longer script. I had a working -g adapter search from a file, and the line worked before I tried to add ;rightmost after the file name, in the hopes of trimming the rightmost match for reads with more than one match to the same 5' adapter (my understanding of the rightmost adapter search parameter). But the two did not seem to be compatible, or I am making a mistake and would appreciate guidance!

Here is the command within the script:
cutadapt -g "file:${well_barcodes};rightmost" -O 14 --revcomp -e 0.15 --cores=0 --info-file ${plate_dir}/${plate}_well_${reads_name}_cutadapt_porechop_INFO.tsv -o ${plate_dir}/${plate}_{name}_${reads_name}_cutadapt_porechop.fastq ${plate_dir}/${plate_file_name} > ${plate_dir}/${plate}_well_${reads_name}_cutadapt_porechop.log;

${well_barcodes} is a .fasta file with my adapter sequences, with format like this:

adpt01
ATCGATCGATCGATCGATCGATCG
adpt02
TAGCTAGCTAGCTAGCTAGCTAGC
....
adpt96
ACGTACGTACGTACGTACGTACGT

Here is the error:

Traceback (most recent call last):
  File "/home/cmatt5/.conda/envs/cutadapt/bin/cutadapt", line 8, in <module>
    sys.exit(main_cli())
             ^^^^^^^^^^
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/cli.py", line 1166, in main_cli
    main(sys.argv[1:])
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/cli.py", line 1222, in main
    adapters, adapters2 = adapters_from_args(args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/cli.py", line 1011, in adapters_from_args
    adapters = make_adapters_from_specifications(args.adapters, search_parameters)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/parser.py", line 389, in make_adapters_from_specifications
    adapters.extend(
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/parser.py", line 420, in make_adapters_from_one_specification
    yield make_adapter(
          ^^^^^^^^^^^^^
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/parser.py", line 469, in make_adapter
    return _make_not_linked_adapter(spec, name, adapter_type, search_parameters)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/parser.py", line 547, in _make_not_linked_adapter
    return adapter_class(
           ^^^^^^^^^^^^^^
  File "/home/cmatt5/.conda/envs/cutadapt/lib/python3.12/site-packages/cutadapt/adapters.py", line 691, in __init__
    super().__init__(*args, **kwargs)
TypeError: SingleAdapter.__init__() got an unexpected keyword argument 'rightmost'

Here is the command that worked:
cutadapt -g file:${well_barcodes} -O 14 --revcomp -e 0.15 --cores=0 --info-file ${plate_dir}/${plate}_well_${reads_name}_cutadapt_porechop_INFO.tsv -o ${plate_dir}/${plate}_{name}_${reads_name}_cutadapt_porechop.fastq ${plate_dir}/${plate_file_name} > ${plate_dir}/${plate}_well_${reads_name}_cutadapt_porechop.log;

My output when using without rightmost is something like this:
Done 00:00:00 44 reads @ 21709.2 µs/read; 0.00 M reads/minute

I think this is related to my using the line within a bash script, but not 100% sure. As of right now, I have not tried hard-coding the file name along with the ";rightmost" parameter added. But I was able to create a workaround that works in my bash script, below, by basically just listing the adapters individually, but with an array becuase there are a lot of them. But thought this issue might still be useful?

declare -a well_g_args=()
while read -r wb_name && read -r wb_seq; do
    wb_name="${wb_name#>}"
    well_g_args+=(-g "${wb_name}=${wb_seq};rightmost")
done < "${well_barcodes}"

cutadapt "${well_g_args[@]}" -O 14 --revcomp -e 0.15 --cores=0 \
    --info-file ${plate_dir}/${plate}_well_${reads_name}_cutadapt_porechop_INFO.tsv \
    -o ${plate_dir}/${plate}_{name}_${reads_name}_cutadapt_porechop.fastq \
    ${plate_dir}/${plate_file_name} \
    > ${plate_dir}/${plate}_well_${reads_name}_cutadapt_porechop.log

Another note - I am also hoping to add --times to this line, if possible. But I'm not sure if it will be compatible or function as I am expecting yet.

Thanks so much!
Courtney

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