chemistry1.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from vedo import show, download
  2. from vedo.chemistry import Molecule, PeriodicTable, Protein
  3. ###################################################################
  4. # Create an instance of PeriodicTable
  5. pt = PeriodicTable()
  6. print(pt)
  7. # Get atomic number from symbol
  8. symbol = "Co"
  9. print(f"\nAtomic number of {symbol}: {pt.get_atomic_number(symbol)}")
  10. path1 = download("https://www.dropbox.com/scl/fi/6ml4xr88xyyaupe8hs61u/3gea.pdb?rlkey=xm8lkknyzklqacepqmqmod0i0&dl=0")
  11. path2 = download("https://www.dropbox.com/scl/fi/91tcay1a8vr8r5nogudr6/caffeine.pdb?rlkey=hhw217vyje54z6b9tdjzurmoq&dl=0")
  12. ###################################################################
  13. protein = Protein(path1)
  14. protein.set_coil_width(0.3)
  15. protein.set_helix_width(0.8)
  16. protein.set_sphere_resolution(15)
  17. show(protein, axes=1).close()
  18. ###################################################################
  19. mol = Molecule(path2)
  20. # mol = Molecule()
  21. # o_atom = mol.append_atom([0, 0, 0], 8) # Oxygen
  22. # h1_atom = mol.append_atom([0.757, 0.586, 0], 1) # Hydrogen 1
  23. # h2_atom = mol.append_atom([-0.757, 0.586, 0], 1) # Hydrogen 2
  24. # mol.append_bond(o_atom, h1_atom, 1) # Single bond O-H1
  25. # mol.append_bond(o_atom, h2_atom, 1) # Single bond O-H2
  26. # Display atom info
  27. print(f"Number of atoms: {mol.get_number_of_atoms()}")
  28. print(f"Number of bonds: {mol.get_number_of_bonds()}")
  29. print(f"Atom positions:\n{mol.get_atom_positions()}")
  30. print(f"Atomic numbers: {set(mol.get_atomic_numbers())}")
  31. print(f"Bond 0: {mol.get_bond(0)}")
  32. # Customize rendering
  33. mol.use_ball_and_stick()
  34. show(mol, axes=1)