rotifer.db.local.core.FileCollection#

class rotifer.db.local.core.FileCollection(basedir='/databases/fadb', pattern='*.fa', recursive=True, checksum=True, ignore=[], **kwargs)[source]#

Bases: object

Index the data files found under a directory tree.

Scans basedir for files matching one or more glob patterns and collects the results in a dataframe, one row per file. Extra keyword arguments describe companion files to look up for each entry, each becoming an additional column.

Parameters:
basedirpath-like, default ‘/databases/fadb’

Root of the directory tree to scan.

patternstr or list of str, default ‘*.fa’

Glob pattern(s) identifying the data files. The matched suffix is stripped from each file name to build the entry name.

recursivebool, default True

Whether to descend into subdirectories.

checksumbool, default True

Whether to add a checksum column.

ignorelist of str, default []

Entry names to skip.

**kwargsdict

Companion file groups, one per resulting column. Each value is a dictionary with a pattern key and an optional basedir key, searched relative to the entry name. A group that matches nothing yields None, a single match yields the path itself and several matches yield a list.

Attributes:
dfpandas.DataFrame

One row per data file, with the name and path columns plus any companion columns named by kwargs.

Notes

Passing checksum=True (the default) appends a checksum column name without producing a matching value, so building the dataframe raises a length mismatch; hashlib is imported but never used. See docs/OPEN_QUESTIONS.md.

Examples

>>> from rotifer.db.local.core import FileCollection
>>> fc = FileCollection(basedir="/databases/fadb", checksum=False)
>>> fc.df.head()
__getitem__(key)[source]#

Fetch a row of the underlying dataframe.

Parameters:
keylabel

Row label, as accepted by pandas.DataFrame.loc.

Returns:
pandas.Series

The row describing one indexed file.

keys()[source]#

List the row labels of the underlying dataframe.

Returns:
list

The dataframe index, as a list.