Friday, 5 February 2010

Parsing and drawing molecular structures with delphi part I

After being very busy in several projects that I'm enrolled. I've managed to get some time extra to go on in my little project. This week I've been working on a little scripting language that let me build different structures by using it. I still have to fix some bugs and I have a very long list of new features. By using this little structure, we can modify the different nodes and edges that we are building. For example if we have this:


node(1).ToNode(2).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(2).ToNode(3).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(3).ToNode(4).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(4).ToNode(5).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(5).ToNode(6).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(6).ToNode(1).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];


The application will build the next structure:

Well, at this point, how can we manage molecular structures? In this case, we only need the adjacent list and parse it to let the application force the position by using its force-directed graph layout. It's amazing the all kind of structures that the system can process and work with.

By drawing on paper the diagram and then inserting the adjacent list, we can build structures like that:

food colouring:

this is an example of a natural food colouring

cube structure:
invented structure:

this structure was done to show the power of the application.


I've modified a little the managing of the graph, and now we can get the script of the graph by using the option that we have in the menu of the application.

With this little utility we can imagine our structure, make it bigger, and generate the script to export. For example, if we get the last cube diagram, we can use this structure, draw on it to get it bigger and export with the scripting language. Then we can save this plain structure and keep it whatever we want, and we can build structures as brilliant as these:

This video will show you how the parsing list works, and how can we build this kind of structures. On the output window we can get the list to parse into the graph implementator.

The version is not stable, and I haven't uploaded it yet, but let me time to finish the syntactic analyser, and then give to the editor a try.





As you can see, the project is working and every week you can find a new version on SourceForge with all this new features, and please, if you notice any bug, report it into the bug tracker or if you want to ask any question, feel free to contact me, by adding a comment into the article or by my web page.

I hope you enjoy!.

0 comments:

Post a Comment