Skip to content

Commit

Permalink
#182, don't return completionstamp
Browse files Browse the repository at this point in the history
  • Loading branch information
zqfang committed Dec 19, 2022
1 parent ce30a2e commit be3969a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
29 changes: 19 additions & 10 deletions gseapy/biomart.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from collections.abc import Iterable
from io import StringIO
from typing import Any, AnyStr, Dict, Iterable, List, Optional, Set, Tuple, Union
from xml.etree import cElementTree as ET

import pandas as pd
Expand All @@ -10,7 +11,7 @@
class Biomart:
"""query from BioMart"""

def __init__(self, host="www.ensembl.org", verbose=False):
def __init__(self, host: str = "www.ensembl.org", verbose: bool = False):
"""A wrapper of BioMart() from bioseverices.
How to query validated dataset, attributes, filters.
Expand Down Expand Up @@ -47,7 +48,7 @@ def __init__(self, host="www.ensembl.org", verbose=False):
"header": 0,
"uniqueRows": 1,
"configVersion": "0.6",
"completionStamp": 1,
"completionStamp": 0,
}

self.header = (
Expand All @@ -66,7 +67,7 @@ def __init__(self, host="www.ensembl.org", verbose=False):
# get supported marts
self._marts = self.get_marts()["name"].to_list()

def _set_host(self, host):
def _set_host(self, host: str):
"""set host"""

hosts = ["www.ensembl.org", "asia.ensembl.org", "useast.ensembl.org"]
Expand All @@ -93,7 +94,7 @@ def _set_host(self, host):
if i == len(hosts):
raise ValueError("host {} is not reachable. Please check your input")

def add_filter(self, name, value):
def add_filter(self, name: str, value: Iterable[str]):
"""
key: filter names
value: Iterable[str]
Expand All @@ -107,11 +108,11 @@ def add_filter(self, name, value):
_filter = """<Filter name="%s" value="%s"/>""" % (name, value)
self.filters_xml.append(_filter)

def add_attribute(self, attribute):
def add_attribute(self, attribute: str):
_attr = """<Attribute name="%s"/>""" % attribute
self.attributes_xml.append(_attr)

def add_dataset(self, dataset):
def add_dataset(self, dataset: str):
self.dataset_xml = """<Dataset name="%s" interface="default" >""" % dataset

def reset(self):
Expand Down Expand Up @@ -169,7 +170,7 @@ def get_datasets(self, mart="ENSEMBL_MART_ENSEMBL"):
return datasets
return resp.text

def get_attributes(self, dataset="hsapiens_gene_ensembl"):
def get_attributes(self, dataset: str = "hsapiens_gene_ensembl"):
"""Get available attritbutes from dataset you've selected"""
# assert dataset in

Expand All @@ -184,7 +185,7 @@ def get_attributes(self, dataset="hsapiens_gene_ensembl"):
return attributes
return resp.text

def get_filters(self, dataset="hsapiens_gene_ensembl"):
def get_filters(self, dataset: str = "hsapiens_gene_ensembl"):
"""Get available filters from dataset you've selected"""
# filters = super(Biomart, self).filters(dataset)
# if dataset not in [x for k in self.valid_attributes.keys() for x in self.valid_attributes[k]]:
Expand All @@ -206,7 +207,11 @@ def get_filters(self, dataset="hsapiens_gene_ensembl"):
return resp.text

def query(
self, dataset="hsapiens_gene_ensembl", attributes=[], filters={}, filename=None
self,
dataset: str = "hsapiens_gene_ensembl",
attributes: List[str] = [],
filters: Dict[str, Iterable[str]] = {},
filename: Optional[str] = None,
):
"""mapping ids using BioMart.
Expand Down Expand Up @@ -255,7 +260,11 @@ def query(
return df

def query_simple(
self, dataset="hsapiens_gene_ensembl", attributes=[], filters={}, filename=None
self,
dataset: str = "hsapiens_gene_ensembl",
attributes: List[str] = [],
filters: Dict[str, Iterable[str]] = {},
filename: Optional[str] = None,
):
"""
This function is a simple version of BioMart REST API.
Expand Down
1 change: 0 additions & 1 deletion gseapy/enrichr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
from collections import OrderedDict
from io import StringIO
from tempfile import TemporaryDirectory
from typing import Any, AnyStr, Dict, Iterable, List, Optional, Set, Tuple, Union

import pandas as pd
Expand Down

0 comments on commit be3969a

Please sign in to comment.