How to query the COD database

COD provides possibilities to query the database contents using MySQL clients, and to retrieve CIFs using specific URIs.

Querying the COD database

If you want to quickly issue simple queries, you can use the Web search form. The more sophisticated queries however may need direct access to the COD SQL server and issuing SQL queries directly. As of 2011, we are using MySQL server and thus you will need the MySQL query language to take full advantage of our database.

There is a designated user, 'cod_reader', that can issue SELECT queries (i.e. has SELECT privilege) directly from the COD data tables. For example, using a command line client 'mysql' in Linux, you can find all structures that have Fobs files deposited using a query below:

saulius@koala ~/ > mysql -u cod_reader -h -e 'select 
count(*) from data where flags like "%has Fobs%"' cod | cat

saulius@koala ~/ > mysql -u cod_reader -h -e 'select file from data where flags like "%has Fobs%"' cod | tail -n +2 | head -7

The same select works over the Web search as well, just flag the 'has Fobs' check-box and click submit. You will be able to download the list of COD numbers as a text file if you wish.

Obtaining desired CIFs

If you pick any COD number from the above set, there are two URLs that return you CIFs with coordinates, and CIFs with structure factors, respectively. You can retrieve the CIFs using your browser, or a command line utility such as 'wget' or 'curl':

curl -s

curl -s

(The historic URLs and are also supported)

Since COD records are intensively curated, there might be different revisions of the same COD record available. The above-mentioned persistent URL's are always pointing that the most recent revision of the record (which should be te most accurate and the most complete). In case you need to retrieve a specific version of a COD record, you can do that by appending the desired revision number after an '@' sign to the COD URLs:

curl -s

curl -s

The revision numbers are available for '.cif' and '.hkl' records.

All recisions are documented in a revision log file, which can be queried for the whole COD database:

svn log svn://

or for a specific record:

svn log svn://

The subdirectories under the cif/ tree are constructed using the first, the second-third and the fouth-fith digits of the COD ID.

For automatic parsing o fthe COD logs, XML format is recommended:

svn log --xml svn://

svn log --verbose --xml svn://

For more information on how to use Subversion commands, please see "Version Control with Subversion".

NB.: if you use this method to download all files, please introduce some delay (10-30 seconds) between the subsequent downloads, so as to not overload our servers, and please cache (store) the downloaded files on your local hard disk.

Of course, there are ways to download the whole COD.