text: user191: 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 for my analysis, which is implemented in HYPHY.
  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?
  
  user191: 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.
  
original_text: 191: <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>
   191: <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>
  