Utils
A module for shared utilities used in GFFtk.
- gfftk.utils.check_file_type(filepath)
Checks if a file is text, gzipped binary, or other binary.
- gfftk.utils.filter_annotations(annotations, grep=None, grepv=None)
Filter annotations based on grep and grepv patterns.
- Parameters:
- Returns:
Filtered annotation dictionary
- Return type:
Examples
# Keep only genes with “kinase” in product filtered = filter_annotations(genes, grep=[“product:kinase”])
# Remove genes from specific source filtered = filter_annotations(genes, grepv=[“source:augustus”])
# Case-insensitive matching filtered = filter_annotations(genes, grep=[“product:kinase:i”])
- gfftk.utils.is_gzipped(filepath)
Checks if a file is gzipped.
- gfftk.utils.is_text_file(filepath)
Checks if a file is likely a text file.
- gfftk.utils.test_table2asn_functional()
Test if table2asn binary is functional by running it with -help flag.
- Returns:
True if table2asn runs successfully, False otherwise
- Return type:
- gfftk.utils.zopen(filename, mode='r', buff=1048576, external=2)
Open pipe, zipped, or unzipped file automagically
# external == 0: normal zip libraries # external == 1: (zcat, gzip) or (bzcat, bzip2) # external == 2: (pigz -dc, pigz) or (pbzip2 -dc, pbzip2)