Overview
This script serves as a controller to automate the mutation and analysis of a protein structure using multiple supporting Python scripts:
- mutintro.py - Introduces mutations into the provided PDB file.
- contacts.py - Analyzes residue contacts in the mutated PDB structure.
- foldxana.py - Evaluates the energetic effects of mutations using FoldX.
The script reads user-provided input through command-line arguments, processes the mutation data, and orchestrates the execution of the analysis pipeline.
Usage
python main_script.py --pdb_file path/to/input.pdb --output_dir path/to/output --mutations path/to/mutations.csv --mode single
Arguments
--pdb_file
(required): Path to the input PDB file that the mutations will be introduced into.--output_dir
(required): Path to the directory where the variant PDB systems will be saved.--mutations
(required): Path to a CSV file containing a list of mutations.--mode
(optional): Mutation introduction mode.single
(default): Introduces mutations one at a time.multiple
: Introduces multiple mutations at once.
Workflow
- The script captures the current working directory with
os.getcwd()
. - Command-line arguments are parsed using
argparse
. - The script calls three external Python scripts sequentially using
os.system()
:mutintro.py
: Introduces mutations.contacts.py
: Analyzes contacts between residues post-mutation.foldxana.py
: Performs energetic evaluation of the mutated structures.
Example
To run the script in single mutation mode:
python main_script.py --pdb_file 1abc.pdb --output_dir ./output --mutations mutations.csv
To run in multiple mutation mode:
python main_script.py --pdb_file 1abc.pdb --output_dir ./output --mutations mutations.csv --mode multiple
Dependencies
- Python 3.x
- argparse
- os (standard library)
- External scripts:
mutintro.py
,contacts.py
,foldxana.py
Notes
- Ensure that the supporting scripts are in the same directory or accessible via PATH.
- The mutation CSV file should follow the expected format required by
mutintro.py
. - Consider replacing
os.system()
withsubprocess.run()
for better error handling and security. For example:import subprocess subprocess.run(["python", "mutintro.py", "--arg1", "value1"], check=True)
Prerequisites
- Ensure Python 3.x is installed and added to your system PATH.
- Install any required Python libraries using
pip install
. - Verify that the external scripts (
mutintro.py
,contacts.py
,foldxana.py
) are present in the working directory.
Error Handling
To improve error handling, consider implementing logging and exception handling in your script. For example:
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
try:
subprocess.run(["python", "mutintro.py", "--arg1", "value1"], check=True)
except subprocess.CalledProcessError as e:
logging.error(f"Error occurred: {e}")
exit(1)