Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute 'readline' #275

Closed
jlblancopastor opened this issue Dec 12, 2017 · 8 comments

Comments

@jlblancopastor
Copy link

commented Dec 12, 2017

When running cutadapt on my fastq gzipped file:
cutadapt -m 8 -a AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC -o output_fastq.gz input_fastq.gz

I get the following error message:

Traceback (most recent call last):
File "./cutadapt", line 11, in
load_entry_point('cutadapt==1.15', 'console_scripts', 'cutadapt')()
File "./miniconda2/lib/python2.7/site-packages/cutadapt-1.15-py2.7-linux-x86_64.egg/cutadapt/main.py", line 717, in main
File "./miniconda2/lib/python2.7/site-packages/cutadapt-1.15-py2.7-linux-x86_64.egg/cutadapt/pipeline.py", line 97, in set_input
File "./miniconda2/lib/python2.7/site-packages/cutadapt-1.15-py2.7-linux-x86_64.egg/cutadapt/seqio.py", line 698, in open
File "./miniconda2/lib/python2.7/site-packages/cutadapt-1.15-py2.7-linux-x86_64.egg/cutadapt/seqio.py", line 768, in _seqopen1
AttributeError: 'str' object has no attribute 'readline'

@marcelm

This comment has been minimized.

Copy link
Owner

commented Dec 12, 2017

Thanks for the report. Can you please rename the input file to input.fastq.gz (no underscore) and try again? Please leave the report open if it helps. Cutadapt should handle this in a better way (or at least print a better error message).

@jlblancopastor

This comment has been minimized.

Copy link
Author

commented Dec 12, 2017

Yes, it worked now without underscores in the input file.
Thanks!

@marcelm

This comment has been minimized.

Copy link
Owner

commented Dec 12, 2017

Great, thanks for letting me know! I’ll fix this when I am less busy with other things.

@BioNastya

This comment has been minimized.

Copy link

commented Jan 29, 2018

Hi, I have the same problem
cutadapt -a TCTCGTATGCCGTC -o pe180f.short.cut.fq.gz pe180.forward.paired.short.gz
Traceback (most recent call last):
File "/usr/local/bin/cutadapt", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/cutadapt/main.py", line 717, in main
fileformat=options.format, interleaved=is_interleaved_input)
File "/usr/local/lib/python2.7/dist-packages/cutadapt/pipeline.py", line 97, in set_input
interleaved, mode='r')
File "/usr/local/lib/python2.7/dist-packages/cutadapt/seqio.py", line 698, in open
mode=mode, qualities=qualities)
File "/usr/local/lib/python2.7/dist-packages/cutadapt/seqio.py", line 768, in _seqopen1
first_line = file.readline()
AttributeError: 'str' object has no attribute 'readline'

@marcelm

This comment has been minimized.

Copy link
Owner

commented Jan 29, 2018

Please rename your input file such that it has the extension .fastq.gz. Currently, cutadapt recognizes the input file format from the file name, and in your example, it does not know how to interpret .short.gz.

@BioNastya

This comment has been minimized.

Copy link

commented Feb 1, 2018

Thanks for your answer!

marcelm added a commit that referenced this issue Aug 20, 2018

@marcelm marcelm added the bug label Aug 30, 2018

@marcelm marcelm closed this in f2fc43e Oct 3, 2018

@frimz

This comment has been minimized.

Copy link

commented Dec 13, 2018

my command alredy has no undescore and its showing the same attribute error
#input
echo "Adapter trimming"
bin/cutadapt -a TGGAATTCTCGGGTGCCAAGG -m 15 -M 76 -o $out_dir_prefix"trimmed/"$prefix.fastq.gz $out_dir_prefix"fastq/"$prefix.fastq.gz > $out_dir_prefix"logs/cutadapt/"$prefix.txt
#output
File "bin/cutadapt", line 11, in
sys.exit(main())
File "/data/programs/PIWI/scripts/cutadapt/main.py", line 776, in main
fileformat=options.format, interleaved=is_interleaved_input)
File "/data/programs/PIWI/scripts/cutadapt/pipeline.py", line 107, in set_input
interleaved, mode='r')
File "/data/programs/PIWI/scripts/cutadapt/seqio.py", line 695, in open
mode=mode, qualities=qualities)
File "/data/programs/PIWI/scripts/cutadapt/seqio.py", line 765, in _seqopen1
first_line = file.readline()
AttributeError: 'str' object has no attribute 'readline'

@marcelm

This comment has been minimized.

Copy link
Owner

commented Dec 13, 2018

What are the actual file names in your case? You can add this to the top of your shell script, which will make it print the commands when they are executed:

set -x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.