autopaths is a python package for dealing with file paths and automation.
Project description
# autopaths version 1.0.2
autopaths is a python package for dealing with file paths and automation.
It contains several submodules that are useful when building pipelines. See below for examples and documentation.
# FilePath object
Here is an example usage of this object:
from autopaths.file_path import FilePath f = FilePath(“input/raw/reads_56.fastq”) print(f.exists) print(f.extension) print(f.size) print(f.contains_binary) f.prepend(’# This file was backed-upn’) f.gzip_to(‘backup/old_reads/reads_56.fastq’)
As you can see, once you have created a FilePath, many useful methods are available. No more need for long os.path or shutil commands of which you can never remember the syntax.
To see the complete list of utility methods and properties, look at the source code. You can find lots of the common things you would need to do with file paths f.make_executable() etc etc.
# DirectoryPath object
Similar to a file path object. Here is an example usage of this object:
from autopaths.dir_path import DirectoryPath d = DirectoryPath(“cleaned/reads/”) print(d.mod_time) d.create_if_not_exists() f = d + ‘new.fastq’
# AutoPaths object
You can use this class like this when making pipelines to quickly refer to a predefined file path with a simple attribute lookup. This example explains it:
- class Sample(object):
- all_paths = ‘’’
/raw/raw.sff /raw/raw.fastq /clean/trim.fastq /clean/clean.fastq’’’
- def __init__(self, base_dir):
self.p = AutoPaths(base_dir, self.all_paths)
- def clean(self):
shutil.move(self.p.raw_sff, self.p.clean_fastq)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for autopaths-1.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df57d5c0c8c88131693fc2c6adfeef3d82e0b49bdc7cba38ff3431e2e2e7459d |
|
MD5 | f1aa419c37648c34b673420d1e9d460c |
|
BLAKE2b-256 | cb701a1b91eda4252c8ac460c1da6c3f7a2720524e9beeae5d4ca00b540183d6 |