示例#1
0
 def test_domains_of_interest(self):
     analysis = ActiveSiteAnalysis("not-p450", (self.domain, ),
                                   "PKSI-KR.hmm2", [5, 6], ["C", "S"])
     assert analysis.domains_of_interest == []
     analysis = ActiveSiteAnalysis("p450", (self.domain, ), "PKSI-KR.hmm2",
                                   [5, 6], ["C", "S"])
     assert analysis.domains_of_interest == [self.domain]
示例#2
0
 def test_bad_args(self):
     with self.assertRaisesRegex(ValueError,
                                 "No database file located for"):
         ActiveSiteAnalysis("test", tuple(), "bad_db", [5, 6], ["C", "S"])
     with self.assertRaisesRegex(
             ValueError,
             "Number of expected values must match number of positions"):
         ActiveSiteAnalysis("test", tuple(), "PKSI-KR.hmm2", [5, 6], ["C"])
     with self.assertRaisesRegex(
             ValueError,
             "Number of expected values must match number of positions"):
         ActiveSiteAnalysis("test", tuple(), "PKSI-KR.hmm2", [5],
                            ["C", "S"])
     with self.assertRaisesRegex(
             ValueError,
             "Number of emissions must match number of positions"):
         ActiveSiteAnalysis("test",
                            tuple(),
                            "PKSI-KR.hmm2", [5, 6], ["C", "S"],
                            emissions=[1.0, .2, .3])
     with self.assertRaisesRegex(
             ValueError,
             "Number of emissions must match number of positions"):
         ActiveSiteAnalysis("test",
                            tuple(),
                            "PKSI-KR.hmm2", [5, 6], ["C", "S"],
                            emissions=[1.0])
示例#3
0
 def test_domains_of_interest(self):
     domain = DummyPFAMDomain(domain="p450")
     analysis = ActiveSiteAnalysis("not-p450", (domain, ), "PKSI-KR.hmm2",
                                   [5, 6], ["C", "S"])
     assert analysis.domains_of_interest == []
     analysis = ActiveSiteAnalysis("p450", (domain, ), "PKSI-KR.hmm2",
                                   [5, 6], ["C", "S"])
     assert analysis.domains_of_interest == [domain]
示例#4
0
 def test_no_candidates_doesnt_break(self):
     analysis = ActiveSiteAnalysis("test", tuple(), "PKSI-KR.hmm2", [5, 6],
                                   ["C", "S"])
     with patch.object(subprocessing,
                       "run_hmmpfam2",
                       side_effect=RuntimeError()) as mocked_run:
         assert analysis.get_alignments() == []
         mocked_run.assert_not_called()
示例#5
0
 def test_alignment_generation_no_hits(self):
     no_hits = list(
         SearchIO.parse(
             open(path.get_full_path(__file__, 'data', 'no_hits.output')),
             "hmmer2-text"))
     mock("subprocessing.run_hmmpfam2", returns=no_hits)
     for result in no_hits:
         assert not result.hsps, "hits shouldn't exist"
     domains = self.generate_domains()
     analysis = ActiveSiteAnalysis("PKS_KS", domains, "PKSI-KS_N.hmm2",
                                   [176, 186, 187, 188],
                                   ['G', 'S', 'S', 'S'])
     assert analysis.get_alignments() == []
示例#6
0
    def test_alignment_generation(self):
        pregenerated = list(
            SearchIO.parse(
                open(path.get_full_path(__file__, 'data', 'KS_N.output')),
                "hmmer2-text"))
        mock("subprocessing.run_hmmpfam2", returns=pregenerated)

        domains = self.generate_domains()
        analysis = ActiveSiteAnalysis("PKS_KS", domains, "PKSI-KS_N.hmm2",
                                      [176, 186, 187, 188],
                                      ['G', 'S', 'S', 'S'])
        assert {"PKS_KS"} == {
            domain.domain
            for domain in analysis.domains_of_interest
        }
        alignments = analysis.get_alignments()
        assert len(alignments) == 4
        assert [align.domain for align in alignments[:4]] == domains[:4]
示例#7
0
 def create_analysis(self, positions, expected):
     return ActiveSiteAnalysis("test", tuple(), "PKSI-KR.hmm2", positions,
                               expected)
示例#8
0
 def test_bad_candidates(self):
     with self.assertRaisesRegex(TypeError,
                                 "Candidates must be Domains, not"):
         ActiveSiteAnalysis("not-p450", ("not a Domain", ), "PKSI-KR.hmm2",
                            [5, 6], ["C", "S"])
示例#9
0
 def test_no_candidates_doesnt_break(self):
     mock("subprocessing.run_hmmpfam2", returns=RuntimeError)
     analysis = ActiveSiteAnalysis("test", tuple(), "PKSI-KR.hmm2", [5, 6],
                                   ["C", "S"])
     assert analysis.get_alignments() == []