[BioPython] Loading keywords into database

Andreas Kuntzagk andreas.kuntzagk@mdc-berlin.de
Mon, 03 Jun 2002 15:44:35 +0200


Here is how i tried to load the keywords into the biosql Database. Is this correct?

(From my Version of BioSQL.Loader)
------------
     def _load_bioentry_keyword(self, record):
         """Add keywords into the database"""
         try:
             id = self.adaptor.fetch_seqid_by_display_id(self.dbid, record.name)
             keywords = record.annotations["keywords"]
             keyword_ont_id =  self._get_ontology_id("keyword")
             sql = r"INSERT INTO bioentry_qualifier_value VALUES" \
                   r" (%s, %s, %s)"
             for k in keywords:
                 self.adaptor.execute_one(sql, (bioentry_id, keyword_ont_id ,k))
         except KeyError:
             pass
------------

(I thought, i already sent this to the list, but couldn't find in the Archive, 
so I probably missed the "Send"-Button :-(

I also noticed that the Loader could be more robust. It chokes if an entry is 
already in the Database. Not good, if i bulk-load from a file, it crashes 
somehow in the middle and i want to start again.

Ciao, Andreas

PS: What is the best place to send this code? The developer list? Or would it be 
better (if possible) to check this into cvs?