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

input from STDIN stops working when -f option given #38

Closed
marcelm opened this issue Mar 13, 2015 · 3 comments
Closed

input from STDIN stops working when -f option given #38

marcelm opened this issue Mar 13, 2015 · 3 comments
Labels

Comments

@marcelm
Copy link
Owner

marcelm commented Mar 13, 2015

From pat...@gmail.com on August 18, 2011 01:35:31

If I run cutadapt on very simple fasta input, I get an error when taking input from STDIN and using the -f fasta option. When reading input from a file, or not using -f, everything works correctly.

My test input file (test0.fa) contains the following:

perfect
TTTGGGGGGG

I want to test cutadapt taking input from STDIN. With no -f option, it works as expected:

$ cat test0.fa | cutadapt -a GGGGGGGGGGGGGGG -

perfect
TTT
cutadapt version 0.9.4
Command line parameters: -a GGGGGGGGGGGGGGG -
Maximum error rate: 10.00%
Processed reads: 1
Trimmed reads: 1 (100.0%)
Too short reads: 0 ( 0.0% of processed reads)
Too long reads: 0 ( 0.0% of processed reads)
Total time: 0.00 s
Time per read: 0.00 ms

=== Adapter 1 ===

Adapter 'GGGGGGGGGGGGGGG', length 15, was trimmed 1 times.

Histogram of adapter lengths
length count
7 1

However, if I add -f fasta to the options, it stops working:

$ cat test0.fa | cutadapt -f fasta -a GGGGGGGGGGGGGGG -
Traceback (most recent call last):
File "/home/weronika/programs/work_software/cutadapt", line 5, in
pkg_resources.run_script('cutadapt==0.9.4', 'cutadapt')
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 461, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1194, in run_script
execfile(script_filename, namespace, namespace)
File "/home/weronika/programs/work_software/cutadapt-0.9.4-py2.6-linux-x86_64.egg/EGG-INFO/scripts/cutadapt", line 595, in
sys.exit(main())
File "/home/weronika/programs/work_software/cutadapt-0.9.4-py2.6-linux-x86_64.egg/EGG-INFO/scripts/cutadapt", line 546, in main
for desc, seq, qualities in reader:
File "/home/weronika/programs/work_software/cutadapt-0.9.4-py2.6-linux-x86_64.egg/cutadapt/seqio.py", line 154, in _streaming_iter
for line in self.fp:
IOError: File not open for reading

Just to make sure, if I run it with the -f option but reading input from a file instead of STDIN, it also works as expected:

$ cutadapt -f fasta -a GGGGGGGGGGGGGGG test0.fa

perfect
TTT
cutadapt version 0.9.4
Command line parameters: -f fasta -a GGGGGGGGGGGGGGG test0.fa
Maximum error rate: 10.00%
Processed reads: 1
Trimmed reads: 1 (100.0%)
Too short reads: 0 ( 0.0% of processed reads)
Too long reads: 0 ( 0.0% of processed reads)
Total time: 0.01 s
Time per read: 10.00 ms

=== Adapter 1 ===

Adapter 'GGGGGGGGGGGGGGG', length 15, was trimmed 1 times.

Histogram of adapter lengths
length count
7 1

Cutadapt version: cutadapt-0.9.4-py2.6-linux-x86_64.egg

Operating system: Linux, Ubuntu 10.04, 64-bit.
$ uname -a
Linux bleen 2.6.32-32-generic #62-Ubuntu SMP Wed Apr 20 21:52:38 UTC 2011 x86_64 GNU/Linux

Original issue: http://code.google.com/p/cutadapt/issues/detail?id=28

@marcelm
Copy link
Owner Author

marcelm commented Mar 13, 2015

From marcel.m...@tu-dortmund.de on August 24, 2011 07:08:54

Hi, thanks for the report and sorry for the late reply (due to vacation).

It seems you've stumbled upon an error that I have fixed in the most recent cutadapt version (without putting a note about this in the changelog, sorry).

Please either upgrade to cutadapt 0.9.5 or fix the problem by changing within your file /home/weronika/programs/work_software/cutadapt-0.9.4-py2.6-linux-x86_64.egg/cutadapt/xopen.py the line

return sys.stdout if 'r' in mode else sys.stdin
to
return sys.stdin if 'r' in mode else sys.stdout

Regards,
Marcel

@marcelm
Copy link
Owner Author

marcelm commented Mar 13, 2015

From pat...@gmail.com on August 25, 2011 17:57:29

Thanks for the very helpful answer! I made the line change, it works now.

@marcelm
Copy link
Owner Author

marcelm commented Mar 13, 2015

From marcel.m...@tu-dortmund.de on October 07, 2011 05:36:25

Status: Fixed

@marcelm marcelm closed this as completed Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant