nut-nutrition - analyze meals with the USDA Nutrient Database
NUT allows you to record what you eat and analyze your meals for nutrient composition. The database included is the USDA Nutrient Database
for Standard Reference, Release 22.
This database of food composition tables contains values for calories, protein, carbohydrates, fiber, total fat, etc., and includes all the
nutrient data in the USDA database, including the Omega-6 and Omega-3 polyunsaturated fatty acids. Nutrient levels are expressed as a per-
centage of the DV or Daily Value, the familiar standard of food labeling in the United States. The essential fatty acids, Omega-6 and
Omega-3, are not currently mentioned in these standards, and a reference value has been supplied.
You may search this list of foods and view nutrient values for different serving sizes; you may also rank foods in order of level of a par-
ticular nutrient. You may change the daily calorie level to correspond to your personal metabolism, and the levels for fat, carbohydrates,
fiber, and protein are automatically adjusted. You may customize the ratios of carbohydrates to protein to fat to suit your personal regi-
men. You may add your own recipes to the database, by creating them from the foods in the database. You can also add foods from the
information on commercial food labels. The program is completely menu-driven and there are no commands to learn.
NUT can be called with an optional argument to specify a database subdirectory. For example, if a user tracks meals for other family mem-
bers, each person can have his own database, and each database is entirely separate. The database subdirectory name (if there is one) is
displayed on all screens.
The functions included are:
Record Meals: Foods are found in the database, a number of servings, weight, or calories is entered, and thus a meal is recorded showing
the amount of each food eaten. The meal date can be entered in full "yyyymmdd" format or as a positive or negative offset from today, such
as "-3" or "+1". All numbers expressing food quantities are entered as decimal numbers, but the number of servings can also be entered as
a common fraction such as 3/4. An analysis screen can be brought up by typing a dot. Individual foods are deleted from the meal list by
entering the food number shown, but you can also modify the quantity by typing the food number and a new quantity, for example "2 100g",
i.e. change food #2 to 100 grams. Another way to change the quantity is to type "protein", "carb", or "fat" instead of an explicit new
quantity; for example, "2 carb" indicates you want the second food's quantity changed so that the meal's Daily Value for non-fiber carb is
satisfied. To do the analogous operation on three foods so that protein, carbs, and fat all become exactly equal to the Daily Value for
the entire meal, use the "pcf" command like this: "pcf 5 1 2", where 5 is a protein food, 1 is a carb food, and 2 is a fat food. For the
program analysis to come out right you must record all the meals the program is set for. For instance, if set for three meals, and you eat
more than three, combine them into three; if you eat less than three, record some mimimal item such as an ounce of water for each missing
meal. (See below under "Delete Meals and Set Meals Per Day" for the means to set the program to between 1 and 19 meals per day instead of
the default 3.)
Analyze Meals and Food Suggestions: An analysis of meals in the database is presented in terms of the percentage of each nutrient, where
100% signifies a rate of 100% of the DV (Daily Value) per day. The program will analyze any subset of the latest meals recorded, consid-
ering each meal to be an appropriate fraction of a day. By pressing "s" on the analysis screen, nutrients for which the DV have not been
achieved are listed, and some random foods are chosen from the database which contain the additional nutrients. By pressing "c" the ratios
are reset to cause the meals being analyzed to represent 100% of calories (but see "Set Personal Options and Log Weight" below for options
that can be locked in place and not reset from the analysis screen). By pressing "m" the macronutrient ratios are reset to the absolute
values in the analysis, including calories, protein, carbohydrate, and fat. (There is also an "n" option, not shown in the prompt, which
works just like "m" but sets the macronutrients by percentage rather than absolute values.) By pressing "e" all values are reset to the
absolute values in the analysis. By pressing "o" all DV defaults are restored. By pressing "d" the display alternates between DV percent-
ages, absolute values of the DV nutrients, and a series of screens of all additional nutrients in the database. (There is a hidden "p"
option that moves the screens back the other way.) When you leave the analysis screen (or the "View Foods" screen) with a particular set
of nutrients showing, that set of nutrients will be used in the other functions in the program, including printing menus, ranking foods,
and drawing graphs.
If the value "(nd)" shows up on a screen, it signifies the database has no data for that particular nutrient for the foods viewed.
If the analysis screen is brought up during "Record Meals", it analyzes backwards from the meal being viewed, which might not be the last
meal; however, the "Analyze Meals" screen from main menu option 2 always analyzes from the last meal in the database.
The "Record Meals" and "Analyze Meals" analyses each separately remember how many meals were last analyzed, so that a user could, for
example, always look at a single meal on the "Record Meals" analysis, and always look at a couple of weeks of meals on "Analyze Meals", but
not have to specify how many meals each time.
Delete Meals and Set Meals Per Day: Some or all of the collected meals may be removed from the database; or an automatic feature may be
selected which keeps the meal database from getting unnecessarily huge, deleting the oldest meals in excess of a number of meals set by the
user. When all meals are deleted, an option may be set to change the program's default from 3 meals a day to 1 to 19 meals a day.
View Foods: Foods can be viewed using the same interface as for "Record Meals," specifying whatever serving size the user wishes to see
analyzed for nutrient content, and if necessary typing a "d" or "p" to change the display to a different set of nutrients. You can type
just the beginning of a food name or a part of a food name, and a numbered menu of all possible completions continues to be shown until a
unique food is chosen.
If the value "(nd)" shows up on a screen, it signifies the database has no data for that particular nutrient for the foods viewed.
Add Foods and Modify Serving Sizes: This item has three selections, "Add a Recipe," "Add a Labeled Food," and "Modify Serving Sizes."
To add a recipe, foods are selected in exactly the same way as adding a meal, a number of servings or weight is entered for each food, and
the recipe is recorded. Then the software divides the recipe into the number of servings desired, and provides an opportunity to adjust
the weight of the servings to allow for water gained or lost in preparation.
NUT allows you to add a labeled food with an ordered list of ingredients and a nutrition statement. The new food will have additional
nutrients that were not on the nutrition statement, but that the database says are in the food. First, the labeled food is named. Next
the program requests that the food's listed ingredients be found in the order of greatest to least. Do not worry about ingredients you
cannot find. No amount or weight is set for any ingredient--the ingredient is simply selected. Selected ingredients may be grouped with
parentheses where an ingredient number is followed by either "(", ")", or "!" to begin a group, end a group, or remove a group indicator.
To delete an ingredient, simply type its number; to move an ingredient, type its number, an "m", and the destination--such as "5m2". When
the ingredient list is complete, the nutrient lists are presented so the nutritional information can be copied into the program. Whenever
you quit a nutrient screen, an opportunity is presented to select a different set of nutrients. The "DV" percentages for this part of the
program are the USA standard 2000-calorie Daily Values, and not any customized options--but users can always set the label's nutrient
information in grams. Only Daily Value nutrients greater than zero are considered as constraints when NUT constructs an approximate recipe
in order to fill in nutrient values that were not expressed on the food label. Occasionally the "recipe" that NUT estimates for a pack-
aged food will only show a "trace" of every ingredient, and this is NUT's way of saying that according to the food database, there is no
way to match the ingredients with the constraints of the nutrition statement. After the recipe is displayed there is an additional oppor-
tunity to edit the nutrient values. Perhaps the food was so heavily fortified with vitamins that the user waited until after NUT con-
structed a recipe to specify the additional vitamin amounts. Whatever the rationale for additional editing, the user has total control
over the nutritional information no matter what NUT's approximate recipe suggested. The new food record is saved in the database in the
same manner as a recipe.
To modify the serving size of an existing food, the food is selected and the serving sizes on file are displayed so one can be selected.
Alternately, the user may simply type in his own serving size consisting of number of grams, the serving unit (such as cups or table-
spoons), and the serving quantity.
View Nutrients and Rank Foods: The nutrients are reviewed and one of the nutrients is selected to list all the foods rich in that nutrient.
The food database can be queried in this manner for nutrients per 100 grams, per 100 grams dry weight, per 100 grams within a USDA-defined
food group, per 100 calories, per serving, per serving minimizing some other nutrient, and per recorded meals (average intake per day).
The set of nutrients operated on are the last set viewed or analyzed.
The "Rank Foods per Recorded Meals" option is useful for discovering which foods contribute the most to your intake of a particular nutri-
ent. When you use "Record Meals" to view a meal earlier than your last meal, this "per recorded meals" option looks back from that same
meal, to show which foods you were eating during that earlier period. Likewise, the program remembers how many meals were last analyzed,
and only searches that subset of meals to find which foods to list.
Note that processed foods which contain hydrogenated vegetable oil or significant "trans-" fats may not contain as much of the essential
fatty acids as the program shows because the USDA database does not yet completely distinguish between essential fatty acids and the
"trans-" fats, which cannot serve for essential fatty acids in the body.
Set Personal Options and Log Weight: These screens set and remove options, locking options in place so they cannot be reset from the analy-
sis screen. Options are to change the DV for calories and the levels for fat, carbohydrate, fiber, and protein are then adjusted appropri-
ately (there is also an automatic feature to do this for you from your average calories, or else from the "Weight Log Regression" daily
results if the latest entry included both weight and body fat percentage); control how the program adjusts essential fatty acids in rela-
tion to calories, or else use absolute amounts; set the saturated fat percentage; set the fiber absolute amount; set the carbohydrate per-
centage; set the protein percentage; set the carbohydrate absolute amount; set the protein absolute amount; and restore all program
defaults. Some of the carbohydrate and protein settings are mutually exclusive and affect the fat percentages as carbs, protein, and fat
of course must total 100%; however, calories per gram vary from food to food, so the percentage of calories from carbs, protein, and fat
will vary even if grams of each remain constant, so consider these settings approximations. A special value may be set for the carbohy-
drate absolute amount to indicate a constant gram amount of Non-Fiber Carb always added to the Fiber DV--simply enter the Non-Fiber Carb
amount as a negative number.
The "Essential Fatty Acid Options" uses the analysis field "Omega-6/3 Balance" to select reference values based on Dr. William Lands'
empirical equation for the percentages of Omega-6 and Omega-3 fatty acids in tissue phospholipids based on diet. When you reset the analy-
sis screen, the program recomputes all fatty acid values automatically, but you can set the target Omega-6 percentage for your personal
optimum of more or less Omega-3. You can also set the maximum EPA plus DHA to the highest value where you get no side-effects, and the
program will then show when Omega-6 has to be reduced to meet the target. Turn the feature off completely by setting the "Omega-6/3 Bal-
ance" target to 90/10, and then the EPA plus DHA requirement will simply be the maximum EPA plus DHA value. The default is that the fea-
ture is set for an "Omega-6/3 Balance" target of 50/50 and the maximum EPA plus DHA value is 2.2 grams.
"Weight Log Regression" does not tell you what you weigh; what it does is apply linear regression to a series of daily weight and body fat
percentage entries to smooth out the random noise and tell you which direction your weight is trending, how fast it is going there, and how
much of the change is lean or fat. When both fat mass and lean mass are going down, calories are too low. If the lean mass change number
is less than than the fat mass change number, this is a sign of insulin resistance; and conversely, the larger the spread between a high
lean mass change number and a low fat mass change number, the greater the insulin sensitivity. To make a daily entry, type the weight and
body fat percentage at the prompt, like this: "150.2 17.9". If you did not measure the body fat percentage, just type the weight. This
algorithm is free of units, so it will work with weights in pounds or kilos. The daily entry is automatically timestamped, so it should be
entered into the program immediately after measurement. The algorithm does not have the precision for weight measurements taken much more
often than daily. If you want to erase the weight log and start over, just type a "!", or you may directly edit the file "WLOG.txt" in the
Plot Daily and Monthly Trends: The list of nutrients is presented and one nutrient is chosen for its level to be graphed facing a plot of
protein, carbohydrate, and fat calories. The user enters the number of the nutrient plus a letter, either "d" or "m" to specify "daily" or
"monthly" i.e., "22m". It is only necessary to enter the "d" or "m" once in order to set the mode. Monthly graphs cover the entire period
of the meal database; daily graphs cover 36 days back from the last meal viewed or analyzed. The graphs of Daily Values for fat are spe-
cial and show the constituent fat types symbolically where . = non-fatty acid constituents, s = saturated, m = monounsaturated, 6 = unspec-
ified Omega-6, 3 = unspecified Omega-3, L = linoleic acid, A = arachidonic acid, n = linolenic acid, e = EPA, and d = DHA. In a similar
vein, the "Total Carb" graph shows non-fiber carb as "." and fiber as ":".
Record 'The Usual'--Customary Meals: When NUT asks what you are having, you can answer "the usual." Specifically, this function allows you
to record a customary meal, and give it a name. Later, when recording a regular meal, all these foods can be added to the meal quickly by
typing "theusualname", where "name" is the name you gave to the customary meal. Foods added this way can be individually deleted from the
meal, and other foods added, because this function does not make the individual foods lose their identity as in "Add a Recipe."
Print Menus from Meal Database: Makes a printable file (called "menus.txt" in the current directory) which lists foods and quantities
recorded for each meal, and a nutrient analysis that is the sum of nutrients for each meal, not the rate of nutrient intake as on the "Ana-
lyze Meals" screen. In common with other functions in the program, it looks back from the last meal recorded or analyzed, only prints the
number of meals last analyzed, and prints that set of nutrients last displayed on an analysis or "View Foods" screen.
sr22.nut Joined text version of USDA Nutrient Database
FOOD_DES.txt USDA-format food records for user recipes and edits
NUT_DATA.txt USDA-format nutrient records for user recipes and edits
WEIGHT.txt USDA-format weight records for user recipes and edits
WEIGHT.lib Joined serving sizes from USDA Nutrient Database
food.db Food database
meal.db Meal database
theusual.db Customary Meals database
OPTIONS.txt Personal Options records
WLOG.txt Weight Log records
WLOG.old Last deleted Weight Log
version NUT software version number
menus.txt ASCII print file of meal database
Jim Jozwiak (firstname.lastname@example.org, email@example.com)
Copyright (C) 1996-2010 by Jim Jozwiak.