@@ -0,0 +1,2560 @@
+#bfrm_normalize.py%0Aimport os%0Aimport hash_method%0Aimport subprocess%0Aimport module_utils%0Aimport rule_engine%0Aimport shutil%0Adef run(parameters,objects,pipeline):%0A    identifier,single_object = get_identifier(parameters,objects)%0A    outfile =  get_outfile(parameters,objects,pipeline)%0A    import Betsy_config%0A    bfrm_path = Betsy_config.BFRMNORM%0A    bfrm_BIN = module_utils.which(bfrm_path)%0A    assert bfrm_BIN,'cannot find the %25s' %25bfrm_path%0A    num_factor = 10%0A    if 'num_factors' in parameters.keys():%0A        num_factor = int(parameters%5B'num_factors'%5D)%0A        assert num_factor %3E= 1, 'the num_factor should be %3E=1'%0A        import arrayio%0A        M = arrayio.read(identifier)%0A        col_num = M.ncol()%0A        assert num_factor %3C= col_num,'the num_factor should be less than %25d'%25col_num%0A    tmp = 'tmp_dir'%0A    command = %5B'python', bfrm_BIN,identifier,'-f',str(num_factor), '-o',tmp%5D%0A    process = subprocess.Popen(command,shell=False,%0A                                stdout=subprocess.PIPE,%0A                                stderr=subprocess.PIPE)%0A    error_message = process.communicate()%5B1%5D%0A    if error_message:%0A        raise ValueError(error_message)%0A    assert module_utils.exists_nz(tmp),'the output dir %25s%5C%0A             for bfrm_normalize fails' %25tmp%0A    assert module_utils.exists_nz(os.path.join(tmp,'normalized.gct')),'the output gct file %5C%0A             for bfrm_normalize fails'%0A    shutil.copyfile(os.path.join(tmp,'normalized.gct'),outfile)%0A    new_objects = get_newobjects(parameters,objects,pipeline)%0A    module_utils.write_Betsy_parameters_file(%0A        parameters,single_object,pipeline)%0A    return new_objects%0A    %0Adef make_unique_hash(identifier,pipeline,parameters):%0A    return module_utils.make_unique_hash(%0A            identifier,pipeline,parameters)%0A   %0Adef get_outfile(parameters,objects,pipeline):%0A    return module_utils.get_outfile(%0A        parameters,objects,'signal_file','contents,preprocess',pipeline)%0A    %0Adef get_identifier(parameters,objects):%0A    identifier,single_object = module_utils.find_object(%0A        parameters,objects,'signal_file','contents,preprocess')%0A    assert os.path.exists(identifier),'the input file %5C%0A        %25s for bfrm_normalize does not exist'%25identifier%0A    return identifier,single_object%0A%0Adef get_newobjects(parameters,objects,pipeline):%0A    outfile = get_outfile(parameters,objects,pipeline)%0A    identifier,single_object = get_identifier(parameters,objects)%0A    new_objects = module_utils.get_newobjects(%0A        outfile,'signal_file',parameters,objects,single_object)%0A    return new_objects%0A    %0A%0A

add bfrm_normalize.py