diff --git a/MANIFEST.in b/MANIFEST.in index 0da8967c..c010435d 100755 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ -include neofox/published_features/neoag/neoag-master/* include neofox/published_features/self_similarity/BLOSUM62-2.matrix.txt include neofox/published_features/Tcell_predictor/amino-acids-features.pickle include neofox/published_features/Tcell_predictor/genes-expression.pickle diff --git a/README.md b/README.md index 488752d0..eb426c40 100755 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ NeoFox covers the following neoantigen features and prediction algorithms: | Vaxrank | Rubinsteyn, 2017, Front Immunol | https://doi.org/10.3389/fimmu.2017.01807 | | Priority score | Bjerregaard et al, 2017, Cancer Immunol Immunother. | https://doi.org/10.1007/s00262-017-2001-3 | | Tcell predictor | Besser et al, 2019, Journal for ImmunoTherapy of Cancer | https://doi.org/10.1186/s40425-019-0595-z | -| neoag | Smith et al, 2019, Cancer Immunology Research | https://doi.org/10.1158/2326-6066.CIR-19-0155 | | PRIME § | Schmidt et al., 2021, Cell Reports Medicine | https://doi.org/10.1016/j.xcrm.2021.100194 | | HEX § | Chiaro et al., 2021, Cancer Immunology Research | https://doi.org/10.1158/2326-6066.CIR-20-0814 | diff --git a/docs/source/01_overview.md b/docs/source/01_overview.md index a8f57019..3188acc6 100644 --- a/docs/source/01_overview.md +++ b/docs/source/01_overview.md @@ -43,7 +43,6 @@ A list of implemented features and their references are given in Table 1. Please | Vaxrank | Rubinsteyn, 2017, Front Immunol | https://doi.org/10.3389/fimmu.2017.01807 | | Priority score | Bjerregaard et al., 2017, Cancer Immunol Immunother. | https://doi.org/10.1007/s00262-017-2001-3 | | Tcell predictor | Besser et al., 2019, Journal for ImmunoTherapy of Cancer | https://doi.org/10.1186/s40425-019-0595-z | -| neoag | Smith et al., 2019, Cancer Immunology Research | https://doi.org/10.1158/2326-6066.CIR-19-0155 | | PRIME v2.0 § | Schmidt et al., 2021, Cell Reports Medicine | https://doi.org/10.1016/j.xcrm.2021.100194 | | HEX § | Chiaro et al., 2021, Cancer Immunology Research | https://doi.org/10.1158/2326-6066.CIR-20-0814 | diff --git a/docs/source/03_02_output_data.md b/docs/source/03_02_output_data.md index b90e4e60..fce7159f 100755 --- a/docs/source/03_02_output_data.md +++ b/docs/source/03_02_output_data.md @@ -104,7 +104,6 @@ The following table describes each of the annotations in the output: | Priority_score_fromRNA | combinatorial score of several features such as MHC binding, transcription expression and VAF in RNA | Priority score | | Priority_score_imputed_fromDNA | combinatorial score of several features such as MHC binding, imputed gene expression and VAF in DNA | Priority score | | Priority_score_imputed_fromRNA | combinatorial score of several features such as MHC binding, imputed gene expression and VAF in RNA | Priority score | -| Neoag_immunogenicity | output score of neoag model | neoag | | IEDB_Immunogenicity_MHCI | IEDB Immunogenicity score for `NetMHCpan_bestAffinity_peptide` | IEDB Immunogenicity | | IEDB_Immunogenicity_MHCII | IEDB Immunogenicity score for `NetMHCIIpan_bestAffinity_peptide` | IEDB Immunogenicity | | MixMHCpred_bestScore_peptide | MHC class I neoepitope candidate sequence with maximum MixMHCpred score over all neoepitope canidates (8-11mers) and MHC I alleles | MixMHCpred | diff --git a/neofox/MHC_predictors/MixMHCpred/mixmhc2pred.py b/neofox/MHC_predictors/MixMHCpred/mixmhc2pred.py index 896ff6fe..8ac8e613 100755 --- a/neofox/MHC_predictors/MixMHCpred/mixmhc2pred.py +++ b/neofox/MHC_predictors/MixMHCpred/mixmhc2pred.py @@ -23,7 +23,7 @@ from neofox.helpers.epitope_helper import EpitopeHelper from neofox.model.mhc_parser import MhcParser, get_alleles_by_gene -from neofox.references.references import DependenciesConfiguration +from neofox.references.references import DependenciesConfiguration, MhcDatabase from neofox.helpers.runner import Runner @@ -46,23 +46,34 @@ class MixMHC2pred: ANNOTATION_PREFIX = 'MixMHC2pred' ANNOTATION_PREFIX_WT = 'MixMHC2pred_WT' - def __init__(self, runner: Runner, configuration: DependenciesConfiguration, mhc_parser: MhcParser): + def __init__(self, runner: Runner, configuration: DependenciesConfiguration, mhc_parser: MhcParser, + mhc_database: MhcDatabase): self.runner = runner self.configuration = configuration - self.available_alleles = self._load_available_alleles() + self.mhc_database = mhc_database self.mhc_parser = mhc_parser + self.available_alleles = self._load_available_alleles(mhc_database) self.results = None - def _load_available_alleles(self): + def _load_available_alleles(self, mhc_database): """ loads file with available HLA II alllels for MixMHC2pred prediction, returns set :return: """ - - alleles = pd.read_csv( - self.configuration.mix_mhc2_pred_alleles_list, skiprows=2, sep="\t" - ) + if mhc_database.is_homo_sapiens(): + alleles = pd.read_csv( + self.configuration.mix_mhc2_pred_human_alleles_list, skiprows=2, sep="\t" + ) + # run only + else: + # to test if the required PWMdef folder for mouse is downloaded + if self.configuration.mix_mhc2_pred_mouse_alleles_list is not None: + alleles = pd.read_csv( + self.configuration.mix_mhc2_pred_mouse_alleles_list, skiprows=2, sep="\t" + ) + else: + logger.warning("The PWMdef folder of mouse has not been downloaded.") return list(alleles["AlleleName"]) @@ -87,7 +98,8 @@ def _combine_dq_dp_alleles(alpha_alleles: List[str], beta_alleles: List[str]): return alleles_pairs + alleles_triplets @staticmethod - def _get_mixmhc2_allele_representation(hla_alleles: List[MhcAllele]): + def _get_mixmhc2_allele_human_representation(hla_alleles: List[MhcAllele]): + # alleles: hla_alleles return list( map( lambda x: "{gene}_{group}_{protein}".format( @@ -98,12 +110,12 @@ def _get_mixmhc2_allele_representation(hla_alleles: List[MhcAllele]): ) @staticmethod - def _get_mixmhc2_isoform_representation(isoform: Mhc2Isoform): + def _get_mixmhc2_isoform_human_representation(isoform: Mhc2Isoform): - beta_chain = MixMHC2pred._get_mixmhc2_allele_representation([isoform.beta_chain])[0] + beta_chain = MixMHC2pred._get_mixmhc2_allele_human_representation([isoform.beta_chain])[0] if isoform.alpha_chain is not None and isoform.alpha_chain.name: # for DR only beta chain is provided - alpha_chain = MixMHC2pred._get_mixmhc2_allele_representation([isoform.alpha_chain])[0] + alpha_chain = MixMHC2pred._get_mixmhc2_allele_human_representation([isoform.alpha_chain])[0] return "{alpha}__{beta}".format(alpha=alpha_chain, beta=beta_chain) return beta_chain @@ -118,22 +130,49 @@ def transform_hla_ii_alleles_for_prediction(self, mhc: List[Mhc2]) -> List[str]: dqb1_alleles = get_alleles_by_gene(mhc, Mhc2GeneName.DQB1) dp_allele_combinations = self._combine_dq_dp_alleles( - alpha_alleles=self._get_mixmhc2_allele_representation(dpa1_alleles), - beta_alleles=self._get_mixmhc2_allele_representation(dpb1_alleles) + alpha_alleles=self._get_mixmhc2_allele_human_representation(dpa1_alleles), + beta_alleles=self._get_mixmhc2_allele_human_representation(dpb1_alleles) ) dq_allele_combinations = self._combine_dq_dp_alleles( - alpha_alleles=self._get_mixmhc2_allele_representation(dqa1_alleles), - beta_alleles=self._get_mixmhc2_allele_representation(dqb1_alleles) + alpha_alleles=self._get_mixmhc2_allele_human_representation(dqa1_alleles), + beta_alleles=self._get_mixmhc2_allele_human_representation(dqb1_alleles) ) return [ a - for a in self._get_mixmhc2_allele_representation(drb1_alleles) + for a in self._get_mixmhc2_allele_human_representation(drb1_alleles) + dq_allele_combinations + dp_allele_combinations if a in self.available_alleles ] + @staticmethod + def _get_mixmhc2_allele_mouse_representation(h2_alleles: List[MhcAllele]): + return list( + map( + lambda x: "H2_{gene}a_{protein}__H2_{gene}b_{protein}".format( + gene=x.gene[-1], protein=x.protein + ), + h2_alleles, + ) + ) + + def _get_mixmhc2_isoform_mouse_representation(isoform: Mhc2Isoform): + if isoform is not None: + return "H2_{gene}a_{protein}__H2_{gene}b_{protein}".format(gene=isoform[-3], protein=isoform[-1]) + + def transform_h2_alleles_for_prediction(self, mhc:List[Mhc2]) -> List[str]: + """ + prepares list of H2 alleles for prediction in required format + """ + + h2a_alleles = get_alleles_by_gene(mhc, Mhc2GeneName.H2A) + h2e_alleles = get_alleles_by_gene(mhc, Mhc2GeneName.H2E) + + return [ + a for i in (h2a_alleles, h2e_alleles) for a in self._get_mixmhc2_allele_mouse_representation(i) if a in self.available_alleles + ] + def _parse_mixmhc2pred_output(self, filename: str) -> List[PredictedEpitope]: parsed_results = [] @@ -157,10 +196,15 @@ def _parse_mixmhc2pred_output(self, filename: str) -> List[PredictedEpitope]: return parsed_results def _mixmhc2prediction(self, isoforms: List[str], potential_ligand_sequences: List[str]) -> List[PredictedEpitope]: - - + # TODO: define the pwm_path again because the mouse path is only defined by the config tmptxt = intermediate_files.create_temp_mixmhc2pred(potential_ligand_sequences, prefix="tmp_sequence_") outtmp = intermediate_files.create_temp_file(prefix="mixmhc2pred", suffix=".txt") + + if self.mhc_database.is_homo_sapiens(): + pwm_path = os.path.dirname(self.configuration.mix_mhc2_pred_human_alleles_list) + else: + #pwm_path = '/home/nguyenhv/code/MixMHC2pred/2.0/PWMdef/PWMdef_Mouse/' # reference folder + pwm_path = os.path.dirname(self.configuration.mix_mhc2_pred_mouse_alleles_list) cmd = [ self.configuration.mix_mhc2_pred, "-a", @@ -169,6 +213,8 @@ def _mixmhc2prediction(self, isoforms: List[str], potential_ligand_sequences: Li tmptxt, "-o", outtmp, + "-f", + pwm_path, "--no_context" ] self.runner.run_command(cmd) @@ -187,10 +233,14 @@ def run(self, mhc: List[Mhc2], neoantigen: Neoantigen, uniprot): self.results = None potential_ligand_sequences = EpitopeHelper.generate_nmers( - neoantigen=neoantigen, lengths=[12,13, 14, 15, 16, 17, 18, 19, 20, 21], uniprot=uniprot) + neoantigen=neoantigen, lengths=[12, 13, 14, 15, 16, 17, 18, 19, 20, 21], uniprot=uniprot) if len(potential_ligand_sequences) > 0: - mhc2_alleles = self.transform_hla_ii_alleles_for_prediction(mhc) + if self.mhc_database.is_homo_sapiens(): + mhc2_alleles = self.transform_hla_ii_alleles_for_prediction(mhc) + else: + mhc2_alleles = self.transform_h2_alleles_for_prediction(mhc) + if len(mhc2_alleles) > 0: self.results = self._mixmhc2prediction( isoforms=mhc2_alleles, potential_ligand_sequences=potential_ligand_sequences) @@ -203,7 +253,10 @@ def run_peptide(self, peptide: str, isoform: Mhc2Isoform) -> PredictedEpitope: Performs MixMHC2pred prediction for desired hla allele and writes result to temporary file. """ result = None - isoform_representation = self._get_mixmhc2_isoform_representation(isoform) + if self.mhc_database.is_homo_sapiens(): + isoform_representation = self._get_mixmhc2_isoform_human_representation(isoform) + else: + isoform_representation = self._get_mixmhc2_isoform_mouse_representation(isoform) if isoform_representation in self.available_alleles: results = self._mixmhc2prediction( isoforms=[isoform_representation], diff --git a/neofox/__init__.py b/neofox/__init__.py index de59c270..fd361f58 100755 --- a/neofox/__init__.py +++ b/neofox/__init__.py @@ -18,7 +18,7 @@ # along with this program. If not, see .# -VERSION = "1.1.0b28" +VERSION = "1.1.0b29" REFERENCE_FOLDER_ENV = "NEOFOX_REFERENCE_FOLDER" NEOFOX_BLASTP_ENV = "NEOFOX_BLASTP" diff --git a/neofox/annotator/neoantigen_annotator.py b/neofox/annotator/neoantigen_annotator.py index 7325a0a6..fd2d6d86 100755 --- a/neofox/annotator/neoantigen_annotator.py +++ b/neofox/annotator/neoantigen_annotator.py @@ -31,7 +31,6 @@ from neofox.model.factories import AnnotationFactory from neofox.model.mhc_parser import MhcParser from neofox.published_features.Tcell_predictor.tcellpredictor_wrapper import TcellPrediction -from neofox.published_features.neoag.neoag_gbm_model import NeoagCalculator from neofox.published_features.self_similarity.self_similarity import SelfSimilarityCalculator from neofox.published_features.expression import Expression from neofox.model.neoantigen import Patient, Neoantigen, Annotations, PredictedEpitope @@ -57,7 +56,6 @@ def __init__(self, references: ReferenceFolder, configuration: DependenciesConfi self.rank_mhcii_threshold = rank_mhcii_threshold # NOTE: these resources do not read any file thus can be initialised fast - self.neoag_calculator = NeoagCalculator(runner=self.runner, configuration=configuration) self.expression_calculator = Expression() self.mhc_database = references.get_mhc_database() self.mhc_parser = MhcParser.get_mhc_parser(self.mhc_database) @@ -193,14 +191,6 @@ def get_annotated_neoantigen(self, neoantigen: Neoantigen, patient: Patient, wit ) ) - # neoag immunogenicity model - if netmhcpan and netmhcpan.best_epitope_by_affinity: - neoantigen.neofox_annotations.annotations.append( - self.neoag_calculator.get_annotation( - epitope_mhci=netmhcpan.best_epitope_by_affinity, - neoantigen=neoantigen) - ) - # IEDB immunogenicity if self.organism == ORGANISM_HOMO_SAPIENS: neoantigen.neofox_annotations.annotations.extend( diff --git a/neofox/annotator/neoantigen_mhc_binding_annotator.py b/neofox/annotator/neoantigen_mhc_binding_annotator.py index 327bf382..b2707e4e 100644 --- a/neofox/annotator/neoantigen_mhc_binding_annotator.py +++ b/neofox/annotator/neoantigen_mhc_binding_annotator.py @@ -8,7 +8,7 @@ from neofox.helpers.runner import Runner from neofox.model.mhc_parser import MhcParser from neofox.model.neoantigen import Neoantigen, Patient -from neofox.references.references import DependenciesConfiguration, AvailableAlleles, ReferenceFolder, \ +from neofox.references.references import DependenciesConfiguration, AvailableAlleles, ReferenceFolder, MhcDatabase, \ ORGANISM_HOMO_SAPIENS @@ -56,16 +56,20 @@ def get_mhc_binding_annotations(self, neoantigen: Neoantigen, patient: Patient): neoantigen, patient ) + + if self.configuration.mix_mhc2_pred is not None and has_mhc2: + mixmhc2pred = self._run_mixmhc2pred( + self.runner, + self.configuration, + self.mhc_parser, + neoantigen, + patient, + self.mhc_database + ) + # avoids running MixMHCpred and PRIME for non human organisms if self.organism == ORGANISM_HOMO_SAPIENS: - if self.configuration.mix_mhc2_pred is not None and has_mhc2: - mixmhc2pred = self._run_mixmhc2pred( - self.runner, - self.configuration, - self.mhc_parser, - neoantigen, - patient, - ) + if self.configuration.mix_mhc_pred is not None and has_mhc1: mixmhcpred = self._run_mixmhcpred( self.runner, @@ -155,7 +159,8 @@ def _run_mixmhc2pred( mhc_parser: MhcParser, neoantigen: Neoantigen, patient: Patient, + mhc_database: MhcDatabase ): - mixmhc2 = MixMHC2pred(runner, configuration, mhc_parser) + mixmhc2 = MixMHC2pred(runner, configuration, mhc_parser, mhc_database) mixmhc2.run(mhc=patient.mhc2, neoantigen=neoantigen, uniprot=self.uniprot) return mixmhc2 \ No newline at end of file diff --git a/neofox/annotator/neoepitope_annotator.py b/neofox/annotator/neoepitope_annotator.py index 32f7602c..091c113e 100755 --- a/neofox/annotator/neoepitope_annotator.py +++ b/neofox/annotator/neoepitope_annotator.py @@ -32,7 +32,6 @@ from neofox.model.factories import AnnotationFactory from neofox.model.mhc_parser import MhcParser from neofox.published_features.Tcell_predictor.tcellpredictor_wrapper import TcellPrediction -from neofox.published_features.neoag.neoag_gbm_model import NeoagCalculator from neofox.published_features.self_similarity.self_similarity import SelfSimilarityCalculator from neofox.published_features.expression import Expression from neofox.model.neoantigen import Patient, Neoantigen, Annotations, PredictedEpitope @@ -54,7 +53,6 @@ def __init__(self, references: ReferenceFolder, configuration: DependenciesConfi self.available_alleles = references.get_available_alleles() # NOTE: these resources do not read any file thus can be initialised fast - self.neoag_calculator = NeoagCalculator(runner=self.runner, configuration=configuration) self.mhc_database = references.get_mhc_database() self.mhc_parser = MhcParser.get_mhc_parser(self.mhc_database) diff --git a/neofox/annotator/neoepitope_mhc_binding_annotator.py b/neofox/annotator/neoepitope_mhc_binding_annotator.py index 684484ef..c7dafe5f 100644 --- a/neofox/annotator/neoepitope_mhc_binding_annotator.py +++ b/neofox/annotator/neoepitope_mhc_binding_annotator.py @@ -40,7 +40,7 @@ def __init__(self, references: ReferenceFolder, configuration: DependenciesConfi runner=self.runner, configuration=configuration, mhc_parser=self.mhc_parser, blastp_runner=self.proteome_blastp_runner) self.mixmhcpred = MixMHCpred(self.runner, self.configuration, self.mhc_parser) - self.mixmhc2pred = MixMHC2pred(self.runner, self.configuration, self.mhc_parser) + self.mixmhc2pred = MixMHC2pred(self.runner, self.configuration, self.mhc_parser, self.mhc_database) self.prime = Prime(self.runner, self.configuration, self.mhc_parser) def get_mhc_binding_annotations(self, neoepitope: PredictedEpitope) -> PredictedEpitope: @@ -105,8 +105,6 @@ def _run_netmhcpan(self, neoepitope: PredictedEpitope) -> PredictedEpitope: sequence=neoepitope.mutated_peptide, alleles=netmhcpan_allele) annotated_neoepitope.affinity_mutated = mutated_epitope.affinity_mutated annotated_neoepitope.rank_mutated = mutated_epitope.rank_mutated - annotated_neoepitope.core = mutated_epitope.core - annotated_neoepitope.neofox_annotations = mutated_epitope.neofox_annotations wt_epitope = self.netmhcpan.mhc_prediction_peptide( sequence=neoepitope.wild_type_peptide, alleles=netmhcpan_allele) annotated_neoepitope.affinity_wild_type = wt_epitope.affinity_mutated @@ -123,8 +121,6 @@ def _run_netmhc2pan(self, neoepitope: PredictedEpitope) -> PredictedEpitope: mhc2_isoform=neoepitope.isoform_mhc_i_i) annotated_neoepitope.affinity_mutated = mutated_epitope.affinity_mutated annotated_neoepitope.rank_mutated = mutated_epitope.rank_mutated - annotated_neoepitope.core = mutated_epitope.core - annotated_neoepitope.neofox_annotations = mutated_epitope.neofox_annotations wt_epitope = self.netmhc2pan.mhc2_prediction_peptide( sequence=neoepitope.wild_type_peptide, mhc2_isoform=neoepitope.isoform_mhc_i_i) diff --git a/neofox/model/mhc_parser.py b/neofox/model/mhc_parser.py index 10d963a3..056cedb6 100644 --- a/neofox/model/mhc_parser.py +++ b/neofox/model/mhc_parser.py @@ -41,7 +41,7 @@ H2_ALLELE_PATTERN = re.compile(r"(H2-?[KDLAE])([a-z][0-9]?)") H2_NETMHCPAN_ALLELE_PATTERN = re.compile(r"H-2-I?(K|D|L|A|E)([a-z][0-9]?)") H2_MOLECULE_PATTERN = re.compile(r"(H2A|H2E)([a-z][0-9]?)") - +H2_MIXMHC2PRED_ALLELE = re.compile(r"H2_(A|E)a_([a-z][0-9]?)__H2_(A|E)b_([a-z][0-9]?)") ALLELE_PATTERN_BY_ORGANISM = { ORGANISM_HOMO_SAPIENS: HLA_ALLELE_PATTERN, ORGANISM_MUS_MUSCULUS: H2_ALLELE_PATTERN, @@ -112,7 +112,15 @@ def parse_mhc_allele(self, allele: str, pattern=H2_ALLELE_PATTERN) -> MhcAllele: def parse_mhc2_isoform(self, allele: str) -> Mhc2Isoform: # MHC II molecules in H2 lab mouse are represented as single chain proteins # NOTE: by convention we represent this allele in both the alpha and beta chains + # format from current version of MixMHC2pred: H2_Aa_b__H2_Aa_b + # "H2_{gene}a_{protein}__H2_{gene}b_{protein}" + match = H2_NETMHCPAN_ALLELE_PATTERN.match(allele) + + # convert the allele format in MixMHC2pred to the normal format + # H2_Aa_b__H2_Aa_b to H2Ab + if len(allele) > 5: + match = H2_MIXMHC2PRED_ALLELE.match(allele) if match: # this ensures that netmhcpan output is normalized allele = "H2{gene}{protein}".format(gene=match.group(1), protein=match.group(2)) diff --git a/neofox/references/references.py b/neofox/references/references.py index 74b40cf9..75bae363 100755 --- a/neofox/references/references.py +++ b/neofox/references/references.py @@ -77,7 +77,11 @@ HLA_DATABASE_AVAILABLE_ALLELES_FILE = "hla_database_allele_list.csv" H2_DATABASE_AVAILABLE_ALLELES_FILE = "h2_database_allele_list.csv" MIXMHCPRED_AVAILABLE_ALLELES_FILE = "allele_list.txt" -MIXMHC2PRED_AVAILABLE_ALLELES_FILE = "PWMdef/Alleles_list_Human.txt" +MIXMHC2PRED_AVAILABLE_HUMAN_ALLELES_FILE = "PWMdef/Alleles_list_Human.txt" +MIXMHC2PRED_PWM_MOUSE = "MixMHC2pred_PWMdef_Mouse" +MIXMHC2PRED_AVAILABLE_MOUSE_ALLELES_FILE = "PWMdef_Mouse/Alleles_list_Mouse.txt" + + PRIME_AVAILABLE_ALLELES_FILE = "alleles.txt" RESOURCES_VERSIONS = "resources_versions.json" @@ -129,10 +133,15 @@ def __init__(self): neofox.NEOFOX_MIXMHC2PRED_ENV, default_value=DEFAULT_MIXMHC2PRED, optional=True, path_search=False) if self.mix_mhc2_pred is not None: - self.mix_mhc2_pred_alleles_list = os.path.join( - os.path.dirname(self.mix_mhc2_pred), MIXMHC2PRED_AVAILABLE_ALLELES_FILE) + self.mix_mhc2_pred_human_alleles_list = os.path.join( + os.path.dirname(self.mix_mhc2_pred), MIXMHC2PRED_AVAILABLE_HUMAN_ALLELES_FILE) + # run this only when the PWMdef_Mouse was downloaded + if os.path.isdir(os.path.join(neofox.REFERENCE_FOLDER_ENV, MIXMHC2PRED_PWM_MOUSE)): + self.mix_mhc2_pred_mouse_alleles_list = os.path.join( + neofox.REFERENCE_FOLDER_ENV, MIXMHC2PRED_PWM_MOUSE, MIXMHC2PRED_AVAILABLE_MOUSE_ALLELES_FILE) else: - self.mix_mhc2_pred_alleles_list = None + self.mix_mhc2_pred_human_alleles_list = None + self.mix_mhc2_pred_mouse_alleles_list = None self.mix_mhc_pred = self._check_and_load_binary( neofox.NEOFOX_MIXMHCPRED_ENV, default_value=DEFAULT_MIXMHCPRED, optional=True, path_search=False) diff --git a/neofox/tests/integration_tests/test_best_multiple_binder.py b/neofox/tests/integration_tests/test_best_multiple_binder.py index d9e6693b..83de9319 100755 --- a/neofox/tests/integration_tests/test_best_multiple_binder.py +++ b/neofox/tests/integration_tests/test_best_multiple_binder.py @@ -346,5 +346,5 @@ def test_generator_rate_mhcII(self): generator_rate_ADN = best_multiple.determine_number_of_alternative_binders(predictions=paired_predictions) generator_rate_CDN = best_multiple.determine_number_of_binders(predictions=paired_predictions) - self.assertEqual(generator_rate_ADN, 6) + self.assertEqual(generator_rate_ADN, 4) self.assertEqual(generator_rate_CDN, 0) diff --git a/neofox/tests/integration_tests/test_mixmhcpred.py b/neofox/tests/integration_tests/test_mixmhcpred.py index 3b147bfb..42181044 100755 --- a/neofox/tests/integration_tests/test_mixmhcpred.py +++ b/neofox/tests/integration_tests/test_mixmhcpred.py @@ -40,8 +40,8 @@ def setUp(self): runner=self.runner, configuration=self.configuration, mhc_parser=mhc_parser ) self.mixmhc2pred = MixMHC2pred( - runner=self.runner, configuration=self.configuration, mhc_parser=mhc_parser - ) + runner=self.runner, configuration=self.configuration, mhc_parser=mhc_parser, + mhc_database=self.references.get_mhc_database()) self.hla_database = self.references.get_mhc_database() self.test_mhc_one = integration_test_tools.get_hla_one_test(self.hla_database) self.test_mhc_two = integration_test_tools.get_hla_two_test(self.hla_database) diff --git a/neofox/tests/integration_tests/test_neoag.py b/neofox/tests/integration_tests/test_neoag.py deleted file mode 100755 index 35caf85d..00000000 --- a/neofox/tests/integration_tests/test_neoag.py +++ /dev/null @@ -1,66 +0,0 @@ -# -# Copyright (c) 2020-2030 Translational Oncology at the Medical Center of the Johannes Gutenberg-University Mainz gGmbH. -# -# This file is part of Neofox -# (see https://github.com/tron-bioinformatics/neofox). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see .# -from unittest import TestCase - -from neofox.model.neoantigen import Annotation, PredictedEpitope, MhcAllele -from neofox.published_features.neoag.neoag_gbm_model import NeoagCalculator -from neofox.helpers.runner import Runner -import neofox.tests.integration_tests.integration_test_tools as integration_test_tools -from neofox.tests.tools import get_neoantigen - - -class TestNeoantigenFitness(TestCase): - def setUp(self): - self.references, self.configuration = integration_test_tools.load_references() - self.fastafile = integration_test_tools.create_temp_aminoacid_fasta_file() - self.runner = Runner() - - def test_neoag(self): - - mutation = get_neoantigen( - mutated_xmer= "DEVLGEPSQDILVTDQTRLEATISPET", - wild_type_xmer="DEVLGEPSQDILVIDQTRLEATISPET" - ) - result = NeoagCalculator( - runner=self.runner, configuration=self.configuration - ).get_annotation( - epitope_mhci=PredictedEpitope( - mutated_peptide="ILVTDQTRL", wild_type_peptide="ILVIDQTRL", - affinity_mutated=0, position=0, allele_mhc_i=MhcAllele(name="hla"), rank_mutated=0 - ), - neoantigen=mutation, - ) - self.assertTrue(isinstance(result, Annotation)) - self.assertTrue(float(result.value) > 0) - - def test_affinity_threshold(self): - mutation = get_neoantigen( - mutated_xmer="DEVLGEPSQDILVTDQTRLEATISPET", - wild_type_xmer="DEVLGEPSQDILVIDQTRLEATISPET", - ) - result = NeoagCalculator( - runner=self.runner, configuration=self.configuration - ).get_annotation( - epitope_mhci=PredictedEpitope( - mutated_peptide="DDDDDV", affinity_mutated=10, position=0, allele_mhc_i=MhcAllele(name="hla"), - rank_mutated=0 - ), - neoantigen=mutation - ) - self.assertEqual(result.value, "NA") diff --git a/neofox/tests/integration_tests/test_neofox.py b/neofox/tests/integration_tests/test_neofox.py index 531430e8..76a18bb9 100755 --- a/neofox/tests/integration_tests/test_neofox.py +++ b/neofox/tests/integration_tests/test_neofox.py @@ -204,7 +204,7 @@ def test_neofox_model_input(self): ).get_annotations() self.assertEqual(5, len(annotations)) self.assertIsInstance(annotations[0], Neoantigen) - self.assertEqual(len(annotations[0].neofox_annotations.annotations), 105) + self.assertEqual(len(annotations[0].neofox_annotations.annotations), 104) def test_neofox_without_mixmhcpreds(self): """ @@ -328,7 +328,7 @@ def test_neofox_without_mhc2(self): ).get_annotations() self.assertEqual(5, len(annotations)) self.assertIsInstance(annotations[0], Neoantigen) - self.assertEqual(len(annotations[0].neofox_annotations.annotations), 80) + self.assertEqual(len(annotations[0].neofox_annotations.annotations), 79) def test_neofox_without_mhc1(self): neoantigens, patients = self._get_test_data() diff --git a/neofox/tests/synthetic_data/data_generator.py b/neofox/tests/synthetic_data/data_generator.py index 1adb677a..caba2110 100644 --- a/neofox/tests/synthetic_data/data_generator.py +++ b/neofox/tests/synthetic_data/data_generator.py @@ -23,7 +23,7 @@ def __init__(self, reference_folder: ReferenceFolder, configuration: Dependencie mhc1_alleles = mixmhcpred_alleles.union(netmhcpan_alleles) mixmhc2pred_alleles = set(self.load_mhc2_alleles( - MixMHC2pred(runner=None, configuration=configuration, mhc_parser=None).available_alleles)) + MixMHC2pred(runner=None, configuration=configuration, mhc_parser=None, mhc_database=self.hla_database).available_alleles)) netmhc2pan_alleles = set(self.load_mhc2_alleles( reference_folder.get_available_alleles().get_available_mhc_ii())) mhc2_isoforms = mixmhc2pred_alleles.union(netmhc2pan_alleles)