torognes / swarm

A robust and fast clustering method for amplicon-based studies
GNU Affero General Public License v3.0
123 stars 23 forks source link

Swarm doesn't exit when run without any inputs #105

Closed complexgenome closed 6 years ago

complexgenome commented 7 years ago

Hi,
I'm using Swarm 2.1.13, OSX 10.11.5 El Capitan. I downloaded swarm, followed instructions to make it. In bin I run swarm as ./swarm

I get message as attached in .txt file. Shouldn't swarm exit or abort if run without any input files/parameters? swarm_message.txt

frederic-mahe commented 7 years ago

Hi @sariya , that's normal.

swarm can read from a file, but also from stdin, so in the absence of input, it just waits. Use ctrl + c to stop swarm.

complexgenome commented 7 years ago

Ah, makes sense. Thanks.

torognes commented 7 years ago

Perhaps we should make it a requirement to add a filename on the command line? To read from stdin it would now be enough to include a hyphen (-). This could make it a bit easier for beginners by giving some help information if nothing was specified on the command line. Would probably break some scripts though, so it should wait until version 3.0.0.

frederic-mahe commented 7 years ago

When launched without option or input, swarm writes a few lines of information and waits for data to arrive on its standard input:

swarm
Swarm 2.1.13 [Jul  4 2017 21:01:31]
Copyright (C) 2012-2017 Torbjorn Rognes and Frederic Mahe
https://github.com/torognes/swarm

Mahe F, Rognes T, Quince C, de Vargas C, Dunthorn M (2014)
Swarm: robust and fast clustering method for amplicon-based studies
PeerJ 2:e593 https://doi.org/10.7717/peerj.593

Mahe F, Rognes T, Quince C, de Vargas C, Dunthorn M (2015)
Swarm v2: highly-scalable and high-resolution amplicon clustering
PeerJ 3:e1420 https://doi.org/10.7717/peerj.1420

CPU features:      mmx sse sse2 sse3 ssse3 sse4.1 sse4.2 popcnt avx avx2
Database file:     /dev/stdin
Output file:       /dev/stdout
Resolution (d):    1
Threads:           1
Break OTUs:        Yes
Fastidious:        No

When no input file is given (i.e. read from stdin), what about adding one more line of information explaining what is going on? Something like:

waiting for data... (hit ctrl-c and run swarm -h if you meant to read data from a file)

If data is coming on stdin then the message will be immediately followed by new lines showing the clustering progress. If not, then the user will have the time to read the message and to understand what to do next. I think that solution would accommodate both new and power-users (maybe @colinbrislawn could give us his opinion on that topic?).

colinbrislawn commented 7 years ago

Oh that's perfect!

waiting for data... (hit ctrl-c and run swarm -h if you meant to read data from a file)

That sounds like a perfect way to help new users, while being consistent with *unix programs and maintaining functionality for existing pipelines.

These little hints make big gains in accessibility. 🎉

torognes commented 7 years ago

Sounds like a good idea! Will implement that.

torognes commented 7 years ago

Fixed. When waiting for input from stdin (or pipe), swarm will show this message:

Waiting for data... (Hit Ctrl-C and run swarm -h if you meant to read data from a file.)

torognes commented 6 years ago

Fixed in version 2.2.0 just released.