from Module import AbstractModule

class Module(AbstractModule):
    def __init__(self):
        AbstractModule.__init__(self)

    def run(
        self, network, antecedents, out_attributes, user_options, num_cores,
        outfile):
        import os
        import shutil
        from genomicode import filelib
        in_data = antecedents
        result_files = os.listdir(in_data.identifier)
        for result_file in result_files:
            if '-controls' in result_file:
                goal_file = os.path.join(in_data.identifier, result_file)
                shutil.copyfile(goal_file, outfile)
    
        
        assert filelib.exists_nz(outfile), (
            'the output file %s for illu_control fails' % outfile
        )


    def name_outfile(self, antecedents, user_options):
        from Betsy import module_utils
        original_file = module_utils.get_inputid(antecedents.identifier)
        filename = 'control_illumina_' + original_file + '.gct'
        return filename




[(5, 'Module.AbstractModule.__init__', 'AbstractModule.__init__', False, 'from Module import AbstractModule\n'), (14, 'os.listdir', 'os.listdir', False, 'import os\n'), (21, 'genomicode.filelib.exists_nz', 'filelib.exists_nz', False, 'from genomicode import filelib\n'), (28, 'Betsy.module_utils.get_inputid', 'module_utils.get_inputid', False, 'from Betsy import module_utils\n'), (17, 'os.path.join', 'os.path.join', False, 'import os\n'), (18, 'shutil.copyfile', 'shutil.copyfile', False, 'import shutil\n')]