physicell-settings


Namephysicell-settings JSON
Version 0.4.4 PyPI version JSON
download
home_pagehttps://github.com/mruscone/PhysiCell_Settings
SummaryUser-friendly Python package for generating PhysiCell_settings.xml configuration files
upload_time2025-08-08 20:50:36
maintainerNone
docs_urlNone
authorMarco Ruscone
requires_python>=3.8
licenseNone
keywords physicell multicellular simulation biology computational-biology bioinformatics cancer tissue xml configuration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PhysiCell Settings

A powerful, modular Python package for generating PhysiCell_settings.xml configuration files with comprehensive parameter coverage, intuitive API design, and maintainable architecture.

[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![PyPI version](https://img.shields.io/pypi/v/physicell-settings.svg)](https://pypi.org/project/physicell-settings/)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

## ๐Ÿš€ Overview

The PhysiCell Settings package provides a powerful yet simple API for creating complex PhysiCell simulations. Built with a modern modular architecture, it handles all aspects of PhysiCell configuration with a focus on ease of use, maintainability, and compatibility with existing PhysiCell standards.

## ๐Ÿ“ฆ Installation

Install from PyPI using pip:

```bash
pip install physicell-settings
```

**Requirements:**
- Python 3.8 or higher
- No external dependencies (uses only Python standard library)

## ๐Ÿš€ Quick Start

```python
import physicell_config
from physicell_config import PhysiCellConfig

# Create a new configuration
config = PhysiCellConfig()

# Set up simulation domain
config.domain.set_bounds(x_min=-500, x_max=500, y_min=-500, y_max=500)

# Add substrates
config.substrates.add_substrate(
    name="oxygen", 
    diffusion_coefficient=100000.0,
    decay_rate=0.1
)

# Add cell type
config.cell_types.add_cell_type(
    name="cancer_cell",
    cycle_model="Ki67_basic"
)

# Save configuration
config.save("PhysiCell_settings.xml")
```

## ๐Ÿ”„ **NEW: Bidirectional XML Support**

**Load, modify, and save existing PhysiCell configurations!**

```python
# Load existing PhysiCell configuration
config = PhysiCellConfig()
config.load_xml("existing_simulation.xml")

# Modify as needed
config.domain.set_bounds(-600, 600, -400, 400)
config.substrates.add_substrate("my_drug", diffusion_coefficient=1000.0)

# Add cell rules
rules = config.cell_rules_csv
rules.add_rule("cancer_cell", "oxygen", "decreases", "necrosis", 0, 3.75, 8, 0)

# Save modified configuration
config.save_xml("modified_simulation.xml")
```

**Features:**
- โœ… **Complete XML Loading** - Load any existing PhysiCell configuration
- โœ… **Perfect Data Preservation** - Round-trip loading maintains all data
- โœ… **PhysiBOSS Support** - Full intracellular model loading and saving
- โœ… **Robust Validation** - Clear error messages for invalid XML files
- โœ… **Cell Rules Integration** - Preserve and modify existing rule configurations

[๐Ÿ“– **Full Documentation: BIDIRECTIONAL_XML_SUPPORT.md**](BIDIRECTIONAL_XML_SUPPORT.md)

## ๐Ÿšง Development Status

**Current Version:** 0.1.0 (Beta)

This package is currently in active development. While it's functional and available on PyPI, some features are still being refined and additional functionality is being added.

### โœ… **What's Working:**
- Core configuration generation
- All major PhysiCell modules (domain, substrates, cell types, etc.)
- PyPI installation and basic usage
- Modular architecture

### ๐Ÿ”„ **In Progress:**
- Additional validation and error handling
- Enhanced documentation and examples
- Extended API coverage for advanced features
- Performance optimizations

### ๐Ÿ“‹ **Planned Features:**
- Advanced parameter validation
- Configuration templates
- Migration tools from legacy formats
- Enhanced PhysiBoSS integration

**Note:** The repository is currently private as we finalize features and documentation. The package is stable for basic use cases.

## โœจ Key Features

- **๐Ÿ—๏ธ Modular Architecture** - Well-organized, maintainable codebase with focused modules
- **๐ŸŽฏ Simple & Intuitive** - Clean API with sensible defaults and method chaining
- **๐Ÿ”ง Comprehensive Coverage** - All PhysiCell features: domain, substrates, cells, rules, PhysiBoSS
- **โœ… Built-in Validation** - Configuration validation with detailed error reporting
- **๐Ÿ”„ Full Compatibility** - Generates standard PhysiCell XML, reproduces existing configs
- **๐Ÿงฌ Advanced Features** - Cell rules, PhysiBoSS integration, initial conditions, enhanced visualization
- **๐Ÿ“Š Cell Rules CSV** - Context-aware generation of rules.csv files with signal/behavior validation
- **๐Ÿ“š Well Documented** - Extensive examples and clear modular documentation

### ๐ŸŽฏ Perfect For

- **Researchers** building new PhysiCell models with complex requirements
- **Developers** programmatically generating parameter sweeps and batch simulations
- **Teams** collaborating on large simulation projects with maintainable code
- **Educators** teaching computational biology with clear, reproducible examples

## ๐Ÿ—๏ธ Modular Architecture

The configuration builder uses a modular composition pattern that provides:

- **Clean Separation**: Each module handles one aspect of configuration
- **Easy Maintenance**: Small, focused files instead of monolithic code
- **Team Development**: Multiple developers can work on different modules
- **Extensibility**: Easy to add new modules without affecting existing code

### Module Structure

```
โ”œโ”€โ”€ config_builder_modular.py       # Main configuration class
โ””โ”€โ”€ modules/
    โ”œโ”€โ”€ domain.py                # Simulation domain and mesh
    โ”œโ”€โ”€ substrates.py            # Microenvironment substrates  
    โ”œโ”€โ”€ cell_types.py            # Cell definitions and phenotypes
    โ”œโ”€โ”€ cell_rules.py            # Cell behavior rules
    โ”œโ”€โ”€ cell_rules_csv.py        # rules.csv generation with context awareness
    โ”œโ”€โ”€ physiboss.py             # PhysiBoSS boolean networks
    โ”œโ”€โ”€ initial_conditions.py    # Initial cell placement
    โ”œโ”€โ”€ save_options.py          # Output and visualization
    โ””โ”€โ”€ options.py               # Simulation parameters
```

## ๐Ÿš€ Quick Start

### Installation

The package is available on PyPI for easy installation:

```bash
pip install physicell-settings
```

### Basic Usage

```python
import physicell_config
from physicell_config import PhysiCellConfig

# Create configuration
config = PhysiCellConfig()

# Set up simulation domain
config.domain.set_bounds(x_min=-400, x_max=400, y_min=-400, y_max=400)

# Add substrates
config.substrates.add_substrate(
    name="oxygen", 
    diffusion_coefficient=100000.0,
    decay_rate=0.1
)

# Add cell type
config.cell_types.add_cell_type(
    name="cancer_cell",
    cycle_model="Ki67_basic"
)
```

### Advanced Modular Usage

```python
# Direct module access for advanced features
config.domain.set_bounds(-500, 500, -500, 500)
config.substrates.add_substrate("glucose", diffusion_coefficient=50000.0)

config.cell_types.add_cell_type("immune_cell")
config.cell_types.set_motility("immune_cell", speed=2.0, enabled=True)
config.cell_types.add_secretion("immune_cell", "oxygen", uptake_rate=5.0)

config.cell_rules.add_rule("oxygen", "proliferation", "cancer_cell")
config.physiboss.enable_physiboss("boolean_model.bnd")
config.initial_conditions.add_cell_cluster("cancer_cell", x=0, y=0, radius=100)
```

## ๐Ÿ“– Examples

### Complete Tumor-Immune Simulation

```python
from config_builder_modular import PhysiCellConfig

# Create configuration
config = PhysiCellConfig()

# Setup domain  
config.domain.set_bounds(-600, 600, -600, 600)
config.domain.set_mesh(20.0, 20.0)

# Add substrates
config.substrates.add_substrate("oxygen", 
    diffusion_coefficient=100000.0,
    decay_rate=0.1, 
    initial_condition=38.0)

config.substrates.add_substrate("glucose",
    diffusion_coefficient=50000.0,
    decay_rate=0.01,
    initial_condition=10.0)

# Add cell types
config.cell_types.add_cell_type("cancer_cell")
config.cell_types.set_motility("cancer_cell", speed=0.5, enabled=True)
config.cell_types.add_secretion("cancer_cell", "oxygen", uptake_rate=10.0)

config.cell_types.add_cell_type("immune_cell")  
config.cell_types.set_motility("immune_cell", speed=2.0, enabled=True)

# Add initial conditions
config.initial_conditions.add_cell_cluster("cancer_cell", x=0, y=0, radius=150, num_cells=100)
config.initial_conditions.add_cell_cluster("immune_cell", x=300, y=300, radius=50, num_cells=20)

# Add cell rules to XML
config.cell_rules.add_rule(
    signal="oxygen",
    behavior="proliferation",
    cell_type="cancer_cell",
    min_signal=0.0,
    max_signal=38.0,
    min_behavior=0.0,
    max_behavior=0.05
)

# Configure visualization
config.save_options.set_svg_options(
    interval=120.0,
    plot_substrate=True,
    substrate_to_plot="oxygen",
    cell_color_by="cell_type"
)

# Save configuration
config.save_xml("tumor_immune_simulation.xml")
```

### Loading Cell Rules from CSV

```python
# Create rules CSV file
import csv

rules = [
    {"signal": "oxygen", "behavior": "proliferation", "cell_type": "cancer_cell", 
     "min_signal": 0.0, "max_signal": 38.0, "min_behavior": 0.0, "max_behavior": 0.05},
    {"signal": "pressure", "behavior": "apoptosis", "cell_type": "cancer_cell",
     "min_signal": 0.0, "max_signal": 1.0, "min_behavior": 0.0, "max_behavior": 0.1}
]

with open("cell_rules.csv", "w", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=rules[0].keys())
    writer.writeheader()
    writer.writerows(rules)

# Load rules in configuration
config.cell_rules.load_rules_from_csv("cell_rules.csv")
```

## ๐Ÿงช Testing and Validation

### Run Demo
```bash
python demo_modular.py
```

### Configuration Validation
```python
# Built-in validation
issues = config.validate()
if issues:
    for issue in issues:
        print(f"โš ๏ธ  {issue}")
else:
    print("โœ… Configuration is valid!")

# Get configuration summary
summary = config.get_summary()
print(f"Substrates: {summary['substrates']}")
print(f"Cell types: {summary['cell_types']}")
```

## ๐Ÿ“ Project Structure

```
physicell_config/
โ”œโ”€โ”€ README.md                          # This file
โ”œโ”€โ”€ config_builder.py                  # Main configuration class
โ”œโ”€โ”€ demo_modular.py                    # Demonstration script
โ”œโ”€โ”€ modules/                           # Modular components
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ base.py                        # Common utilities
โ”‚   โ”œโ”€โ”€ domain.py                      # Domain configuration
โ”‚   โ”œโ”€โ”€ substrates.py                  # Substrate management
โ”‚   โ”œโ”€โ”€ cell_types.py                  # Cell type definitions
โ”‚   โ”œโ”€โ”€ cell_rules.py                  # Cell behavior rules
โ”‚   โ”œโ”€โ”€ physiboss.py                   # PhysiBoSS integration
โ”‚   โ”œโ”€โ”€ initial_conditions.py          # Initial cell placement
โ”‚   โ”œโ”€โ”€ save_options.py                # Output configuration
โ”‚   โ””โ”€โ”€ options.py                     # Simulation options
โ”œโ”€โ”€ examples/                          # Example configurations
โ”‚   โ”œโ”€โ”€ PhysiCell_settings.xml         # Reference PhysiCell config
โ”‚   โ”œโ”€โ”€ basic_tumor.py                 # Basic tumor example
โ”‚   โ”œโ”€โ”€ cancer_immune.py               # Cancer-immune interaction
โ”‚   โ””โ”€โ”€ physiboss_integration.py       # PhysiBoSS example
โ”œโ”€โ”€ MODULAR_ARCHITECTURE.md            # Detailed architecture docs
โ”œโ”€โ”€ MODULARIZATION_COMPLETE.md         # Project completion summary
โ””โ”€โ”€ setup.py                          # Package setup
```

## ๐Ÿ”ง Advanced Features

### PhysiBoSS Integration
```python
# Enable PhysiBoSS boolean networks
config.physiboss.enable_physiboss("boolean_model.bnd")
config.physiboss.add_mutation("mutant_cell", "p53", False)
config.physiboss.add_initial_value("EGFR", True)
```

### Complex Initial Conditions
```python
# Multiple initial condition types
config.initial_conditions.add_cell_cluster("cancer", 0, 0, radius=100)
config.initial_conditions.add_single_cell("stem_cell", 200, 200)
config.initial_conditions.add_rectangular_region("stromal", -300, 300, -300, 300, density=0.3)
```

### Enhanced Visualization
```python
# Advanced SVG options
config.save_options.set_svg_options(
    plot_substrate=True,
    substrate_to_plot="oxygen", 
    cell_color_by="cell_type",
    interval=60.0
)
```

### Cell Rules CSV Generation
```python
# Create cell rules CSV with context awareness
rules = config.cell_rules_csv

# Explore available signals and behaviors
rules.print_available_signals(filter_by_type="contact")
rules.print_available_behaviors(filter_by_type="motility")
rules.print_context()  # Shows current cell types and substrates

# Add rules following PhysiCell CSV format
rules.add_rule("tumor", "oxygen", "decreases", "necrosis", 0, 3.75, 8, 0)
rules.add_rule("tumor", "contact with immune_cell", "increases", "apoptosis", 0.1, 0.5, 4, 0)

# Generate PhysiCell-compatible CSV file
rules.generate_csv("config/differentiation/rules.csv")
```

### PhysiBoSS Integration
```python
# Add intracellular models to cell types
config.cell_types.add_intracellular_model("T_cell", "maboss")
config.cell_types.set_intracellular_settings("T_cell", 
    bnd_filename="tcell.bnd",
    cfg_filename="tcell.cfg")
config.cell_types.add_intracellular_mutation("T_cell", "FOXP3", 0)
```

## ๐Ÿค Contributing

We welcome contributions! The modular architecture makes it easy to:

- Add new modules for additional PhysiCell features
- Enhance existing modules with new functionality  
- Improve documentation and examples
- Add comprehensive test suites

## ๐Ÿ“ง Support & Contact

- **Author:** Marco Ruscone
- **Email:** ym.ruscone94@gmail.com
- **PyPI:** https://pypi.org/project/physicell-settings/

For questions, suggestions, or bug reports, please feel free to reach out via email.

## ๐Ÿ“„ License

This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- PhysiCell development team for creating the simulation framework
- The open-source community for inspiration and best practices

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mruscone/PhysiCell_Settings",
    "name": "physicell-settings",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "physicell, multicellular, simulation, biology, computational-biology, bioinformatics, cancer, tissue, xml, configuration",
    "author": "Marco Ruscone",
    "author_email": "ym.ruscone94@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/42/c0b14bced0f1a326e1ca2c2e5e8e3bcb3d9d4ce203ce13f6b00989c6a0ab/physicell_settings-0.4.4.tar.gz",
    "platform": null,
    "description": "# PhysiCell Settings\n\nA powerful, modular Python package for generating PhysiCell_settings.xml configuration files with comprehensive parameter coverage, intuitive API design, and maintainable architecture.\n\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![PyPI version](https://img.shields.io/pypi/v/physicell-settings.svg)](https://pypi.org/project/physicell-settings/)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n## \ud83d\ude80 Overview\n\nThe PhysiCell Settings package provides a powerful yet simple API for creating complex PhysiCell simulations. Built with a modern modular architecture, it handles all aspects of PhysiCell configuration with a focus on ease of use, maintainability, and compatibility with existing PhysiCell standards.\n\n## \ud83d\udce6 Installation\n\nInstall from PyPI using pip:\n\n```bash\npip install physicell-settings\n```\n\n**Requirements:**\n- Python 3.8 or higher\n- No external dependencies (uses only Python standard library)\n\n## \ud83d\ude80 Quick Start\n\n```python\nimport physicell_config\nfrom physicell_config import PhysiCellConfig\n\n# Create a new configuration\nconfig = PhysiCellConfig()\n\n# Set up simulation domain\nconfig.domain.set_bounds(x_min=-500, x_max=500, y_min=-500, y_max=500)\n\n# Add substrates\nconfig.substrates.add_substrate(\n    name=\"oxygen\", \n    diffusion_coefficient=100000.0,\n    decay_rate=0.1\n)\n\n# Add cell type\nconfig.cell_types.add_cell_type(\n    name=\"cancer_cell\",\n    cycle_model=\"Ki67_basic\"\n)\n\n# Save configuration\nconfig.save(\"PhysiCell_settings.xml\")\n```\n\n## \ud83d\udd04 **NEW: Bidirectional XML Support**\n\n**Load, modify, and save existing PhysiCell configurations!**\n\n```python\n# Load existing PhysiCell configuration\nconfig = PhysiCellConfig()\nconfig.load_xml(\"existing_simulation.xml\")\n\n# Modify as needed\nconfig.domain.set_bounds(-600, 600, -400, 400)\nconfig.substrates.add_substrate(\"my_drug\", diffusion_coefficient=1000.0)\n\n# Add cell rules\nrules = config.cell_rules_csv\nrules.add_rule(\"cancer_cell\", \"oxygen\", \"decreases\", \"necrosis\", 0, 3.75, 8, 0)\n\n# Save modified configuration\nconfig.save_xml(\"modified_simulation.xml\")\n```\n\n**Features:**\n- \u2705 **Complete XML Loading** - Load any existing PhysiCell configuration\n- \u2705 **Perfect Data Preservation** - Round-trip loading maintains all data\n- \u2705 **PhysiBOSS Support** - Full intracellular model loading and saving\n- \u2705 **Robust Validation** - Clear error messages for invalid XML files\n- \u2705 **Cell Rules Integration** - Preserve and modify existing rule configurations\n\n[\ud83d\udcd6 **Full Documentation: BIDIRECTIONAL_XML_SUPPORT.md**](BIDIRECTIONAL_XML_SUPPORT.md)\n\n## \ud83d\udea7 Development Status\n\n**Current Version:** 0.1.0 (Beta)\n\nThis package is currently in active development. While it's functional and available on PyPI, some features are still being refined and additional functionality is being added.\n\n### \u2705 **What's Working:**\n- Core configuration generation\n- All major PhysiCell modules (domain, substrates, cell types, etc.)\n- PyPI installation and basic usage\n- Modular architecture\n\n### \ud83d\udd04 **In Progress:**\n- Additional validation and error handling\n- Enhanced documentation and examples\n- Extended API coverage for advanced features\n- Performance optimizations\n\n### \ud83d\udccb **Planned Features:**\n- Advanced parameter validation\n- Configuration templates\n- Migration tools from legacy formats\n- Enhanced PhysiBoSS integration\n\n**Note:** The repository is currently private as we finalize features and documentation. The package is stable for basic use cases.\n\n## \u2728 Key Features\n\n- **\ud83c\udfd7\ufe0f Modular Architecture** - Well-organized, maintainable codebase with focused modules\n- **\ud83c\udfaf Simple & Intuitive** - Clean API with sensible defaults and method chaining\n- **\ud83d\udd27 Comprehensive Coverage** - All PhysiCell features: domain, substrates, cells, rules, PhysiBoSS\n- **\u2705 Built-in Validation** - Configuration validation with detailed error reporting\n- **\ud83d\udd04 Full Compatibility** - Generates standard PhysiCell XML, reproduces existing configs\n- **\ud83e\uddec Advanced Features** - Cell rules, PhysiBoSS integration, initial conditions, enhanced visualization\n- **\ud83d\udcca Cell Rules CSV** - Context-aware generation of rules.csv files with signal/behavior validation\n- **\ud83d\udcda Well Documented** - Extensive examples and clear modular documentation\n\n### \ud83c\udfaf Perfect For\n\n- **Researchers** building new PhysiCell models with complex requirements\n- **Developers** programmatically generating parameter sweeps and batch simulations\n- **Teams** collaborating on large simulation projects with maintainable code\n- **Educators** teaching computational biology with clear, reproducible examples\n\n## \ud83c\udfd7\ufe0f Modular Architecture\n\nThe configuration builder uses a modular composition pattern that provides:\n\n- **Clean Separation**: Each module handles one aspect of configuration\n- **Easy Maintenance**: Small, focused files instead of monolithic code\n- **Team Development**: Multiple developers can work on different modules\n- **Extensibility**: Easy to add new modules without affecting existing code\n\n### Module Structure\n\n```\n\u251c\u2500\u2500 config_builder_modular.py       # Main configuration class\n\u2514\u2500\u2500 modules/\n    \u251c\u2500\u2500 domain.py                # Simulation domain and mesh\n    \u251c\u2500\u2500 substrates.py            # Microenvironment substrates  \n    \u251c\u2500\u2500 cell_types.py            # Cell definitions and phenotypes\n    \u251c\u2500\u2500 cell_rules.py            # Cell behavior rules\n    \u251c\u2500\u2500 cell_rules_csv.py        # rules.csv generation with context awareness\n    \u251c\u2500\u2500 physiboss.py             # PhysiBoSS boolean networks\n    \u251c\u2500\u2500 initial_conditions.py    # Initial cell placement\n    \u251c\u2500\u2500 save_options.py          # Output and visualization\n    \u2514\u2500\u2500 options.py               # Simulation parameters\n```\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\nThe package is available on PyPI for easy installation:\n\n```bash\npip install physicell-settings\n```\n\n### Basic Usage\n\n```python\nimport physicell_config\nfrom physicell_config import PhysiCellConfig\n\n# Create configuration\nconfig = PhysiCellConfig()\n\n# Set up simulation domain\nconfig.domain.set_bounds(x_min=-400, x_max=400, y_min=-400, y_max=400)\n\n# Add substrates\nconfig.substrates.add_substrate(\n    name=\"oxygen\", \n    diffusion_coefficient=100000.0,\n    decay_rate=0.1\n)\n\n# Add cell type\nconfig.cell_types.add_cell_type(\n    name=\"cancer_cell\",\n    cycle_model=\"Ki67_basic\"\n)\n```\n\n### Advanced Modular Usage\n\n```python\n# Direct module access for advanced features\nconfig.domain.set_bounds(-500, 500, -500, 500)\nconfig.substrates.add_substrate(\"glucose\", diffusion_coefficient=50000.0)\n\nconfig.cell_types.add_cell_type(\"immune_cell\")\nconfig.cell_types.set_motility(\"immune_cell\", speed=2.0, enabled=True)\nconfig.cell_types.add_secretion(\"immune_cell\", \"oxygen\", uptake_rate=5.0)\n\nconfig.cell_rules.add_rule(\"oxygen\", \"proliferation\", \"cancer_cell\")\nconfig.physiboss.enable_physiboss(\"boolean_model.bnd\")\nconfig.initial_conditions.add_cell_cluster(\"cancer_cell\", x=0, y=0, radius=100)\n```\n\n## \ud83d\udcd6 Examples\n\n### Complete Tumor-Immune Simulation\n\n```python\nfrom config_builder_modular import PhysiCellConfig\n\n# Create configuration\nconfig = PhysiCellConfig()\n\n# Setup domain  \nconfig.domain.set_bounds(-600, 600, -600, 600)\nconfig.domain.set_mesh(20.0, 20.0)\n\n# Add substrates\nconfig.substrates.add_substrate(\"oxygen\", \n    diffusion_coefficient=100000.0,\n    decay_rate=0.1, \n    initial_condition=38.0)\n\nconfig.substrates.add_substrate(\"glucose\",\n    diffusion_coefficient=50000.0,\n    decay_rate=0.01,\n    initial_condition=10.0)\n\n# Add cell types\nconfig.cell_types.add_cell_type(\"cancer_cell\")\nconfig.cell_types.set_motility(\"cancer_cell\", speed=0.5, enabled=True)\nconfig.cell_types.add_secretion(\"cancer_cell\", \"oxygen\", uptake_rate=10.0)\n\nconfig.cell_types.add_cell_type(\"immune_cell\")  \nconfig.cell_types.set_motility(\"immune_cell\", speed=2.0, enabled=True)\n\n# Add initial conditions\nconfig.initial_conditions.add_cell_cluster(\"cancer_cell\", x=0, y=0, radius=150, num_cells=100)\nconfig.initial_conditions.add_cell_cluster(\"immune_cell\", x=300, y=300, radius=50, num_cells=20)\n\n# Add cell rules to XML\nconfig.cell_rules.add_rule(\n    signal=\"oxygen\",\n    behavior=\"proliferation\",\n    cell_type=\"cancer_cell\",\n    min_signal=0.0,\n    max_signal=38.0,\n    min_behavior=0.0,\n    max_behavior=0.05\n)\n\n# Configure visualization\nconfig.save_options.set_svg_options(\n    interval=120.0,\n    plot_substrate=True,\n    substrate_to_plot=\"oxygen\",\n    cell_color_by=\"cell_type\"\n)\n\n# Save configuration\nconfig.save_xml(\"tumor_immune_simulation.xml\")\n```\n\n### Loading Cell Rules from CSV\n\n```python\n# Create rules CSV file\nimport csv\n\nrules = [\n    {\"signal\": \"oxygen\", \"behavior\": \"proliferation\", \"cell_type\": \"cancer_cell\", \n     \"min_signal\": 0.0, \"max_signal\": 38.0, \"min_behavior\": 0.0, \"max_behavior\": 0.05},\n    {\"signal\": \"pressure\", \"behavior\": \"apoptosis\", \"cell_type\": \"cancer_cell\",\n     \"min_signal\": 0.0, \"max_signal\": 1.0, \"min_behavior\": 0.0, \"max_behavior\": 0.1}\n]\n\nwith open(\"cell_rules.csv\", \"w\", newline=\"\") as f:\n    writer = csv.DictWriter(f, fieldnames=rules[0].keys())\n    writer.writeheader()\n    writer.writerows(rules)\n\n# Load rules in configuration\nconfig.cell_rules.load_rules_from_csv(\"cell_rules.csv\")\n```\n\n## \ud83e\uddea Testing and Validation\n\n### Run Demo\n```bash\npython demo_modular.py\n```\n\n### Configuration Validation\n```python\n# Built-in validation\nissues = config.validate()\nif issues:\n    for issue in issues:\n        print(f\"\u26a0\ufe0f  {issue}\")\nelse:\n    print(\"\u2705 Configuration is valid!\")\n\n# Get configuration summary\nsummary = config.get_summary()\nprint(f\"Substrates: {summary['substrates']}\")\nprint(f\"Cell types: {summary['cell_types']}\")\n```\n\n## \ud83d\udcc1 Project Structure\n\n```\nphysicell_config/\n\u251c\u2500\u2500 README.md                          # This file\n\u251c\u2500\u2500 config_builder.py                  # Main configuration class\n\u251c\u2500\u2500 demo_modular.py                    # Demonstration script\n\u251c\u2500\u2500 modules/                           # Modular components\n\u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u251c\u2500\u2500 base.py                        # Common utilities\n\u2502   \u251c\u2500\u2500 domain.py                      # Domain configuration\n\u2502   \u251c\u2500\u2500 substrates.py                  # Substrate management\n\u2502   \u251c\u2500\u2500 cell_types.py                  # Cell type definitions\n\u2502   \u251c\u2500\u2500 cell_rules.py                  # Cell behavior rules\n\u2502   \u251c\u2500\u2500 physiboss.py                   # PhysiBoSS integration\n\u2502   \u251c\u2500\u2500 initial_conditions.py          # Initial cell placement\n\u2502   \u251c\u2500\u2500 save_options.py                # Output configuration\n\u2502   \u2514\u2500\u2500 options.py                     # Simulation options\n\u251c\u2500\u2500 examples/                          # Example configurations\n\u2502   \u251c\u2500\u2500 PhysiCell_settings.xml         # Reference PhysiCell config\n\u2502   \u251c\u2500\u2500 basic_tumor.py                 # Basic tumor example\n\u2502   \u251c\u2500\u2500 cancer_immune.py               # Cancer-immune interaction\n\u2502   \u2514\u2500\u2500 physiboss_integration.py       # PhysiBoSS example\n\u251c\u2500\u2500 MODULAR_ARCHITECTURE.md            # Detailed architecture docs\n\u251c\u2500\u2500 MODULARIZATION_COMPLETE.md         # Project completion summary\n\u2514\u2500\u2500 setup.py                          # Package setup\n```\n\n## \ud83d\udd27 Advanced Features\n\n### PhysiBoSS Integration\n```python\n# Enable PhysiBoSS boolean networks\nconfig.physiboss.enable_physiboss(\"boolean_model.bnd\")\nconfig.physiboss.add_mutation(\"mutant_cell\", \"p53\", False)\nconfig.physiboss.add_initial_value(\"EGFR\", True)\n```\n\n### Complex Initial Conditions\n```python\n# Multiple initial condition types\nconfig.initial_conditions.add_cell_cluster(\"cancer\", 0, 0, radius=100)\nconfig.initial_conditions.add_single_cell(\"stem_cell\", 200, 200)\nconfig.initial_conditions.add_rectangular_region(\"stromal\", -300, 300, -300, 300, density=0.3)\n```\n\n### Enhanced Visualization\n```python\n# Advanced SVG options\nconfig.save_options.set_svg_options(\n    plot_substrate=True,\n    substrate_to_plot=\"oxygen\", \n    cell_color_by=\"cell_type\",\n    interval=60.0\n)\n```\n\n### Cell Rules CSV Generation\n```python\n# Create cell rules CSV with context awareness\nrules = config.cell_rules_csv\n\n# Explore available signals and behaviors\nrules.print_available_signals(filter_by_type=\"contact\")\nrules.print_available_behaviors(filter_by_type=\"motility\")\nrules.print_context()  # Shows current cell types and substrates\n\n# Add rules following PhysiCell CSV format\nrules.add_rule(\"tumor\", \"oxygen\", \"decreases\", \"necrosis\", 0, 3.75, 8, 0)\nrules.add_rule(\"tumor\", \"contact with immune_cell\", \"increases\", \"apoptosis\", 0.1, 0.5, 4, 0)\n\n# Generate PhysiCell-compatible CSV file\nrules.generate_csv(\"config/differentiation/rules.csv\")\n```\n\n### PhysiBoSS Integration\n```python\n# Add intracellular models to cell types\nconfig.cell_types.add_intracellular_model(\"T_cell\", \"maboss\")\nconfig.cell_types.set_intracellular_settings(\"T_cell\", \n    bnd_filename=\"tcell.bnd\",\n    cfg_filename=\"tcell.cfg\")\nconfig.cell_types.add_intracellular_mutation(\"T_cell\", \"FOXP3\", 0)\n```\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! The modular architecture makes it easy to:\n\n- Add new modules for additional PhysiCell features\n- Enhance existing modules with new functionality  \n- Improve documentation and examples\n- Add comprehensive test suites\n\n## \ud83d\udce7 Support & Contact\n\n- **Author:** Marco Ruscone\n- **Email:** ym.ruscone94@gmail.com\n- **PyPI:** https://pypi.org/project/physicell-settings/\n\nFor questions, suggestions, or bug reports, please feel free to reach out via email.\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- PhysiCell development team for creating the simulation framework\n- The open-source community for inspiration and best practices\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "User-friendly Python package for generating PhysiCell_settings.xml configuration files",
    "version": "0.4.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/mruscone/PhysiCell_Settings/issues",
        "Documentation": "https://github.com/mruscone/PhysiCell_Settings#readme",
        "Homepage": "https://github.com/mruscone/PhysiCell_Settings",
        "Source Code": "https://github.com/mruscone/PhysiCell_Settings"
    },
    "split_keywords": [
        "physicell",
        " multicellular",
        " simulation",
        " biology",
        " computational-biology",
        " bioinformatics",
        " cancer",
        " tissue",
        " xml",
        " configuration"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d3ba90cd92c99f2c579361cb58aa90a90689f547ee095384599e5c1dbb005072",
                "md5": "47f886a819c11c42a689f08ec31afbdb",
                "sha256": "79a98e5797c48d364d23bfa9f4aa151cba540fb146ab356eff56c6e5645f17b4"
            },
            "downloads": -1,
            "filename": "physicell_settings-0.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "47f886a819c11c42a689f08ec31afbdb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 57431,
            "upload_time": "2025-08-08T20:50:34",
            "upload_time_iso_8601": "2025-08-08T20:50:34.977878Z",
            "url": "https://files.pythonhosted.org/packages/d3/ba/90cd92c99f2c579361cb58aa90a90689f547ee095384599e5c1dbb005072/physicell_settings-0.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0b42c0b14bced0f1a326e1ca2c2e5e8e3bcb3d9d4ce203ce13f6b00989c6a0ab",
                "md5": "66eaa4334af2c701775960f7616f1f78",
                "sha256": "a61200984123a667da884fc05d52e9dd0577168d1a6f107c1a6744a6507789b1"
            },
            "downloads": -1,
            "filename": "physicell_settings-0.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "66eaa4334af2c701775960f7616f1f78",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 72490,
            "upload_time": "2025-08-08T20:50:36",
            "upload_time_iso_8601": "2025-08-08T20:50:36.114641Z",
            "url": "https://files.pythonhosted.org/packages/0b/42/c0b14bced0f1a326e1ca2c2e5e8e3bcb3d9d4ce203ce13f6b00989c6a0ab/physicell_settings-0.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-08 20:50:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mruscone",
    "github_project": "PhysiCell_Settings",
    "github_not_found": true,
    "lcname": "physicell-settings"
}
        
Elapsed time: 1.80947s