code: def canonicalize(lig, preserve_bond_order=False):
      
      atomorder = None
      # Get canonical atom order
  
      lig = pybel.ob.OBMol(lig.OBMol)
      if not preserve_bond_order:
          for bond in pybel.ob.OBMolBondIter(lig):
              if bond.GetBondOrder() != 1:
                  bond.SetBondOrder(1)
      lig.DeleteData(pybel.ob.StereoData)
      lig = pybel.Molecule(lig)
      testcan = lig.write(format='can')
      try:
          pybel.readstring('can', testcan)
          reference = pybel.readstring('can', testcan)
      except IOError:
          testcan, reference = '', ''
      if testcan != '':
          reference.removeh()
          isomorphs = get_isomorphisms(reference, lig)  # isomorphs now holds all isomorphisms within the molecule
          if not len(isomorphs) == 0:
              smi_dict = {}
              smi_to_can = isomorphs[0]
              for x in smi_to_can:
                  smi_dict[int(x[1]) + 1] = int(x[0]) + 1
              atomorder = [smi_dict[x + 1] for x in range(len(lig.atoms))]
          else:
              atomorder = None
      return atomorder
docs: Get the canonical atom order for the ligand.