scientific and technical website design projects news

CookandKaye News

CAS number validation with PHP

Chemical names tend to be a mixture of IUPAC and lab-speak, and an empirical formula can represent a dozen very different substances. So, when it is important that you report chemicals accurately – how do you do it? This is a problem we have recently encountered in developing an interactive database for the ‘Control of Substances Hazardous to Health’ (COSHH) for a University department. Here the system must be able to unambiguously associate chemical substances with risk and safety data.

Pretty much the only way to do this is through the CAS registry number, this is issued to all reported chemicals by the Americal Chemical Society. The chemicals themeselves will be called up by users by their IUPAC name or any synonym that is available in the database, or by fragments of these, making it easier and quicker to use, though the option of using the CAS registry number will also be available to them.

The CAS number has the format 1234567-12-1, i.e. a number up to seven digits long – a two digit number – a single digit number. The last number acts as a check for the whole number, to help prevent typo’s, so this system is quite robust, and allows us to add new chemicals to the existing database without great fear of duplication (in fact some chemicals have been associated with more than one CAS number, so even this is not infallible).

All we need now is a check program for the CAS number, to help ensure the user or administrator does not make typos. This we adapted from the code posted by Rich Apodaca on Depth First (in Ruby):


function valid_cas($cas_no) {
$pattern=false;
$sum=false;
$checksum=0;
//pattern check
if(ereg('[0-9]{2,7}-[0-9]{2}-[0-9]', $cas_no)){
$pattern=true;
}
//perform check sum
$cas_no=strrev($cas_no);//reverse the string
$cas_no=str_replace('-','',$cas_no);//take out hyphens
$chk_digit=substr($cas_no, 0, 1);//get the check digit, now the first number!
for($i=0; $i<strlen($cas_no); $i++){
$digit[$i]=substr($cas_no, $i, 1);
$checksum=$checksum+($digit[$i]*$i);
}
if($chk_digit==$checksum%10){
$sum=true;
}
if(($pattern)AND($sum)){
return true;
} else {
return false;
}
}

Calling valid_cas(number-to-test) within a PHP code block will return true or false, depending upon whether or not the CAS number has a valid format, so providing a valuable chack against typos on adding new chemicals to the database, and permitting the database to check against duplication.

For more on the CAS registry number – see the wikipedia entry

Polymer Centre research map

The new Polymer Centre research map has been built on an existing staff CMS that stores keywords and a précis of information about staff research interests. To create the map the keywords were first grouped into superordinate terms – for example the keywords ‘Rheology’ and ‘Optical properties’ falls under the generic class of ‘Polymer Analysis’ (or just Analysis).

To make the system as flexible as possible, the link between keywords and superordinate terms is done through a ‘plug board’ programming interface. In this, each keyword is assigned to a number of generic categories through selecting check boxes – easy!

The results are stored in a MySQL database, and this is used to power the research map itself. On first sight the map provides a coarse list of the superordinate terms – polymer analysis, characterisation and so on. On selecting one of these terms the list expands to show the relevant keywords. The keywords can in turn be expanded to display the names of research staff engaged in the work of interest.

The system therefore offers a simple visitor interface that can be quickly and intuitively navigated to find the information of interest. It offers a great advantage over an empty search box on one vital respect – it always offers the visitor a positive result! Not all sites have Google-like resources, and using a controlled language of keywords in this way allows us to guide a visitor to what we have, rather than their getting lots of failed searches.

While the research map offers visitors a neat tool for finding the information they want, it is also an engine to help ensure that search engines can tie our keywords to content on the Polymer Centre website. To do this, the meta content on each of the staff pages contains the same keywords they are associated with in the database.

In addition, however, the meta content of the research map itself is served dynamically. The page title, description and keywords are updated to reflect the level of the map that is being examined. Thus if you have opened a keyword, that keyword and the associated staff appear in the appropriate meta content sections of the research map page. As these sections are important to search engines in ascertaining the important content of a page, this design helps to ensure that the information the Polymer Centre carries about polymer research and near market activity is readily available on the world wide web.

Dielectric relaxation

A diagrammatic representation of polar molecules in an electric field. When the field is applied
the molecules orientate themselves so that the end of the molecule with a small positive charge faces the negatively charged electrode. When the field is removed, the molecules slowly relax to their previous state.

This is a movie that shows diagrammatically how simple polar molecules in a fluid phase might respond to an electric field. In real instances each molecule would also have substantial translational velocities.

You can apply a field by clicking on the switch symbol. More information is available about the molecule when you move your mouse over the top left hand instance.

What is in a favicon?

A favicon is a small graphic that appears by your web page address in a visitor’s browser, or in their bookmarks list, and helps to identify your site. As such it is a very important piece of web real estate, and contributes strongly to your online brand image. Being only 16 by 16 pixels in size, however, there is quite an art to getting a meaningful design into a ‘favicon’.

For most of us, one favicon is enough, and we would not want to re-brand this part of our identity any more often than we have to, as this may confuse visitors! For a complex brand like Google’s, however, changing the favicon has been a common event over the last eighteen months, culminating in the latest, a stained glass ‘g’. Where will Google go from here – does the new icon more accurately reflect their core brand? Or is the Google ‘spirit of innovation’ simply incompatible with a fixed brand image?

The image (above right) shows a 16 by 16 icon expaned 10 fold. The original icon held the word ‘icon’, and now appears in the dot of the ‘i’!

For more on the Google favicon, and an opportunity to have a go at designing your own favicon, see the BBC Magazine article linked below:

BBC: What’s with Google’s new mini icon?

Previous post on favicon design

Polymer expertise for industry

Screen-shot of the new FaraPack website.

We’ve just completed a new website for FarPack Polymers. The site is based on their new brochure, designed by Alpha Design. The home page uses an interactive FLASH image, installed with background transparency, making background graphics used in the body of the site visible, and correctly positioned, so the act of browsing from the home page through the rest of the site is as smooth as possible.

The Flash itself is installed using ‘Flash Satay’ system by Drew McLellan, suggested by the W3C. We have been using this system for quite a while now, after playing with Javascript based installers. Essentialy we found that the latter simply imposed another barrier to getting content accross (does your browser understand our Javascript, as well as do you have Flash!). The satay method allows us to install (in this instance) a full text page with links hidden behind the Flash, for anyone who either does not have a compatible Flash player, or who has accessibility problems with this type of pure visual medium. Flash free? – No problem, you get a page formatted like the rest of the site, with all of the text and links you need!

Another nice feature of this website is that we are installing a constellation of micro-sites in different languages, to help our client with European business. The site makes extensive use of PHP to permit us to re-use components accross pages within a given language, and between micro-sites, allowing us to add new languages quickly and inexpensively!

FaraPack Polymers

Flash Satay

Gunfight at the software corral

It is a dog-eat-dog world* out there, and these times of uncertainty increase the importance of a sound procurement process for all businesses. On the web design front, this means that you’ve got to get as much mileage out of your money as possible (no change there), but perhaps you should also consider getting a robust product that is going to survive even if the companies that do your websites and your software do not…**

There is still a place for plain vanilla HTML, but most websites now make use of one or more additional technologies to deliver interactive content. As a consequence many clients now need ongoing technical backup to update and develop this interactivity as a part of their business model.

At CookandKaye we use MySQL and PHP to generate interactive components based on information held on databases linked to the website. Usually these programs are offered as part of the ‘LAMP’ standard. LAMP comes from the initials of the four programs that make this standard up – Linux, Apache, MySQL and PHP. Each component does a different job:

  • Linux is the operating system for the computer on which your server software is running.
  • Apache is the server software, and actually handles the web requests, and ensures that your web pages are delivered as required.
  • MySQL provides fast SQL compatible database services to your website. We also work with PostgreSQL when necessary, as this has better compatibility with geospatial applications than MySQL.
  • PHP provides the code that lets your web pages speak to the server and the database, pulling all the bits together into a seamless HTML web page. PHP runs on the server, not your visitor’s computer, so your visitor only needs a browser capable of displaying simple HTML to get all the interactivity you require!

The popularity of this standard means that any customer buying a bespoke interactive website has the security of knowing there are an awful lot of programmers out there who they can fall back on should anything go wrong. An additional advantage is that all of this software is open-source. This means that you have full rights to your website – not your web designer, no trickily worded license deals, no hidden fees…

Not only do these technologies give you considerable security for a bespoke product, if you have them on your server you also have access to an amazing library of ‘off the peg’ applications including blogging tools, galleries, content management systems, bulletin boards… These can all be integrated with your existing website, or they may do everything you need on the web!

We use the LAMP standard because we believe it is the only sensible choice for bespoke web design for most SME’s, and it is a damn site better choice than a lot of the stuff larger enterprises are using! Don’t just take our word for it though, look at the TIOBE or Scriptol indices (or do your own research on Google!):

TIOBE Programming Community Index

Scriptol, popular programming languages

*A saying, which, if accurate, probably implies that things are not too bad, as our dog definitely prefers biscuits…

**Remember when you wrote your first business plan? If one of your suppliers lets you down, can you get the widgets you need elsewhere at a comparable cost? This thinking shouldn’t just apply to widgets…

Public perceptions of scientists

The image of a mad scientist.

Yesterday I managed a day out to get to the Polymer IRC’s UK Polymer Showcase at York. As you’d expect, most of the presentations were about polymers and plastics research, but the Material World’s Quentin Cooper also gave a very entertaining guest presentation entitled Plastic and Past Stuck – Why Science Changes the World but Scientists’ Image Stays the Same. In this Quentin explored perceptions of science.

One of the most engaging parts of this was a look at the images children produce when asked to draw a scientist; inevitably the clichés of lab coat and glassware were overwhelming. The image here is my own effort from a number of years ago (but not, sadly, as a child in response to a scientifically conducted pole!). I guess the general premise is that people build stereotypes that overlook the essential humanity of the scientist. Science is a job that you can do, but it is also a way of looking at things? Getting answers to questions?

I had a great day out, so thanks and congratulations to Helen and the Polymer IRC team for organising this event…

The Material World

The Polymer IRC

Kinlochbervie historic wrecksite

Kinlochbervie is close to the most North Westerly part of the British mainland, and quite a long drive from anywhere! The scenery is spectacular, however, particularly the drive north of Ullapool, so it was a great privilege to get the chance to work there for a few weeks in 2002.

While I did do a bit of web work on the journey North,* my primary task was to provide scientific support for the Kinlochbervie wrecksite project. At this point it is perhaps germane to state that I was trained as a chemist, and had been researching new methods for conserving underwater archaeological finds at the University of St Andrews for the last decade. My interest in the web started with writing web pages for this project in 1997 (when the web was still quite young)…

By coincidence, the shipwreck at Kinlochbervie was also found in 1997, by members of RAF Lossiemouth Sub Aqua Club (SAC). Roy Hemmings from the club took the lead role in developing a project to study the wreck, and ensure it was properly protected. The previous year had seen a very high profile investigation from Channel 4’s Time Team (Kinlochbervie NW Scotland), during the course of which the finest collection of renaisance Majollica ever to be found in Scotland was recorded. This brief investigation raised questions about the stability of the site, and how well protected the remains were…

So, 2002 finds us on board Gemini Storm with a team of very experienced archaeological divers under the direction of Phil Robertson (now at Historic Scoltland).

* CookandKaye had started earlier that same year; as I recall I designed the banner for the Centre for Biomaterials and Tissue Engineering on a storm tossed boat beating its way North from Kyle – Jo says I was very inconveniently wedged in the loo for the duration of the storm!

On Crosby beach

A couple of photos from last summer (which was as wet as this summer, from my recollection) taken on Crosby beach. The beach is a super stretch of sand adjacent to the Port of Liverpool, it is also the setting for Anthony Gormley’s Another Place, a series of iron castings standing on the beach and in the shallow waters.

Here I’ve captured the weathered visage of one of the statues, and the Port wind-farm. Roll your cursor over the image to switch focus between one and the other…

Catalysis in supercritical fluids

Catalysis in supercritical fluids offers potential operational and environmental benefits over conventional catalytic processes. This demonstration system developed by scientists at the University of St Andrews shows the hydrocarbonylation (addition of hydrogen and carbon monoxide) to pentene to produce an aldehyde (hexanal).

The reactants are passed into the reaction chamber in supercritical (SC) carbon dioxide solution, where they dissolve in an ionic solvent containing the rhodium catalyst. The reactants bind to the catalyst and are converted to the product, which is released back into solution. The SC carbon dioxide dissolves the aldehyde, and is passed into a low pressure separator, where the aldehyde drops out of SC solution. The carbon dioxide and any unreacted starting materials are re-compressed back into the reactor.