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, 8, 5, 37), 'Module.AbstractModule.__init__', 'AbstractModule.__init__', ({(5, 32, 5, 36): 'self'}, {}), '(self)', False, 'from Module import AbstractModule\n'), ((14, 23, 14, 53), 'os.listdir', 'os.listdir', ({(14, 34, 14, 52): 'in_data.identifier'}, {}), '(in_data.identifier)', False, 'import os\n'), ((21, 15, 21, 41), 'genomicode.filelib.exists_nz', 'filelib.exists_nz', ({(21, 33, 21, 40): 'outfile'}, {}), '(outfile)', False, 'from genomicode import filelib\n'), ((28, 24, 28, 72), 'Betsy.module_utils.get_inputid', 'module_utils.get_inputid', ({(28, 49, 28, 71): 'antecedents.identifier'}, {}), '(antecedents.identifier)', False, 'from Betsy import module_utils\n'), ((17, 28, 17, 73), 'os.path.join', 'os.path.join', ({(17, 41, 17, 59): 'in_data.identifier', (17, 61, 17, 72): 'result_file'}, {}), '(in_data.identifier, result_file)', False, 'import os\n'), ((18, 16, 18, 51), 'shutil.copyfile', 'shutil.copyfile', ({(18, 32, 18, 41): 'goal_file', (18, 43, 18, 50): 'outfile'}, {}), '(goal_file, outfile)', False, 'import shutil\n')]