Skip to content

Running the TNRS on OSX

pmidford edited this page Sep 6, 2011 · 5 revisions

Running the TNRS on OSX

Disclaimer

This is not a supported activity, but since the question was asked, we will try to answer it.

The Question

I've been trying to install TNRS on my laptop with the hope of experimenting with loading some of our [redacted for privacy] taxonomy products. So, I'm starting from OSX 10.6.8 with developer tools and MySQL installed. Since the INSTALL directions are for Linux I assume this is possible but that there will be problems along the way. So the simplest question is whether anyone else has tried installing to OSX? At the moment, I got the script that builds the MySQL tables to run, but the php scripts for the later steps seem to be broken, partially because the includes seem to be looking in the wrong places. I've tried some work arounds, but it seems like changing the php configuration somehow might be more effective. I'm rather rusty with php - it's been about 7 years since I last did anything with it.

Hope this gives you an idea where I am, and that you or someone else out there can suggest a course of action.

The Response

It sounds like you are talking about the scripts that create and populate the core database called tnrs, so here goes.

I don't see any reason why the scripts shouldn't run on OSX, as long as you have php and mysql installed and properly configured, with all the right permissions.

You should only need to alter two scripts.

(1) In the base directory, edit 'global_params.inc'. Look for:

////////////////////////////////////// // Db configuration /////////////////////////////////////

and fill out the relevant parameters.

Also, just below the db configuration parameters, look for

////////////////////////////////////// // Taxonomy source parameters //////////////////////////////////////

You might want to change your taxonomy source name parameters to something relevant to your data source.

(2) Next, in the directory 'import', find the file 'params.inc' and make sure you set the variable

$namesfile =

to the name of the file containing your source taxonomy (names and synonymy).

If you place the file in the directory 'import' you can leave

$path="";

otherwise you will need to set the path to the file as well.

Also make sure that the settings under

// Import parameters for text file

are correct for your taxonomy file. The parameters are used to compose a standard MySQL "LOAD DATA INFILE..." statement.

(3) Finally, make sure that your taxonomy file has exactly the same columns as the example I have included, which should be called

tropicos_api_pinaceae_example.txt

A couple of important details about this file.

a) Every name has its own integer nameID b) Every name, except for the root, has a link to the immediate parentNameID. For the root, parentNameID is NULL. c) The synonymy-related fields are acceptance and acceptedNameID. If you don't have this information, no problem, the script will still run. If you do have this information, the values for acceptance are A (=accepted), S (=synonym) or NULL. If acceptance='S' then there should also be a link to the acceptedNameID, although the script will still run if the link is missing. d) In general (if I remember correctly) the higher taxon fields family and subclass are optional as long as all the necessary higher taxa are present in the list (but still include the column, even if empty). Higher taxa will populated by walking up the tree using the recursive nameID-parentNameID links. e) The really critical fields are nameID, parentNameID, scientificName and nameRank. They should not be NULL, except for the parentNameID of the root. Use "unranked" for unranked taxa. Circular nameID-parentNameID links will cause trouble. f) Finally, ensure that all scientificName+scientificNameAuthorship combinations are unique. scientificNameAuthorship can be NULL.

I recommend you do a trail build first using the example file. If it works, then you can go ahead and try again using your own taxonomy file.

Last caveat. The current version of the TNRS database scripts load only one taxonomic source, so you'll need to put all your taxonomy into that one file. I'm working on a new version that will load multiple sources. Stay tuned.

After making the above changes, follow the directions in the readme file in the base directory, and you should be set.

Getting php on OSX to talk to MySQL

Assuming you have installed the OSX developer tools (to get php) and installed MySQL, you may encounter the following problem:

Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in .../tnrs/tnrs_db_scripts/sql_functions.inc on line 112

Warning: mysql_connect(): No such file or directory in .../tnrs/tnrs_db_scripts/sql_functions.inc on line 112

Could not connect to MySQL on localhost.

The workaround (at least in OSX 10.6.8 with MySQL 5.5) is to create a symbolic link so php can find mysql.sock: sudo mkdir /var/mysql cd /var/mysql sudo ln -s /private/tmp/mysql.sock