Exemple #1
0
 def test_process(self):
   """Bypass the UI and test the main logic function directly."""
   m = StringIO.StringIO(self.maf1 + "\n\n" + self.maf2)
   ga = GenomeAlignment([x for x in genome_alignment_iterator(m, "A")])
   prof = processBED(StringIO.StringIO(self.roi), ga, 4, CENTRE)
   expect = [0.53333333, 0.66666666, 0.83333333, 0.73333333]
   self.assertEqual(len(prof), len(expect))
   for i in range(0, len(expect)):
     self.assertAlmostEqual(prof[i], expect[i])
Exemple #2
0
 def test_process(self):
     """Bypass the UI and test the main logic function directly."""
     m = StringIO.StringIO(self.maf1 + "\n\n" + self.maf2)
     ga = GenomeAlignment([x for x in genome_alignment_iterator(m, "A")])
     prof = processBED(StringIO.StringIO(self.roi), ga, 4, CENTRE)
     expect = [0.53333333, 0.66666666, 0.83333333, 0.73333333]
     self.assertEqual(len(prof), len(expect))
     for i in range(0, len(expect)):
         self.assertAlmostEqual(prof[i], expect[i])
Exemple #3
0
    def test_conservation_profile_pid(self):
        """Test getting conservation profiles (PID) from genome alignments."""
        m = StringIO.StringIO(self.maf1 + "\n\n" + self.maf2)
        ga = GenomeAlignment([x for x in genome_alignment_iterator(m, "A")])

        # here we're testing directly; the actual script will adjust the regions
        # before it does this step.
        expect_raw = [[0.66666666, 1.00000000, 1.00000000, 1.0000000],
                      [0.66666666, 0.33333333, None],
                      [0.33333333, 0.33333333, 0.66666666, 0.33333333],
                      [None, None, 1.00000000, 1.00000000],
                      [0.33333333, 0.66666666],
                      [0.33333333, 1.00000000, 1.00000000],
                      [0.66666666, 1.00000000, 0.66666666]]
        in_regions = [r for r in BEDIterator(StringIO.StringIO(self.roi))]
        res = [conservtion_profile_pid(r, ga) for r in in_regions]
        self.assertEqual(len(expect_raw), len(res))
        for i in range(0, len(expect_raw)):
            self.assertEqual(len(expect_raw[i]), len(res[i]))
            for j in range(0, len(expect_raw[i])):
                self.assertAlmostEqual(expect_raw[i][j], res[i][j])

        # now we test with the adjusted regions
        for l in in_regions:
            transform_locus(l, CENTRE, 4)
        res_adjusted = [conservtion_profile_pid(r, ga) for r in in_regions]
        expect_adjusted = [[0.66666666, 1.00000000, 1.00000000, 1.0000000],
                           [0.66666666, 0.33333333, None, None],
                           [0.33333333, 0.33333333, 0.66666666, 0.33333333],
                           [None, None, 1.00000000, 1.00000000],
                           [None, 0.33333333, 0.66666666, 0.66666666],
                           [0.33333333, 1.00000000, 1.00000000, 0.66666666],
                           [0.66666666, 1.00000000, 0.66666666, None]]
        self.assertEqual(len(expect_adjusted), len(res_adjusted))
        for i in range(0, len(expect_adjusted)):
            self.assertEqual(len(expect_adjusted[i]), len(res_adjusted[i]))
            for j in range(0, len(expect_adjusted[i])):
                self.assertAlmostEqual(expect_adjusted[i][j],
                                       res_adjusted[i][j])
Exemple #4
0
  def test_conservation_profile_pid(self):
    """Test getting conservation profiles (PID) from genome alignments."""
    m = StringIO.StringIO(self.maf1 + "\n\n" + self.maf2)
    ga = GenomeAlignment([x for x in genome_alignment_iterator(m, "A")])

    # here we're testing directly; the actual script will adjust the regions
    # before it does this step.
    expect_raw = [[0.66666666, 1.00000000, 1.00000000, 1.0000000],
                  [0.66666666, 0.33333333, None],
                  [0.33333333, 0.33333333, 0.66666666, 0.33333333],
                  [None, None, 1.00000000, 1.00000000],
                  [0.33333333, 0.66666666],
                  [0.33333333, 1.00000000, 1.00000000],
                  [0.66666666, 1.00000000, 0.66666666]]
    in_regions = [r for r in BEDIterator(StringIO.StringIO(self.roi))]
    res = [conservtion_profile_pid(r, ga) for r in in_regions]
    self.assertEqual(len(expect_raw), len(res))
    for i in range(0, len(expect_raw)):
      self.assertEqual(len(expect_raw[i]), len(res[i]))
      for j in range(0, len(expect_raw[i])):
        self.assertAlmostEqual(expect_raw[i][j], res[i][j])

    # now we test with the adjusted regions
    for l in in_regions:
      transform_locus(l, CENTRE, 4)
    res_adjusted = [conservtion_profile_pid(r, ga) for r in in_regions]
    expect_adjusted = [[0.66666666, 1.00000000, 1.00000000, 1.0000000],
                       [0.66666666, 0.33333333, None, None],
                       [0.33333333, 0.33333333, 0.66666666, 0.33333333],
                       [None, None, 1.00000000, 1.00000000],
                       [None, 0.33333333, 0.66666666, 0.66666666],
                       [0.33333333, 1.00000000, 1.00000000, 0.66666666],
                       [0.66666666, 1.00000000, 0.66666666, None]]
    self.assertEqual(len(expect_adjusted), len(res_adjusted))
    for i in range(0, len(expect_adjusted)):
      self.assertEqual(len(expect_adjusted[i]), len(res_adjusted[i]))
      for j in range(0, len(expect_adjusted[i])):
        self.assertAlmostEqual(expect_adjusted[i][j], res_adjusted[i][j])