def _mixmhcprediction( self, mhc_alleles: List[str], potential_ligand_sequences ) -> pd.DataFrame: """ Performs MixMHCpred prediction for desired hla allele and writes result to temporary file. """ outtmp = intermediate_files.create_temp_file(prefix="mixmhcpred", suffix=".txt") tmpfasta = intermediate_files.create_temp_fasta( potential_ligand_sequences, prefix="tmp_sequence_" ) command = [ self.configuration.mix_mhc_pred, "-a", ",".join(mhc_alleles), "-i", tmpfasta, "-o", outtmp, ] self.runner.run_command( cmd=command ) try: results = pd.read_csv(outtmp, sep="\t", comment="#") except EmptyDataError: message = "Results from MixMHCpred are empty, something went wrong [{}]. MHC I alleles {}, ligands {}".format( " ".join(command), ",".join(mhc_alleles), potential_ligand_sequences ) logger.error(message) results = pd.DataFrame() os.remove(outtmp) return results
def mhc2_prediction(self, mhc_alleles: List[str], sequence) -> List[PredictedEpitope]: """ Performs netmhcIIpan prediction for desired hla alleles and writes result to temporary file.""" # TODO: integrate generate_mhc_ii_alelle_combinations() here to easu utilisation tmp_fasta = intermediate_files.create_temp_fasta( [sequence], prefix="tmp_singleseq_") tmp_folder = tempfile.mkdtemp(prefix="tmp_netmhcIIpan_") lines, _ = self.runner.run_command([ self.configuration.net_mhc2_pan, "-BA", "-a", ",".join(mhc_alleles), "-f", tmp_fasta, "-tdir", tmp_folder, "-dirty", ]) return self._parse_netmhcpan_output(lines)
def mhc_prediction(self, mhc_alleles: List[Mhc1], set_available_mhc: Set, sequence) -> List[PredictedEpitope]: """Performs netmhcpan4 prediction for desired hla allele and writes result to temporary file.""" input_fasta = intermediate_files.create_temp_fasta( sequences=[sequence], prefix="tmp_singleseq_") available_alleles = self._get_only_available_alleles( mhc_alleles, set_available_mhc) if available_alleles is None or available_alleles == "": raise NeofoxCommandException( "None of the provided MHC I alleles are supported: {}".format( mhc_alleles)) cmd = [ self.configuration.net_mhc_pan, "-a", available_alleles, "-f", input_fasta, "-BA", ] lines, _ = self.runner.run_command(cmd) return self._parse_netmhcpan_output(lines)