Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable passing encoding #51

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pybiopax/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,27 @@ def model_from_owl_file(fname: Union[str, pathlib.Path, os.PathLike],
return model_from_owl_str(owl_str)


def model_from_owl_gz(path: Union[str, pathlib.Path, os.PathLike]) \
-> BioPaxModel:
def model_from_owl_gz(
path: Union[str, pathlib.Path, os.PathLike],
encoding: Optional[str] = None,
) -> BioPaxModel:
"""Return a BioPAX Model from an OWL file (gzipped).

Parameters
----------
path :
A path to a gzipped OWL file of BioPAX content.
encoding :
The encoding to read the file with. Defaults to the
system default. Sometimes, windows users will need to
explicitly set this to utf-8.

Returns
-------
:
A BioPAX Model deserialized from the OWL file.
"""
with gzip.open(path, 'rt') as fh:
with gzip.open(path, 'rt', encoding=encoding) as fh:
return BioPaxModel.from_xml(etree.parse(fh).getroot())


Expand Down
Loading