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

Alignment Name with Spaces Breaks mafft Call #388

Closed
emmahodcroft opened this issue Oct 28, 2019 · 3 comments
Closed

Alignment Name with Spaces Breaks mafft Call #388

emmahodcroft opened this issue Oct 28, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@emmahodcroft
Copy link
Member

If trying to use augur align with an alignment with a space in the filename (e.g. E30 FLs.FST), this is passed to mafft with the space, but without quotes, and breaks mafft.

The call:

augur align --sequences "E30 FLs.FST" --output "E30_FL_aligned.fasta" --reference-sequence "echo30-genome-ref.gb" --remove-reference

Give this error:

ERROR: shell exited 1 when running: mafft --reorder --anysymbol --thread 1 E30 FLs.FST.ref.fasta 1> E30_FL_aligned.fasta 2> E30_FL_aligned.fasta.log

And also makes a super weird log file. Nothing points to the fact the space in the file name is the error.

Renaming file to remove the space fixes the error. Also seems like changing line 97 in align.py:

        cmd = "mafft --reorder --anysymbol --thread %d %s 1> %s 2> %s.log"%(args.nthreads, seq_fname, output, output)

to have single quotes around the input file name

        cmd = "mafft --reorder --anysymbol --thread %d '%s' 1> %s 2> %s.log"%(args.nthreads, seq_fname, output, output)

Fixes this. However, I imagine this kind of problem could happen other places here (what if reference file has a space? Output file?) and in other augur commands (tree?). Dunno if it would be better to do something more comprehensive, or just fix this for now?

@emmahodcroft emmahodcroft added the bug Something isn't working label Oct 28, 2019
@tsibley
Copy link
Member

tsibley commented Nov 4, 2019

The best way to fix this issue is to run commands without using the shell by providing a list of command arguments (argv) instead of a command string.

The next best way is to shell-quote all the variables interpolated into command strings using shlex.quote. However, this is more verbose for the caller and prone to being forgotten by the programmer, so it's less robust.

@CameronDevine
Copy link
Contributor

It appears this specific problem was addressed in #422. There is a similar problem which could now occur when providing a filename which includes spaces to the --existing-alignment argument of augur align. This issue is addressed in #452.

@tsibley
Copy link
Member

tsibley commented Mar 9, 2020

@CameronDevine Thanks for the nuanced note here, very helpful!

@tsibley tsibley closed this as completed Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants