HyPhy message board
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl
Methodology Questions >> How to >> Batch files
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl?num=1312819536

Message started by jhughes on Aug 8th, 2011 at 9:05am

Title: Batch files
Post by jhughes on Aug 8th, 2011 at 9:05am
Hi,

I'm new to HYPHY. I am trying to create batch files for processing 100s of files. So far I have managed to do a batch for testing the best model using AIC. Now I want to use SLAC to calculate dN/dS and whether there are any sites under selection using the best model selected using modeltest. The QuickSelectionDetection.bf requests a ModelString. What is the best way to get and use the output from the MotelTest batch file and in particular the ModelString to use in the QuickSelectionDetection batch files.

Cheers,
Joseph

Title: Re: Batch files
Post by Sergei on Aug 9th, 2011 at 4:17pm
Hi Joseph,

You probably want to use a wrapper file. Take a look at Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login Login

For ModelTest, if you run the hierarchical version of the test, the best model string will be in


Code (]
modelStrings[chosenMatrix):

[/code],

otherwise it will be in
[code]
modelStrings[aicMatrix]


In your wrapper file do something like


Code (]

...

for (...)
{
    ...

    ExecuteAFile (HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "ModelTest.bf", modelTestOptions);

    slacOptions = {};
    ...

    slacOptions [".."):

= modelStrings[aicMatrix];
   
    ...

ExecuteAFile (HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "QuickSelectionDetectiob.bf", slacOptions);

}


Sergei

Title: Re: Batch files
Post by jhughes on Aug 10th, 2011 at 12:49am
In the end I succeeded by doing this, where every other line of the list of files provided is the ModelString from model test.


Code (]/* This is a HY-PHY Batch File for producing the SLAC analyses.

 
*/

fileToExe = HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "QuickSelectionDetection.bf";

/* a  list of file paths */
SetDialogPrompt ( "Provide a list of files to process:" );
fscanf ( PROMPT_FOR_FILE, "Lines", _inDirectoryPaths );

fprintf (stdout, "[READ ", Columns (_inDirectoryPaths), " file path lines):

\n");

/* the options passed to the GUI are encoded here */
inputRedirect = {};
inputRedirect["01"]="Universal";
inputRedirect["02"]="New Analysis";
inputRedirect["04"]="Custom";
inputRedirect["08"]="Estimate + CI";
inputRedirect["09"]="Single Ancestor Counting";
inputRedirect["10"]="Full tree";
inputRedirect["11"]="Averaged";
inputRedirect["12"]="Approximate";
inputRedirect["13"]="0.05";
inputRedirect["14"]="Export to File";
inputRedirect["16"]="Skip";

for ( _fileLine = 0; _fileLine < Columns ( _inDirectoryPaths ); _fileLine = _fileLine + 2 ) {

     inputRedirect [ "03" ]      = "/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/UniqsNoStop/"+_inDirectoryPaths[ _fileLine ]+".fasta";
     inputRedirect [ "05" ]      = _inDirectoryPaths[ _fileLine + 1];
     inputRedirect [ "06" ]      = "/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/trees/"+_inDirectoryPaths[ _fileLine ]+".tre";
     inputRedirect [ "07" ]      = "/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/SLAC/"+_inDirectoryPaths[ _fileLine ]+".bf";
     inputRedirect [ "15" ]      = "/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/SLAC/"+_inDirectoryPaths[ _fileLine ]+".out";
     ExecuteAFile ( fileToExe, inputRedirect );
}


I will try your more elegant approach.

Cheers,
Joseph

Title: Re: Batch files
Post by jhughes on Aug 10th, 2011 at 3:31am
And just in case someone finds this useful, here is the more elegant way that Sergei suggested:
Code (]/* a  list of file paths */
SetDialogPrompt ( "Provide a list of files to process:" );
fscanf ( PROMPT_FOR_FILE, "Lines", _inDirectoryPaths );

fprintf (stdout, "[READ ", Columns (_inDirectoryPaths), " file path lines):

\n");


for ( _fileLine = 0; _fileLine < Columns ( _inDirectoryPaths ); _fileLine = _fileLine + 1 ) {
inputRedirect = {};
inputRedirect["01"]="Universal";
inputRedirect["02"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/UniqsNoStop/"+_inDirectoryPaths[ _fileLine ]+".fasta";
inputRedirect["03"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/trees/"+_inDirectoryPaths[ _fileLine ]+".tre";
inputRedirect["04"]="4";
inputRedirect["05"]="AIC Test";
inputRedirect["06"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/modeltest/"+_inDirectoryPaths[ _fileLine ]+".out";
ExecuteAFile (HYPHY_BASE_DIRECTORY + "TemplateBatchFiles"+ DIRECTORY_SEPARATOR+"ModelTest.bf", inputRedirect);

inputRedirect = {};
inputRedirect["01"]="Universal";
inputRedirect["02"]="New Analysis";
inputRedirect["03"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/UniqsNoStop/"+_inDirectoryPaths[ _fileLine ]+".fasta";
inputRedirect["04"]="Custom";
inputRedirect["05"]=modelStrings[aicMatrix];
inputRedirect["06"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/trees/"+_inDirectoryPaths[ _fileLine ]+".tre";
inputRedirect["07"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/SLAC/"+_inDirectoryPaths[ _fileLine ]+".bf";
inputRedirect["08"]="Estimate + CI";
inputRedirect["09"]="Single Ancestor Counting";
inputRedirect["10"]="Full tree";
inputRedirect["11"]="Averaged";
inputRedirect["12"]="Approximate";
inputRedirect["13"]="0.05";
inputRedirect["14"]="Export to File";
inputRedirect["15"]="/Users/jhughes/Documents/PabloProjects/HYPHYanalyses/SLAC/"+_inDirectoryPaths[ _fileLine ]+".out";
inputRedirect["16"]="Skip";

ExecuteAFile (HYPHY_BASE_DIRECTORY + "TemplateBatchFiles"+
DIRECTORY_SEPARATOR+"QuickSelectionDetection.bf", inputRedirect);

}
Joseph :)

HyPhy message board » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2024. All Rights Reserved.