Skip to content

Commit

Permalink
Change docstring format to Google style
Browse files Browse the repository at this point in the history
  • Loading branch information
robertopreste committed Aug 31, 2019
1 parent 3029713 commit 733285f
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 181 deletions.
117 changes: 56 additions & 61 deletions apyhgnc/apyhgnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,97 @@


def info() -> Info:
"""
Retrieve basic information from HGNC.
:return: Info
"""Retrieve basic information from HGNC.
Example::
Returns:
Info
>>> i = apyhgnc.info()
>>> i.searchableFields # list of searchable fields
>>> i.storedFields # list of stored fields
>>> i.lastModified # date of last HGNC database modification
>>> i.numDoc # number of entries in HGNC database
Examples:
>>> i = apyhgnc.info()
>>> i.searchableFields # list of searchable fields
>>> i.storedFields # list of stored fields
>>> i.lastModified # date of last HGNC database modification
>>> i.numDoc # number of entries in HGNC database
"""
i = Info()
return i


def search(*args, **kwargs) -> pd.DataFrame:
"""
Launch a synchronous search on HGNC.
:param args: either a single term to search all available fields,
or a specific field and term to restrich the search
:param kwargs: one or more keywork arguments with a field and a
string or list of strings representing the search term(s)
:return: pd.DataFrame
Example::
>>> apyhgnc.search("BRAF") # search all searchable fields
>>> apyhgnc.search("symbol", "BRAF") # restrict search to symbol field
>>> apyhgnc.search(symbol="BRAF") # search with a keyword argument
>>> apyhgnc.search(symbol=["BRAF", "ZNF"]) # search with OR
>>> apyhgnc.search(symbol="BRAF", status="Approved") # search multiple keywords
"""Launch a synchronous search on HGNC.
Args:
*args: either a single term to search all available fields,
or a specific field and term to restrich the search
**kwargs: one or more keywork arguments with a field and a
string or list of strings representing the search term(s)
Returns:
pd.DataFrame
Examples:
>>> apyhgnc.search("BRAF") # search all searchable fields
>>> apyhgnc.search("symbol", "BRAF") # restrict search to symbol field
>>> apyhgnc.search(symbol="BRAF") # search with a keyword argument
>>> apyhgnc.search(symbol=["BRAF", "ZNF"]) # search with OR
>>> apyhgnc.search(symbol="BRAF", status="Approved") # search multiple keywords
"""
s = Search(*args, **kwargs)
return s.query()


async def asearch(*args, **kwargs) -> pd.DataFrame:
"""
Launch an asynchronous search on HGNC.
"""Launch an asynchronous search on HGNC.
:param args: either a single term to search all available fields,
or a specific field and term to restrich the search
Args:
*args: either a single term to search all available fields,
or a specific field and term to restrich the search
**kwargs: one or more keywork arguments with a field and a
string or list of strings representing the search term(s)
:param kwargs: one or more keywork arguments with a field and a
string or list of strings representing the search term(s)
Returns:
pd.DataFrame
:return: pd.DataFrame
Example::
>>> import asyncio
>>> loop = asyncio.get_event_loop()
>>> loop.run_until_complete(apyhgnc.asearch("symbol", "BRAF"))
Example:
>>> import asyncio
>>> loop = asyncio.get_event_loop()
>>> loop.run_until_complete(apyhgnc.asearch("symbol", "BRAF"))
"""
s = Search(*args, **kwargs)
return await s.aquery()


def fetch(field: str, term: Union[str, int]) -> pd.DataFrame:
"""
Launch a synchronous fetch from HGNC.
:param str field: HGNC field to query
"""Launch a synchronous fetch from HGNC.
:param Union[str,int] term: query term
Args:
field (str): HGNC field to query
term (Union[str,int]): query term
:return: pd.DataFrame
Returns:
pd.DataFrame
Example::
>>> apyhgnc.fetch("symbol", "ZNF3")
Example:
>>> apyhgnc.fetch("symbol", "ZNF3")
"""
f = Fetch(field, term)
return f.query()


async def afetch(field: str, term: Union[str, int]) -> pd.DataFrame:
"""
Launch an asynchronous fetch from HGNC.
:param str field: HGNC field to query
:param Union[str,int] term: query term
"""Launch an asynchronous fetch from HGNC.
:return: pd.DataFrame
Args:
field (str): HGNC field to query
term (Union[str,int]): query term
Example::
Returns:
pd.DataFrame
>>> import asyncio
>>> loop = asyncio.get_event_loop()
>>> loop.run_until_complete(apyhgnc.afetch("symbol", "ZNF3"))
Example:
>>> import asyncio
>>> loop = asyncio.get_event_loop()
>>> loop.run_until_complete(apyhgnc.afetch("symbol", "ZNF3"))
"""
f = Fetch(field, term)
return await f.aquery()
Loading

0 comments on commit 733285f

Please sign in to comment.