Welcome, Guest. Please Login
YaBB - Yet another Bulletin Board
 
  HomeHelpSearchLogin  
 
change model in the batch file (Read 2994 times)
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
change model in the batch file
Jun 19th, 2008 at 9:20am
 
Dear Sergei,

I have a very easy question for you about a batch file to reconstruct the ancestor sequence. I attached here the batch file (you send me it about 2 months ago).
I would like to change the model for the reconstruction, now it is working by GY94 codon model and I would like using the simple JC nucleotide model, but I have some problems changing it about Global/Local analysis options.

Thank you very much.
Regards,
Miguel

SetDialogPrompt ("CSV file with pathnames and genetic codes");
ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +
                                                     "Utility" + DIRECTORY_SEPARATOR + "ReadDelimitedFiles.bf");

fscanf                  (PROMPT_FOR_FILE,"Lines",listOfFiles);
linesRead =      Columns (listOfFiles);

fileNames = {};
fileCodes = {};

fprintf (stdout, "\n");

for (k=0; k<linesRead; k=k+1)
{
     aLine = splitOnRegExp (listOfFiles[k], "\\ *\\,\\ *");
     if (Abs (aLine) == 2)
     {
           fileNames [Abs(fileNames)] = aLine[0];
           fileCodes [Abs(fileCodes)] = aLine[1];
           fprintf (stdout, "[FILE ", Abs(fileNames), " ", aLine[0], " - ", aLine[1], "]\n");
     }
}

DATA_FILE_PRINT_FORMAT = 9;
/* FASTA */

for (fileCount = 0; fileCount < Abs(fileNames); fileCount = fileCount + 1)
{
     analysisOptions      = {};
     analysisOptions["0"] = fileCodes[fileCount];
     ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +
                         "TemplateModels" + DIRECTORY_SEPARATOR + "chooseGeneticCode.def", analysisOptions);

     DataSet        ds               = ReadDataFile (fileNames[fileCount]);
     DataSetFilter filteredData = CreateFilter (ds,3,"","",GeneticCodeExclusions);
     
     analysisOptions["0"] = "Global";
     ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +
                         "TemplateModels" + DIRECTORY_SEPARATOR + "GY94.mdl", analysisOptions);
                        
     kappa := 1;
     fprintf (stdout, "[WORKING ON FILE ", fileNames[fileCount], "]\n");
     Tree givenTree = DATAFILE_TREE;
     fprintf (stdout, "\t[FITTING THE GY94_JC69 MODEL]\n");
     LikelihoodFunction lf = (filteredData, givenTree);
     Optimize (res, lf);
     fprintf (stdout, "\t[RECONSTRUCTING ANCESTORS]\n");      
     DataSet ancestors = ReconstructAncestors(lf);      
     DataSetFilter recFilter = CreateFilter(ancestors,1);
     ancestorOutFile = "Ancestors_" + fileNames[fileCount] + "_.fas";
     fprintf (stdout, "\t[WRITING ANCESTORS TO ",ancestorOutFile,"]\n");      
     fprintf (ancestorOutFile,CLEAR_FILE,recFilter);
}
Back to top
 
WWW WWW  
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: change model in the batch file
Reply #1 - Jun 20th, 2008 at 12:11am
 
Dear Miguel,

What seems to be the problem with the analysis?

Cheers,
Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: change model in the batch file
Reply #2 - Jun 20th, 2008 at 3:59am
 
Dear Sergei,

For changing the model (from GY94 codon model to JC nucleotide model), I introduced the JC69.mdl file. However, I still have an output error:

Not a valid option: 'Global' passed to Choice List 'Model Options' using redirected stdin input
Current BL Command:Choice List for Model Options with choice list:SKIP_NONE. Store result in modelType

I know I must change 'Global' for 'Local', but in analysisOptions lines (lines 63 and 70) I have to introduce a number for 'Local' (0 is for 'Global') and I am not sure about what is that number.
Well, I do not know if I have to introduce more changes in this batchfile for the reconstruction of the ancestor sequence by JC nucleotide model.
Below you can see the batch file that I am working about.

Regards,
Miguel


/*SetDialogPrompt ("CSV file with pathnames and genetic codes");*/
ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +
                                                     "Utility" + DIRECTORY_SEPARATOR + "ReadDelimitedFiles.bf");

/*fscanf                  (PROMPT_FOR_FILE,"Lines",listOfFiles);*/
fscanf                  (test.csv,"Lines",listOfFiles);

linesRead =      Columns (listOfFiles);

fileNames = {};
fileCodes = {};

fprintf (stdout, "\n");

for (k=0; k<linesRead; k=k+1)
{
     aLine = splitOnRegExp (listOfFiles[k], "\\ *\\,\\ *");
     if (Abs (aLine) == 2)
     {
           fileNames [Abs(fileNames)] = aLine[0];
           fileCodes [Abs(fileCodes)] = aLine[1];
           fprintf (stdout, "[FILE ", Abs(fileNames), " ", aLine[0], " - ", aLine[1], "]\n");
     }
}

DATA_FILE_PRINT_FORMAT = 9;
/* FASTA */

for (fileCount = 0; fileCount < Abs(fileNames); fileCount = fileCount + 1)
{


/* MA */

#include "myFunctions.bf";

     /* load data in */
     inputfile = fileNames[fileCount];
     DataSet ds = ReadDataFile (inputfile);
     DataSetFilter filteredData = CreateFilter (ds,1);
     dataType = 0; /* DNA sequences */
     fprintf (stdout, "\n\n*********** NEW DATA: ",inputfile," ***********");

     /* define the model JC */
     equalFreqs = {{.25}{.25}{.25}{.25}};
     JC69 = {{*,a,a,a}{a,*,a,a}{a,a,*,a}{a,a,a,*}};
     Model JC69model = (JC69, equalFreqs);
     UseModel (JC69model);

     /* build NJ */
     distanceChoice = 0; /* raw distances */
     modelType = 0; /* no rate variation*/
     methodIndex = 1; /* Negative Branch Lengths are Allowed */
     p = InferTreeTopology(1.0); /* in myFunctions.bf */
     treeString = TreeMatrix2TreeString (1); /* treeString stores the tree in Newick format */
     fprintf (stdout,"\nInferred NJ tree before rerooting: ", treeString);
     treeString = RerootTree (treeString,0);
     fprintf (stdout,"\nInferred NJ tree: ", treeString);

/* MA */

     analysisOptions      = {};
     analysisOptions["0"] = fileCodes[fileCount];
     ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +
                         "TemplateModels" + DIRECTORY_SEPARATOR + "chooseGeneticCode.def", analysisOptions);

     DataSet        ds               = ReadDataFile (fileNames[fileCount]);
     DataSetFilter filteredData = CreateFilter (ds,3,"","",GeneticCodeExclusions);
     
     analysisOptions["0"] = "Global";
     ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +
                         "TemplateModels" + DIRECTORY_SEPARATOR + "JC69.mdl", analysisOptions);
                        
     kappa := 1;
     fprintf (stdout, "[WORKING ON FILE ", fileNames[fileCount], "]\n");
     
     /*Tree givenTree = DATAFILE_TREE;*/
     Tree givenTree = treeString;
     
     fprintf (stdout, "\t[FITTING THE JC69 MODEL]\n");
     LikelihoodFunction lf = (filteredData, givenTree);
     Optimize (res, lf);
     fprintf (stdout, "\n\nResults from the likelihood optimization:\n",lf);
     fprintf (stdout, "\t[RECONSTRUCTING ANCESTORS]\n");      
     DataSet ancestors = ReconstructAncestors(lf);      
     DataSetFilter recFilter = CreateFilter(ancestors,1);
     
     ancestorOutFile = fileNames[fileCount] + "_ancestors.fas";
     
     fprintf (stdout, "\t[WRITING ANCESTORS TO ",ancestorOutFile,"]\n");      
     fprintf (ancestorOutFile,CLEAR_FILE,recFilter);
     fprintf (ancestorOutFile, "\nNJtree (NJ): ",treeString);
     fprintf (ancestorOutFile, "\n\nTreeUsed: ",givenTree);      
     
}

Back to top
 
WWW WWW  
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: change model in the batch file
Reply #3 - Jun 20th, 2008 at 9:17am
 
Dear Miguel,

Replace "Global" with "Fixed Rates" before you call ExecuteAFile for JC69.mdl

Take a look at section 2.8 in Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login Login for details on how to set up option lists.

Cheers,
Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: change model in the batch file
Reply #4 - Jun 20th, 2008 at 12:17pm
 
It is Perfect.
Thank you!

Cheers,
Miguel  Smiley
Back to top
 
WWW WWW  
IP Logged