Data Model version 2.1.2

Method: getChemAtomSets


    getter for derived link chemAtomSets

guid: www.ccpn.ac.uk_Fogh_2006-08-16-18:23:24_00003
OpType: get
OpSubType: None
isQuery: True
isAbstract: False
Scope: instance_level
Code: chemAtomVars = self.chemAtoms
chemAtomSets = set(self.chemComp.chemAtomSets)

# remove ChemAtomSets that do not have all atoms within ChemCompVar
for ca in self.chemComp.chemAtoms:
  if isinstance(ca, ChemAtom) and ca not in chemAtomVars:
    cas = ca.chemAtomSet
    while cas in chemAtomSets:
      chemAtomSets.remove(cas)
      cas = cas.chemAtomSet

# remove ChemAtomSets with duplicate names
casByName = {}
for cas in chemAtomSets.copy():
  name = cas.name
  cas0 = casByName.get(name)

  if cas0 is None:
    casByName[name] = cas

  else:
    set1 = cas.chemAtomSets
    if set1:
      set0 = cas0.chemAtomSets
    else:
      set1 = cas.chemAtoms
      set0 = cas0.chemAtoms

    if set1 < set0:
      casx = cas
      if not set1:
        raise ApiError("%s found ChemAtomSets %s and %s that are incompatible" % (self, cas, cas0))

    elif set0 < set1:
      casByName[name] = cas
      casx = cas0
      if not set0:
        raise ApiError("%s found ChemAtomSets %s and %s that are incompatible" % (self, cas, cas0))

    else:
      raise ApiError("%s found ChemAtomSets %s and %s that are not subsets of each other" % (self, cas, cas0))
      
    while casx in chemAtomSets:
      chemAtomSets.remove(casx)
      casx = casx.chemAtomSet
#
result = frozenset(chemAtomSets)
  Data Model Version 2.1.2
Go to Top  
  Autogenerated by  PyApiDocGen  revision 1.3   on  Fri Mar 28 11:18:04 2014    from data model package  ccp.api.molecule.ChemComp.ChemCompVar   revision ?  
  Work done by the CCPN team.
www.ccpn.ac.uk