Exemplo n.º 1
0
    def test_create_temporary_phylip(self, temp_mock):
        temp_file = StringIO()
        temp_mock.return_value = temp_file

        builder = TreeBuilder()

        fasta_file = StringIO("""\
>cluster_A
NNAACAAAANN
>cluster_B
CCAACAAAANN
""")

        expected_output = """\
 2 11
cluster_A  NNAACAAAAN N
cluster_B  CCAACAAAAN N
"""

        builder.load_fasta_sequences(fasta_file)
        output_file = builder._create_temporary_phylip(builder.sequences)

        self.assertEqual(output_file, temp_file)

        output_file.seek(0)
        self.assertEqual(output_file.read(), expected_output)
Exemplo n.º 2
0
  def test_create_temporary_phylip(self, temp_mock):
    temp_file = StringIO()
    temp_mock.return_value = temp_file

    builder = TreeBuilder()

    fasta_file = StringIO("""\
>cluster_A
NNAACAAAANN
>cluster_B
CCAACAAAANN
""")

    expected_output = """\
 2 11
cluster_A  NNAACAAAAN N
cluster_B  CCAACAAAAN N
"""

    builder.load_fasta_sequences(fasta_file)
    output_file = builder._create_temporary_phylip(builder.sequences)

    self.assertEqual(output_file, temp_file)

    output_file.seek(0)
    self.assertEqual(output_file.read(), expected_output)
Exemplo n.º 3
0
  def test_run_raxml(self):
    builder = TreeBuilder()

    fasta_file = open(os.path.join(test_data(), 'animals.mfa'), 'r')
    builder.load_fasta_sequences(fasta_file)
    fasta_file.close()

    phylip_file = builder._create_temporary_phylip(builder.sequences)
    phylip_file.close()

    output_directory = tempfile.mkdtemp()
    raxml_stdout, raxml_stderr = builder._run_raxml('raxmlHPC', {}, phylip_file.name, output_directory)

    self.assertTrue('Best-scoring ML tree written to' in raxml_stdout)

    os.remove(phylip_file.name)
    shutil.rmtree(output_directory)
Exemplo n.º 4
0
    def test_run_raxml(self):
        builder = TreeBuilder()

        fasta_file = open(os.path.join(test_data(), 'animals.mfa'), 'r')
        builder.load_fasta_sequences(fasta_file)
        fasta_file.close()

        phylip_file = builder._create_temporary_phylip(builder.sequences)
        phylip_file.close()

        output_directory = tempfile.mkdtemp()
        raxml_stdout, raxml_stderr = builder._run_raxml(
            'raxmlHPC', {}, phylip_file.name, output_directory)

        self.assertTrue('Best-scoring ML tree written to' in raxml_stdout)

        os.remove(phylip_file.name)
        shutil.rmtree(output_directory)