Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Jul 26, 2021
1 parent 48183a4 commit 807594d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions src/bioservices/biocarta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# documentation: http://packages.python.org/bioservices
#
##############################################################################
#$Id$
"""Interface to some part of the UniProt web service
.. topic:: What is UniProt ?
Expand Down Expand Up @@ -50,7 +49,7 @@

from bs4 import BeautifulSoup
from bioservices.services import REST
from bioservices.xmltools import readXML, HTTPError
from bioservices.xmltools import readXML


__all__ = ["BioCarta"]
Expand Down Expand Up @@ -108,7 +107,8 @@ def _get_organism(self):

def _set_organism(self, organism):
organism = organism[:1].upper() + organism[1:].lower()
if organism == self._organism: return
if organism == self._organism:
return
if organism not in BioCarta.organisms:
raise ValueError("Invalid organism. Check the list in :attr:`organisms` attribute")

Expand All @@ -120,7 +120,7 @@ def _set_organism(self, organism):

def _get_pathway_categories(self):
if self._pathway_categories is None:
self._pathway_categories = self.services.http_get_ou_post()
self._pathway_categories = self.services.http_get
return self._pathway_categories
pathway_categories = property(_get_pathway_categories)

Expand Down Expand Up @@ -160,7 +160,7 @@ def get_pathway_protein_names(self, pathway):
"""
self.logging.info("Fetching the pathway")
self.services.logging.info("Fetching the pathway")
# first identify gene from GeneInfo tag
# this is not XML but HTML
url = "http://cgap.nci.nih.gov/Pathways/BioCarta/%s" % pathway
Expand All @@ -171,7 +171,7 @@ def get_pathway_protein_names(self, pathway):

links = set([link.attrs['href'] for link in links])

self.logging.info("Scanning information about %s genes" % len(links))
self.services.logging.info("Scanning information about %s genes" % len(links))
# open each page and get info
genes = {}
for link in links:
Expand All @@ -181,19 +181,22 @@ def get_pathway_protein_names(self, pathway):
table_gene_info = soup.findAll("table")[1]

gene_name = link.rsplit("=", 1)[1]
self.logging.info(" - " + gene_name)
self.services.logging.info(" - " + gene_name)

genes[gene_name] = {}
self.tt = table_gene_info
for row in table_gene_info.find_all('tr'):
entry = row.find_all('td')
try:key = entry[0].text.strip()
except:continue
try:value = entry[1].text.strip()
except:continue
try:
key = entry[0].text.strip()
except:
continue
try:
value = entry[1].text.strip()
except:
continue
if "[Text]" in key:
continue
genes[gene_name][key] = value


return genes
2 changes: 1 addition & 1 deletion test/webservices/test_biocarta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from bioservices import BioCarta

def _test_biocarta():
def test_biocarta():

b = BioCarta()
res = b.get_pathway_protein_names('h_RELAPathway')
Expand Down

0 comments on commit 807594d

Please sign in to comment.