|
20 | 20 | }, |
21 | 21 | { |
22 | 22 | "cell_type": "code", |
23 | | - "execution_count": 2, |
| 23 | + "execution_count": null, |
24 | 24 | "id": "32069b9b", |
25 | 25 | "metadata": {}, |
26 | 26 | "outputs": [], |
27 | 27 | "source": [ |
28 | 28 | "import os\n", |
29 | 29 | "import molSimplify\n", |
30 | | - "\n", |
| 30 | + "from openbabel import openbabel\n", |
31 | 31 | "from molSimplify.Classes import mol3D" |
32 | 32 | ] |
33 | 33 | }, |
34 | 34 | { |
35 | 35 | "cell_type": "code", |
36 | | - "execution_count": 4, |
| 36 | + "execution_count": null, |
37 | 37 | "id": "604aa4ca", |
38 | 38 | "metadata": {}, |
39 | 39 | "outputs": [ |
|
70 | 70 | ], |
71 | 71 | "source": [ |
72 | 72 | "#Example with one file\n", |
| 73 | + "#this seems to work only with mol v2\n", |
73 | 74 | "\n", |
74 | 75 | "filename = \"./data/cis_platin.mol\"\n", |
75 | 76 | "complex_mol = mol3D()\n", |
|
79 | 80 | }, |
80 | 81 | { |
81 | 82 | "cell_type": "code", |
82 | | - "execution_count": 6, |
| 83 | + "execution_count": null, |
| 84 | + "id": "f0f589b8", |
| 85 | + "metadata": {}, |
| 86 | + "outputs": [], |
| 87 | + "source": [ |
| 88 | + "filename = \"./data/cis_platin.mol\"\n", |
| 89 | + "\n", |
| 90 | + "test_mol = openbabel.OBMol()\n", |
| 91 | + "\n", |
| 92 | + "# Create an OBConversion object\n", |
| 93 | + "obConversion = openbabel.OBConversion()\n", |
| 94 | + "\n", |
| 95 | + "# Set the input format ('mol') and output format ('xyz')\n", |
| 96 | + "obConversion.SetInFormat(\"mol\")\n", |
| 97 | + "obConversion.SetOutFormat(\"xyz\")\n", |
| 98 | + "\n", |
| 99 | + "if not obConversion.ReadFile(test_mol, filename):\n", |
| 100 | + " print(\"Error: Could not read the mol file.\")\n", |
| 101 | + "else:\n", |
| 102 | + " xyz_string = obConversion.WriteString(test_mol)\n", |
| 103 | + "\n", |
| 104 | + " complex_mol = mol3D()\n", |
| 105 | + " complex_mol.readfromstring(xyz_string)\n", |
| 106 | + " print(complex_mol.get_geometry_type())" |
| 107 | + ] |
| 108 | + }, |
| 109 | + { |
| 110 | + "cell_type": "code", |
| 111 | + "execution_count": null, |
| 112 | + "id": "cf526836", |
| 113 | + "metadata": {}, |
| 114 | + "outputs": [], |
| 115 | + "source": [ |
| 116 | + "directory = './data'\n", |
| 117 | + "\n", |
| 118 | + "absolute_file_paths = [os.path.abspath(os.path.join(directory, f)) for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f)) and \"mol\" in f and not \"xyz\" in f]\n", |
| 119 | + "\n", |
| 120 | + "tmp_mol = openbabel.OBMol()\n", |
| 121 | + "\n", |
| 122 | + "# Create an OBConversion object\n", |
| 123 | + "obConversion = openbabel.OBConversion()\n", |
| 124 | + "\n", |
| 125 | + "# Set the input format ('mol') and output format ('xyz')\n", |
| 126 | + "obConversion.SetInFormat(\"mol\")\n", |
| 127 | + "obConversion.SetOutFormat(\"xyz\")\n", |
| 128 | + "\n", |
| 129 | + "for cur_fn in absolute_file_paths:\n", |
| 130 | + " \n", |
| 131 | + " complex_mol = mol3D()\n", |
| 132 | + "\n", |
| 133 | + " try:\n", |
| 134 | + " print(\"----------------------\")\n", |
| 135 | + " print(cur_fn)\n", |
| 136 | + " \n", |
| 137 | + " if not obConversion.ReadFile(tmp_mol, filename):\n", |
| 138 | + " print(\"Error: Could not read the mol file.\")\n", |
| 139 | + " else: \n", |
| 140 | + " xyz_string = obConversion.WriteString(test_mol)\n", |
| 141 | + " \n", |
| 142 | + " complex_mol = mol3D()\n", |
| 143 | + " complex_mol.readfromstring(xyz_string)\n", |
| 144 | + " \n", |
| 145 | + " geo_dict = complex_mol.get_geometry_type()\n", |
| 146 | + " if \"geometry\" in geo_dict:\n", |
| 147 | + " print(geo_dict[\"geometry\"])\n", |
| 148 | + " except Exception as ex:\n", |
| 149 | + " # pass\n", |
| 150 | + " print(\"error\", str(ex))\n", |
| 151 | + " \n" |
| 152 | + ] |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "code", |
| 156 | + "execution_count": null, |
83 | 157 | "id": "55927958", |
84 | 158 | "metadata": {}, |
85 | 159 | "outputs": [ |
|
103 | 177 | } |
104 | 178 | ], |
105 | 179 | "source": [ |
| 180 | + "#works only with mol v2\n", |
| 181 | + "\n", |
106 | 182 | "directory = './data'\n", |
107 | 183 | "\n", |
108 | 184 | "absolute_file_paths = [os.path.abspath(os.path.join(directory, f)) for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f)) and \"mol\" in f and not \"xyz\" in f]\n", |
|
121 | 197 | " except Exception as ex:\n", |
122 | 198 | " print(\"error\", str(ex))" |
123 | 199 | ] |
| 200 | + }, |
| 201 | + { |
| 202 | + "cell_type": "code", |
| 203 | + "execution_count": null, |
| 204 | + "id": "facfae74", |
| 205 | + "metadata": {}, |
| 206 | + "outputs": [], |
| 207 | + "source": [ |
| 208 | + "\n" |
| 209 | + ] |
124 | 210 | } |
125 | 211 | ], |
126 | 212 | "metadata": { |
|
0 commit comments