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(target, database=None, template=None)[source]

Bases: object

Pandora main class. This function simply initialized the object and

checks for database or template availavbility.

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

  • database (Database.Database, optional) – Pandora Database object. Defaults to None.

  • template (PMHC.Template, optional) – Template object. To provide only if a specific template needs to be used. Defaults to None.

Raises:

Exception – If no database not remplate object are provided, an exception will be raised.

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.

copy_template()[source]

Move the template pdb to the output directory

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

remove_B2M()[source]

Rewrites the template file without Beta-2 Microglobulin

Returns:

None.

write_modeller_script(n_loop_models=20, n_homology_models=1, loop_refinement='slow', n_jobs=None, helix=False, sheet=False, restraints_stdev=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)

  • 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.

  • restraints_stdev (bool or float) – if True, keeps the whole peptide flexible. Increases computational time by 30-50% but increases accuracy. If float, it used as standard deviation of modelling restraints. Higher = more flexible restraints. Defaults to False. Setting it to True only will set the default standard dev iation to 0.1.

model(n_loop_models=20, n_homology_models=1, best_n_templates=1, n_jobs=None, loop_refinement='slow', pickle_out=False, benchmark=False, verbose=True, helix=False, sheet=False, RMSD_atoms=['C', 'CA', 'N', 'O'], clip_C_domain=False, restraints_stdev=False)[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 os.getcwd().

  • 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.

  • clip_C_domain (bool or list) – if True, clips away the C-like domain, levaing only the G-domain according to IMGT. If a listcontaining the G domain(s) span is provided, will use it to cut the sequence. The list should have this format: [(1,182)] for MHCI and [(1,91),(1,86)] for MHCII.

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

  • 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.

  • restraints_stdev (bool or float) – if True, keeps the whole peptide flexible. Increases computational time by 50-90% but increases accuracy and prevents from artifacts at the anchor positions. If float, it used as standard deviation of modelling restraints. Higher = more flexible restraints. Defaults to False. Setting it to True only will set the default standard deviation to 0.1.

  • 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, output_dir, verbose=True, rm_netmhcpan_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

  • output_dir – (string) Path to output directory

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

  • rm_netmhcpan_output – (bool): If True, removes the netmhcpan infile and outfile after having used them for netmhcpan.

Returns: (lst): list of predicted anchor predictions

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

Uses netMHCIpan 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

  • output_dir – (string) Path to output directory

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

  • rm_netmhcpan_output – (bool): If True, removes the netmhcpan infile and outfile after having used them for netmhcpan.

Returns: (lst): list of predicted anchor predictions

PANDORA.Pandora.Modelling_functions.score_peptide_alignment(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.find_template(target, database, best_n_templates=1, benchmark=False, blastdb=PANDORA.PANDORA_data + '/BLAST_databases/templates_blast_db/templates_blast_db')[source]

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

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

  • database (Database.Database) – Database object

  • blastdb (str) – Path to blast database to use for sequence-based template selection.

Returns: Template object

PANDORA.Pandora.Modelling_functions.write_ini_script(target, template, alignment_file, output_dir, clip_C_domain=False)[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, helix=False, sheet=False, restraints_stdev=False, clip_C_domain=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

  • 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.

  • restraints_stdev (bool or float) – if True, keeps the whole peptide flexible. Increases computational time by 30-50% but increases accuracy. If float, it used as standard deviation of modelling restraints. Higher = more flexible restraints. Defaults to False. Setting it to True only will set the default standard dev iation to 0.1.

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.blast_mhc_seq(seq, chain='M', blastdb=PANDORA.PANDORA_data + '/BLAST_databases/refseq_blast_db/refseq_blast_db')[source]
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(MHC_class, ori_alleles, 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)