Exemple #1
0
class TestBlast(TestCase):
    def setUp(self):
        self.references, self.configuration, self.fastafile = self._load_references(
        )
        self.proteome_blastp_runner = BlastpRunner(
            runner=Runner(verbose=False),
            configuration=self.configuration,
            database=self.references.get_proteome_database())
        self.iedb_blastp_runner = BlastpRunner(
            runner=Runner(verbose=False),
            configuration=self.configuration,
            database=self.references.get_iedb_database())

    def _load_references(self):
        references, configuration = integration_test_tools.load_references()
        fastafile = integration_test_tools.create_temp_aminoacid_fasta_file()
        return references, configuration, fastafile

    def test_blast(self):
        sequence = "FIAGLIAIV"
        res = self.proteome_blastp_runner.get_most_similar_wt_epitope(sequence)
        self.assertIsNotNone(res)
        self.assertEqual('FVAGLIVLL', res)

    def test_calculate_similarity_database(self):
        sequence = "FIAGLIAIV"
        res = self.iedb_blastp_runner.calculate_similarity_database(sequence)
        self.assertIsNotNone(res)
        self.assertEqual(1.0, res)

    def test_performance_most_similar_wt_epitope(self):
        times = []
        for k in [9, 15, 25, 50]:
            for _ in range(10):
                kmer = integration_test_tools.get_random_kmer(k=9)
                start = time.time()
                similar_wt = self.proteome_blastp_runner.get_most_similar_wt_epitope(
                    kmer)
                times.append(time.time() - start)
                logger.info("{}: {}".format(kmer, similar_wt))
            logger.info("Average time for {}-mers: {}".format(
                k, np.mean(times)))
            logger.info("Standard deviation for {}-mers: {}".format(
                k, np.std(times)))

    def test_performance_calculate_similarity_database(self):
        times = []
        for k in [9, 15, 25, 50]:
            for _ in range(10):
                kmer = integration_test_tools.get_random_kmer(k=9)
                start = time.time()
                similarity = self.proteome_blastp_runner.calculate_similarity_database(
                    kmer)
                times.append(time.time() - start)
                logger.info("{}: {}".format(kmer, similarity))
            logger.info("Average time for {}-mers: {}".format(
                k, np.mean(times)))
            logger.info("Standard deviation for {}-mers: {}".format(
                k, np.std(times)))
Exemple #2
0
 def setUp(self):
     self.references, self.configuration, self.fastafile = self._load_references(
     )
     self.proteome_blastp_runner = BlastpRunner(
         runner=Runner(verbose=False),
         configuration=self.configuration,
         database=self.references.get_proteome_database())
     self.iedb_blastp_runner = BlastpRunner(
         runner=Runner(verbose=False),
         configuration=self.configuration,
         database=self.references.get_iedb_database())
 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()
     self.proteome_blastp_runner = BlastpRunner(
         runner=self.runner, configuration=self.configuration,
         database=os.path.join(self.references.proteome_db, "homo_sapiens"))
Exemple #4
0
 def setUp(self):
     self.references, self.configuration, self.fastafile = self._load_references(
     )
     self.iedb_blastp_runner = BlastpRunner(
         runner=Runner(verbose=False),
         configuration=self.configuration,
         database=self.references.get_iedb_database())
     self.neoantigen_fitness_calculator = NeoantigenFitnessCalculator(
         iedb_blastp_runner=self.iedb_blastp_runner)
    def __init__(
        self,
        references: ReferenceFolder,
        configuration: DependenciesConfiguration,
        tcell_predictor: TcellPrediction,
        self_similarity: SelfSimilarityCalculator,
        affinity_threshold =neofox.AFFINITY_THRESHOLD_DEFAULT
    ):
        """class to annotate neoantigens"""
        self.runner = Runner()
        self.configuration = configuration
        self.proteome_db = references.proteome_db
        self.available_alleles = references.get_available_alleles()
        self.tcell_predictor = tcell_predictor
        self.self_similarity = self_similarity
        self.organism = references.organism

        # NOTE: this one loads a big file, but it is faster loading it multiple times than passing it around
        self.uniprot = Uniprot(references.uniprot_pickle)

        # initialise proteome and IEDB BLASTP runners
        self.proteome_blastp_runner = BlastpRunner(
            runner=self.runner, configuration=configuration,
            database=references.get_proteome_database())
        self.iedb_blastp_runner = BlastpRunner(
            runner=self.runner, configuration=configuration,
            database=references.get_iedb_database())

        # NOTE: these resources do not read any file thus can be initialised fast
        self.dissimilarity_calculator = DissimilarityCalculator(
            proteome_blastp_runner=self.proteome_blastp_runner, affinity_threshold=affinity_threshold)
        self.neoantigen_fitness_calculator = NeoantigenFitnessCalculator(iedb_blastp_runner=self.iedb_blastp_runner)
        self.neoag_calculator = NeoagCalculator(
            runner=self.runner, configuration=configuration, affinity_threshold=affinity_threshold
        )
        self.differential_binding = DifferentialBinding(affinity_threshold=affinity_threshold)
        self.priority_score_calculator = PriorityScore()
        self.iedb_immunogenicity = IEDBimmunogenicity(affinity_threshold=affinity_threshold)
        self.amplitude = Amplitude()
        self.hex = Hex(runner=self.runner, configuration=configuration, references=references)
        self.mhc_database = references.get_mhc_database()
        self.mhc_parser = MhcParser.get_mhc_parser(self.mhc_database)

        self.resources_versions = references.get_resources_versions()
Exemple #6
0
 def setUp(self):
     references, self.configuration = integration_test_tools.load_references(organism=ORGANISM_MUS_MUSCULUS)
     self.runner = Runner()
     self.available_alleles = references.get_available_alleles()
     self.test_mhc_one = integration_test_tools.get_h2_one_test(references.get_mhc_database())
     self.test_mhc_two = integration_test_tools.get_h2_two_test(references.get_mhc_database())
     self.mhc_parser = MhcParser.get_mhc_parser(references.get_mhc_database())
     self.proteome_blastp_runner = BlastpRunner(
         runner=self.runner, configuration=self.configuration,
         database=references.get_proteome_database())
Exemple #7
0
 def setUp(self):
     references, self.configuration = integration_test_tools.load_references(
     )
     self.runner = Runner()
     self.available_alleles_mhc1 = (
         references.get_available_alleles().get_available_mhc_i())
     self.available_alleles_mhc2 = (
         references.get_available_alleles().get_available_mhc_ii())
     self.hla_database = references.get_mhc_database()
     self.mhc_parser = MhcParser.get_mhc_parser(self.hla_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)
     self.uniprot = Uniprot(references.uniprot_pickle)
     self.proteome_blastp_runner = BlastpRunner(
         runner=self.runner,
         configuration=self.configuration,
         database=references.get_proteome_database())