Main Module (Pandora)

This is the main PANDORA module, to find the template for a given target and run the modelling, including all the intermediate steps. The main class used for the data generation is PANDORA.Pandora.Pandora.

Basic building Example:

>>> case = Pandora.Pandora(target, db)
>>> case.model()

Where target is a pre-defined PANDORA.PMHC.Target object and db is a pre-defined PANDORA.Database.Database object.

Pandora

class PANDORA.Pandora.Pandora.Pandora(self, target, database=None, template=None, output_dir=PANDORA.PANDORA_data + '/outputs')[source]

Bases: object

find_template(best_n_templates=1, benchmark=False, verbose=True)[source]

Find the best template structure given a Target object

Parameters
  • best_n_templates (int, optional) – how many template structures are used for modelling. The best n are used. Defaults to 1.

  • benchmark (bool) – Perform L-RMSD calculations? only works if the target id is an existing pdb id. Defaults to False.

  • verbose – (bool): Print information. Defaults to True.

prep_output_dir()[source]
Create an output directory and move the template pdb there
Uses self.output_dir (str): Path to output directory.

Defaults to <PANDORA_location>/PANDORA_files/data/outputs.

Parameters

None

align(verbose=True)[source]

Create the alignment file for modeller.

Parameters

verbose – (bool): Print information

write_ini_script()[source]

Write the python scipt that modeller uses for creating the initial model

create_initial_model(python_script='cmd_modeller_ini.py', verbose=True)[source]
Run modeller to create the initial model. Modeller can only output files in its work directory

(why though?), so the current work directory is changed to the output dir and later changed back the the old working dir.

Parameters
  • python_script – (str): path to script that performs the modeller modelling. Default = cmd_modeller_ini.py

  • verbose – (bool): Print information. Default = True

run_modeller(python_script='cmd_modeller.py', benchmark=False, pickle_out=True, verbose=True, keep_IL=False, RMSD_atoms=['C', 'CA', 'N', 'O'])[source]
Perform the homology modelling of a target structure on template model(s). Models are saved in the output

directory and in pandora.results[].

Parameters
  • python_script – (str): path to script that performs the modeller modelling. Default = cmd_modeller.py

  • benchmark – (bool): Perform L-RMSD calculations? only works if the target id is an existing pdb id. Default = False

  • pickle_out – (bool): Save a .pkl with the results. Default = True

  • verbose – (bool): Print information. Default = True

  • keep_IL – (bool): Keep the initial homology model (non optimized loops). Default = False

  • RMSD_atoms – (list[str]): atoms used for the L-RMSD calculation. Default = [‘C’, ‘CA’, ‘N’, ‘O’], which is the backbone

anchor_contacts(verbose=True)[source]

Calculate anchor contacts and writes a contacts.list file that modeller uses for restraints.

Parameters

verbose – (bool): Print information. Default = True

write_modeller_script(n_loop_models=20, n_homology_models=1, loop_refinement='slow', n_jobs=None, stdev=0.1, helix=False, sheet=False)[source]
Write the script that modeller uses for the final homology modelling. Most modelling settings are set in

this script.

Parameters
  • n_loop_models – (int): number of loop refinement models PANDORA will generate. Default = 20

  • n_homology_models – (int): number of generated homology models PANDORA generates. Default = 1

  • loop_refinement – (str): levels of loop refinements. Default = slow. Supported: very_fast, fast, slow, very_slow, slow_large.

  • n_jobs – (int): number of parallel jobs. Is recommended to use as many jobs as the number of models:

  • run (less will result in a slower) –

  • unnecessarily. (more will not add any benefit but might occupy cores) –

  • stdev – (float): standard deviation of modelling restraints that is allowed during modelling. Default = 0.1. A stdev of 0.2 is recommended for modelling MHC II

  • helix – (bool/list): False if no alpha-helix must be modelled. Otherwise, a list of the alpha helix start and end-positions as integers. I.e. [3,8] for a helix between peptide residue 3 and 8.

  • sheet – (bool/list): False if no beta-sheet must be modelled. Otherwise, a list containing: start position of B-sheet 1, start position of B-sheet 2 and the length of the B-sheet in h-bonds. For example: [“O:2:P”,”N:54:M”,2] for a parallel B-sheet; The sheet starts at the Oxigen atom of the 2nd residue of chain P and at the Nitrogen of the 54th residue of chain M and has a length of 2 H-bonds. Or; [“N:6:P”, “O:13:P”, -3], with -3 denoting an anti-parallel B-sheet with a length of 3 H-bonds.

model(self, output_dir=PANDORA.PANDORA_data + '/outputs', n_loop_models=20, n_homology_models=1, best_n_templates=1, n_jobs=None, loop_refinement='slow', pickle_out=False, stdev=0.1, benchmark=False, verbose=True, helix=False, sheet=False, RMSD_atoms=['C', 'CA', 'N', 'O'])[source]

Wrapper function that combines all modelling steps.

Parameters
  • benchmark – (Optional, bool) If True, performs L-RMSD calculations with target strcutre. Only works if the target id is present in the template set. Defaults to False.

  • helix (Optional, False or list) – List of integers. Contains starting and ending position of a predicted alpha-helix in the peptide. Defaults to False.

  • loop_refinement (Optional, str) – Type of MODELLER loop refinement to apply. Available options are: very_fast,fast,slow,very_slow,slow_large. Defaults to ‘slow’.

  • n_loop_models (Optional, int) – number of models modeller generates per run. Defaults to 20.

  • n_homology_models (Optional, int) – number of initial peptide homology models to generate. Defaults to 1.

  • n_jobs (Optional, int or None) – Number of parallel loop model jobs. Setting it higher than n_loop_models gives no computational time advantage. Recommended to change only when producing high number of loop models for one peptide. Defaults to None.

  • output_dir (Optional, str) – Path to output directory. Defaults to PANDORA.PANDORA_data + ‘/outputs’.

  • pickle_out (Optional, bool) – If True, saves a pickle file containing the PANDORA.PMHC.Model objects for the generated models in the output directory. Defaults to False.

  • RMSD_atoms (Optional, list) – list of atoms to use for final RMSD calculation. Works only if benchmark==True. Defaults to [‘C’, ‘CA’, ‘N’, ‘O’]

  • stdev (Optional, float) – standard deviation of modelling restraints. A higher stdev means more flexible restraints. Defaults to 0.1.

  • sheet (Optional, False or list) – List containing: start position of B-sheet 1, start position of B-sheet 2 and the length of the B-sheet in h-bonds. For example: [“O:2:P”,”N:54:M”,2] for a parallel B-sheet; The sheet starts at the Oxigen atom of the 2nd residue of chain P and at the Nitrogen of the 54th residue of chain M and has a length of 2 H-bonds. Or; [“N:6:P”, “O:13:P”, -3], with -3 denoting an anti-parallel B-sheet with a length of 3 H-bonds.

  • verbose (Optional, bool) – If True, print modelling information. Defaults to True.

Returns

None

Modelling_functions

PANDORA.Pandora.Modelling_functions.check_target_template(target, template)[source]
Checks if the target and the template are the same. If the user gave sequence info in the target, use that, else

use the allele type.

Parameters
  • target – (Target): Target object

  • template – (Template): Template object

Returns: (bool): True if target/template are the same, False if they are not.

PANDORA.Pandora.Modelling_functions.check_presence(target, database, seq_based_templ_selection=False)[source]
Checks if the target the user submitted, already exists in has a template in the database with the same allele

and peptide.

Parameters
  • target – Target object

  • database – Database object

  • seq_based_templ_selection – bool, select the template based on the chain sequences.

Returns: bool/Template object. If the target is already in the db, return the Template, otherwise return False

PANDORA.Pandora.Modelling_functions.predict_anchors_netMHCIIpan(peptide, allele_type, verbose=True)[source]

Uses netMHCIIpan to predict the binding core of a peptide and infer the anchor positions from that.

Parameters

target – (Target): Target object containing the peptide sequence and allele type

Returns: (lst): list of predicted anchor predictions

PANDORA.Pandora.Modelling_functions.predict_anchors_netMHCpan(peptide, allele_type, verbose=True, rm_output=True)[source]

Uses netMHCIIpan to predict the binding core of a peptide and infer the anchor positions from that.

Parameters
  • peptide – (str): AA sequence of the peptide

  • allele_type – (lst): list of strings of allele types

  • verbose – (bool):

Returns: (lst): list of predicted anchor predictions

PANDORA.Pandora.Modelling_functions.score_peptide_alignment_MHCI(target, template, substitution_matrix='PAM30')[source]

Calculate the alignment score of the target and template peptide

Parameters
  • target – (Target): Target object

  • template – (Template): Template object

  • substitution_matrix – (str): name of subtitution matrix, default is PAM30 (BLOSUM80 etc)

Returns: (flt): alignment score

PANDORA.Pandora.Modelling_functions.score_peptide_alignment_MHCII(target, template, substitution_matrix='PAM30')[source]

Calculate the alignment score of the target and template peptide using pairwise alignment

Parameters
  • target – (Target): Target object

  • template – (Template): Template object

  • substitution_matrix – (str): name of subtitution matrix, default is PAM30 (BLOSUM80 etc)

Returns: (flt): alignment score

PANDORA.Pandora.Modelling_functions.find_template(target, database, best_n_templates=1, benchmark=False)[source]

Selects the template structure that is best suited as template for homology modelling of the target

Parameters
  • target – Target object

  • database – Database object

  • seq_based_templ_selection – (bool) Use template selection based on template sequences instead of allele.

Returns: Template object

PANDORA.Pandora.Modelling_functions.write_ini_script(target, template, alignment_file, output_dir)[source]
Writes the MyLoop.py and cmd_modeller_ini.py files. This function takes two template python scripts and fills

in the required information: Anchor positions for the MyLoop file and structure name + alignment file for the cmd_modeller_ini file.

Parameters
  • target – Target object

  • template – Template object

  • alignment_file – (string) path to alignment file

  • output_dir – (string) path to output directory

PANDORA.Pandora.Modelling_functions.write_modeller_script(target, template, alignment_file, output_dir, n_homology_models=1, n_loop_models=20, loop_refinement='slow', n_jobs=None, stdev=0.1, helix=False, sheet=False)[source]

Write script that refines the loops of the peptide

Parameters
  • target (PANDORA.PMHC.PMHC.Target) – Target object

  • template (PANDORA.PMHC.PMHC.Template) – Template object

  • alignment_file (str) – path to alignment file

  • output_dir (str) – path to output directory

  • n_homology_models (int) – number of homology models that are generated per run.

  • n_loop_models (int) – number of loop models modeller generates per homology model

  • n_jobs (int) – number of parallel jobs. Is recommended to use at most as many jobs as the number of models: ore will not add any benefit but might occupy cores unnecessarily.

  • loop_refinement (str) – Level of loop refinement: very_fast,fast,slow,very_slow,slow_large. Defaults to slow

  • stdev (float) – standard deviation of modelling restraints. Higher = more flexible restraints.

  • helix (list) – List of the alpha helix start and end-positions as integers. I.e. [3,8] for a helix between peptide residue 3 and 8.

  • sheet (list) – List containing: start position of B-sheet 1, start position of B-sheet 2 and the length of the B-sheet in h-bonds. For example: [“O:2:P”,”N:54:M”,2] for a parallel B-sheet; The sheet starts at the Oxigen atom of the 2nd residue of chain P and at the Nitrogen of the 54th residue of chain M and has a length of 2 H-bonds. Or; [“N:6:P”, “O:13:P”, -3], with -3 denoting an anti-parallel B-sheet with a length of 3 H-bonds.

PANDORA.Pandora.Modelling_functions.run_modeller(output_dir, target, python_script='cmd_modeller.py', benchmark=False, pickle_out=True, keep_IL=False, RMSD_atoms=['C', 'CA', 'N', 'O'])[source]

Perform the homology modelling.

Parameters
  • output_dir – (string) path to output directory

  • target – Target object

  • python_script – (string) path to script that performs the modeller modelling. cmd_modeller.py

  • benchmark – (bool) Perform L-RMSD calculations? only works if the target id is an existing pdb id

  • pickle_out – (bool) Save a .pkl with the results

Returns: (list) of Model objects

PANDORA.Pandora.Modelling_functions.align_peptides(seq1, anch1_seq1, anch2_seq1, seq2, anch1_seq2, anch2_seq2)[source]

Align two MHC-I peptides making overlap the anchors. This function does NOT use an alignment matrix (e.g. BLOSUM, PAM, etc). It computes a simple anchor position alignment and inserts gap in the middle part to make the final sequences have the same lenghts.

Parameters
  • seq1 (str) – sequence of the first peptide.

  • anch1_seq1 (int) – position of the first anchor of seq1. Position must be given in Python numbering (0-N)

  • anch2_seq1 (int) – position of the second anchor of seq1. Position must be given in Python numbering (0-N)

  • seq2 (str) – sequence of the second peptide.

  • anch1_seq1 – position of the first anchor of seq1. Position must be given in Python numbering (0-N)

  • anch2_seq1 – position of the second anchor of seq1. Position must be given in Python numbering (0-N)

Returns

ali_seq1(str)

PANDORA.Pandora.Modelling_functions.allele_name_adapter(allele, available_alleles)[source]

Cuts the given allele name to make it consistent with the alleles in allele_ID.

Parameters
  • allele (list) – Allele names

  • allele_ID (dict) – Dictionary of structure IDs (values) in the dataset for each allele (keys)

Returns

List of adapted (cut) allele names

Return type

allele(list)