No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
373a2f1
... +3 ...
7a118ce
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
30 | 30 | mol: openeye RDKMol object |
|
31 | 31 | openeye molecule to convert to chemper Mol object |
|
32 | 32 | """ |
|
33 | - | if type(mol) != Chem.rdchem.Mol: |
|
34 | - | raise Exception("Expecting an rdchem.Mol instead of %s" % type(mol)) |
|
33 | + | if not isinstance(mol, Chem.rdchem.Mol): |
|
34 | + | raise TypeError("Expecting an rdchem.Mol instead of %s" % type(mol)) |
|
35 | 35 | self.mol = mol |
|
36 | 36 | ||
37 | 37 | def __str__(self): return self.get_smiles() |
186 | 186 | atom: RDKAtom |
|
187 | 187 | Atom object from an RDK molecule |
|
188 | 188 | """ |
|
189 | - | if type(atom) != Chem.rdchem.Atom: |
|
190 | - | raise Exception("Expecting an rdchem.Atom instead of %s" % type(atom)) |
|
189 | + | if not isinstance(atom, Chem.rdchem.Atom): |
|
190 | + | raise TypeError("Expecting a rdchem.Atom instead of %s" % type(atom)) |
|
191 | 191 | self.atom = atom |
|
192 | + | self._idx = self.atom.GetIdx() |
|
193 | + | ||
194 | + | def __str__(self): return '%i%s' % (self._idx, self.atom.GetSymbol()) |
|
192 | 195 | ||
193 | 196 | def atomic_number(self): |
|
194 | 197 | """ |
284 | 287 | index: int |
|
285 | 288 | atom index in its molecule |
|
286 | 289 | """ |
|
287 | - | return self.atom.GetIdx() |
|
290 | + | return self._idx |
|
288 | 291 | ||
289 | 292 | def is_connected_to(self, atom2): |
|
290 | 293 | """ |
298 | 301 | connected: boolean |
|
299 | 302 | True if atom2 is a direct neighbor or atom1 |
|
300 | 303 | """ |
|
301 | - | if not type(atom2.atom) is Chem.rdchem.Atom: |
|
302 | - | # TODO: raise exception/return something else? |
|
304 | + | if not isinstance(atom2.atom, Chem.rdchem.Atom): |
|
303 | 305 | return False |
|
304 | 306 | neighbors = [a.GetIdx() for a in self.atom.GetNeighbors()] |
|
305 | 307 | return atom2.get_index() in neighbors |
350 | 352 | bond: RDKBond |
|
351 | 353 | Bond object from an RDK molecule |
|
352 | 354 | """ |
|
353 | - | if type(bond) != Chem.rdchem.Bond: |
|
354 | - | raise Exception("Expecting an rdchem.Bond instead of %s" % type(bond)) |
|
355 | + | if not isinstance(bond, Chem.rdchem.Bond): |
|
356 | + | raise TypeError("Expecting an rdchem.Bond instead of %s" % type(bond)) |
|
355 | 357 | self.bond = bond |
|
356 | - | self.order = self.bond.GetBondTypeAsDouble() |
|
358 | + | ||
359 | + | # save index |
|
360 | + | self._idx = self.bond.GetIdx() |
|
361 | + | ||
362 | + | # save order information |
|
363 | + | self._order = self.bond.GetBondTypeAsDouble() |
|
364 | + | orders = {1:'-', 2:'=', 3:'#', 1.5:':'} |
|
365 | + | self._order_symbol = orders.get(self._order, '~') |
|
366 | + | ||
367 | + | # save atoms in bond |
|
357 | 368 | self.beginning = Atom(self.bond.GetBeginAtom()) |
|
358 | 369 | self.end = Atom(self.bond.GetEndAtom()) |
|
359 | 370 | ||
371 | + | def __str__(self): |
|
372 | + | return "%i %s%s%s" % (self.get_index(), self.beginning, |
|
373 | + | self._order_symbol, self.end) |
|
374 | + | ||
360 | 375 | def get_order(self): |
|
361 | 376 | """ |
|
362 | 377 | Returns |
|
363 | 378 | ------- |
|
364 | 379 | order: int or float |
|
365 | 380 | This is the absolute order, returns 1.5 if bond is aromatic |
|
366 | 381 | """ |
|
367 | - | return self.order |
|
382 | + | return self._order |
|
368 | 383 | ||
369 | 384 | def get_atoms(self): |
|
370 | 385 | """ |
400 | 415 | is_single: boolean |
|
401 | 416 | True if it is a single bond |
|
402 | 417 | """ |
|
403 | - | return self.order == 1 |
|
418 | + | return self._order == 1 |
|
404 | 419 | ||
405 | 420 | def is_double(self): |
|
406 | 421 | """ |
409 | 424 | is_double: boolean |
|
410 | 425 | True if it is a double bond |
|
411 | 426 | """ |
|
412 | - | return self.order == 2 |
|
427 | + | return self._order == 2 |
|
413 | 428 | ||
414 | 429 | def is_triple(self): |
|
415 | 430 | """ |
418 | 433 | is_triple: boolean |
|
419 | 434 | True if it is a triple bond |
|
420 | 435 | """ |
|
421 | - | return self.order == 3 |
|
436 | + | return self._order == 3 |
|
422 | 437 | ||
423 | 438 | def get_molecule(self): |
|
424 | 439 | """ |
439 | 454 | index: int |
|
440 | 455 | index of this bond in its parent molecule |
|
441 | 456 | """ |
|
442 | - | return self.bond.GetIdx() |
|
457 | + | return self._idx |
|
458 | + | ||
459 | + | # ===================================================================== |
|
460 | + | # functions for importing molecules from files |
|
461 | + | # ===================================================================== |
|
443 | 462 | ||
444 | 463 | def mols_from_mol2(mol2_file): |
|
445 | 464 | """ |
469 | 488 | mol_path = get_data_path(os.path.join('molecules', mol2_file)) |
|
470 | 489 | ||
471 | 490 | if not os.path.exists(mol_path): |
|
472 | - | raise IOError("File '%s' not found locally or in chemper/data/molecules." % mol_file) |
|
491 | + | raise IOError("File '%s' not found locally or in chemper/data/molecules." % mol2_file) |
|
473 | 492 | else: |
|
474 | 493 | mol2_file = mol_path |
|
475 | 494 |
484 | 503 | molecules = list() |
|
485 | 504 | mol2_block = list() |
|
486 | 505 | ||
487 | - | file_open = open(mol2_file, 'r') |
|
506 | + | file_open = open(mol2_file) |
|
488 | 507 | ||
489 | 508 | for line in file_open: |
|
490 | 509 | if line.startswith(delimiter) and mol2_block: |
31 | 31 | openeye molecule to convert to chemper Mol object |
|
32 | 32 | """ |
|
33 | 33 | if not isinstance(mol, oechem.OEMolBase): |
|
34 | - | raise Exception("Expecting an OEMol object instead of %s" % type(mol)) |
|
34 | + | raise TypeError("Expecting an OEMol object instead of %s" % type(mol)) |
|
35 | 35 | self.mol = mol |
|
36 | 36 | ||
37 | 37 | def __str__(self): return self.get_smiles() |
188 | 188 | Atom object from an OpenEye molecule |
|
189 | 189 | """ |
|
190 | 190 | if not isinstance(atom, oechem.OEAtomBase): |
|
191 | - | raise Exception("Expecting an OEAtomBase object instead of %s" % type(atom)) |
|
191 | + | raise TypeError("Expecting an OEAtomBase object instead of %s" % type(atom)) |
|
192 | 192 | self.atom = atom |
|
193 | - | self._index = self.atom.GetIdx() |
|
193 | + | self._idx = self.atom.GetIdx() |
|
194 | + | ||
195 | + | def __str__(self): return "%i%s" % (self._idx, |
|
196 | + | oechem.OEGetAtomicSymbol(self.atomic_number())) |
|
194 | 197 | ||
195 | 198 | def atomic_number(self): |
|
196 | 199 | """ |
280 | 283 | index: int |
|
281 | 284 | atom index in its molecule |
|
282 | 285 | """ |
|
283 | - | return self._index |
|
286 | + | return self._idx |
|
284 | 287 | ||
285 | 288 | def is_connected_to(self, atom2): |
|
286 | 289 | """ |
294 | 297 | connected: boolean |
|
295 | 298 | True if atom2 is a direct neighbor or atom1 |
|
296 | 299 | """ |
|
300 | + | if not isinstance(atom2.atom, oechem.OEAtomBase): |
|
301 | + | return False |
|
297 | 302 | return self.atom.IsConnected(atom2.atom) |
|
298 | 303 | ||
299 | 304 | def get_neighbors(self): |
324 | 329 | molecule this atom is stored in |
|
325 | 330 | """ |
|
326 | 331 | mol = oechem.OEMol(self.atom.GetParent()) |
|
327 | - | self.atom = mol.GetAtom(oechem.OEHasAtomIdx(self._index)) |
|
332 | + | self.atom = mol.GetAtom(oechem.OEHasAtomIdx(self._idx)) |
|
328 | 333 | return Mol(mol) |
|
329 | 334 | ||
330 | 335 | # ======================================= |
344 | 349 | Bond object from an OpenEye molecule |
|
345 | 350 | """ |
|
346 | 351 | if not isinstance(bond, oechem.OEBondBase): |
|
347 | - | raise Exception("Expecting an OEBondBase object instead of %s" % type(bond)) |
|
352 | + | raise TypeError("Expecting an OEBondBase object instead of %s" % type(bond)) |
|
348 | 353 | self.bond = bond |
|
354 | + | ||
355 | + | # save index |
|
356 | + | self._idx = self.bond.GetIdx() |
|
357 | + | ||
358 | + | # store order information |
|
349 | 359 | self._order = self.bond.GetOrder() |
|
350 | 360 | if self.is_aromatic(): |
|
351 | 361 | self._order = 1.5 |
|
352 | 362 | ||
353 | - | self._idx = self.bond.GetIdx() |
|
363 | + | orders = {1:'-', 2:'=', 3:'#', 1.5:':'} |
|
364 | + | self._order_symbol = orders.get(self._order, '~') |
|
365 | + | ||
366 | + | # save atoms in bond |
|
367 | + | self.beginning = Atom(self.bond.GetBgn()) |
|
368 | + | self.end = Atom(self.bond.GetEnd()) |
|
369 | + | ||
370 | + | def __str__(self): |
|
371 | + | return "%i %s%s%s" % (self.get_index(), self.beginning, |
|
372 | + | self._order_symbol, self.end) |
|
354 | 373 | ||
355 | 374 | def get_order(self): |
|
356 | 375 | """ |
368 | 387 | atoms: list of chemper Atoms |
|
369 | 388 | the two atoms connected by this bond |
|
370 | 389 | """ |
|
371 | - | beginning = Atom(self.bond.GetBgn()) |
|
372 | - | end = Atom(self.bond.GetEnd()) |
|
373 | - | return [beginning, end] |
|
390 | + | return [self.beginning, self.end] |
|
374 | 391 | ||
375 | 392 | def is_ring(self): |
|
376 | 393 | """ |
Files | Coverage |
---|---|
chemper | -0.08% 89.40% |
Project Totals (11 files) | 89.40% |
7a118ce
188d4eb
f4e3a2c
bf3252b
373a2f1