Example #1
0
    def test_write_sequences(self):
        builder = TreeBuilder()

        fasta_filename = os.path.join(test_data(), 'animals.mfa')
        fasta_file = open(fasta_filename, 'r')
        sequences = Bio.SeqIO.parse(fasta_file, 'fasta')

        output = StringIO()

        builder._write_sequences(sequences, output)

        fasta_file.close()

        with open(fasta_filename, 'r') as fasta_file:
            expected = fasta_file.readlines()
            expected = "".join(expected[5:])  # Remove comments from the top
        output.seek(0)

        self.assertEqual(output.read(), expected)
Example #2
0
  def test_write_sequences(self):
    builder = TreeBuilder()

    fasta_filename = os.path.join(test_data(), 'animals.mfa')
    fasta_file = open(fasta_filename, 'r')
    sequences = Bio.SeqIO.parse(fasta_file, 'fasta')

    output = StringIO()

    builder._write_sequences(sequences, output)

    fasta_file.close()

    with open(fasta_filename, 'r') as fasta_file:
      expected = fasta_file.readlines()
      expected = "".join(expected[5:]) # Remove comments from the top
    output.seek(0)

    self.assertEqual(output.read(), expected)
Example #3
0
    def test_write_output(self):
        builder = TreeBuilder()
        builder.sequences = {"seq1": "a sequence object"}
        builder.tree = "Tree"
        builder.sequences_output_file = StringIO()
        builder.tree_output_file = StringIO()

        builder._write_tree = MagicMock()
        builder._write_sequences = MagicMock()

        builder.write_output()

        builder._write_tree.assert_called_with("Tree",
                                               builder.tree_output_file)
        builder._write_sequences.assert_called_with(
            ["a sequence object"], builder.sequences_output_file)
Example #4
0
  def test_write_output(self):
    builder = TreeBuilder()
    builder.sequences = {"seq1": "a sequence object"}
    builder.tree = "Tree"
    builder.sequences_output_file = StringIO()
    builder.tree_output_file = StringIO()

    builder._write_tree = MagicMock()
    builder._write_sequences = MagicMock()

    builder.write_output()

    builder._write_tree.assert_called_with("Tree",
                                           builder.tree_output_file)
    builder._write_sequences.assert_called_with(["a sequence object"],
                                                builder.sequences_output_file)