def _write_domain_structure_file(self, pdb_id, pdb_chains, pdb_domain_defs): """Write a pdb file containing template domain chains (cut to domain bounaries).""" if conf.CONFIGS["pdb_dir"] is not None: pdb_file = structure_tools.get_pdb_file(pdb_id, conf.CONFIGS["pdb_dir"], "ent") elif conf.CONFIGS["allow_internet"]: pdb_file = structure_tools.download_pdb_file( pdb_id, conf.CONFIGS["unique_temp_dir"]) else: raise Exception sp = structure_tools.StructureParser(pdb_file, pdb_chains, pdb_domain_defs) sp.extract() sp.save_structure(conf.CONFIGS["unique_temp_dir"]) sp.save_sequences(conf.CONFIGS["unique_temp_dir"]) structure_file = op.join(conf.CONFIGS["unique_temp_dir"], sp.pdb_id + "".join(sp.chain_ids) + ".pdb") structure_seqrecords = [] for pdb_chain in pdb_chains: chain_sequence = sp.chain_sequence_dict[pdb_chain] seqrecord = SeqRecord(id=pdb_id + pdb_chain, seq=Seq(chain_sequence)) structure_seqrecords.append(seqrecord) return structure_file, structure_seqrecords
def run_pdb_mutation_pipeline(pdb_id, pdb_mutatations): pdb_file = structure_tools.download_pdb_file( pdb_id, conf.CONFIGS["unique_temp_dir"]) for chain_id, mutations in pdb_mutatations: for mutation in mutations: mutation_pdb = "{}_{}".format(chain_id, mutation) lp = standalone_pipeline.StandalonePipeline(pdb_file, mutations=mutation_pdb) lp.run_all_sequences() lp.run_all_models() lp.run_all_mutations() logger.info("Pass")
def test_foldx(test_data, tmpdir): tmp_dir = str(tmpdir.mkdtemp()) pdb_file = download_pdb_file(test_data["pdb_id"], tmp_dir) pdb_chains = (test_data["pdb_chain"], test_data["pdb_partner_chain"]) foldx_mutation = (test_data["pdb_mutation"][0] + test_data["pdb_chain"] + test_data["pdb_mutation"][1:]) foldx = FoldX(tmp_dir) structure_file_wt, structure_file_mut = _test_build_model( pdb_file, foldx_mutation, foldx, test_data["stability_results_"]) _test_stability(structure_file_wt, structure_file_mut, foldx, test_data["stability_results_"]) _test_analyse_complex( structure_file_wt, structure_file_mut, pdb_chains, foldx, test_data["analyze_complex_results_"], )
def run_sequence_mutation_pipeline(pdb_id_sequence, sequence_mutations): """ Parameters ---------- pdb_id_sequence : tuple (pdb_id, uniprot_id) """ pdb_id, sequence_id = pdb_id_sequence pdb_file = structure_tools.download_pdb_file(pdb_id, conf.CONFIGS["unique_temp_dir"]) sequence_file = elaspic_sequence.download_uniport_sequence(sequence_id, conf.CONFIGS["unique_temp_dir"]) for chain_pos in sequence_mutations[pdb_id_sequence]: for mutation in sequence_mutations[pdb_id_sequence][chain_pos]: mutation_sequence = "{}_{}".format(chain_pos, mutation) lp = standalone_pipeline.StandalonePipeline(pdb_file, sequence_file, mutations=mutation_sequence) lp.run_all_sequences() lp.run_all_models() lp.run_all_mutations() logger.info("Done!\n") logger.info("Pass")
def run_pdb_mutation_pipeline(pdb_id, pdb_mutatations, have_sequences=False, have_models=False, have_mutations=False): pdb_file = structure_tools.download_pdb_file(pdb_id, conf.CONFIGS["unique_temp_dir"]) for chain_id in pdb_mutatations[pdb_id]: for mutation in pdb_mutatations[pdb_id][chain_id]: mutation_pdb = "{}_{}".format(chain_id, mutation) lp = standalone_pipeline.StandalonePipeline(pdb_file, mutations=mutation_pdb) if have_sequences: assert lp.have_sequences else: lp.run_all_sequences() if have_models: assert lp.have_models else: lp.run_all_models() if have_mutations: assert lp.have_mutations else: lp.run_all_mutations() logger.info("Pass")
def _write_domain_structure_file(self, pdb_id, pdb_chains, pdb_domain_defs): """Write a pdb file containing template domain chains (cut to domain bounaries).""" pdb_file = structure_tools.get_pdb_file(pdb_id, conf.CONFIGS["pdb_dir"], "ent") if not op.isfile(pdb_file) and conf.CONFIGS["allow_internet"]: pdb_file = structure_tools.download_pdb_file(pdb_id, conf.CONFIGS["pdb_dir"]) sp = structure_tools.StructureParser(pdb_file, pdb_chains, pdb_domain_defs) sp.extract() sp.save_structure(conf.CONFIGS["unique_temp_dir"]) sp.save_sequences(conf.CONFIGS["unique_temp_dir"]) structure_file = op.join(conf.CONFIGS["unique_temp_dir"], sp.pdb_id + "".join(sp.chain_ids) + ".pdb") structure_seqrecords = [] for pdb_chain in pdb_chains: chain_sequence = sp.chain_sequence_dict[pdb_chain] seqrecord = SeqRecord(id=pdb_id + pdb_chain, seq=Seq(chain_sequence)) structure_seqrecords.append(seqrecord) return structure_file, structure_seqrecords
def get_structure(pdb_id, input_folder, output_folder, use_remote=True): """Move PDB structure to the local working directory.""" input_file = op.join(input_folder, pdb_id + ".pdb") output_file = op.join(output_folder, pdb_id + ".pdb") # If the PDB already exists, do nothing... if op.isfile(output_file): logger.debug("Structure file {} already exists!".format(output_file)) return output_file # Look for PDB file in the same folder if not op.isfile(input_file): if use_remote: input_file = structure_tools.download_pdb_file(pdb_id, input_folder) else: raise Exception("No PDB input file found!") logger.info("Copying {} to {}...".format(input_file, output_file)) shutil.copy(input_file, output_file) return output_file
def run_sequence_mutation_pipeline(pdb_id_sequence, sequence_mutations): """ Parameters ---------- pdb_id_sequence : tuple (pdb_id, uniprot_id) """ pdb_id, sequence_id = pdb_id_sequence pdb_file = structure_tools.download_pdb_file( pdb_id, conf.CONFIGS["unique_temp_dir"]) sequence_file = elaspic_sequence.download_uniport_sequence( sequence_id, conf.CONFIGS["unique_temp_dir"]) for chain_pos, mutations in sequence_mutations: for mutation in mutations: mutation_sequence = "{}_{}".format(chain_pos, mutation) lp = standalone_pipeline.StandalonePipeline( pdb_file, sequence_file, mutations=mutation_sequence) lp.run_all_sequences() lp.run_all_models() lp.run_all_mutations() logger.info("Pass")
def get_structure(pdb_id, input_folder, output_folder, use_remote=True): """Move PDB structure to the local working directory.""" input_file = op.join(input_folder, pdb_id + ".pdb") output_file = op.join(output_folder, pdb_id + ".pdb") # If the PDB already exists, do nothing... if op.isfile(output_file): logger.debug("Structure file {} already exists!".format(output_file)) return output_file # Look for PDB file in the same folder if not op.isfile(input_file): if use_remote: input_file = structure_tools.download_pdb_file( pdb_id, input_folder) else: raise Exception("No PDB input file found!") logger.info("Copying {} to {}...".format(input_file, output_file)) shutil.copy(input_file, output_file) return output_file