Mercurial > repos > bimib > marea
changeset 35:7b1971251c63 draft
Uploaded
author | bimib |
---|---|
date | Mon, 25 Nov 2019 05:40:30 -0500 |
parents | 1a97d1537623 |
children | 94c51690d40c |
files | Marea/marea.py Marea/marea.xml |
diffstat | 2 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Marea/marea.py Sat Oct 26 07:49:31 2019 -0400 +++ b/Marea/marea.py Mon Nov 25 05:40:30 2019 -0500 @@ -5,7 +5,6 @@ import scipy.stats as st import collections import lxml.etree as ET -import shutil import pickle as pk import math import os @@ -201,6 +200,7 @@ l = l[1:] return (tmp, err) + def replace_gene(l, d): if l =='and' or l == 'or': return l @@ -577,7 +577,7 @@ ############################ gene ############################################# def data_gene(gene, type_gene, name, gene_custom): - args = process_args(sys.argv) + args = process_args(sys.argv) for i in range(len(gene)): tmp = gene.iloc[i, 0] if tmp.startswith(' ') or tmp.endswith(' '): @@ -586,6 +586,7 @@ collections.Counter(gene[gene.columns[0]]).items() if count > 1] pat_dup = [item for item, count in collections.Counter(list(gene.columns)).items() if count > 1] + if gene_dup: if gene_custom == None: if args.rules_selector == 'HMRcore': @@ -607,12 +608,14 @@ if pat_dup: warning('Warning: duplicated label\n' + str(pat_dup) + 'in ' + name + '\n') + return (gene.set_index(gene.columns[0])).to_dict() ############################ resolve ########################################## def resolve(genes, rules, ids, resolve_none, name): resolve_rules = {} + names_array = [] not_found = [] flag = False for key, value in genes.items(): @@ -630,7 +633,7 @@ tmp_resolve.append(ris) flag = True else: - tmp_resolve.append(None) + tmp_resolve.append(None) resolve_rules[key] = tmp_resolve if flag is False: warning('Warning: no computable score (due to missing gene values)' + @@ -662,7 +665,7 @@ ############################ create_ras ####################################### -def create_ras (resolve_rules, dataset_name, single_ras): +def create_ras (resolve_rules, dataset_name, single_ras, rules, ids): if resolve_rules == None: warning("Couldn't generate RAS for current dataset: " + dataset_name) @@ -673,6 +676,8 @@ geni[i] = 'None' output_ras = pd.DataFrame.from_dict(resolve_rules) + + output_ras.insert(0, 'Reactions', ids) output_to_csv = pd.DataFrame.to_csv(output_ras, sep = '\t', index = False) if (single_ras): @@ -741,7 +746,7 @@ create_svg = check_bool(args.generate_svg) create_pdf = check_bool(args.generate_pdf) generate_ras = check_bool(args.generate_ras) - + os.makedirs('result') if generate_ras: @@ -771,10 +776,10 @@ ids, rules = load_id_rules(recon.get(type_gene)) elif args.rules_selector == 'Custom': genes = data_gene(dataset, type_gene, name, gene_in_rule) - + resolve_rules, err = resolve(genes, rules, ids, resolve_none, name) - create_ras(resolve_rules, name, True) + create_ras(resolve_rules, name, True, rules, ids) if err != None and err: warning('Warning: gene\n' + str(err) + '\nnot found in class ' @@ -802,10 +807,11 @@ elif args.rules_selector == 'Custom': genes = data_gene(dataset, type_gene, name, gene_in_rule) + resolve_rules, err = resolve(genes, rules, ids, resolve_none, name) if generate_ras: - create_ras(resolve_rules, name, False) + create_ras(resolve_rules, name, False, rules, ids) if err != None and err: warning('Warning: gene\n' + str(err) + '\nnot found in class ' @@ -837,7 +843,7 @@ if resolve_rules != None: class_pat = split_class(classes, resolve_rules) if generate_ras: - create_ras(resolve_rules, name, False) + create_ras(resolve_rules, name, False, rules, ids) if args.rules_selector == 'Custom':
--- a/Marea/marea.xml Sat Oct 26 07:49:31 2019 -0400 +++ b/Marea/marea.xml Mon Nov 25 05:40:30 2019 -0500 @@ -1,4 +1,4 @@ -<tool id="MaREA" name="Metabolic Reaction Enrichment Analysis" version="1.0.5"> +<tool id="MaREA" name="Metabolic Reaction Enrichment Analysis" version="1.0.6"> <description></description> <macros> <import>marea_macros.xml</import>