In [34]:
# TESTING OPENBABEL DRAWING
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>')
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
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
In [ ]: