So I’m building a project where one of the steps involves converting SDF (molecular file) data into PDB data since that loader is a built-in add-on, however this conversion package I’m using currently only operates on Python and I’m trying to create a pure Nextjs repo that can do all of the same things. It would be super helpful if there was a SDF Loader add-on as well. I can even build it myself but I think it would be cool to integrate and provide for everyone. What does everyone think? Also I’m trying to make sure the lack of an SDF Loader was just because no one had come along and done it yet, rather than it just being some gargantuan nonsensical task.
IMO, there was simply no demand so far for loading SDF molecule definitions, especially since there is a PDBLoader
around. Looking at the SDF/Mol File Format Specification, a loader shouldn’t be that complicated to implement. However, I would suggest a different approach like with PDBLoader
.
It might make more sense to write a three.js
independent library that takes SDF text content as an input and returns a JSON representation. We could then add an external three.js example that imports the lib, parse a loaded SDF with it and then visualizes the result with a CSS renderer or with WebGL/WebGPU.
Unlike other loaders for OBJ, FBX or glTF, the visualization of molecule data is quite application specific. So instead of writing a SDFLoader
that returns mesh definitions, I would just focus on JSON and let the application do anything else.
The JSON could have the following structure:
{
"molecules": [
{
"name": "Molecule 1 Name (from header if available, or generate one)",
"atoms": [
{
"id": 1,
"element": "C",
"x": 0.0,
"y": 0.0,
"z": 0.0,
"charge": 0
},
{
"id": 2,
"element": "O",
"x": 1.2,
"y": 0.0,
"z": 0.0,
"charge": -1
}
// ... more atoms
],
"bonds": [
{
"from_atom": 1,
"to_atom": 2,
"type": 1, // 1 for single, 2 for double, etc.
"stereo": 0
},
// ... more bonds
],
"properties": {
"logP": 2.5,
"ExactMass": 123.45,
"Source": "Some_Database"
// ... other properties from the SDF/MOL file
}
},
// ... more molecules if it's an SDF file
]
}