In [34]:
# TESTING OPENBABEL DRAWING

initialise nb


In [35]:
%load_ext autoreload
%autoreload 2
from eden.util import configure_logging
import logging
configure_logging(logging.getLogger(),verbosity=1)
from IPython.core.display import HTML
HTML('<style>.container { width:95% !important; }</style>')


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
Out[35]:

In [36]:
%matplotlib inline

In [37]:
# get data
from eden.converter.graph.gspan import gspan_to_eden
from itertools import islice

def get_graphs(dataset_fname='../toolsdata/bursi.pos.gspan', size=100):
    return  islice(gspan_to_eden(dataset_fname),size)

In [38]:
from graphlearn.utils import openbabel
g=list(get_graphs(size=20))

print "drawing the same graphs twice once in 3d"
# d3=True
#openbabel.draw(g[:9], d3=True, n_graphs_per_line=3)
#d3=False
openbabel.draw(g[:9], d3=False, n_graphs_per_line=5)

#other parameters:
# title_key... for headlines over graphs
# size..  changes size in case of 2d drawing


drawing the same graphs twice once in 3d
HN N O CH 3 N CH 3 N O O N N O HO N H O S N O HO Br N N CH 3 O
N CH 3 O O HO O H 3 C HN N NH S H 3 C O O O Cl Cl N O OH N O OH OH N O OH

In [39]:
s='''<svg xmlns="http://www.w3.org/2000/svg" font-family="sans-serif" height="100" stroke="rgb(0,0,0)" stroke-linecap="round" stroke-width="2" viewBox="0 0 401.214 357.723" width="100" x="0" y="0">'''
import re

#res = re.findall(r"(\w+),(\d{2}/\d{2}/\d{4}),\"([\d,]+)\",\"([\d,]+)\",(\d+)", data)
viewbox = re.findall('viewBox="0 0 ([\d\.]+) ([\d\.]+)',s)[0]
print viewbox
newbox = (float(viewbox[0])*2,float(viewbox[1])*2)
print newbox
s=s.replace('viewBox="0 0 %s %s' % viewbox,'viewBox="0 0 %f %f' % newbox) 

print s


('401.214', '357.723')
(802.428, 715.446)
<svg xmlns="http://www.w3.org/2000/svg" font-family="sans-serif" height="100" stroke="rgb(0,0,0)" stroke-linecap="round" stroke-width="2" viewBox="0 0 802.428000 715.446000" width="100" x="0" y="0">

In [ ]: