Beispiel #1
0
    def test_iqtree_model_choice(self):
        # Tip to tip dists should NOT be identical under different models.
        # Default is MFP (auto select substitution model). We'll compare ouput
        # of the GTR+G and HKY models.
        # This test is comparing an ordered series of tip-to-tip distances.
        # Take note, that for this comparison to work, all must have the same
        # seed value set.
        input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
        input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')

        # default GTR+G
        with redirected_stdio(stderr=os.devnull):
            gtrg = iqtree(input_sequences, seed=1723,
                          substitution_model='GTR+G')
            gtrg_tree = skbio.TreeNode.read(
                        str(gtrg), convert_underscores=False)
            gtrg_td = set(gtrg_tree.tip_tip_distances().to_series())

        # set HKY
        with redirected_stdio(stderr=os.devnull):
            hky = iqtree(input_sequences, seed=1723,
                         substitution_model='HKY')
            hky_tree = skbio.TreeNode.read(
                         str(hky), convert_underscores=False)
            hky_td = set(hky_tree.tip_tip_distances().to_series())

        # test pairs are not equivalent
        self.assertNotEqual(gtrg_td, hky_td)
Beispiel #2
0
    def test_iqtree_model_choice(self):
        # Tip to tip dists should NOT be identical under different models.
        # Default is MFP (auto select substitution model). We'll compare ouput
        # of the GTR+G and HKY models.
        # This test is comparing an ordered series of tip-to-tip distances.
        # Take note, that for this comparison to work, all must have the same
        # seed value set.
        input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
        input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')

        # default GTR+G
        with redirected_stdio(stderr=os.devnull):
            gtrg = iqtree(input_sequences,
                          seed=1723,
                          substitution_model='GTR+G')
            gtrg_tree = skbio.TreeNode.read(str(gtrg),
                                            convert_underscores=False)
            gtrg_td = set(gtrg_tree.tip_tip_distances().to_series())

        # set HKY
        with redirected_stdio(stderr=os.devnull):
            hky = iqtree(input_sequences, seed=1723, substitution_model='HKY')
            hky_tree = skbio.TreeNode.read(str(hky), convert_underscores=False)
            hky_td = set(hky_tree.tip_tip_distances().to_series())

        # test pairs are not equivalent
        self.assertNotEqual(gtrg_td, hky_td)
 def test_iqtree_safe_allnni(self):
     # Same as `test_iqtree` but testing the `-safe` and `-allnni `flags
     input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
     input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')
     with redirected_stdio(stderr=os.devnull):
         obs = iqtree(input_sequences, safe='True', allnni='True')
     obs_tree = skbio.TreeNode.read(str(obs))
     tips = list(obs_tree.tips())
     tip_names = [t.name for t in tips]
     self.assertEqual(set(tip_names),
                      set(['GCA001510755', 'GCA001045515', 'GCA000454205',
                           'GCA000473545', 'GCA000196255', 'GCA000686145',
                           'GCA001950115', 'GCA001971985', 'GCA900007555']))
Beispiel #4
0
 def test_iqtree_safe_allnni(self):
     # Same as `test_iqtree` but testing the `-safe` and `-allnni `flags
     input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
     input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')
     with redirected_stdio(stderr=os.devnull):
         obs = iqtree(input_sequences, safe='True', allnni='True')
     obs_tree = skbio.TreeNode.read(str(obs))
     tips = list(obs_tree.tips())
     tip_names = [t.name for t in tips]
     self.assertEqual(set(tip_names),
                      set(['GCA001510755', 'GCA001045515', 'GCA000454205',
                           'GCA000473545', 'GCA000196255', 'GCA002142615',
                           'GCA000686145', 'GCA001950115', 'GCA001971985',
                           'GCA900007555']))
 def test_iqtree(self):
     # Test that output tree is made.
     # Reads tree output and compares tip labels to expected labels.
     input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
     input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')
     with redirected_stdio(stderr=os.devnull):
         obs = iqtree(input_sequences)
     obs_tree = skbio.TreeNode.read(str(obs))
     # load the resulting tree and test that it has the right number of
     # tips and the right tip ids
     tips = list(obs_tree.tips())
     tip_names = [t.name for t in tips]
     self.assertEqual(set(tip_names),
                      set(['GCA001510755', 'GCA001045515', 'GCA000454205',
                           'GCA000473545', 'GCA000196255', 'GCA000686145',
                           'GCA001950115', 'GCA001971985', 'GCA900007555']))
Beispiel #6
0
 def test_iqtree(self):
     # Test that output tree is made.
     # Reads tree output and compares tip labels to expected labels.
     input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
     input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')
     with redirected_stdio(stderr=os.devnull):
         obs = iqtree(input_sequences)
     obs_tree = skbio.TreeNode.read(str(obs))
     # load the resulting tree and test that it has the right number of
     # tips and the right tip ids
     tips = list(obs_tree.tips())
     tip_names = [t.name for t in tips]
     self.assertEqual(set(tip_names),
                      set(['GCA001510755', 'GCA001045515', 'GCA000454205',
                           'GCA000473545', 'GCA000196255', 'GCA002142615',
                           'GCA000686145', 'GCA001950115', 'GCA001971985',
                           'GCA900007555']))
    def test_iqtree_n_cores_auto(self):
        # Test that an output tree is made when invoking automatic threads.
        input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
        input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')

        with redirected_stdio(stderr=os.devnull):
            obs = iqtree(input_sequences, n_cores='auto')
        obs_tree = skbio.TreeNode.read(str(obs), convert_underscores=False)

        # load the resulting tree and test that it has the right number of
        # tips and the right tip ids
        tips = list(obs_tree.tips())
        tip_names = [t.name for t in tips]

        self.assertEqual(set(tip_names),
                         set(['GCA001510755', 'GCA001045515', 'GCA000454205',
                              'GCA000473545', 'GCA000196255', 'GCA000686145',
                              'GCA001950115', 'GCA001971985', 'GCA900007555']))
 def test_iqtree_underscore_ids(self):
     # Test that output tree is made with underscores in tip IDs.
     # Some programs and python wrappers may strip underscores.
     # Reads tree output and compares tip labels to expected labels.
     input_fp = self.get_data_path('aligned-dna-sequences-4.fasta')
     input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')
     with redirected_stdio(stderr=os.devnull):
         obs = iqtree(input_sequences)
     obs_tree = skbio.TreeNode.read(str(obs), convert_underscores=False)
     # load the resulting tree and test that it has the right number of
     # tips and the right tip ids
     tips = list(obs_tree.tips())
     tip_names = [t.name for t in tips]
     self.assertEqual(set(tip_names),
                      set(['GCA_001510755_1', 'GCA_001045515_1',
                           'GCA_000454205_1', 'GCA_000473545_1',
                           'GCA_000196255_1', 'GCA_002142615_1',
                           'GCA_000686145_1', 'GCA_001950115_1',
                           'GCA_001971985_1', 'GCA_900007555_1']))
Beispiel #9
0
 def test_iqtree_underscore_ids(self):
     # Test that output tree is made with underscores in tip IDs.
     # Some programs and python wrappers may strip underscores.
     # Reads tree output and compares tip labels to expected labels.
     input_fp = self.get_data_path('aligned-dna-sequences-4.fasta')
     input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')
     with redirected_stdio(stderr=os.devnull):
         obs = iqtree(input_sequences)
     obs_tree = skbio.TreeNode.read(str(obs), convert_underscores=False)
     # load the resulting tree and test that it has the right number of
     # tips and the right tip ids
     tips = list(obs_tree.tips())
     tip_names = [t.name for t in tips]
     self.assertEqual(set(tip_names),
                      set(['GCA_001510755_1', 'GCA_001045515_1',
                           'GCA_000454205_1', 'GCA_000473545_1',
                           'GCA_000196255_1', 'GCA_002142615_1',
                           'GCA_000686145_1', 'GCA_001950115_1',
                           'GCA_001971985_1', 'GCA_900007555_1']))
Beispiel #10
0
    def test_iqtree_with_seed(self):
        # Test tip-to-tip dists are identical to manually run IQ-TREE output.
        # This test is comparing an ordered series of tip-to-tip distances
        # to a tree output from a manual run of the default command:
        #     iqtree -seed 1723 -m HKY -s aligned-dna-sequences-3.fasta
        #            -nt 1 -pre q2iqtree
        # NOTE: I cleanly rounded the tip-to-tip dists (i.e. `%.4f`) as
        # IQ-TREE may return slightly different rounding errors on different
        # systems.
        input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
        input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')

        with redirected_stdio(stderr=os.devnull):
            obs = iqtree(input_sequences, seed=1723, substitution_model='HKY')
        obs_tree = skbio.TreeNode.read(str(obs), convert_underscores=False)
        obs_tl = list(obs_tree.tip_tip_distances().to_series())
        obs_series = set(['%.4f' % e for e in obs_tl])

        exp_tree = skbio.TreeNode.read(self.get_data_path('test4.tre'))
        exp_tl = list(exp_tree.tip_tip_distances().to_series())
        exp_series = set(['%.4f' % e for e in exp_tl])

        self.assertEqual(obs_series, exp_series)
Beispiel #11
0
    def test_iqtree_with_seed(self):
        # Test tip-to-tip dists are identical to manually run IQ-TREE output.
        # This test is comparing an ordered series of tip-to-tip distances
        # to a tree output from a manual run of the default command:
        #     iqtree -seed 1723 -m HKY -s aligned-dna-sequences-3.fasta
        #            -nt 1 -pre q2iqtree
        # NOTE: I cleanly rounded the tip-to-tip dists (i.e. `%.4f`) as
        # IQ-TREE may return slightly different rounding errors on different
        # systems.
        input_fp = self.get_data_path('aligned-dna-sequences-3.fasta')
        input_sequences = AlignedDNAFASTAFormat(input_fp, mode='r')

        with redirected_stdio(stderr=os.devnull):
            obs = iqtree(input_sequences, seed=1723,
                         substitution_model='HKY')
        obs_tree = skbio.TreeNode.read(str(obs), convert_underscores=False)
        obs_tl = list(obs_tree.tip_tip_distances().to_series())
        obs_series = set(['%.4f' % e for e in obs_tl])

        exp_tree = skbio.TreeNode.read(self.get_data_path('test4.tre'))
        exp_tl = list(exp_tree.tip_tip_distances().to_series())
        exp_series = set(['%.4f' % e for e in exp_tl])

        self.assertEqual(obs_series, exp_series)