[Biopython-dev] [patch] BioSQL.BioSeq.Annotation._get_dblinks

Yves Bastide ybastide at irisa.fr
Wed Nov 27 12:13:44 EST 2002


Hi,

quick patch to BioSQL.BioSeq, which used a nonexistant table for db 
links.  Also add the NCBI taxon id in the Species class.


yves
-------------- next part --------------
Index: BioSQL/BioSeq.py
===================================================================
RCS file: /home/repository/biopython/biopython/BioSQL/BioSeq.py,v
retrieving revision 1.9
diff -u -p -r1.9 BioSeq.py
--- BioSQL/BioSeq.py	2002/11/24 20:07:04	1.9
+++ BioSQL/BioSeq.py	2002/11/27 17:12:50
@@ -132,10 +132,11 @@ _is_title = re.compile(r"[A-Z][^A-Z]*$")
 _is_lower = re.compile(r"[^A-Z]+$")
 
 class Species:
-    def __init__(self, classification, common_name = None, sub_species = None,
-                 organelle = None):
+    def __init__(self, classification, common_name = None, ncbi_id = None,
+                 sub_species = None, organelle = None):
         self.classification = classification
         self.common_name = common_name
+        self.ncbi_id = ncbi_id
         self.sub_species = sub_species
         self.organelle = organelle
 
@@ -236,8 +237,9 @@ class Annotation:
         
     def _get_dblinks(self):
         dblink_info = self.adaptor.execute_and_fetchall(
-            """select dbname, accession from bioentry_direct_links
-                    where source_bioentry_id = %s""",
+            "SELECT dbname, accession FROM bioentry_dblink, dbxref" \
+            " WHERE bioentry_dblink.dbxref_id = dbxref.dbxref_id" \
+            " AND bioentry_id = %s""",
             (self.primary_id,))
         dblinks =  [DBLink(database, primary_id) for (database, primary_id)
                                                      in dblink_info]
@@ -426,14 +428,14 @@ class DBSeqRecord:
         return self.dates
 
     def _get_species(self):
-        full_lineage, common_name = self.adaptor.execute_one(
-            """select tx.full_lineage, tx.common_name
+        full_lineage, common_name, ncbi_id = self.adaptor.execute_one(
+            """select tx.full_lineage, tx.common_name, tx.ncbi_taxon_id
                            from taxon tx, bioentry be
                            where tx.taxon_id = be.taxon_id and
                                  be.bioentry_id = %s""",
             (self.primary_id,))
         terms = full_lineage.split(":")
-        species = Species(terms, common_name)
+        species = Species(terms, common_name, ncbi_id)
         return species
 
     def _get_seq_version(self):


More information about the Biopython-dev mailing list