[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bkchem-user] Using BKChem as a library for generation of 2D structu
From: |
Noel O'Boyle |
Subject: |
Re: [Bkchem-user] Using BKChem as a library for generation of 2D structure images |
Date: |
Fri, 28 Mar 2008 10:23:37 +0000 |
OSRA looks perfect for the job (particularly example2.py). I will
carry out some tests with it over the weekend.
Noel
On 27/03/2008, Beda Kosata <address@hidden> wrote:
> Noel O'Boyle wrote:
> >
> > Hmm...it seems that it's necessary to start the Application. Do you
> > have any plans to separate some of the functionality into a library
> > that could be accessed without starting the App? For example, I simply
> > want to (1) build a molecule (using the information in the connection
> > table of a pybel molecule), (2) generate 2D layout, (3) create an
> > image (preferably stored in a string, rather than in a file).
>
>
> The problem here is that the started App lets you measure exact (or
> almost exact) text size, thus enabling much nicer output.
> Also there is the whole machinery of the App behind you, so you can
> relatively easily work with color, fonts, etc.
> But its true that it is slow and ineffective.
>
>
> >
> > It would be great to have this as a library, not just for Pybel.
> > According to today's write up on Depth First, BKChem is one of only 4
> > available structure diagram generators...and the only one in Python
> > (see
> http://depth-first.com/articles/2008/03/26/five-open-tools-for-2d-structure-layout-aka-structure-diagram-generation)
> >
>
>
> Interesting. The 2D coordinate generation is done in the OASA library I
> mentioned. This particular part of the library was written some 3 or 4
> years ago when I was doing a postdoc in Germany and had plenty of free
> time in the evenings. I did not touch the code since and it has some
> weak points (such as possible overlaps of atoms in highly branched
> structures), etc.
>
> This brings us nicely to the second option I mentioned - using OASA (the
> library that is behind BKChem). I use it on http://inchi.info to
> generate pictures in the converter. It is not able to run without
> X-windows installed, because it uses cairo for picture generation and
> cairo does not work without X installed. However, you don't need X
> running. I use it for PNGs now, but cairo is capable of producing PDF's,
> EPS's and SVG's as well.
> I attach two small scripts that demonstrate what you can do. Just copy
> it to the bkchem directory where the oasa library resides and run it. As
> you can see the OASA api is not that different from Pybel and it would
> be almost no effort to create a bridge between the two (as I intent to
> do in neat future :)
> The only problem here is that I did not put that much effort into the
> cairo output backend, so the result is not that nice. Also there is not
> much support for configuration of display options for atoms, fancy
> things like sub- and superscripts, etc. (In BKChem you can say "I want
> this atom rendered with symbol on and hydrogens on, I also want each
> nitrogen atom painted in green"; you cannot do this in OASA (without
> some hacking)).
> It all depends on what you need.
>
>
> > My other question is how stable is the BKChem API?
> >
>
>
> Well, it depends. Some parts of the API are pretty stable, but I don't
> hesitate when I need to change something when I need to. I try to
> document changes in commit logs, but not very thoroughly because I am
> the only one working on BKChem.
> Maybe it is better to give an example - there are some batch scripts
> that I have created some two years ago that work even with recent
> versions. On the other hand there are a few that I had to tweak slightly
> because they used things that changed slightly over the time.
>
> Best regards
>
>
> Beda
>
>
Re: [Bkchem-user] Using BKChem as a library for generation of 2D structure images, mpalmer, 2008/03/27