コード例 #1
0
    def test_write_consensus(self):
        cluster = ClusterConsensus()

        cluster.output_file = StringIO()
        cluster.cluster_name = 'cluster_1000'
        cluster._calculate_consensus = MagicMock(return_value='NNANTGUNCN')

        cluster.write_consensus()

        expected_results = """\
>cluster_1000
NNANTGUNCN
"""
        cluster.output_file.seek(0)
        self.assertEqual(cluster.output_file.read(), expected_results)
コード例 #2
0
  def test_write_consensus(self):
    cluster = ClusterConsensus()

    cluster.output_file = StringIO()
    cluster.cluster_name = 'cluster_1000'
    cluster._calculate_consensus = MagicMock(return_value='NNANTGUNCN')

    cluster.write_consensus()

    expected_results = """\
>cluster_1000
NNANTGUNCN
"""
    cluster.output_file.seek(0)
    self.assertEqual(cluster.output_file.read(), expected_results)
コード例 #3
0
  def test_real_file(self):
    test_folder = os.path.abspath(os.path.dirname(__file__))
    test_data_path = os.path.join(test_folder, 'data', 'cluster_A_multifasta.aln')

    cluster = ClusterConsensus()
    cluster.output_file = StringIO()
    cluster.output_file.name = "fake_filename.aln"
    with open(test_data_path, 'r') as input_file:
      cluster.load_fasta_file(input_file)
      cluster.write_consensus()

    expected_response = """\
>fake_filename
ANNAACAAAANN
"""
    cluster.output_file.seek(0)
    self.assertEqual(cluster.output_file.read(), expected_response)
コード例 #4
0
    def test_real_file(self):
        test_folder = os.path.abspath(os.path.dirname(__file__))
        test_data_path = os.path.join(test_folder, 'data',
                                      'cluster_A_multifasta.aln')

        cluster = ClusterConsensus()
        cluster.output_file = StringIO()
        cluster.output_file.name = "fake_filename.aln"
        with open(test_data_path, 'r') as input_file:
            cluster.load_fasta_file(input_file)
            cluster.write_consensus()

        expected_response = """\
>fake_filename
ANNAACAAAANN
"""
        cluster.output_file.seek(0)
        self.assertEqual(cluster.output_file.read(), expected_response)