Skip to content

Ketcher format (current version)

even1024 edited this page Feb 16, 2021 · 10 revisions

Root schema

{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"title": "ket",
	"description": "Ketcher format schema",
	"type": "object",
	"required": [
		"root"
	],
	"properties": {
		"root": {
			"type": "object",
			"required": [
				"nodes"
			],
			"properties": {
				"nodes": {
					"type": "array",
					"items": {
						"anyOf": [
							{
								"$ref": "#/definitions/simpleObject"
							},
							{
								"type": "object",
								"properties": {
									"$ref": {
										"type": "string",
										"anyOf": [
											{
												"pattern": "^mol\\d+"
											},
											{
												"pattern": "^rg[1-9]\\d*"
											}
										]
									}
								}
							}
						]
					}
				}
			}
		}
	},
	"patternProperties": {
		"^rg[1-9]\\d*": {
			"$ref": "#/definitions/rgroup"
		},
		"^mol\\d+": {
			"$ref": "#/definitions/molecule"
		}
	}

Molecule schema

		"molecule": {
			"type": "object",
			"required": [
				"atoms",
				"type"
			],
			"properties": {
				"stereoFlag": {
					"type": "string",
					"enum": [
						"ABS",
						"AND",
						"OR",
						"Mixed"
					]
				},
				"type": {
					"const": "molecule"
				},
				"atoms": {
					"type": "array",
					"items": {
						"anyOf": [
							{
								"$ref": "#/definitions/atom"
							},
							{
								"$ref": "#/definitions/rsite"
							},
							{
								"$ref": "#/definitions/atomlist"
							}
						]
					}
				},
				"bonds": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/bond"
					}
				},
				"highlight": {
					"type": "array",
					"items": {
						"type": "object",
						"required": [
							"entityType",
							"items"
						],
						"properties": {
							"entityType": {
								"type": "string",
								"enum": [
									"atoms",
									"bonds"
								]
							},
							"items": {
								"type": "array",
								"items": {
									"type": "integer"
								}
							}
						}
					}
				},
				"selection": {
					"type": "array",
					"items": {
						"type": "object",
						"required": [
							"entityType",
							"items"
						],
						"properties": {
							"entityType": {
								"type": "string",
								"enum": [
									"atoms",
									"bonds"
								]
							},
							"items": {
								"type": "array",
								"items": {
									"type": "integer"
								}
							}
						}
					}
				},
				"sgroups": {
					"$ref": "#/definitions/sgroups"
				}
			}
		}

Atom schema

		"atom": {
			"type": "object",
			"required": [
				"label"
			],
			"properties": {
				"label": {
					"type": "string"
				},
				"location": {
					"type": "array",
					"items": {
						"type": "number",
						"maxItems": 3
					}
				},
				"charge": {
					"type": "integer",
					"minimum": -1000,
					"maximum": 1000
				},
				"explicitValence": {
					"type": "integer",
					"enum": [
						-1,
						0,
						1,
						2,
						3,
						4,
						5,
						6,
						7,
						8,
						9,
						10,
						11,
						12
					]
				},
				"isotope": {
					"type": "integer",
					"minimum": 0
				},
				"radical": {
					"type": "integer",
					"enum": [
						0,
						2,
						1,
						3
					]
				},
				"attachmentPoints": {
					"type": "integer",
					"enum": [
						0,
						1,
						2,
						3
					]
				},
				"stereoParity": {
					"type": "integer",
					"enum": [
						0,
						1,
						2,
						3
					]
				},
				"ringBondCount": {
					"type": "integer",
					"enum": [
						0,
						-2,
						-1,
						2,
						3,
						4
					]
				},
				"substitutionCount": {
					"type": "integer",
					"enum": [
						0,
						-2,
						-1,
						1,
						2,
						3,
						4,
						5,
						6
					]
				},
				"unsaturatedAtom": {
					"type": "boolean"
				},
				"hCount": {
					"type": "integer",
					"enum": [
						-1,
						0,
						1,
						2,
						3,
						4,
						5
					]
				},
				"mapping": {
					"type": "integer",
					"minimum": 0
				},
				"invRet": {
					"type": "integer",
					"enum": [
						0,
						1,
						2
					]
				},
				"exactChangeFlag": {
					"type": "boolean"
				}
			}
		}

Atom list schema

		"atomlist": {
			"type": "object",
			"required": [
				"type",
				"location"
			],
			"properties": {
				"type": {
					"const": "atom-list"
				},
				"notList": {
					"type": "boolean"
				},
				"location": {
					"type": "array",
					"items": {
						"type": "number",
						"maxItems": 3
					}
				},
				"elements": {
					"type": "array",
					"minItems": 2,
					"items": {
						"type": "string"
					}
				},
				"attachmentPoints": {
					"type": "integer",
					"enum": [
						0,
						1,
						2,
						3
					]
				}
			}

Bond schema

		"bond": {
			"type": "object",
			"required": [
				"atoms"
			],
			"properties": {
				"type": {
					"type": "integer",
					"enum": [
						1,
						2,
						3,
						4,
						5,
						6,
						7,
						8,
						9,
						10,
						11,
						12
					]
				},
				"atoms": {
					"type": "array",
					"minItems": 2,
					"maxItems": 2,
					"items": {
						"type": "integer"
					}
				},
				"stereo": {
					"type": "integer",
					"enum": [
						0,
						1,
						2,
						3
					]
				},
				"topology": {
					"type": "integer",
					"enum": [
						0,
						1,
						2
					]
				},
				"center": {
					"type": "integer",
					"enum": [
						0,
						-1,
						1,
						2,
						4,
						8,
						12
					]
				},
				"stereobox": {
					"type": "integer",
					"enum": [
						0,
						1
					]
				}
			}
		}

R-Site schema

		"rsite": {
			"type": "object",
			"required": [
				"type",
				"location"
			],
			"properties": {
				"type": {
					"const": "rg-label"
				},
				"location": {
					"type": "array",
					"items": {
						"type": "number",
						"maxItems": 3
					}
				},
				"$refs": {
					"type": "array",
					"items": {
						"type": "string",
						"pattern": "^rg-[1-9]\\d*"
					}
				},
				"attachmentPoints": {
					"type": "integer",
					"enum": [
						0,
						1,
						2,
						3
					]
				}
			}
		}

S-Groups schema

		"sgroups": {
			"type": "array",
			"items": {
				"required": [
					"atoms",
					"type"
				],
				"properties": {
					"atoms": {
						"type": "array",
						"items": {
							"type": "integer"
						}
					},
					"type": {
						"type": "string",
						"enum": [
							"GEN",
							"MUL",
							"SRU",
							"SUP",
							"DAT"
						]
					}
				},
				"if": {
					"properties": {
						"type": {
							"const": "MUL"
						}
					}
				},
				"then": {
					"required": [
						"mul"
					],
					"properties": {
						"mul": {
							"type": "integer",
							"minimum": 1,
							"maximum": 1000
						}
					}
				},
				"if": {
					"properties": {
						"type": {
							"const": "SRU"
						}
					}
				},
				"then": {
					"required": [
						"subscript",
						"connectivity"
					],
					"properties": {
						"subscript": {
							"type": "string",
							"pattern": "^[a-zA-Z]$"
						},
						"connectivity": {
							"type": "string",
							"enum": [
								"HT",
								"HH",
								"EU"
							]
						}
					}
				},
				"if": {
					"properties": {
						"type": {
							"const": "SUP"
						}
					}
				},
				"then": {
					"required": [
						"type"
					],
					"properties": {
						"type": {
							"type": "string",
							"minLength": 1
						}
					}
				},
				"if": {
					"properties": {
						"type": {
							"const": "DAT"
						}
					}
				},
				"then": {
					"required": [
						"context",
						"fieldName",
						"fieldValue"
					],
					"properties": {
						"context": {
							"enum": [
								"Fragment",
								"Multifragment",
								"Bond",
								"Atom",
								"Group"
							]
						},
						"fieldName": {
							"type": "string",
							"minLength": 1
						},
						"fieldValue": {
							"type": "string",
							"minLength": 1
						},
						"display": {
							"type": "boolean"
						},
						"placement": {
							"type": "boolean"
						},
						"bonds": {
							"type": "array",
							"items": {
								"type": "integer"
							}
						}
					}
				}
			}
		}

R-Group

		"rgroup": {
			"type": "object",
			"required": [
				"rlogic"
			],
			"properties": {
				"rlogic": {
					"type": "object",
					"properties": {
						"number": {
							"type": "integer",
							"minimum": 1
						}
					}
				},
				"type": {
					"const": "rgroup"
				},
				"atoms": {
					"type": "array",
					"items": {
						"anyOf": [
							{
								"$ref": "#/definitions/atom"
							},
							{
								"$ref": "#/definitions/rsite"
							},
							{
								"$ref": "#/definitions/atomlist"
							}
						]
					}
				},
				"bonds": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/bond"
					}
				},
				"highlight": {
					"type": "array",
					"items": {
						"type": "object",
						"required": [
							"entityType",
							"items"
						],
						"properties": {
							"entityType": {
								"type": "string",
								"enum": [
									"atoms",
									"bonds"
								]
							},
							"items": {
								"type": "array",
								"items": {
									"type": "integer"
								}
							}
						}
					}
				},
				"selection": {
					"type": "array",
					"items": {
						"type": "object",
						"required": [
							"entityType",
							"items"
						],
						"properties": {
							"entityType": {
								"type": "string",
								"enum": [
									"atoms",
									"bonds"
								]
							},
							"items": {
								"type": "array",
								"items": {
									"type": "integer"
								}
							}
						}
					}
				},
				"sgroups": {
					"$ref": "#/definitions/sgroups"
				}
			}
		}

Simple object schema

		"simpleObject": {
			"type": "object",
			"required": [
				"type",
				"data"
			],
			"properties": {
				"type": {
					"const": "simpleObject"
				},
				"data": {
					"type": "object",
					"required": [
						"mode",
						"pos"
					],
					"properties": {
						"mode": {
							"type": "string",
							"enum": [
								"line",
								"rectangle",
								"circle"
							]
						},
						"pos": {
							"type": "array",
							"minItems": 2,
							"maxItems": 2,
							"items": {
								"type": "object",
								"properties": {
									"x": {
										"type": "number"
									},
									"y": {
										"type": "number"
									},
									"z": {
										"type": "number"
									}
								}
							}
						}
					}
				}
			}
		}