Closed RiesBen closed 10 months ago
additional this bit could be useful to plot all mappings of a network for example: (code shamelessly used from here: https://greglandrum.github.io/rdkit-blog/posts/2023-05-26-drawing-options-explained.html)
from PIL import Image, ImageOps
from io import BytesIO
def show_images(imgs,buffer=4, ncols=3):
height = 0
width = 0
nrows= (len(imgs)+1)//ncols if(len(imgs)%3>0) else len(imgs)//ncols
for img in imgs:
height = max(height, img.height)
width = max(width, img.width)
#simplistic columnizing
print(ncols, nrows)
height = height* nrows
width = width * ncols
width += buffer*ncols
height += buffer*nrows
print(width,height)
res = Image.new("RGBA",(width,height))
x = 0
y = 0
for i, img in enumerate(imgs):
img = ImageOps.expand(img, border=3, fill="grey")
res.paste(img,(x,y))
x += img.width + buffer
if(i%ncols == 0 and i!=0):
y+= img.height + buffer
x=0
return res
views = []
for m in mappings:
view = draw_mapping(m._compA_to_compB, m.componentA.to_rdkit(),
m.componentB.to_rdkit(),)
bio = BytesIO(view)
view = Image.open(bio)
views.append(view)
res = show_images(views)
res.save(out_name)
res
@RiesBen yes please!
@richardjgowers Started a branch with a first draft :)
https://github.com/OpenFreeEnergy/gufe/blob/441b70a6f716038dfa6c139c89c2ce2ebff6db14/gufe/visualization/mapping_visualization.py#L167C1-L173C6
@richardjgowers How about this addition, if we can assume ofe-name is always present?: