Ignore:
Timestamp:
22/09/08 17:31:19 (11 years ago)
Author:
cbyrom
Message:

Adjust atom to include atom type term ID as well as the vocab url - and
update the vocab data to include the terms for the various different
atom subtypes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4214 r4217  
    127127        if atomType: 
    128128            logging.info(" - of type '%s'" %atomType) 
    129         self.atomType = atomType 
     129        self.atomTypeID = atomType 
    130130 
    131131        # some data have further subtypes specified 
     
    168168        else: 
    169169            self.VTD = VTD() 
    170           
     170 
     171        if self.atomTypeID: 
     172            self.atomTypeName = self.VTD.TERM_DATA[self.atomTypeID].title 
     173 
    171174        self.ME = ME.MolesEntity() 
    172175         
     
    187190 
    188191 
     192    def getValidSubTypes(self): 
     193        ''' 
     194        Get list of subtypes that are valid wrt this atom type 
     195        ''' 
     196        logging.debug("Lookup up subtypes for type, '%s'" %self.atomTypeID) 
     197        subTypes = self.VTD.SUBTYPE_TERMS.get(self.atomTypeID) or [] 
     198        logging.debug(subTypes) 
     199        return subTypes 
     200         
     201             
     202 
    189203    def __addAtomTypeDataXML(self, root): 
    190204        ''' 
     
    192206        - and lookup and add the appropriate vocab term data 
    193207        ''' 
    194         if self.atomType: 
     208        if self.atomTypeID: 
    195209            logging.info("Adding atom type info to XML output") 
    196210            category = Category() 
    197             category.label = self.VTD.TERM_DATA[self.atomType].title 
     211            category.label = self.atomTypeID 
    198212            # look up the appropriate vocab term data 
    199             category.scheme = self.VTD.getTermCurrentVocabURL(self.atomType) 
     213            category.scheme = self.VTD.getTermCurrentVocabURL(self.atomTypeID) 
    200214            category.term = self.ATOM_TYPE 
    201215            root.append(category.toXML()) 
     
    204218            logging.info("Adding atom subtype info to XML output") 
    205219            # NB subtypes not all defined, so leave this out for the moment 
    206             category.label = self.subtype #self.VTD.TERM_DATA[self.subtype].title 
     220            category.label = self.subtype 
    207221            # look up the appropriate vocab term data 
    208             category.scheme = 'NOT SET UP AT PRESENT'#self.VTD.getTermCurrentVocabURL(self.subtype) 
     222            category.scheme = self.VTD.getTermCurrentVocabURL(self.subtype) 
    209223            category.term = self.ATOM_SUBTYPE 
    210224            root.append(category.toXML()) 
     
    511525            if cat.term == self.ATOM_TYPE: 
    512526                logging.debug("Found atom type data") 
    513                 self.atomType = cat.label 
     527                self.atomTypeID = cat.label 
     528                self.atomTypeName = self.VTD.TERM_DATA[cat.label].title  
    514529                continue 
    515530            elif cat.term == self.ATOM_SUBTYPE: 
Note: See TracChangeset for help on using the changeset viewer.