Skip to main content

A set of tools to retrieve information from filepaths.

Project description

Path2Insight

travis readthedocs

Path2Insight (p2i) is a modular and scalable python module which aims at offering a unified and comprehensive set of processing tools for analyzing file paths. P2i supports static file systems analysis without requiring access to the original physical storage. Basically, a scan of the storage’s content exported as a text file suffices to explore the saved resources. There is also no need to access the content of the files as the p2i module import file paths as strings.

Once loaded, the file paths are stored in-memory as a python object enabling: preprocessing, text processing and descriptive analysis of folders and files.

Preprocessing: Sample, sort and select files based on multiple criteria (e.g. parent folder, depth).

Text processing: Chunk file paths into tokens (full path, stem and name), n-grams or complete paths with the help of several extensible tokenizers. Also, taggers offer the option to aggregate files based on their structure and content (which prepare paths for further analysis such as entity recognition or classification tasks).

Descriptive analysis: P2i implements counters for tokens, stems and extensions. It supports also statistical features such as X2 tests on the distribution of extensions, stems and names. Further, a representation of the complexity of the folder structure is facilitated by folder-depth analysis functionalities.

The table below shows how Path2Insight differ and complement functionalities offered by lower-level python modules (pathlib and os.path).

Functionality

P2i

Pathlib

os.path

Preprocessing

Pathlib + Sampling, sorting, selection

match, joinpath

Normcase, norm path

Descriptive statistics

Counters: stem, extension, name. Taggers. Tokenizers

os.stat

os.stat

Text processing

Pathlib + Tokens, n-grams, taggers, lower, upper,…

Stem, name, parent, extension drive, …

Split

Access or modify information on the system

No, can be linked to additional metadata (datetimes, users) by joining on the full path

Yes, chmod, current folder. …

Yes, user, size, datetimes, descriptors, …

P2i is dependency free (only pathlib2 is required for Python 2.7 users), fast and scalable path processing toolkit. It is compliant with the major data analysis python modules such as pandas, scikit-learn, nltk and matplotlib to extent the analytical possibilities of path2insight.

Example

Import the module and load a demo dataset with static file paths (or use path2insight.walk to collect from you file system).

>>> import path2insight
>>> from path2insight.datasets import load_ensembl

>>> filepaths = load_ensembl()
>>> path2insight.depth_counts(filepaths)
Counter({3: 1, 4: 11, 5: 39424, 6: 5543, 7: 2733, 8: 3388})
>>> path2insight.token_counts(filepaths).most_common(10)
[('txt', 31977),
 ('gene', 13798),
 ('ensembl', 12727),
 ('dm', 12500),
 ('homolog', 7380),
 ('fa', 5890),
 ('chromosome', 5011),
 ('feature', 4878),
 ('dna', 4608),
 ('90', 3404)]
>>> path2insight.extension_counts(filepaths).most_common(10)
[('.gz', 44427),
 ('', 3094),
 ('.bb', 847),
 ('.nsq', 349),
 ('.nin', 349),
 ('.nhr', 349),
 ('.tsv', 336),
 ('.psq', 250),
 ('.pin', 250),
 ('.phr', 250)]
>>> path2insight.select_re(filepaths, level5='micro.*')
[PosixFilePath('/Volumes/release-90/variation/VEP/microtus_ochrogaster_vep_90_MicOch1.0.tar.gz'),
 PosixFilePath('/Volumes/release-90/variation/VEP/microtus_ochrogaster_refseq_vep_90_MicOch1.0.tar.gz'),
 PosixFilePath('/Volumes/release-90/variation/VEP/microtus_ochrogaster_merged_vep_90_MicOch1.0.tar.gz'),
 PosixFilePath('/Volumes/release-90/variation/VEP/microcebus_murinus_vep_90_Mmur_2.0.tar.gz'),
 PosixFilePath('/Volumes/release-90/rdf/microtus_ochrogaster/microtus_ochrogaster_xrefs.ttl.gz.graph'),
>>> path2insight.distance_on_token(filepaths[0:10])
array([[ 0.        ,  2.        ,  1.41421356,  3.        ,  3.        ],
       [ 2.        ,  0.        ,  2.44948974,  3.31662479,  3.31662479],
       [ 1.41421356,  2.44948974,  0.        ,  3.        ,  3.        ],
       [ 3.        ,  3.31662479,  3.        ,  0.        ,  1.41421356],
       [ 3.        ,  3.31662479,  3.        ,  1.41421356,  0.        ]])

Installation and dependencies

Path2Insight is available on Pypi. This make it possible to install it with through:

pip install path2insight

To upgrade path2insight use

pip install --upgrade path2insight

Path2Insight is available for Python 2.7 and Python 3.4+. Path2Insight depends heavily on the pathlib module. This module is part of Python 3.4 or higher. For Python 2, the backport pathlib2 is used. Therefore, it is advised to use Path2Insight with Python 3.4 or higher.

Some of the submodules of Path2Insight depend on other Python packages (numpy, pandas, sklearn, scipy, jellyfish). One can get a full installation by installing the packages in the requirements-full.txt file.

pip install -r requirements-full.txt

Cite

Follows.

Authors

  • Armel Lefebvre

  • Jonathan de Bruin

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

path2insight-1.0b2.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

path2insight-1.0b2-py2.py3-none-any.whl (1.6 MB view details)

Uploaded Python 2Python 3

File details

Details for the file path2insight-1.0b2.tar.gz.

File metadata

  • Download URL: path2insight-1.0b2.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for path2insight-1.0b2.tar.gz
Algorithm Hash digest
SHA256 32db51b2dce585b5e9f4ba446590695ecf0c9877ee4f7b6745ac92bb4627e747
MD5 061a4cf5c41fcde4c0655a20244cdce2
BLAKE2b-256 05ed6f919bc4de9f0b0a21e2e68786c9ea96ca4634ca3e9c1eb288152a76fe88

See more details on using hashes here.

File details

Details for the file path2insight-1.0b2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for path2insight-1.0b2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d618de89d5d131abacb717f6a4b0e5451f29a4eb76a5e2660e1972c34f4801b
MD5 ee0de692aa8889d317ac07bd89341eed
BLAKE2b-256 a3eba21d19530150551e9eaca37f433abd99b09d0d29c7d7213ce99711532fef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page