PostEra

Temporary fix for visualisation (Michelanglo)

The XChem team has been working hard to allow uploading of SDF files and proper integration into Fragalysis, their fragment analysis site.
In the meanwhile, I have been throwing together interactive views in Michelanglo, which is a site that allows biochemists to make a page with an interactive 3D protein (using NGL like Fragalysis) and a user written narrative about the protein with links that alter its orientation and representations —so not really ideal for this.
Here is an example:

I have added the code to make the totally-off-specs interactive pages with tables to the client-side Python API code, just in case it helps:


Here is code specific for MPro with a XChem-ready SDF file. A few things to note:
  • “Basic” users cannot do this to prevent client side exploits. Only approved users can (message me and I’ll approve you).

  • the data needs to be stored on GitHub for retrieval: it gets split into mol files (getting a user to download 20 MB on a webpage is not okay, especially as 50% of users are on mobile devices).

  • A JSON table is made and automatically placed in the same folder

  • template.pdb or whatever your column name has (see below) has to be in the same folder (manually placed).

  • inspiration hits need to be manually placed in the same folder

  • Under T&Cs the content is your responsibility, so if the data is not yours explicitly pass blame/credit to the author.

    from michelanglo_api import MikeAPI, MikePage
    mike = MikeAPI('username','password') # use your username and password
    assert mike.verify_user()['rank'] != 'basic', 'Only privileged users can add JS'
    

Make a page via the GUI and copy the uuid part of the URL (the gibberish part).

  page = MikePage(mike, 'uuid').retrieve()

Alternatively make one via python (less pretty, especially since the autoView does not change view angle)

  page = mike.convert_pdb('6LU7').retrieve()

Then, with appropriate changes run:

  gitfolder='/Users/you/path_to_your_github_repo_on_your_machine'
  sdfile='/Users/you/path_to_sdfile.sdf'
  folder = 'folder_name_within_repo'
  targetfolder=f'{gitfolder}/{folder}'
  page.description = 'Hello world. '
  page.loadfun = ''
  page.columns_viewport = 6
  page.columns_text = 6

  page.sdf_to_mols(sdfile=sdfile,
                 targetfolder=targetfolder,
                 skip_first=True) # first row is metadata in a SDF for XChem
  page.sdf_to_json(sdfile=sdfile,
                 keys=('∆∆G', 'comRMSD', 'N_constrained_atoms', 'runtime', 'disregarded', 'smiles'),
                 key_defaults=(999., 999., 0, 999., 'NA', 'NA'), #what to set stuff that is null
                 filename=f'{targetfolder}/data.json')
  page.make_fragment_table(sdfile=sdfile,
                   username='matteoferla',
                   repo_name='Data_for_own_Michelanglo_pages',
                   foldername=folder,
                   protein_sele='145:A', # show this on protein. NGL selection
                   sort_col=2, #sort by column index 2.
                   sort_dir='asc', #asc or desc
                   template_row=-1, # is the template a file called `template.pdb` (-1) or a filename in the row n?
                   fragment_row=1, # the inspiration fragments (-1 for none). The names must match with or without a .mol.
                   jsonfile='data.json')
  page.commit()
  # if in a Jupyter notebook
  page.show_link()

The files with need to be Git-pushed first.

1 Like