This document provides detailed documentation for the PhosphoMojo Python API.
The main API class for PhosphoMojo analysis.
from phosphomojo.api import PhosphoAPI
# Default configuration
api = PhosphoAPI()
# Custom configuration
from phosphomojo.config import PhosphoConfig
config = PhosphoConfig()
config.mass_tolerance = 10.0
config.num_threads = 8
api = PhosphoAPI(config)Load mass spectrometry spectra from a file.
Parameters:
file_path(str): Path to spectra file (mzML, mzXML, MGF)
Returns:
int: Number of spectra loaded
Example:
count = api.load_spectra("experiment.mzML")
print(f"Loaded {count} spectra")Load protein database from a FASTA file.
Parameters:
file_path(str): Path to FASTA file
Returns:
int: Number of proteins loaded
Example:
count = api.load_database("proteins.fasta")
print(f"Loaded {count} proteins")Load analysis results from MaxQuant or other software.
Parameters:
file_path(str): Path to results file
Returns:
int: Number of results loaded
Example:
count = api.load_results("MaxQuant/Phospho (STY)Sites.txt")
print(f"Loaded {count} phosphosites")Run the complete analysis pipeline.
Returns:
dict: Analysis statistics
Example:
stats = api.analyze()
print(f"Peptides: {stats['peptides']}")
print(f"Phosphosites: {stats['phosphosites']}")Identify peptides from spectra.
Returns:
list: List of identified peptides
Example:
peptides = api.identify_peptides()
for peptide in peptides:
print(f"{peptide.sequence}: score={peptide.score}")Identify phosphorylation sites.
Returns:
list: List of phosphorylation sites
Example:
sites = api.identify_phosphosites()
for site in sites:
print(f"{site.protein_accession}_{site.residue}{site.position}")Quantify phosphorylation sites.
Returns:
list: List of quantitation results
Example:
results = api.quantify_sites()
for result in results:
print(f"{result.id}: mean_intensity={result.get_mean_intensity()}")Perform differential phosphorylation analysis.
Parameters:
group1(list): Sample names in group 1group2(list): Sample names in group 2
Returns:
list: List of statistical results
Example:
control = ["control_1", "control_2", "control_3"]
treatment = ["treatment_1", "treatment_2", "treatment_3"]
results = api.analyze_differential(control, treatment)
for result in results:
if result.is_significant:
print(f"{result.id}: FC={result.fold_change}, p={result.p_value}")Analyze sequence motifs around phosphorylation sites.
Returns:
list: List of motif results
Example:
motifs = api.analyze_motifs()
for motif in motifs:
print(f"{motif.phospho_site}: {motif.best_motif}")Get identified peptides.
Returns:
list: List of Peptide objects
Get phosphorylation sites.
Returns:
list: List of PhosphoSite objects
Get quantitation results.
Returns:
list: List of QuantitationResult objects
Get statistical analysis results.
Returns:
list: List of StatisticalResult objects
Get motif analysis results.
Returns:
list: List of MotifResult objects
Get statistically significant phosphorylation sites.
Parameters:
p_threshold(float): P-value threshold (default: 0.05)fc_threshold(float): Fold change threshold (default: 2.0)
Returns:
list: List of significant PhosphoSite objects
Example:
significant = api.get_significant_sites(p_threshold=0.01, fc_threshold=3.0)
print(f"Found {len(significant)} significant sites")Export results to files.
Parameters:
output_dir(str): Output directory path
Example:
api.export_results("output/")Get a summary of the analysis results.
Returns:
str: Summary string
Example:
summary = api.get_summary()
print(summary)Configuration class for PhosphoMojo analysis.
from phosphomojo.config import PhosphoConfig
config = PhosphoConfig()
# Mass spectrometry parameters
config.mass_tolerance = 20.0 # ppm
config.fragment_tolerance = 0.5 # Da
# Peptide search parameters
config.enzyme = "trypsin"
config.max_missed_cleavages = 2
config.min_peptide_length = 7
config.max_peptide_length = 30
# Phosphorylation parameters
config.localization_threshold = 0.75
config.phospho_residues = "STY"
# Statistical parameters
config.p_value_threshold = 0.05
config.fold_change_threshold = 2.0
config.multiple_testing_correction = "BH"
# Performance parameters
config.num_threads = 4
config.batch_size = 1000Represents an identified peptide.
Attributes:
sequence(str): Amino acid sequencecharge(int): Precursor charge statemass(float): Monoisotopic massscore(float): Identification scoreis_phospho(bool): Whether peptide contains phosphorylationmodifications(list): List of modifications
Represents a phosphorylation site.
Attributes:
protein_accession(str): Protein accession numberresidue(str): Phosphorylated residue (S, T, or Y)position(int): Position in protein (1-indexed)peptide_sequence(str): Peptide sequencelocalization_probability(float): Localization probability (0-1)intensity(float): Signal intensityfold_change(float): Fold change between conditionsp_value(float): Statistical p-value
Represents quantitation results.
Attributes:
id(str): Feature identifierintensities(dict): Intensity values per samplefold_changes(dict): Fold changes per comparisonis_significant(bool): Whether significantly different
Represents statistical analysis results.
Attributes:
id(str): Feature identifiercomparison(str): Comparison namep_value(float): Raw p-valueadjusted_p_value(float): Adjusted p-valuefold_change(float): Fold changelog2_fold_change(float): Log2 fold changeis_significant(bool): Whether statistically significant
Represents motif analysis results.
Attributes:
id(str): Result identifierphospho_site(str): Phosphosite IDmatched_motifs(list): List of matched motifsbest_motif(str): Best matching motifkinase_predictions(dict): Predicted kinases
from phosphomojo.api import PhosphoAPI
# Initialize
api = PhosphoAPI()
# Load data
api.load_spectra("experiment.mzML")
api.load_database("proteins.fasta")
# Run analysis
stats = api.analyze()
# Get results
phosphosites = api.get_phosphosites()
print(f"Found {len(phosphosites)} phosphosites")
# Export
api.export_results("output/")from phosphomojo.api import PhosphoAPI
api = PhosphoAPI()
api.load_spectra("experiment.mzML")
api.load_database("proteins.fasta")
api.analyze()
# Define groups
control = ["control_1", "control_2", "control_3"]
treatment = ["treatment_1", "treatment_2", "treatment_3"]
# Differential analysis
results = api.analyze_differential(control, treatment)
# Get significant sites
significant = api.get_significant_sites(p_threshold=0.05)
for site in significant:
print(f"{site.protein_accession}_{site.residue}{site.position}")from phosphomojo.api import PhosphoAPI
api = PhosphoAPI()
api.load_results("Phospho (STY)Sites.txt")
# Analyze motifs
motifs = api.analyze_motifs()
for motif in motifs:
print(f"Site: {motif.phospho_site}")
print(f"Motif: {motif.best_motif}")
print(f"Kinase: {motif.get_top_kinase()}")