from SemiBin.main import generate_data_single
import os
import pytest
import logging
import pandas as pd

def test_generate_data_coassembly():
    logger = logging.getLogger('SemiBin')
    logger.setLevel(logging.INFO)
    sh = logging.StreamHandler()
    sh.setFormatter(logging.Formatter('%(asctime)s - %(message)s'))
    logger.addHandler(sh)

    os.makedirs('output_coassembly',exist_ok=True)
    generate_data_single(bams=['test/coassembly_sample_data/input.sorted1.bam',
                               'test/coassembly_sample_data/input.sorted2.bam',
                               'test/coassembly_sample_data/input.sorted3.bam',
                               'test/coassembly_sample_data/input.sorted4.bam',
                               'test/coassembly_sample_data/input.sorted5.bam'],
                         num_process=1,
                         logger=logger,
                         output='output_coassembly',
                         handle='test/coassembly_sample_data/input.fasta',
                         binned_short=False,
                         must_link_threshold=4000
                         )

    data = pd.read_csv('output_coassembly/data.csv',index_col=0)
    data_split = pd.read_csv('output_coassembly/data_split.csv',index_col=0)

    assert data.shape == (40,141)
    assert data_split.shape == (80,141)
[(8, 'logging.getLogger', 'logging.getLogger', (['"""SemiBin"""'], {}), False, 'import logging\n'), (10, 'logging.StreamHandler', 'logging.StreamHandler', ([], {}), False, 'import logging\n'), (14, 'os.makedirs', 'os.makedirs', (['"""output_coassembly"""'], {'exist_ok': '(True)'}), False, 'import os\n'), (15, 'SemiBin.main.generate_data_single', 'generate_data_single', ([], {'bams': "['test/coassembly_sample_data/input.sorted1.bam',\n    'test/coassembly_sample_data/input.sorted2.bam',\n    'test/coassembly_sample_data/input.sorted3.bam',\n    'test/coassembly_sample_data/input.sorted4.bam',\n    'test/coassembly_sample_data/input.sorted5.bam']", 'num_process': '(1)', 'logger': 'logger', 'output': '"""output_coassembly"""', 'handle': '"""test/coassembly_sample_data/input.fasta"""', 'binned_short': '(False)', 'must_link_threshold': '(4000)'}), False, 'from SemiBin.main import generate_data_single\n'), (28, 'pandas.read_csv', 'pd.read_csv', (['"""output_coassembly/data.csv"""'], {'index_col': '(0)'}), True, 'import pandas as pd\n'), (29, 'pandas.read_csv', 'pd.read_csv', (['"""output_coassembly/data_split.csv"""'], {'index_col': '(0)'}), True, 'import pandas as pd\n'), (11, 'logging.Formatter', 'logging.Formatter', (['"""%(asctime)s - %(message)s"""'], {}), False, 'import logging\n')]