def test_get_cluster_name(self, random_mock):
    cluster = ClusterConsensus()

    cluster.output_file = StringIO()
    random_mock.return_value = 10000
    self.assertEqual(cluster._get_cluster_name(), 'cluster_10000')
    
    cluster.output_file = MagicMock()
    cluster.output_file.name = 'foo/bar.baz.mfa'
    self.assertEqual(cluster._get_cluster_name(), 'bar.baz')

    cluster.cluster_name = 'foo'
    self.assertEqual(cluster._get_cluster_name(), 'foo')
Example #2
0
    def test_get_cluster_name(self, random_mock):
        cluster = ClusterConsensus()

        cluster.output_file = StringIO()
        random_mock.return_value = 10000
        self.assertEqual(cluster._get_cluster_name(), 'cluster_10000')

        cluster.output_file = MagicMock()
        cluster.output_file.name = 'foo/bar.baz.mfa'
        self.assertEqual(cluster._get_cluster_name(), 'bar.baz')

        cluster.cluster_name = 'foo'
        self.assertEqual(cluster._get_cluster_name(), 'foo')
  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)
Example #4
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)
  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)
Example #6
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)