<p><strong>TL;DR</strong></p>

<p>I made the following bash script to generate an input file for HYPHY.</p>



<pre><code>#!/bin/bash
cat &lt;&lt; EOF
inputRedirect = {};
inputRedirect["01"]="Universal"; // genetic code
inputRedirect["02"]="$(readlink -f $1)"; // codon data
inputRedirect["03"]="$(readlink -f $2)"; // tree
inputRedirect["04"]="${3:-All}"; // Test for selection on a branch
inputRedirect["05"]=""; // complete selection


ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles/BUSTED.bf", inputRedirect);
EOF
</code></pre>

<p>If you want to test all the branches jointly run:</p>

<pre><code>./gen_busted.sh alignment.phy tree.nwk &gt; script.bf
</code></pre>

<p>Or for a particular branch:</p>

<pre><code>./gen_busted.sh alignment.phy tree.nwk branchLabel &gt; script.bf
</code></pre>

<p>And then run:</p>

<pre><code>HYPHYMP script.bf
</code></pre>

<p>Now you can use the script to generate a <code>.bf</code> file for every sequence alignment you have, and run HYPHY for every file.</p>

<p><strong>Longer version</strong></p>

<p>I will describe how to make a similar script for any model, such as MEME, RELAX or PARRIS.</p>

<p>First, find the <code>.bf</code> script which performs the analysis. On GNU/Linux it should be at <code>HYPHY_INSTALLATION_PATH/lib/hyphy/TemplateBatchFiles</code> (it might be different between different OS). In case of BUSTED your script has a name <code>BUSTED.bf</code>.</p>

<p>Now run this model in the interactive mode in order to record all the inputs required by the model. Make sure to specify <strong>full paths</strong> to all the files.</p>

<pre><code>HYPHYMP HYPHY_INSTALLATION_PATH/lib/hyphy/TemplateBatchFiles/BUSTED.bf
</code></pre>

<p>In case of BUSTED the inputs are:</p>

<ol>
<li>Genetic code.</li>
<li>Codon data (sequence alignment in phylip format).</li>
<li>Tree (in newick format).</li>
<li>Which branches to test.</li>
</ol>

<p>Now for every input alignment you need to generate a batch file which looks like this:</p>

<pre><code>inputRedirect = {};
inputRedirect["01"]="Universal"; // genetic code
inputRedirect["02"]="/path/to/alignment.phy"; // codon data
inputRedirect["03"]="/path/to/tree.nwk"; // tree
inputRedirect["04"]="All"; // Test for selection on all branches
inputRedirect["05"]="BRANCH1"; // Test for selection on branch1 
inputRedirect["06"]="BRANCH2"; // Test for selection on branch2 
inputRedirect["07"]=""; // complete selection


ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles/BUSTED.bf", inputRedirect);
</code></pre>

<p>Now you can create a script which generates the file. The most important thing, don't forget to use full paths in the <code>.bf</code> file.</p>

CC BY-SA 3.0
2017-05-17T10:51:38.000Z
I am not a moderator, but we should be asking expert questions that would define the on-topicness of the site at this stage of the site. If we start asking about how to do X in each program. We'll end up without expert question.
llrs
CC BY-SA 3.0
2017-05-17T10:56:53.920Z
@Llopis I was sharing similar (but less detailed) information with the three colleagues of mine from my department, some of them where postdocs.
This particular question is brought up over and over again, because despite the fact the the software is used a lot (almost 2k citations), the documentation is very preliminary and scattered.
Iakov Davydov
CC BY-SA 3.0
2017-05-17T11:17:56.990Z
To document that you could use your private site, or a blog, not necessarily this site. Or you could even contact with the software providers to address that problem if they want people to use their software.
llrs
CC BY-SA 3.0
2017-05-17T13:55:44.827Z
It probably is still up for debate, but what is wrong with answering _commonly asked_ question like: 'How to make tool X do task Y'? The bioinformatics field is probably littered with poorly documented tools abandoned by the authors due to lack of funding. For sure Stack Overflow is full of these kind of questions: https://stackoverflow.com/search?q=how+to
holmrenser
CC BY-SA 3.0
2017-05-17T14:06:16.673Z
@holmrenser nothing wrong, but the private beta compels us to write great questions for experts: "The private beta gives you the opportunity to get the site off to a great start with expert questions and answers.". I am  saying the answers doesn't seem to me an expert question. But I might be totally wrong :D
llrs
CC BY-SA 3.0
2017-05-17T09:15:38.363Z
2017-05-18T17:39:37.100Z
2017-05-18T17:39:37.100Z
Iakov Davydov
<p>I would like to test for positive selection in a large set of genes.</p>

<p>I want to have a yes/no answer to the question if gene was evolving under positive selection. Therefore I chose model <a href="https://doi.org/10.1093/molbev/msv035" rel="noreferrer">BUSTED</a> for my analysis, which is implemented in <a href="http://www.hyphy.org/" rel="noreferrer">HYPHY</a>.</p>

<p>When I launch HYPHY in the command-line, I get a series of question I  have to answer in the interactive form.</p>

<p>Is there way to perform a batch analysis involving multiple datasets, i.e. many sequence alignments?</p>

CC BY-SA 3.0
2017-05-17T10:48:02.617Z
What is BUSTED and HYPHY? What have you tried to do that. Does the manual help you?
llrs
CC BY-SA 3.0
2017-05-17T10:52:09.507Z
@Llopis HYPHY is a software for positive seleciton analysis, which is popular but complicated to use.
BUSTED is a model for gene-wide identification of positive selection.
https://doi.org/10.1093/molbev/msv035
I added some background to the question, so it is more clear.
This question is brought up quite regularly by people trying to perform dN/dS analysis. I shared my knowledge here in Q & A form.
Iakov Davydov
CC BY-SA 3.0
2017-05-17T10:55:04.550Z
This is not a **yet** an official Q&A if the site doesn't work it will be closed and deleted. Adding ([edit]ing) the context to the question would make the question better for future readers if the site finally lunchs
llrs
CC BY-SA 3.0
2017-05-17T11:09:43.927Z
@Llopis I corrected the question. Do you think it is better now?
Iakov Davydov
CC BY-SA 3.0
2017-05-17T11:16:49.450Z
It is better but what king of series of questions and answers do you get? Which version of the program are you using ? Under which OS (if that matters)? (I am still not convinced it is on-topic... but let's see)
llrs
<codon><positive-selection>
How to run HYPHY on multiple files non-interactively?
# How to run HYPHY on multiple files non-interactively?

(Asked by: username_0 on 2017-05-17)

I would like to test for positive selection in a large set of genes.

I want to have a yes/no answer to the question if gene was evolving under positive selection. Therefore I chose model [BUSTED](https://doi.org/10.1093/molbev/msv035) for my analysis, which is implemented in [HYPHY](http://www.hyphy.org/).

When I launch HYPHY in the command-line, I get a series of question I have to answer in the interactive form.

Is there way to perform a batch analysis involving multiple datasets, i.e. many sequence alignments?

**Tags:** codon, positive-selection
> **Comments:**
> **username_1**: What is BUSTED and HYPHY? What have you tried to do that. Does the manual help you?  
> **username_0**: @Llopis HYPHY is a software for positive seleciton analysis, which is popular but complicated to use. BUSTED is a model for gene-wide identification of positive selection. https://doi.org/10.1093/molbev/msv035 I added some background to the question, so it is more clear. This question is brought up quite regularly by people trying to perform dN/dS analysis. I shared my knowledge here in Q & A form.  
> **username_1**: This is not a **yet** an official Q&A if the site doesn't work it will be closed and deleted. Adding ([edit]ing) the context to the question would make the question better for future readers if the site finally lunchs  
> **username_0**: @Llopis I corrected the question. Do you think it is better now?  
> **username_1**: It is better but what king of series of questions and answers do you get? Which version of the program are you using ? Under which OS (if that matters)? (I am still not convinced it is on-topic... but let's see)  

---

## 1 answers

### Answer by username_0 on 2017-05-17. Score: 5 | Accepted answer

TL;DR
I made the following bash script to generate an input file for HYPHY.
#!/bin/bash
cat << EOF
inputRedirect = {};
inputRedirect["01"]="Universal"; // genetic code
inputRedirect["02"]="$(readlink -f $1)"; // codon data
inputRedirect["03"]="$(readlink -f $2)"; // tree
inputRedirect["04"]="${3:-All}"; // Test for selection on a branch
inputRedirect["05"]=""; // complete selection


ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles/BUSTED.bf", inputRedirect);
EOF

If you want to test all the branches jointly run:
./gen_busted.sh alignment.phy tree.nwk > script.bf

Or for a particular branch:
./gen_busted.sh alignment.phy tree.nwk branchLabel > script.bf

And then run:
HYPHYMP script.bf

Now you can use the script to generate a .bf file for every sequence alignment you have, and run HYPHY for every file.
Longer version
I will describe how to make a similar script for any model, such as MEME, RELAX or PARRIS.
First, find the .bf script which performs the analysis. On GNU/Linux it should be at HYPHY_INSTALLATION_PATH/lib/hyphy/TemplateBatchFiles (it might be different between different OS). In case of BUSTED your script has a name BUSTED.bf.
Now run this model in the interactive mode in order to record all the inputs required by the model. Make sure to specify full paths to all the files.
HYPHYMP HYPHY_INSTALLATION_PATH/lib/hyphy/TemplateBatchFiles/BUSTED.bf

In case of BUSTED the inputs are:

Genetic code.
Codon data (sequence alignment in phylip format).
Tree (in newick format).
Which branches to test.

Now for every input alignment you need to generate a batch file which looks like this:
inputRedirect = {};
inputRedirect["01"]="Universal"; // genetic code
inputRedirect["02"]="/path/to/alignment.phy"; // codon data
inputRedirect["03"]="/path/to/tree.nwk"; // tree
inputRedirect["04"]="All"; // Test for selection on all branches
inputRedirect["05"]="BRANCH1"; // Test for selection on branch1 
inputRedirect["06"]="BRANCH2"; // Test for selection on branch2 
inputRedirect["07"]=""; // complete selection


ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles/BUSTED.bf", inputRedirect);

Now you can create a script which generates the file. The most important thing, don't forget to use full paths in the .bf file.

> **Comments:**
> **username_1**: I am not a moderator, but we should be asking expert questions that would define the on-topicness of the site at this stage of the site. If we start asking about how to do X in each program. We'll end up without expert question.  
> **username_0**: @Llopis I was sharing similar (but less detailed) information with the three colleagues of mine from my department, some of them where postdocs. This particular question is brought up over and over again, because despite the fact the the software is used a lot (almost 2k citations), the documentation is very preliminary and scattered.  
> **username_1**: To document that you could use your private site, or a blog, not necessarily this site. Or you could even contact with the software providers to address that problem if they want people to use their software.  
> **username_2**: It probably is still up for debate, but what is wrong with answering _commonly asked_ question like: 'How to make tool X do task Y'? The bioinformatics field is probably littered with poorly documented tools abandoned by the authors due to lack of funding. For sure Stack Overflow is full of these kind of questions: https://stackoverflow.com/search?q=how+to  
> **username_1**: @holmrenser nothing wrong, but the private beta compels us to write great questions for experts: "The private beta gives you the opportunity to get the site off to a great start with expert questions and answers.". I am  saying the answers doesn't seem to me an expert question. But I might be totally wrong :D  

---

