Skip to content

Commit

Permalink
remove unused utils
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Jul 10, 2024
1 parent 593425b commit cdc281f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
33 changes: 0 additions & 33 deletions src/nplinker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,6 @@ def wrapper_check_disk_space(*args, **kwargs):
#


def find_delimiter(file: str | PathLike) -> str:
"""Detect the delimiter for the given tabular file.
Args:
file: Path to tabular file.
Returns:
Detected delimiter character.
Examples:
>>> delim = find_delimiter("~/table.csv")
"""
sniffer = csv.Sniffer()
with open(file, mode="rt", encoding="utf-8") as fp:
delimiter = sniffer.sniff(fp.read(5000)).delimiter
return delimiter


def get_headers(file: str | PathLike) -> list[str]:
"""Read headers from the given tabular file.
Args:
file: Path to the file to read the header from.
Returns:
A list of column names from the header.
"""
with open(file) as f:
headers = f.readline().strip()
dl = find_delimiter(file)
return headers.split(dl)


def is_file_format(file: str | PathLike, format: str = "tsv") -> bool:
"""Check if the file is in the given format.
Expand Down
11 changes: 0 additions & 11 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
from tempfile import mkdtemp
import pytest
from nplinker import utils
from nplinker.utils import find_delimiter
from . import GNPS_DATA_DIR


@pytest.mark.parametrize(
"filename, expected",
[[GNPS_DATA_DIR / "nodes.tsv", "\t"], [GNPS_DATA_DIR / "nodes_mwe.csv", ","]],
)
def test_find_delimiter(filename, expected):
actual = find_delimiter(filename)
assert actual == expected


BGC_GBK_URL = "https://mibig.secondarymetabolites.org/repository/BGC0000001/BGC0000001.gbk"
Expand Down

0 comments on commit cdc281f

Please sign in to comment.