fairmd.idp.protein_functions module
- fairmd.idp.protein_functions.calculate_backbone_correlations(gro_file, xtc_file, output_file)[source]
- fairmd.idp.protein_functions.calculate_backbone_NH_correlation_functions(gro_file, trj_fname, top_fname, sim_folder)[source]
- fairmd.idp.protein_functions.calc_relax_time(correlation_function, magnetic_field, biggest_corr_time, smallest_corr_time, N_exp_to_fit)[source]
- fairmd.idp.protein_functions.calc_dynamic_landscape(correlation_function, biggest_corr_time, smallest_corr_time, N_exp_to_fit)[source]
- fairmd.idp.protein_functions.get_chemical_shift_conditions_from_BMRB(BMRBid, chemical_shift_experiment)[source]
- fairmd.idp.protein_functions.extract_bmrb_fasta(entry_id)[source]
Extracts the FASTA sequence for a given BMRB entry ID.
- Parameters:
entry_id (str or int) – BMRB entry ID (e.g., ‘50115’)
- Returns:
FASTA formatted sequence
- Return type:
str
- fairmd.idp.protein_functions.extract_fasta_from_bmrb(bmrb_id: str, experiment_type) List[str][source]
Extract FASTA sequences from a BMRB entry.
- Parameters:
bmrb_id (str) – BMRB entry ID (e.g., ‘15000’, ‘bmr15000’)
- Returns:
List of FASTA formatted sequences
- Return type:
List[str]
- Raises:
requests.RequestException – If unable to fetch BMRB data
ValueError – If no sequence data found or invalid BMRB ID
- fairmd.idp.protein_functions.save_fasta_sequences(sequences: List[str], filename: str) None[source]
Save FASTA sequences to a file.
- Parameters:
sequences (List[str]) – List of FASTA formatted sequences
filename (str) – Output filename
- fairmd.idp.protein_functions.calculate_SAXS_profile_crysol(gro_file, xtc_file, dt_analysis_ps=100)[source]
- fairmd.idp.protein_functions.calculate_SAXS_profile_maicos(gro_file, xtc_file, water_shell=None, output_file=False)[source]
- fairmd.idp.protein_functions.calculate_ChemShifts_sparta_not_used(gro_file, xtc_file, dt_analysis_ps=100000, be_quiet=True)[source]
- fairmd.idp.protein_functions.calculate_ChemShifts_sparta(gro_file, xtc_file, dt_analysis_ps=1000)[source]
- fairmd.idp.protein_functions.calculate_spin_relaxation_time_RMSD(spin_relaxation_time_file, experimental_data_file)[source]
- fairmd.idp.protein_functions.convert_original_to_nested_dict(data: dict) dict[source]
Convert the original nested dict: {‘meanChemShifts[ppm]’: {(1, ‘C’): 174.59, (1, ‘CA’): 58.19, …}}
directly into: {
1: {“C”: 174.59, “CA”: 58.19, “CB”: 63.19}, 2: {“C”: 174.76, “N”: 120.67}
}
- fairmd.idp.protein_functions.parse_star_file(filename)[source]
Parses chemical shift data from a NMR-star file
- fairmd.idp.protein_functions.load_experimental_chemical_shifts(system, databankPath)[source]
- Returns:
exp_data (dict) ExperimentalFile (bool)
- fairmd.idp.protein_functions.calculate_chemical_shift_rmsd(sim_file, exp_data, nuclei=('C', 'CA', 'CB', 'HA', 'H', 'N'))[source]
Calculate chemical-shift RMSDs.
- fairmd.idp.protein_functions.compute_rmsd_chemical_shift(sim_data, exp_data, nuclei, residues)[source]
Compute RMSD values of chemical shifts per nucleus, along with per-residue differences.
- Parameters:
sim_data (dict) – Dictionary with simulated chemical shifts. Format: {residue_number: {nucleus: value}}
exp_data (dict) – Dictionary with experimental chemical shifts. Format: {residue_number: {nucleus: value}}
nuclei (list of str) – List of nucleus types to evaluate (e.g. [“C”, “CA”, “CB”]).
residues (list of int) – Residues to consider for the RMSD calculation.
- Returns:
Dictionary with the following structure: {
”C”: <RMSD value for nucleus C>, “CA”: <RMSD value for nucleus CA>, … “differences”: {
- <residue_number>: {
“C”: <sim - exp>, “CA”: <sim - exp>, …
}
}
Notes: - RMSDs are computed as sqrt(mean((sim - exp)^2)) across the selected residues. - If a simulated or experimental value is missing, the difference is stored as None
and excluded from the RMSD calculation.
- Return type:
dict
- fairmd.idp.protein_functions.extract_chemical_shift_experiment_name_from_star(star_file_path)[source]
Extracts all experiment names from the _Chem_shift_experiment loop of an NMR-STAR file. Handles both quoted and unquoted experiment names.
- Parameters:
star_file_path (str) – Path to the NMR-STAR file.
- Returns:
List of extracted experiment names (empty list if none found).
- Return type:
list[str]
- fairmd.idp.protein_functions.gro_to_residue_dict(gro_file)[source]
Read a GROMACS .gro file and return a dictionary:
{residue_number: residue_name}
Example
{194: ‘SER’, 195: ‘ASN’, …}
- fairmd.idp.protein_functions.fasta_string_to_residue_dict(fasta_str)[source]
Converts a raw FASTA sequence (with or without header) into {residue_number: three_letter_code}.
- fairmd.idp.protein_functions.fasta_to_residue_dict(fasta_path)[source]
Reads a FASTA file and returns a dictionary: {residue_number: three_letter_code}
- fairmd.idp.protein_functions.plot_quality_heatmap(data_dict, save_path, vmax=None)[source]
Create a traffic-light style heatmap showing quality metrics for each residue and nucleus.
- Parameters:
data_dict (dict) – Dictionary where keys are residues (e.g., “99GLN”) or “Averages”, and values are dicts mapping nuclei (e.g., “CA”, “N”, “Sum”) to scores.
save_path (str) – Path where the generated heatmap image will be saved.
vmax (float, optional) – Maximum value for the color scale. If None, scale automatically to data range. Useful for comparing multiple heatmaps with consistent color limits.
- fairmd.idp.protein_functions.evaluate_chemical_shift_quality(system, atom_accuracies)[source]
Evaluate chemical shift quality for a given system.
- Parameters:
system (dict) – Dictionary containing simulation info with keys: - ‘TRJ’: trajectory identifier - ‘ID’: system ID - ‘path’: relative path to data folder - ‘EXPERIMENT’: includes ‘chemical_shift’ -> ‘alignment_score’
atom_accuracies (dict) – Mapping from nucleus (e.g. ‘C’, ‘CA’, ‘N’, …) to accuracy thresholds.
percentage_over_accuracy (callable) – Function taking (accuracy, rmsd_value) -> quality percentage.
plot_quality_heatmap (callable) – Function taking (data_dict, save_path) to create and save a heatmap.
- Returns:
Path to the generated quality heatmap file.
- Return type:
str
- fairmd.idp.protein_functions.evaluate_spin_relaxation_quality(system, relaxation_accuracies)[source]
Evaluate spin relaxation quality (R1, R2, hetNOE) for a given system.
- Parameters:
system (dict) – Dictionary containing simulation info with keys: - ‘TRJ’: trajectory identifier - ‘ID’: system ID - ‘path’: relative path to data folder - ‘EXPERIMENT’: includes ‘relaxation’ -> ‘alignment_score’
relaxation_accuracies (dict) – Mapping from relaxation type (‘R1’, ‘R2’, ‘hetNOE’) to accuracy thresholds.
percentage_over_accuracy (callable) – Function taking (accuracy, rmsd_value) -> quality percentage.
plot_quality_heatmap (callable) – Function taking (data_dict, save_path) to create and save a heatmap.
- Returns:
Path to the generated relaxation quality heatmap file.
- Return type:
str
- fairmd.idp.protein_functions.compute_residue_nonzero_percentages(input_yaml: str, output_yaml: str) None[source]
Adds non_zero_percentage into each residue block of the original YAML.
- fairmd.idp.protein_functions.stable_contact_analysis(gro_file, xtc_file, sel='name CA', cutoff=8.0, min_seq_sep=4, stability_threshold=0.8)[source]
Computes time-averaged residue-residue contact probabilities and derives a stability-based folding measure, distinguishing persistent (folded-like) contacts from transient (disordered-but-compact) contacts.
- Returns:
(N,N) matrix, P(i,j) = fraction of frames residues i,j are in contact frac_stable_contacts: fraction of possible long-range pairs that are stable frac_residues_stable: fraction of residues with >=1 stable contact mean_instantaneous_contacts: mean per-frame contact count per residue (for comparison)
- Return type:
contact_prob