sugar._io.tab.xsv module

TSV, CSV and XSV file formats IO

TSV and CSV use the same functions under the hood, and just use a different default value for the sep option defining the separator character. In general, arbitrary characters can be used to separate the values (XSV).

sugar._io.tab.xsv.is_fts_csv(f, sep=',', **kw)[source]
sugar._io.tab.xsv.is_fts_tsv(f, sep='\t', **kw)[source]
sugar._io.tab.xsv.read_fts_csv(f, sep=',', **kw)[source]

Read comma separated value (CSV) files with feature information

Parameters:
  • sep (str) – Separator of the fields, defaults to ','

  • ftype (str) – Parameter used as feature type, if parameter is not present use the value of ftype itself.

  • **kw – All other kwargs are passed to pandas.read_csv()

Warning

This function should NOT be called directly, it registers via read_fts(), call this instead.

sugar._io.tab.xsv.read_fts_tsv(f, sep='\t', **kw)[source]

Read tab separated value (TSV) files with feature information

Parameters:
  • sep (str) – Separator of the fields, defaults to '\t'

  • ftype (str) – Parameter used as feature type, if parameter is not present use the value of ftype itself.

  • **kw – All other kwargs are passed to pandas.read_csv()

Warning

This function should NOT be called directly, it registers via read_fts(), call this instead.

sugar._io.tab.xsv.write_fts_csv(fts, f, sep=',', **kw)[source]

Write comma separated value (CSV) files with feature information

Parameters:
  • sep (str) – Separator of the fields, defaults to ','

  • keys – Parameters from the metadata or location to write, 'len' is also allowed, might be a string or tuple, defaults to 'type start stop strand'

  • **kw – All other kwargs are passed to pandas.DataFrame.to_csv()

Warning

This function should NOT be called directly, it registers via FeatureList.write(), call this instead.

sugar._io.tab.xsv.write_fts_tsv(fts, f, sep='\t', **kw)[source]

Write tab separated value (TSV) files with feature information

Parameters:
  • sep (str) – Separator of the fields, defaults to '\t'

  • keys – Parameters from the metadata or location to write, 'len' is also allowed, might be a string or tuple, defaults to 'type start stop strand'

  • **kw – All other kwargs are passed to pandas.DataFrame.to_csv()

Warning

This function should NOT be called directly, it registers via FeatureList.write(), call this instead.