rotifer.db.local.core.FileCollection#
- class rotifer.db.local.core.FileCollection(basedir='/databases/fadb', pattern='*.fa', recursive=True, checksum=True, ignore=[], **kwargs)[source]#
Bases:
objectIndex the data files found under a directory tree.
Scans
basedirfor 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
checksumcolumn.- ignorelist of str, default []
Entry names to skip.
- **kwargsdict
Companion file groups, one per resulting column. Each value is a dictionary with a
patternkey and an optionalbasedirkey, 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
nameandpathcolumns plus any companion columns named bykwargs.
Notes
Passing
checksum=True(the default) appends achecksumcolumn name without producing a matching value, so building the dataframe raises a length mismatch;hashlibis imported but never used. Seedocs/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.