Commits

Aleš Erjavec committed 96417e1

Added all_edges_annotated interface to PPIDatabase.

Comments (0)

Files changed (1)

         """ Return a list of all edges (a list of 3-tuples (id1, id2, score)).
         """
         raise NotImplementedError
+    
+    def all_edges_annotated(self, taxid=None):
+        """ Return a list of all edges annotated. If taxid is not None
+        return the edges for this organism only.
+        
+        """
+        res = []
+        for id in self.ids(taxid):
+            res.extend(self.edges_annotated(id))
+        return res
         
     def edges_annotated(self, id=None):
         """ Return a list of all edges annotated
         """, (id, id))
         return cur.fetchall() 
         
+    def all_edges_annotated(self, taxid=None):
+        """ Return a list of all edges annotated. If taxid is not None
+        return the edges for this organism only.
+        
+        """
+        if taxid is not None:
+            cur = self.db.execute("""\
+                select *
+                from links left join proteins on 
+                    biogrid_id_interactor_a=biogrid_id_interactor or
+                    biogrid_id_interactor_b=biogrid_id_interactor
+                where organism_interactor=?
+            """, (taxid,))
+        else:
+            cur = self.db.execute("""\
+                select *
+                from links
+            """)
+        edges = cur.fetchall()
+        return edges
+        
         
     def edges_annotated(self, id):
         """ Return a list of all links
                       systematic_name_interactor=? or
                       official_symbol_interactor=? or
                       synonyms_interactor=?
-            """ (id,) * 5)
+            """, (id,) * 5)
     
     @classmethod
     def download_data(cls, address):
             where protein_id1=?
             """, (id,))
         return cur.fetchall()
+    
+    def all_edges_annotated(self, taxid=None):
+        """ Return a list of all edges annotated. If taxid is not None
+        return the edges for this organism only.
+        
+        """
+        res = []
+        for id in self.ids(taxid):
+            res.extend(self.edges_annotated(id))
+        return res
         
     def edges_annotated(self, id):
         """ Return a list of all edges annotated.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.