def setUp(self):
     self.peptides_mhcI = [Peptide("SYFPEITHI"), Peptide("IHTIEPFYS")]
     self.peptides_mhcII = [Peptide("AAAAAASYFPEITHI"), Peptide("IHTIEPFYSAAAAAA")]
     self.mhcI = [Allele("HLA-B*07:02"), Allele("HLA-A*02:01")]
     self.mhcII = [Allele("HLA-DRB1*07:01"), Allele("HLA-DRB1*15:01")]
     self.mhcII_combined_alleles = [CombinedAllele("DPA1*01:03-DPB1*01:01"), CombinedAllele("DQA1*06:02-DQB1*06:31")]
     self.transcript = Transcript("")
示例#2
0
    def parse_external_result(self, output):
        """
        Searches within the defined dir _file for the newest dir and reads
        the prediction file from there

        :param str output: The path to the output dir
        :return: The predicted HLA genotype
        :rtype: list(:class:`~Fred2.Core.Allele.Allele`)
        """
        alleles = []
        try:
            with open(output + "-ClassI.HLAgenotype4digits") as c1:
                for row in csv.DictReader(c1, delimiter="\t"):
                    alleles.extend([
                        Allele("HLA-" + row["Allele 1"].replace("'", "")),
                        Allele("HLA-" + row["Allele 2"].replace("'", ""))
                    ])
        except IOError as e:
            warnings.warn(
                "Output file {c1} for HLA-I could not be found. {error}".
                format(c1=output + "-ClassI.HLAgenotype4digits"),
                error=e)

        try:
            with open(output + "-ClassII.HLAgenotype4digits") as c2:
                DQA = []
                DQB = []
                for row in csv.DictReader(c2, delimiter="\t"):
                    a1, a2 = row["Allele 1"], row["Allele 2"]
                    if "DRB" in a1 or "DRB" in a2:
                        alleles.extend([
                            Allele("HLA-" + a1.replace("'", "")),
                            Allele("HLA-" + a2.replace("'", ""))
                        ])
                    elif "DQA" in a1 or "DQA" in a2:
                        DQA.extend([a1.replace("'", ""), a2.replace("'", "")])
                    else:
                        DQB.extend([a1.replace("'", ""), a2.replace("'", "")])
                    for dq in itertools.product(DQA, DQB):
                        alleles.append(CombinedAllele("HLA-" + "-".join(dq)))
        except IOError as e:
            warnings.warn(
                "Output file {c2} for HLA-I could not be found. {error}".
                format(c2=output + "-ClassII.HLAgenotype4digits"),
                error=e)

        return alleles
示例#3
0
 def test_combined_allele(self):
     comb = CombinedAllele("HLA-DPA1*01:03-DPB1*01:01")
     self.assertTrue(repr(comb) == "HLA-DPA1*01:03-DPB1*01:01")
     self.assertEqual(comb, CombinedAllele("HLA-DPA1*01:03-DPB1*01:01"))
     self.assertNotEqual(comb, CombinedAllele("HLA-DPA1*01:03-DPB1*01:02"))