trim argument parser errors
See original GitHub issueFor cutadapt 3.2 with Python 3.6.9.
Using an example from a previous issue (#508), this command works:
cutadapt -g 'ACCTGCGGARGGATCA;min_overlap=16;max_error_rate=0.3' -a 'AACTTTYARCAAYGGATCTC;min_overlap=20;max_error_rate=0.3' --times 1 --max-n 5 --revcomp --trimmed-only --cores 4 --output example_trim.fasta example.fasta
But if I want to use the “required” or “optional” arguments it crashes (only “anywhere” don’t give errors). Using “required”:
This is cutadapt 3.2 with Python 3.6.9
Command line parameters: -g ACCTGCGGARGGATCA;min_overlap=16;max_error_rate=0.3;required -a AACTTTYARCAAYGGATCTC;min_overlap=20;max_error_rate=0.3 --times 1 --max-n 5 --revcomp --trimmed-only --cores 4 --output example_trim.fasta example.fasta
Traceback (most recent call last):
File "/home/fossandon/.local/bin/cutadapt", line 11, in <module>
sys.exit(main_cli())
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/__main__.py", line 845, in main_cli
main(sys.argv[1:])
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/__main__.py", line 895, in main
adapters, adapters2 = adapters_from_args(args)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/__main__.py", line 738, in adapters_from_args
adapters = adapter_parser.parse_multi(args.adapters)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 433, in parse_multi
adapters.extend(self.parse(spec, cmdline_type))
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 410, in parse
yield self._parse(spec, cmdline_type, name=None)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 313, in _parse
return self._parse_not_linked(spec, name, cmdline_type)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 346, in _parse_not_linked
sequence=aspec.sequence, name=aspec.name if name is None else name, **parameters)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/adapters.py", line 493, in __init__
super().__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'required'
Using “optional”:
Command line parameters: -g ACCTGCGGARGGATCA;min_overlap=16;max_error_rate=0.3;optional -a AACTTTYARCAAYGGATCTC;min_overlap=20;max_error_rate=0.3 --times 1 --max-n 5 --revcomp --trimmed-only --cores 4 --output example_trim.fasta example.fasta
Traceback (most recent call last):
File "/home/fossandon/.local/bin/cutadapt", line 11, in <module>
sys.exit(main_cli())
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/__main__.py", line 845, in main_cli
main(sys.argv[1:])
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/__main__.py", line 895, in main
adapters, adapters2 = adapters_from_args(args)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/__main__.py", line 738, in adapters_from_args
adapters = adapter_parser.parse_multi(args.adapters)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 433, in parse_multi
adapters.extend(self.parse(spec, cmdline_type))
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 410, in parse
yield self._parse(spec, cmdline_type, name=None)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 313, in _parse
return self._parse_not_linked(spec, name, cmdline_type)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/parser.py", line 346, in _parse_not_linked
sequence=aspec.sequence, name=aspec.name if name is None else name, **parameters)
File "/home/fossandon/.local/lib/python3.6/site-packages/cutadapt/adapters.py", line 493, in __init__
super().__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'required'
Note that although I used “optional”, it complains about “required” again.
If I link them the crash dissapears: -g 'ACCTGCGGARGGATCA;min_overlap=16;max_error_rate=0.3;required...AACTTTYARCAAYGGATCTC;min_overlap=20;max_error_rate=0.3'
, so the problem only appears when the argument is used without linking (either using -g and -a together or alone).
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
For “historical reasons”, Cutadapt treats all the adapters that you provide as equal. So if you give it four 5’ adapters and seven 3’ adapters, Cutadapt just aligns all eleven of them in turn against the read and chooses the best one. It doesn’t assume that 5’ and 3’ adapters come in pairs or have any other relationship.
In particular, when you provide one 5’ adapter (
-g
) and one 3’ adapter (-a
), Cutadapt removes either the 5’ adapter, the 3’ adapter, or none at all. The required and optional distinction only becomes relevant when you want to remove both at the same time in the normal case, but also want to be able to say what should happen when one of the two cannot be found.Thanks for the report – that’s definitely a bug. I’ll look into this next week.