Wolfram for Food Science | Things to Try

Make edits and run any piece of code by clicking inside the code and pressing
+
.

Analyze Food Chemistry

Generate a 3D plot for the biomolecule alpha-lactalbumin, a major whey protein found in foods made from animal milk:
Run
In[]:=
BioMoleculePlot3D[BioMolecule[ExternalIdentifier["PDBStructureID","1F6S"]]]
Compare the molecular structure of a monounsaturated fatty acid (one double bond) to a saturated fatty acid (no double bonds):
Run
In[]:=
MoleculePlot/@
oleic acid
CHEMICAL
,
palmitic acid
CHEMICAL

Create a tree of all 20 amino acids grouped by the similarities of their molecular structures:
Run
In[]:=
ClusteringTreeEntityList
amino acids
CHEMICALS
,DistanceFunction->MoleculeFeatureDistance
See why the caffeine molecule can cross the blood-brain barrier and act as a stimulant (due to three methyl groups in its molecular structure) versus the minimal stimulant effect from chocolate (with just two methyl groups in chocolate’s theobromine molecule):
Run
In[]:=
MoleculePlot[#,{MoleculePattern["C"]}]&/@
caffeine
CHEMICAL
,
theobromine
CHEMICAL

Plot the conjugated system of alternating single and double bonds that gives turmeric, saffron and paprika their vibrant colors:
Run
In[]:=
colorfulSpicesAssoc=<|"turmeric"->
curcumin
CHEMICAL
,"saffron"->
crocin
CHEMICAL
,"paprika"->
capsanthin
CHEMICAL
|>;​​KeyValueMap[{MoleculePlot[#2,{{MoleculePattern["[#6]:[#6]"],MoleculePattern["[#6]-[#6]=[#6,#8]"]}}],#2}&,colorfulSpicesAssoc]//Thread//Grid
Get the approximate pH of acidic foods:
Run
In[]:=
acidicFoodNames={"lemon","lime","tomato","apple","orange","pineapple","vinegar","sauerkraut"};​​pH=AssociationThreadacidicFoodNames,EntityValueInterpreter["Food"][acidicFoodNames],
approximate pH

Plot the pH:
Run
In[]:=
ListPlot[Values[pH]]

Model Physical and Chemical Properties

Compare the melting points of triglycerides formed with monounsaturated fats versus saturated fats:
Run
In[]:=
DatasetEntityValue
triolein
CHEMICAL
,
tripalmitin
CHEMICAL
,{"Phase","MeltingPoint"},"EntityPropertyAssociation"
Calculate when visible crust color begins to develop for a loaf of bread baking at 180°C:
Run
In[]:=
maillardReactionVariables={​​QuantityVariable["T","Temperature"]->Quantity[180,"DegreesCelsius"],​​QuantityVariable[Subscript["E","a"],"ActivationEnergy"]->Quantity[64.151,"Kilojoules"/"Moles"],​​QuantityVariable["A","FirstOrderArrheniusFactor"]->Quantity[42000,"PerSecond"]​​};​​firstOrderRateConstant=FormulaData["FirstOrderArrheniusEquation",maillardReactionVariables];​​UnitConvert[1/firstOrderRateConstant[[2]],"Minutes"]
Get the thermal conductivity of frying pan materials to see how well they conduct heat:
Run
In[]:=
panMaterials={"copper","aluminum","iron","carbon steel","stainless steel"};​​thermalConductivities=AssociationThread[panMaterials,WolframAlpha["thermal conductivity "<>#,{{"Result",1},"Plaintext"}]&/@panMaterials];​​Grid[Prepend[List@@@Normal[thermalConductivities],{"Material","Thermal Conductivity"}],Frame->All,Spacings->{2,1}]
Explore temperature-viscosity models:
Run
In[]:=
ResourceData["Demonstration: Parameterizing Temperature-Viscosity Relations"]

Ensure Food Safety

Get the maximum recommended refrigerated and frozen storage times for raw ground beef:
Run
In[]:=
EntityValueInterpreter["Food"]["raw ground beef"],
maximum refrigerated storage time
,
maximum frozen storage time
,"PropertyAssociation"
Visualize the 3D biomolecule structure of the peanut allergen Ara h 2:
Run
In[]:=
BioMoleculePlot3D[BioMolecule[ExternalIdentifier["PDBStructureID","3OB4"]],ColorRules->"Residues"]
Compare different models for microbial thermal inactivation:
Run
In[]:=
ResourceData["Demonstration: Weibullian versus Log-Linear Microbial Survival Models"]

Recipe & Nutrition Analysis

Get a compass plot of the macronutrients in 200g of oats as a percent of recommended daily value:
Run
In[]:=
EntityValueEntityInstanceEntity["Food",{EntityProperty["Food","FoodType"]->ContainsExactly[{Entity["FoodType","Oat"]}],EntityProperty["Food","AddedFoodTypes"]->ContainsExactly[{}]}],
200
g
,"CompassPlot"
See the surprising result when comparing iron content in bivalves (mussels, clams and oysters) with the iron per gram in red meat:
Run
In[]:=
bivalvesAndBeefNames={"clams","mussels","oysters","beef"};​​bivalvesAndBeefInterpret=AssociationThread[bivalvesAndBeefNames,(Interpreter["Food"][#1]&)/@bivalvesAndBeefNames];​​ironData=
N[
]
;​​ironDataSorted=ReverseSortBy[ironData,#["RelativeIronContent"]&];​​bivalveLabels=Keys[ironDataSorted];​​customColors=
Map[
]
;​​BarChartironDataSorted,

Plot the linear relationship between the amount of fat and calories in meats:
Run
In[]:=
meats=Interpreter["Food"][{"bacon","beef","chicken","chorizo","duck","ham","mutton","sausage","steak","turkey","goat","hot dog","bison","prosciutto","pastrami","bratwurst"}];​​meatsFat=NQuantityMagnitudeEntityValuemeats,
relative fat content
;​​meatsCalories=NQuantityMagnitudeEntityValuemeats,
relative calorie content
;​​meatsFatCaloriesPairs=Transpose[{meatsFat,meatsCalories}];​​ListPlotmeatsFatCaloriesPairs,

Use linear regression to model the relationship between fat and calories in meats:
Run
In[]:=
ListFitPlot[meatsFatCaloriesPairs,PlotStyle->Red,AxesLabel->{"Fat g/g","Cal/g"},PlotFit->"Linear",PlotFitElements->{"DataPoints","BandCurves"}]
Show the strong positive correlation between the amount of fat and calories in meats with smooth 2D and 3D histograms:
Run
In[]:=
Row[{SmoothHistogram[meatsFatCaloriesPairs,ImageSize->Medium],SmoothHistogram3D[meatsFatCaloriesPairs,ImageSize->Medium]}]
Create an interactive bar chart of amino acid content for a list of high-protein foods:
Run
In[]:=
ResourceFunction["AminoAcidsBarChart"][{"beef","chicken","eggs","pork","tempeh"}]
Get the omega-3 fatty acids content in 4oz salmon:
Run
In[]:=
EntityValueEntityInstance
food
food type
:exactly
salmon
FOOD TYPE
added food types
:exactlynone
(salmon)
,
4
oz
,
absolute docosahexaenoic acid (DHA) content
,
absolute eicosapentaenoic acid content
,
absolute alpha-linolenic acid content
,"PropertyAssociation"

Access Real-World Data Instantly

Get a list of branded foods that contain high fructose corn syrup:
Run
In[]:=
RandomEntity
food
ingredients
:
high fructose corn syrup
FOOD INGREDIENT
,10
Compare the average alcohol content in a glass of wine versus a pint of beer:
Run
In[]:=
EntityValueEntityInstance
food
food type group
:
wines
FOOD TYPE GROUP
added food types
:exactlynone
(wine)
,
5
fl oz
,EntityInstance
food
food type group
:
beers
FOOD TYPE GROUP
added food types
:exactlynone
,
1
pt
,"AbsoluteAlcoholContent"

Focus on Sustainability

Computation for Foodies