veg / hyphy

HyPhy: Hypothesis testing using Phylogenies
http://www.hyphy.org
Other
217 stars 69 forks source link

InputRedirect for SelectionLRT.bf #256

Closed AGrusz closed 8 years ago

AGrusz commented 9 years ago

Hi Sergei,

I would like to use InputRedirect to run SelectionLRT.bf on several hundred trees/files. In the command line version of HYPHYMP there is no prompt for an output file; the output is printed to the screen and related messages to message.log. I would like to have the output for each run printed to a file; is this possible?

Thanks in advance, Amanda

spond commented 9 years ago

Hi Amanda,

You can prefix a call to the SelectionLRT wrapper by setting an appropriate environment variable as in the code snipper below

ALWAYS_RELOAD_FUNCTION_LIBRARIES = 1;

/* set this to use LoadFunctionLibrary which automatically searches 
knowns paths and avoid explicit specification through "ExecuteAFile" */

for (file_id = 0; file_id < file_count; file_id += 1) {
         GLOBAL_FPRINTF_REDIRECT = "/path/to/output/for/this/file";
         LoadFunctionLibrary ("SelectionLRT", options);
}

GLOBAL_FPRINTF_REDIRECT = ""; // back the stdout

Sergei

AGrusz commented 9 years ago

Hi Sergei,

Apologies for being dense. I adapted the inputRedirect.bf file as follows:

LoadFunctionLibrary ("GrabBag");

fileToExe = "/Users/Grusz/bin/hyphy-2.2.3/res/TemplateBatchFiles/SelectionLRT.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["03"]="012345"; inputRedirect["04"]="/Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/species.stree"; inputRedirect["05"]="Node7";

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

inputRedirect [ "02" ]  = _inDirectoryPaths[ _fileLine ]; pathInfo = splitFilePath (_inDirectoryPaths[ _fileLine ]); outputFile = pathInfo["DIRECTORY"] + DIRECTORY_SEPARATOR + pathInfo["FILENAME"] + ".hyphy.out"; GLOBAL_FPRINTF_REDIRECT = outputFile;
ExecuteAFile ( fileToExe, inputRedirect );

}

GLOBAL_FPRINTF_REDIRECT = ""; // back the stdout


When I ran this inputRedirect.bf file, I received the following error messages:


   /HYPHY 2.220150114beta(MP) for Darwin on x86_64\       

***** TYPES OF STANDARD ANALYSES *****

(1) Basic Analyses
(2) Codon Selection Analyses
(3) Compartmentalization
(4) Data File Tools
(5) Miscellaneous
(6) Model Comparison
(7) Kernel Analysis Tools
(8) Molecular Clock
(9) Phylogeny Reconstruction
(10) Positive Selection
(11) Recombination
(12) Selection/Recombination
(13) Relative Rate
(14) Relative Ratio
(15) Substitution Rates

Please select type of analyses you want to list (or press ENTER to process custom batch file):

/usr/local/lib/hyphy/Batch file to run::/Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/backtranslated/test/inputRedirect.bf

/Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/backtranslated/test/Provide a list of files to process::test_list.txt [READ 2 file path lines] Error: Could not find source dataset file:PROMPT_FOR_FILE Path stack: {/usr/local/lib/hyphy/,/Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/backtranslated/test/,/Users/Grusz/bin/hyphy-2.2.3/res/TemplateBatchFiles/}

Function call stack 1 : Read Data Set ds from file PROMPT_FOR_FILE Standard input redirect: 04 : /Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/species.stree 05 : Node7

2 : ExecuteAFile from file fileToExe using basepath /Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/backtranslated/test/. reading input from inputRedirect {"01":"Universal", "03":"012345", "04":"/Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/species.stree", "05":"Node7", "02":"/Users/Grusz/Documents/A_Vittariods/Pteridaceae_transcriptomes/Rates_Analyses/backtranslated/test/1/1.nuc.fasta"}

Segmentation fault: 11

A-Grusz:test Grusz$

Do you have any suggestions?

Thanks!

Amanda