示例#1
0
    def test_dn_ds(self):
        from Bio.CodonAlign.CodonSeq import cal_dn_ds
        codon_seq1 = self.aln[0]
        codon_seq2 = self.aln[1]
        dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='NG86')
        self.assertAlmostEqual(round(dN, 4), 0.0209, places=4)
        self.assertAlmostEqual(round(dS, 4), 0.0178, places=4)
        dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='LWL85')
        self.assertAlmostEqual(round(dN, 4), 0.0203, places=4)
        self.assertAlmostEqual(round(dS, 4), 0.0164, places=4)

        try:
            import scipy
        except ImportError:
            # Silently skip the rest of the test
            return

        # This should be present:
        from scipy.linalg import expm
        dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='YN00')
        self.assertAlmostEqual(round(dN, 4), 0.0198, places=4)
        self.assertAlmostEqual(round(dS, 4), 0.0222, places=4)

        try:
            # New in scipy v0.11
            from scipy.optimize import minimize
            dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='ML')
            self.assertAlmostEqual(round(dN, 4), 0.0194, places=4)
            self.assertAlmostEqual(round(dS, 4), 0.0217, places=4)
        except ImportError:
            # TODO - Show a warning?
            pass
示例#2
0
 def test_dn_ds(self):
     from Bio.CodonAlign.CodonSeq import cal_dn_ds
     codon_seq1 = self.aln[0]
     codon_seq2 = self.aln[1]
     dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='NG86')
     self.assertAlmostEquals(round(dN, 4), 0.0209, places=4)
     self.assertAlmostEquals(round(dS, 4), 0.0178, places=4)
     dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='LWL85')
     self.assertAlmostEquals(round(dN, 4), 0.0203, places=4)
     self.assertAlmostEquals(round(dS, 4), 0.0164, places=4)
     try:
         from scipy.linalg import expm
         dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='YN00')
         self.assertAlmostEquals(round(dN, 4), 0.0198, places=4)
         self.assertAlmostEquals(round(dS, 4), 0.0222, places=4)
     except ImportError:
         warnings.warn(
             'Importing scipy.linalg.expm failed. Skip testing ML method for dN/dS estimation'
         )
         pass
     try:
         from scipy.optimize import minimize
         dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='ML')
         self.assertAlmostEquals(round(dN, 4), 0.0194, places=4)
         self.assertAlmostEquals(round(dS, 4), 0.0217, places=4)
     except ImportError:
         warnings.warn(
             'Importing scipy.optimize.minimize failed. Skip testing ML method for dN/dS estimation'
         )
         pass
示例#3
0
    def test_dn_ds(self):
        from Bio.CodonAlign.CodonSeq import cal_dn_ds
        codon_seq1 = self.aln[0]
        codon_seq2 = self.aln[1]
        dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='NG86')
        self.assertAlmostEqual(round(dN, 4), 0.0209, places=4)
        self.assertAlmostEqual(round(dS, 4), 0.0178, places=4)
        dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='LWL85')
        self.assertAlmostEqual(round(dN, 4), 0.0203, places=4)
        self.assertAlmostEqual(round(dS, 4), 0.0164, places=4)

        try:
            import scipy
        except ImportError:
            # Silently skip the rest of the test
            return

        # This should be present:
        from scipy.linalg import expm
        dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='YN00')
        self.assertAlmostEqual(round(dN, 4), 0.0198, places=4)
        self.assertAlmostEqual(round(dS, 4), 0.0222, places=4)

        try:
            # New in scipy v0.11
            from scipy.optimize import minimize
            dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='ML')
            self.assertAlmostEqual(round(dN, 4), 0.0194, places=4)
            self.assertAlmostEqual(round(dS, 4), 0.0217, places=4)
        except ImportError:
            # TODO - Show a warning?
            pass
示例#4
0
 def test_dn_ds(self):
     from Bio.CodonAlign.CodonSeq import cal_dn_ds
     codon_seq1 = self.aln[0]
     codon_seq2 = self.aln[1]
     dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='NG86')
     self.assertAlmostEquals(round(dN, 4), 0.0209, places=4)
     self.assertAlmostEquals(round(dS, 4), 0.0178, places=4)
     dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='LWL85')
     self.assertAlmostEquals(round(dN, 4), 0.0203, places=4)
     self.assertAlmostEquals(round(dS, 4), 0.0164, places=4)
     try:
         from scipy.linalg import expm
         dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='YN00')
         self.assertAlmostEquals(round(dN, 4), 0.0198, places=4)
         self.assertAlmostEquals(round(dS, 4), 0.0222, places=4)
     except ImportError:
         warnings.warn('Importing scipy.linalg.expm failed. Skip testing ML method for dN/dS estimation')
         pass
     try:
         from scipy.optimize import minimize
         dN, dS = cal_dn_ds(codon_seq1, codon_seq2, method='ML')
         self.assertAlmostEquals(round(dN, 4), 0.0194, places=4)
         self.assertAlmostEquals(round(dS, 4), 0.0217, places=4)
     except ImportError:
         warnings.warn('Importing scipy.optimize.minimize failed. Skip testing ML method for dN/dS estimation')
         pass
示例#5
0
 def get_dn_ds_matrix(self, method="NG86"):
     """Available methods include NG86, LWL85, YN00 and ML.
     """
     from Bio.Phylo.TreeConstruction import _DistanceMatrix as DM
     names = [i.id for i in self._records]
     size = len(self._records)
     dn_matrix = []
     ds_matrix = []
     for i in range(size):
         dn_matrix.append([])
         ds_matrix.append([])
         for j in range(i+1):
             if i != j:
                 dn, ds = cal_dn_ds(self._records[i], self._records[j],
                                    method=method)
                 dn_matrix[i].append(dn)
                 ds_matrix[i].append(ds)
             else:
                 dn_matrix[i].append(0.0)
                 ds_matrix[i].append(0.0)
     dn_dm = DM(names, matrix=dn_matrix)
     ds_dm = DM(names, matrix=ds_matrix)
     return dn_dm, ds_dm
示例#6
0
 def get_dn_ds_matrix(self, method="NG86"):
     """Available methods include NG86, LWL85, YN00 and ML.
     """
     from Bio.Phylo.TreeConstruction import _DistanceMatrix as DM
     names = [i.id for i in self._records]
     size = len(self._records)
     dn_matrix = []
     ds_matrix = []
     for i in range(size):
         dn_matrix.append([])
         ds_matrix.append([])
         for j in range(i + 1):
             if i != j:
                 dn, ds = cal_dn_ds(self._records[i],
                                    self._records[j],
                                    method=method)
                 dn_matrix[i].append(dn)
                 ds_matrix[i].append(ds)
             else:
                 dn_matrix[i].append(0.0)
                 ds_matrix[i].append(0.0)
     dn_dm = DM(names, matrix=dn_matrix)
     ds_dm = DM(names, matrix=ds_matrix)
     return dn_dm, ds_dm