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)
[((156, 184), 'logging.getLogger', 'logging.getLogger', (['"""SemiBin"""'], {}), "('SemiBin')\n", (173, 184), False, 'import logging\n'), ((228, 251), 'logging.StreamHandler', 'logging.StreamHandler', ([], {}), '()\n', (249, 251), False, 'import logging\n'), ((351, 398), 'os.makedirs', 'os.makedirs', (['"""output_coassembly"""'], {'exist_ok': '(True)'}), "('output_coassembly', exist_ok=True)\n", (362, 398), False, 'import os\n'), ((402, 858), '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)'}), "(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\n    =logger, output='output_coassembly', handle=\n    'test/coassembly_sample_data/input.fasta', binned_short=False,\n    must_link_threshold=4000)\n", (422, 858), False, 'from SemiBin.main import generate_data_single\n'), ((1141, 1195), 'pandas.read_csv', 'pd.read_csv', (['"""output_coassembly/data.csv"""'], {'index_col': '(0)'}), "('output_coassembly/data.csv', index_col=0)\n", (1152, 1195), True, 'import pandas as pd\n'), ((1212, 1272), 'pandas.read_csv', 'pd.read_csv', (['"""output_coassembly/data_split.csv"""'], {'index_col': '(0)'}), "('output_coassembly/data_split.csv', index_col=0)\n", (1223, 1272), True, 'import pandas as pd\n'), ((272, 318), 'logging.Formatter', 'logging.Formatter', (['"""%(asctime)s - %(message)s"""'], {}), "('%(asctime)s - %(message)s')\n", (289, 318), False, 'import logging\n')]