Merge branch 'master' into use-original-ada-grammar

This commit is contained in:
Paul Chaignon
2015-05-04 21:35:40 +02:00
16 changed files with 14725 additions and 0 deletions

3
.gitmodules vendored
View File

@@ -656,3 +656,6 @@
[submodule "vendor/grammars/ada.tmbundle"]
path = vendor/grammars/ada.tmbundle
url = https://github.com/textmate/ada.tmbundle
[submodule "vendor/grammars/api-blueprint-sublime-plugin"]
path = vendor/grammars/api-blueprint-sublime-plugin
url = https://github.com/apiaryio/api-blueprint-sublime-plugin

View File

@@ -156,6 +156,9 @@ vendor/grammars/antlr.tmbundle:
vendor/grammars/apache.tmbundle:
- source.apache-config
- source.apache-config.mod_perl
vendor/grammars/api-blueprint-sublime-plugin/:
- text.html.markdown.source.gfm.apib
- text.html.markdown.source.gfm.mson
vendor/grammars/applescript.tmbundle:
- source.applescript
vendor/grammars/asciidoc.tmbundle/:

View File

@@ -59,6 +59,14 @@ ANTLR:
- .g4
ace_mode: text
API Blueprint:
type: markup
color: "#2ACCA8"
ace_mode: markdown
extensions:
- .apib
tm_scope: text.html.markdown.source.gfm.apib
APL:
type: programming
color: "#5A8164"
@@ -1349,6 +1357,13 @@ Hy:
- hylang
tm_scope: source.hy
HyPhy:
type: programming
ace_mode: text
extensions:
- .bf
tm_scope: none
IDL:
type: programming
color: "#a3522f"

View File

@@ -0,0 +1,55 @@
FORMAT: 1A
# Advanced Action API
A resource action is in fact a state transition. This API example demonstrates an action - state transition - to another resource.
## API Blueprint
+ [Previous: Resource Model](11.%20Resource%20Model.md)
+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/11.%20Advanced%20Action.md)
# Tasks [/tasks/tasks{?status,priority}]
+ Parameters
+ status (string)
+ priority (number)
## List All Tasks [GET]
+ Response 200 (application/json)
[
{
"id": 123,
"name": "Exercise in gym",
"done": false,
"type": "task"
},
{
"id": 124,
"name": "Shop for groceries",
"done": true,
"type": "task"
}
]
## Retrieve Task [GET /task/{id}]
This is a state transition to another resource
+ Parameters
+ id (string)
+ Response 200 (application/json)
{
"id": 123,
"name": "Go to gym",
"done": false,
"type": "task"
}
## Delete Task [DELETE /task/{id}]
+ Parameters
+ id (string)
+ Response 204

View File

@@ -0,0 +1,39 @@
FORMAT: 1A
# Attributes API
This API example demonstrates how to describe body attributes of a request or response message.
In this case, the description is complementary (and duplicate!) to the provided JSON example in the body section. The [Advanced Attributes](09.%20Advanced%20Attributes.md) API example will demonstrate how to avoid duplicates and how to reuse attributes descriptions.
## API Blueprint
+ [Previous: Parameters](07.%20Parameters.md)
+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/08.%20Attributes.md)
+ [Next: Advanced Attributes](09.%20Advanced%20Attributes.md)
# Group Coupons
## Coupon [/coupons/{id}]
A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer.
### Retrieve a Coupon [GET]
Retrieves the coupon with the given ID.
+ Response 200 (application/json)
+ Attributes (object)
+ id: 250FF (string)
+ created: 1415203908 (number) - Time stamp
+ percent_off: 25 (number)
A positive integer between 1 and 100 that represents the discount the coupon will apply.
+ redeem_by (number) - Date after which the coupon can no longer be redeemed
+ Body
{
"id": "250FF",
"created": 1415203908,
"percent_off": 25,
"redeem_by:" null
}

View File

@@ -0,0 +1,18 @@
FORMAT: 1A
# The Simplest API
This is one of the simplest APIs written in the **API Blueprint**.
One plain resource combined with a method and that's it! We will explain what is going on in the next installment - [Resource and Actions](02.%20Resource%20and%20Actions.md).
**Note:** As we progress through the examples, do not also forget to view the [Raw](https://raw.github.com/apiaryio/api-blueprint/master/examples/01.%20Simplest%20API.md) code to see what is really going on in the API Blueprint, as opposed to just seeing the output of the Github Markdown parser.
Also please keep in mind that every single example in this course is a **real API Blueprint** and as such you can **parse** it with the [API Blueprint parser](https://github.com/apiaryio/drafter) or one of its [bindings](https://github.com/apiaryio/drafter#bindings).
## API Blueprint
+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/01.%20Simplest%20API.md)
+ [Next: Resource and Actions](02.%20Resource%20and%20Actions.md)
# GET /message
+ Response 200 (text/plain)
Hello World!

View File

@@ -0,0 +1,252 @@
if (Rows (modelMatrixList) == 0)
{
modelMatrixList =
{
{"Equal Input", "EIAA.mdl", "19"}
{"Dayhoff","Dayhoff.mdl","0"}
{"Dayhoff+F","Dayhoff_F.mdl","19"}
{"JTT", "Jones.mdl", "0"}
{"JTT+F", "Jones_F.mdl", "19"}
{"WAG", "WAG.mdl", "0"}
{"WAG+F", "WAG_F.mdl", "19"}
{"rtREV", "rtREV.mdl", "0"}
{"rtREV+F", "rtREV_F.mdl", "19"}
{"mtMAM", "mtMAM.mdl", "0"}
{"mtMAM+F", "mtMAM_F.mdl", "19"}
{"mtREV 24", "mtREV_24.mdl", "0"}
{"mtREV 24+F", "mtREV_24_F.mdl", "19"}
{"HIV within", "HIVwithin.mdl", "0"}
{"HIV within+F", "HIVwithin+F.mdl", "19"}
{"HIV between", "HIVbetween.mdl", "0"}
{"HIV between+F", "HIVbetween+F.mdl", "19"}
{"REV-1 step", "reducedREV.mdl", "19"}
{"REV", "mtREV.mdl", "19"}
};
}
/*___________________________________________________________________________________________________________*/
function runAModel (modelID, fileName, xtraP, midx)
{
ExecuteCommands ("#include \"TemplateModels/"+fileName+"\";");
Tree givenTree = treeString;
LikelihoodFunction lf = (filteredData,givenTree);
GetString (lf_info, lf, -1);
locals = lf_info["Local Independent"];
if (Columns (branchLengthStash))
{
USE_LAST_RESULTS = 1;
for (_iv = 0; _iv < Columns (locals); _iv = _iv+1)
{
ExecuteCommands (locals[_iv] + "=1;\n");
}
currentBL = BranchLength (givenTree,0);
currentBN = BranchName (givenTree,-1);
for (_iv = 0; _iv < Columns (currentBN); _iv = _iv+1)
{
ExecuteCommands ("givenTree."+currentBN[_iv]+".t="+branchLengthStash[_iv]/currentBL+";");
}
}
else
{
for (_iv = 0; _iv < Columns (locals); _iv = _iv+1)
{
ExecuteCommands (locals[_iv] + "=0.1;\n");
}
USE_LAST_RESULTS = 1;
}
Optimize (res,lf);
fprintf (stdout, "| ", modelID);
for (k=0; k<maxModelWidth-Abs(modelID)-1; k=k+1)
{
fprintf (stdout, " ");
}
params = res[1][1]+xtraP;
AIC = 2(-res[1][0]+params);
if (filteredData.sites-params>1)
{
cAIC = 2(-res[1][0]+params*(filteredData.sites/(filteredData.sites-params-1)));
}
else
{
cAIC = 0;
}
branchLengths = BranchLength (givenTree,-1);
TL = 0;
for (k=Rows(branchLengths)*Columns(branchLengths)-1; k>=0; k=k-1)
{
TL = TL + branchLengths[k];
}
fprintf (stdout, "| ", Format (res[1][0],14,3), " | ", Format (params,5,0), " | ",
Format (AIC, 9,3), " | ",);
if (cAIC > 0)
{
fprintf (stdout, Format (cAIC,11,3), " | ");
}
else
{
fprintf (stdout, " N/A | ");
}
fprintf (stdout, Format (TL,11,3), " |\n", sepString);
resultMatrix[midx][0] = res[1][0];
resultMatrix[midx][1] = params;
resultMatrix[midx][2] = AIC;
resultMatrix[midx][3] = cAIC;
resultMatrix[midx][4] = TL;
if (AIC < bestAIC)
{
bestAIC = AIC;
bestAICidx = midx;
branchLengthStash = BranchLength (givenTree,-1);
}
if (cAIC > 0)
{
if (bestCAIC > cAIC)
{
bestCAIC = cAIC;
bestCAICidx = midx;
}
}
return 0;
}
/*___________________________________________________________________________________________________________*/
maxModelWidth = 7;
skipCodeSelectionStep = 0;
ChoiceList (doREV, "Include REV?", 1, SKIP_NONE, "Yes", "Include REV and reduced REV models. CAUTION: these models take a long time to fit.",
"No", "Only use empirical models");
if (doREV < 0)
{
return 0;
}
if (doREV == 0)
{
#include "TemplateModels/chooseGeneticCode.def";
skipCodeSelectionStep = 1;
}
modelCount = Rows (modelMatrixList) - 2*doREV;
for (k=0; k<modelCount; k=k+1)
{
maxModelWidth = Max(maxModelWidth,Abs (modelMatrixList[k][0])+2);
}
sepString = "";
capString = "";
sepString * 256;
sepString * "+";
capString * 256;
capString * "| Model";
for (k=0; k<maxModelWidth; k=k+1)
{
sepString * "-";
}
for (k=0; k<maxModelWidth-6; k=k+1)
{
capString * " ";
}
capString * "| Log Likelihood | #prms | AIC Score | c-AIC Score | Tree Length |\n";
sepString * "+----------------+-------+-----------+-------------+-------------+\n";
sepString * 0;
capString * 0;
branchLengthStash = 0;
SKIP_MODEL_PARAMETER_LIST = 0;
#include "TemplateModels/modelParameters2.mdl";
if (modelType == 1)
{
#include "TemplateModels/defineGamma.mdl";
}
if (modelType == 2)
{
#include "TemplateModels/defineHM.mdl";
}
SKIP_MODEL_PARAMETER_LIST = 1;
SetDialogPrompt ("Please load an amino-acid data file:");
DataSet ds = ReadDataFile (PROMPT_FOR_FILE);
DataSetFilter filteredData = CreateFilter (ds,1);
fprintf (stdout,"\nRunning aminoacid model comparisons on ", LAST_FILE_PATH, "\n\nThe alignment has ",ds.species, " sequences and ", ds.sites, " sites\n");
_DO_TREE_REBALANCE_ = 1;
#include "queryTree.bf";
resultMatrix = {modelCount, 5};
fprintf (stdout, "\n",sepString,capString,sepString);
bestAIC = 1e100;
bestCAIC = 1e100;
bestAICidx = 0;
bestCAICidx = -1;
for (mid=0; mid<modelCount; mid=mid+1)
{
runAModel (modelMatrixList[mid][0], modelMatrixList[mid][1], 0+modelMatrixList[mid][2], mid);
}
fprintf (stdout, "\n\nBest AIC model:\n\t", modelMatrixList[bestAICidx][0], " with the score of ", bestAIC);
if (bestCAICidx>=0)
{
fprintf (stdout, "\n\nBest c-AIC model:\n\t", modelMatrixList[bestCAICidx][0], " with the score of ", bestCAIC);
}
labelMatrix = {{"Log-likelihood","Parameters","AIC","c-AIC","Total tree length",""}};
aaString = "Model";
for (fC = 0; fC < modelCount; fC = fC+1)
{
aaString = aaString + ";" + modelMatrixList[fC][0];
}
USE_LAST_RESULTS = 0;
labelMatrix[5] = aaString;
skipCodeSelectionStep = 0;
OpenWindow (CHARTWINDOW,{{"Model Fits"}
{"labelMatrix"},
{"resultMatrix"},
{"Bar Chart"},
{"Index"},
{"c-AIC"},
{"Model Index"},
{""},
{"AIC"}
},
"SCREEN_WIDTH-60;SCREEN_HEIGHT-60;30;30");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
fprintf (stdout, "\n1). Spawning a zero-populated 5x6 matrix and setting it's values to random numbers in [0,1].\n");

View File

@@ -0,0 +1,147 @@
#include "molclockBootstrap.bf";
RESTORE_GLOBALS = 1;
_DO_TREE_REBALANCE_ = 0;
VERBOSITY_LEVEL = -1;
function RestoreGlobalValues (lfIndex)
{
if (lfIndex==0)
{
for (i=0;i<SAVE_GLOBALS;i=i+1)
{
SetParameter (lf,i,globalSpoolMatrix[i]);
}
}
if (lfIndex==1)
{
for (i=0;i<SAVE_GLOBALS2;i=i+1)
{
SetParameter (lfConstrained,i,globalSpoolMatrix2[i]);
}
}
return 0;
}
fprintf(stdout,"\n ---- RUNNING MOLECULAR CLOCK ANALYSIS ---- \n");
ChoiceList (dataType,"Data type",1,SKIP_NONE,"Nucleotide/Protein","Nucleotide or amino-acid (protein).",
"Codon","Codon (several available genetic codes).");
if (dataType<0)
{
return;
}
if (dataType)
{
NICETY_LEVEL = 3;
#include "TemplateModels/chooseGeneticCode.def";
}
SetDialogPrompt ("Choose the data file:");
DataSet ds = ReadDataFile (PROMPT_FOR_FILE);
fprintf (stdout,"The following data was read:\n",ds,"\n");
if (dataType)
{
DataSetFilter filteredData = CreateFilter (ds,3,"","",GeneticCodeExclusions);
}
else
{
DataSetFilter filteredData = CreateFilter (ds,1);
}
SelectTemplateModel(filteredData);
#include "queryTree.bf";
global RelRatio;
RelRatio = 1.0;
relationString = ":=RelRatio*";
parameter2Constrain = 0;
if (Rows("LAST_MODEL_PARAMETER_LIST")>1)
{
ChoiceList (parameter2Constrain, "Parameter(s) to constrain:",1,SKIP_NONE,LAST_MODEL_PARAMETER_LIST);
if (parameter2Constrain<0)
{
return;
}
if (parameter2Constrain==0)
{
parameter2ConstrainString = "";
for (parameter2Constrain=Rows("LAST_MODEL_PARAMETER_LIST")-1; parameter2Constrain; parameter2Constrain = parameter2Constrain-1)
{
GetString (funnyString,LAST_MODEL_PARAMETER_LIST,parameter2Constrain);
parameter2ConstrainString = parameter2ConstrainString + funnyString + ",";
}
GetString (funnyString,LAST_MODEL_PARAMETER_LIST,0);
parameter2ConstrainString = parameter2ConstrainString + funnyString;
}
else
{
GetString (parameter2ConstrainString,LAST_MODEL_PARAMETER_LIST,parameter2Constrain-1);
}
}
else
{
GetString (parameter2ConstrainString,LAST_MODEL_PARAMETER_LIST,0);
}
timer = Time(0);
LikelihoodFunction lf = (filteredData,givenTree);
Optimize (res,lf);
separator = "*-----------------------------------------------------------*";
fprintf (stdout, "\n", separator, "\nRESULTS WITHOUT THE CLOCK:\n",lf);
fullModelLik = res[1][0];
fullVars = res[1][1];
/* now specify the constraint */
Tree clockTree = treeString;
ExecuteCommands ("MolecularClock (clockTree,"+parameter2ConstrainString+");");
LikelihoodFunction lfConstrained = (filteredData, clockTree);
USE_LAST_RESULTS = 1;
Optimize (res1,lfConstrained);
USE_LAST_RESULTS = 0;
SAVE_GLOBALS = res1[1][2];
if (SAVE_GLOBALS)
{
globalSpoolMatrix = {1,SAVE_GLOBALS};
for (i=0;i<SAVE_GLOBALS;i=i+1)
{
globalSpoolMatrix[i]=res1[0][i];
}
}
fprintf (stdout, "\n", separator,"\n\nRESULTS WITH THE CLOCK:\n",lfConstrained);
lnLikDiff = 2(fullModelLik-res1[1][0]);
degFDiff = fullVars - res1[1][1];
fprintf (stdout, "\n", separator,"\n\n-2(Ln Likelihood Ratio)=",lnLikDiff,"\n","Constrained parameters:",Format(degFDiff,0,0));
fprintf (stdout, "\nP-Value:",1-CChi2(lnLikDiff,degFDiff));
fprintf (stdout, "\nCPU time taken: ", Time(0)-timer, " seconds.\n");

File diff suppressed because it is too large Load Diff

11003
samples/HyPhy/hyphy_cmds.bf Normal file

File diff suppressed because one or more lines are too long

1
samples/HyPhy/profile_test.bf Executable file
View File

@@ -0,0 +1 @@
#profile START;

View File

@@ -17,6 +17,9 @@ else
bundle config build.charlock_holmes --with-icu-dir=$(pwd)/vendor/debs
fi
# Replace SSH links to submodules by HTTPS links.
sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
git submodule init
git submodule sync --quiet
script/fast-submodule-update