Previous changeset 64:53b4fca5bdf9 (2020-03-16) Next changeset 66:858500ec9767 (2020-03-16) |
Commit message:
Uploaded |
modified:
Marea/marea.py |
b |
diff -r 53b4fca5bdf9 -r a61733753aec Marea/marea.py --- a/Marea/marea.py Mon Mar 16 07:47:12 2020 -0400 +++ b/Marea/marea.py Mon Mar 16 08:21:29 2020 -0400 |
[ |
@@ -537,36 +537,6 @@ warning('Warning: wrong format rule in ' + str(err_rules) + '\n') return (split_rules, list(set(tmp_gene_in_rule))) -def make_recon(data): - try: - import cobra as cb - import warnings - with warnings.catch_warnings(): - warnings.simplefilter('ignore') - recon = cb.io.read_sbml_model(data) - react = recon.reactions - rules = [react[i].gene_reaction_rule for i in range(len(react))] - ids = [react[i].id for i in range(len(react))] - except cb.io.sbml.CobraSBMLError: - try: - data = (pd.read_csv(data, sep = '\t', dtype = str, engine='python')).fillna('') - if len(data.columns) < 2: - sys.exit('Execution aborted: wrong format of '+ - 'custom datarules\n') - if not len(data.columns) == 2: - warning('Warning: more than 2 columns in custom datarules.\n' + - 'Extra columns have been disregarded\n') - ids = list(data.iloc[:, 0]) - rules = list(data.iloc[:, 1]) - except pd.errors.EmptyDataError: - sys.exit('Execution aborted: wrong format of custom datarules\n') - except pd.errors.ParserError: - sys.exit('Execution aborted: wrong format of custom datarules\n') - split_rules, tmp_genes = do_rules(rules) - gene_in_rule = {} - for i in tmp_genes: - gene_in_rule[i] = 'ok' - return (ids, split_rules, gene_in_rule) ############################ gene ############################################# @@ -666,7 +636,6 @@ if comparison == "manyvsmany": for i, j in it.combinations(class_pat.keys(), 2): - tmp = {} count = 0 max_F_C = 0 @@ -702,10 +671,6 @@ renderPDF.drawToFile(svg2rlg(file_svg), file_pdf) if not create_svg: - #Ho utilizzato il file svg per generare il pdf, - #ma l'utente non ne ha richiesto il ritorno, quindi - #lo elimino - os.remove('result/' + i + '_vs_' + j + ' (SVG Map).svg') elif comparison == "onevsrest": for single_cluster in class_pat.keys(): @@ -739,8 +704,8 @@ tmp_csv.to_csv(tab, sep = '\t', index = False, header = header) if create_svg or create_pdf: - if args.rules_selector == 'HMRcore' or (args.rules_selector == 'Custom' - and args.yes_no == 'yes'): + if args.custom_rules == 'false' or (args.custom_rules == 'true' + and args.custom_map != ''): fix_map(tmp, core_map, threshold_P_V, threshold_F_C, max_F_C) file_svg = 'result/' + single_cluster + '_vs_ rest (SVG Map).svg' with open(file_svg, 'wb') as new_map: @@ -756,6 +721,10 @@ elif comparison == "onevsmany": for i, j in it.combinations(class_pat.keys(), 2): + if i != control and j != control: + continue + if i == control and j == control: + continue tmp = {} count = 0 max_F_C = 0 @@ -778,8 +747,8 @@ tmp_csv.to_csv(tab, sep = '\t', index = False, header = header) if create_svg or create_pdf: - if args.rules_selector == 'HMRcore' or (args.rules_selector == 'Custom' - and args.yes_no == 'yes'): + if args.custom_rules == 'false' or (args.custom_rules == 'true' + and args.custom_map != ''): fix_map(tmp, core_map, threshold_P_V, threshold_F_C, max_F_C) file_svg = 'result/' + i + '_vs_' + j + ' (SVG Map).svg' with open(file_svg, 'wb') as new_map: @@ -791,10 +760,6 @@ renderPDF.drawToFile(svg2rlg(file_svg), file_pdf) if not create_svg: - #Ho utilizzato il file svg per generare il pdf, - #ma l'utente non ne ha richiesto il ritorno, quindi - #lo elimino - os.remove('result/' + i + '_vs_' + j + ' (SVG Map).svg') @@ -812,9 +777,6 @@ if os.path.isdir('result') == False: os.makedirs('result') - - if args.custom_rules == 'true': - ids, rules, gene_in_rule = make_recon(args.custom_rule) class_pat = {} @@ -879,7 +841,13 @@ else: core_map = ET.parse(args.tool_dir+'/local/HMRcoreMap.svg') - maps(core_map, class_pat, ids, args.pValue, args.fChange, create_svg, create_pdf, args.comparison, args.control) + class_pat_trim = {} + + for key in class_pat.keys(): + class_pat_trim[key.strip()] = class_pat[key] + + + maps(core_map, class_pat_trim, ids, args.pValue, args.fChange, create_svg, create_pdf, args.comparison, args.control) print('Execution succeded') |