PhytoMiner
This is a package for fetching Phytozome data
A Python library for efficiently fetching and processing gene homolog data from the Phytozome database via its InterMine API.
This library is designed to simplify complex, iterative bioinformatic queries, allowing researchers to trace gene homology across multiple species with ease.
Features
- Three-Step Pipeline: A clear, sequential workflow for fetching homologs, merging local data, and retrieving detailed gene information.
- Iterative Search: Automatically performs chained searches using homologs found in previous steps to build a comprehensive dataset.
- Parallel Processing: Utilizes multithreading for efficient, parallel data fetching, significantly speeding up large queries.
- Checkpointing: Automatically saves and loads intermediate results to prevent losing progress and allow for easy resumption of long-running jobs.
- Data Processing & Visualization: Includes functions to clean, de-duplicate, and enrich data, plus a utility to quickly generate a heatmap of homolog distribution.
Installation
You can install the latest PhytoMiner release directly from PyPI:
pip install phytominer
Usage
Here is a complete example of the three-step workflow:
Define a set of known genes in a source organism (e.g., A. thaliana). Run homologs_pipe to find homologs in other species. Run join_tsvs to combine the homolog data with local metadata from TSV files. Run genes_pipe to fetch detailed gene data for the final homolog set.
import logging
from phytominer.workflow import step1_homolog_pipe, step2_merge_pipe, step3_gene_pipe
# It's highly recommended to configure logging to see the progress
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# 1. Define initial search parameters
# The initial organism to start the search from
initial_organism = "A. thaliana TAIR10"
# A dictionary of initial gene IDs and their corresponding subunit names
initial_genes = {
"AT1G01090": "NDHA",
"AT1G01120": "NDHB",
"ATCG00520": "NDHC",
}
# A list of other organisms to find homologs in
subsequent_organisms = [
"S. bicolor v3.1.1",
"O. sativa Kitaake v3.1",
"S. viridis v2.1"
]
# 2. Run the three-step pipeline
# Step 1: Fetch all homolog data, starting with the initial organism
# and iterating through the subsequent ones.
step1_df = homologs_pipe(
initial_organism=initial_organism,
initial_genes_dict=initial_genes,
subsequent_organisms=subsequent_organisms
)
# Step 2: Merge the homolog data with local TSV files containing additional metadata.
# This step assumes you have a directory with TSV files (e.g., 'data/tsv/').
step2_df = join_tsvs()
# Step 3: Fetch detailed gene data (e.g., expression, sequence) for the homologs found.
step3_df = genes_pipe()
# The final DataFrames are saved to CSV files at each step (e.g., step1output.csv).
print("PhytoMiner workflow complete!")
API Overview
The phytominer library is structured around a sequential, three-step workflow.
Workflow Functions These are the main functions you'll use, found in phytominer.workflow.
homologs_pipe(...): Orchestrates the entire homolog search. It starts with an initial set of genes, finds their homologs, and then iteratively searches for homologs of the results in other specified organisms. It handles checkpointing and produces a final, processed DataFrame of homolog data. join_tsvs(...): Takes the output from Step 1 and merges it with local TSV files containing supplementary data (e.g., subunit validation). genes_pipe(...): Takes the output from Step 2 and fetches detailed gene information (sequences, expression data, etc.) for all unique homologs identified in the pipeline.
Utility Functions
These helper functions are available in phytominer.utils.
pivotmap(dataframe, ...): Generates a pivot table and a corresponding heatmap to visualize the count of homologs across different species and subunits. log_summary(df, ...): Logs a concise summary of a DataFrame's shape, columns, memory usage, and other key statistics.
Continuous Integration & Deployment
This project uses GitHub Actions for automated testing and publishing.
- Automated Testing:
Every push to themainbranch triggers the test suite using Python 3.9. - Automated Publishing:
When a new release is published on GitHub, the package is automatically built and uploaded to PyPI.
You can find the workflow configuration in .github/workflows/python-publish.yml.
Contributing
Contributions are welcome! If you have a suggestion or find a bug, please open an issue. Pull requests are also encouraged.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
Running Tests Locally
To run the test suite locally:
pip install -e .[dev]
pytest
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
Author: Kris Kari Email: toffe.kari@gmail.com
Metadata
Release files for phytominer 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| phytominer-0.2.0.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| phytominer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.1 kB
Release files / phytominer-0.2.0.tar.gz
| Download URL | phytominer-0.2.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
337ec1530a8db00964858c4c1f3dce81db26d2d8db208e0e347dcc3410895d5a
|
|
BLAKE2b-256 checksum How to use checksums |
44b08119a3e3a106707c81a879de41382ea47ed4e39442d8b336980114e0ff99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.
Transparency logRelease files / phytominer-0.2.0-py3-none-any.whl
| Download URL | phytominer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e0e65c6a24982551e172f94e279ca1a8bb4f9bfead7ed3ec8420d7b9672f6bc
|
|
BLAKE2b-256 checksum How to use checksums |
83dba690b69a757b9b35655471e161acf79a69f732d3116ebbb0d1df38c37119
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.
Transparency log