Logo Search packages:      
Sourcecode: python-biopython version File versions

def BioSQL::Loader::DatabaseLoader::_get_term_id (   self,
  name,
  ontology_id = None,
  definition = None,
  identifier = None 
) [private]

Get the id that corresponds to a term.

This looks through the term table for a the given term. If it
is not found, a new id corresponding to this term is created.
In either case, the id corresponding to that term is returned, so
that you can reference it in another table.

The ontology_id should be used to disambiguate the term.

Definition at line 60 of file Loader.py.

                                     :
        """Get the id that corresponds to a term.

        This looks through the term table for a the given term. If it
        is not found, a new id corresponding to this term is created.
        In either case, the id corresponding to that term is returned, so
        that you can reference it in another table.

        The ontology_id should be used to disambiguate the term.
        """

        # try to get the term id
        sql = r"SELECT term_id FROM term " \
              r"WHERE name = %s"
        fields = [name]
        if ontology_id:
            sql += ' AND ontology_id = %s'
            fields.append(ontology_id)
        id_results = self.adaptor.execute_and_fetchall(sql, fields)
        # something is wrong
        if len(id_results) > 1:
            raise ValueError("Multiple term ids for %s: %r" % 
                             (name, id_results))
        elif len(id_results) == 1:
            return id_results[0][0]
        else:
            sql = r"INSERT INTO term (name, definition," \
                  r" identifier, ontology_id)" \
                  r" VALUES (%s, %s, %s, %s)"
            self.adaptor.execute(sql, (name, definition,
                                       identifier, ontology_id))
            return self.adaptor.last_id("term")

    def _add_dbxref(self, dbname, accession, version):


Generated by  Doxygen 1.6.0   Back to index