Skip to content

Commit e661480

Browse files
committed
refactor xsv module
1 parent da643f8 commit e661480

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sugar/_io/tab/xsv.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
from sugar import FeatureList
77

88

9-
filename_extensions_fts_tsv = ['tsv']
109
filename_extensions_fts_csv = ['csv']
10+
filename_extensions_fts_tsv = ['tsv']
1111

1212

13-
def _is_xsv(f, sep, **kw):
13+
def _is_fts_xsv(f, sep, **kw):
1414
lines = f.read(1000).splitlines()[:-1]
1515
line0 = lines[0].split(sep)
1616
return ('start' in line0) + ('stop' in line0) + ('len' in line0) >= 2 and all(len(line.split(sep)) == len(line0) for line in lines)
1717

1818

19-
def is_fts_tsv(f, sep='\t', **kw):
20-
return _is_xsv(f, sep)
19+
def is_fts_csv(f, sep=',', **kw):
20+
return _is_fts_xsv(f, sep)
2121

2222

23-
def is_fts_csv(f, sep=',', **kw):
24-
return _is_xsv(f, sep)
23+
def is_fts_tsv(f, sep='\t', **kw):
24+
return _is_fts_xsv(f, sep)
2525

2626

2727
@_add_fmt_doc('read_fts')
@@ -35,7 +35,7 @@ def read_fts_tsv(f, sep='\t', **kw):
3535
:param \*\*kw: All other kwargs are passed to :func:`pandas.read_csv()`
3636
3737
"""
38-
return _read_xsv(f, sep=sep, **kw)
38+
return _read_fts_xsv(f, sep=sep, **kw)
3939

4040

4141
@_add_fmt_doc('read_fts')
@@ -48,7 +48,7 @@ def read_fts_csv(f, sep=',', **kw):
4848
of ftype itself.
4949
:param \*\*kw: All other kwargs are passed to :func:`pandas.read_csv()`
5050
"""
51-
return _read_xsv(f, sep=sep, **kw)
51+
return _read_fts_xsv(f, sep=sep, **kw)
5252

5353

5454
@_add_fmt_doc('write_fts')
@@ -63,7 +63,7 @@ def write_fts_tsv(fts, f, sep='\t', **kw):
6363
:param \*\*kw: All other kwargs are passed to :meth:`pandas.DataFrame.to_csv()`
6464
6565
"""
66-
return _write_xsv(fts, f, sep=sep, **kw)
66+
return _write_fts_xsv(fts, f, sep=sep, **kw)
6767

6868

6969
@_add_fmt_doc('write_fts')
@@ -77,10 +77,10 @@ def write_fts_csv(fts, f, sep=',', **kw):
7777
might be a string or tuple, defaults to ``'type start stop strand'``
7878
:param \*\*kw: All other kwargs are passed to :meth:`pandas.DataFrame.to_csv()`
7979
"""
80-
return _write_xsv(fts, f, sep=sep, **kw)
80+
return _write_fts_xsv(fts, f, sep=sep, **kw)
8181

8282

83-
def _read_xsv(f, ftype=None, **kw):
83+
def _read_fts_xsv(f, ftype=None, **kw):
8484
try:
8585
import pandas
8686
except ImportError:
@@ -89,7 +89,7 @@ def _read_xsv(f, ftype=None, **kw):
8989
return FeatureList.frompandas(df, ftype=ftype)
9090

9191

92-
def _write_xsv(fts: FeatureList, f, vals='type start stop strand', dtype=None, index=False, **kw):
92+
def _write_fts_xsv(fts: FeatureList, f, vals='type start stop strand', dtype=None, index=False, **kw):
9393
try:
9494
df = fts.topandas(vals, dtype=dtype)
9595
except ImportError:

0 commit comments

Comments
 (0)