Exemple #1
0
 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
Exemple #2
0
 def _calculate_tcell_predictor_score(self, gene, substitution, epitope,
                                      score):
     """returns Tcell_predictor score given mps in dictionary format"""
     tmp_tcellPredIN = intermediate_files.create_temp_file(
         prefix="tmp_TcellPredicIN_", suffix=".txt")
     tcell_predictor_score = None
     if not ModelValidator.has_peptide_rare_amino_acids(epitope):
         tcell_predictor_score = self._wrapper_tcellpredictor(
             gene=gene,
             substitution=substitution,
             epitope=epitope,
             score=score,
             tmpfile_in=tmp_tcellPredIN,
         )
     return tcell_predictor_score
Exemple #3
0
    def get_annotation(
        self, sample_id, mutated_peptide_mhci: PredictedEpitope, wt_peptide_mhci: PredictedEpitope, peptide_variant_position, mutation
    ) -> Annotation:
        """wrapper function to determine neoag immunogenicity score for a mutated peptide sequence"""

        neoag_score = None
        if mutation.wild_type_xmer and mutated_peptide_mhci.peptide and wt_peptide_mhci.peptide:
            # TODO: move this tmp file creation inside the method
            tmp_file_name = intermediate_files.create_temp_file(
                prefix="tmp_neoag_", suffix=".txt"
            )
            self._prepare_tmp_for_neoag(
                sample_id,
                mutated_peptide_mhci.peptide,
                mutated_peptide_mhci.affinity_score,
                wt_peptide_mhci.peptide,
                peptide_variant_position,
                tmp_file_name,
            )
            neoag_score = self._apply_gbm(tmp_file_name)
        annotation = AnnotationFactory.build_annotation(
            value=neoag_score, name="Neoag_immunogenicity"
        )
        return annotation