API for padmet.utils.connection

Description:

#TODO

biggAPI_to_padmet

Description:

Require internet access !

Allows to extract the bigg database from the API to create a padmet.

1./ Get all reactions universal id from http://bigg.ucsd.edu/api/v2/universal/reactions, escape reactions of biomass.

2./ Using async_list, extract all the informations for each reactions (compounds, stochio, name …)

3./ Need to use sleep time to avoid to lose the server access.

4./ Because the direction fo the reaction is not set by default in bigg. We get all the models where the reaction is and the final direction will the one found in more than 75%

5./ Also extract xrefs

usage:
    padmet biggAPI_to_padmet --output=FILE [--pwy_file=FILE] [-v]

options:
    -h --help     Show help.
    --output=FILE    path to output, the padmet file.
    --pwy_file=FILE   add kegg pathways from pathways file, line:'pwy_id, pwy_name, x, rxn_id'.
    -v   print info.
padmet.utils.connection.biggAPI_to_padmet.add_kegg_pwy(pwy_file, padmetRef, verbose=False)[source]

#TODO

padmet.utils.connection.biggAPI_to_padmet.biggAPI_to_padmet(output, pwy_file=None, verbose=False)[source]

Extract BIGG database using the api. Create a padmet file. Escape reactions of biomass. Require internet access !

Allows to extract the bigg database from the API to create a padmet.

1./ Get all reactions universal id from http://bigg.ucsd.edu/api/v2/universal/reactions, escape reactions of biomass. 2./ Using async_list, extract all the informations for each reactions (compounds, stochio, name …) 3./ Need to use sleep time to avoid to lose the server access. 4./ Because the direction fo the reaction is not set by default in bigg. We get all the models where the reaction is and the final direction will the one found in more than 75% 5./ Also extract xrefs

Parameters:
  • output (str) – path to output, the padmet file.

  • pwy_file (str) – path to pathway file, add kegg pathways, line:’pwy_id, pwy_name, x, rxn_id’.

  • verbose (bool) – if True print information

padmet.utils.connection.biggAPI_to_padmet.biggAPI_to_padmet_cli(command_args)[source]
padmet.utils.connection.biggAPI_to_padmet.command_help()[source]

Show help for analysis command.

check_orthology_input

Description:

Before running orthology based reconstruction it is necessary to check if the metabolic network and the proteome of the model organism use the same ids for genes (or at least more than a given cutoff). To only check this. Use the 2nd usage.

If the genes ids are not the same, it is necessary to use a dictionnary of genes ids associating the genes ids from the proteome to the genes ids from the metabolic network.

To create the correct proteome from the dictionnnary, use the 3nd usage Finnaly by using the 1st usage, it is possible to:

1/ Check model_faa and model_metabolic for a given cutoff

2/ if under the cutoff, convert model_faa to the correct one with dict_ids_file

3/ if still under, SystemExit()

usage:
    padmet check_orthology_input    --model_metabolic=FILE    --model_faa=FILE    [--cutoff=FLOAT] [--dict_ids_file=FILE] --output=FILE    [-v]
    padmet check_orthology_input    --model_metabolic=FILE    --model_faa=FILE    [--cutoff=FLOAT] [-v]
    padmet check_orthology_input    --model_faa=FILE    --dict_ids_file=FILE    --output=FILE [-v]

option:
    -h --help    Show help.
    --model_metabolic=FILE    pathname to the metabolic network of the model (sbml).
    --model_faa=FILE    pathname to the proteome of the model (faa)
    --cutoff=FLOAT    cutoff [0:1] for comparing model_metabolic and model_faa. [default: 0.70].
    --dict_ids_file=FILE    pathname to the dict associating genes ids from the model_metabolic to the model_faa. line = gene_id_in_metabolic_network       gene_id_in_faa
    --output=FILE    output of get_valid_faa (a faa) or get_dict_ids (a dictionnary of gene ids in tsv)
    -v   print info
padmet.utils.connection.check_orthology_input.check_ids(model_metabolic, model_faa, cutoff, verbose=False)[source]

check if genes ids of model_metabolic = model_faa for a given cutoff faa genes ids are in the first line of each sequence: >GENE_ID …. metabolic netowkrs genes ids are in note section, GENE_ASSOCIATION: gene_id-1 or gene_id-2

Parameters:
  • model_metabolic (str) – path to sbml file

  • model_faa (str) – path to fasta faa file

  • cutoff (int) – cutoff genes ids from model found in faa

  • verbose (bool) – verbose

Returns:

True if same ids, if verbose, print % of genes under cutoff

Return type:

bool

padmet.utils.connection.check_orthology_input.check_orthology_input(model_metabolic, model_faa, dict_ids_file, output, verbose, cutoff)[source]

#TODO

padmet.utils.connection.check_orthology_input.check_orthology_input_cli(command_args)[source]
padmet.utils.connection.check_orthology_input.command_help()[source]

Show help for analysis command.

padmet.utils.connection.check_orthology_input.get_valid_faa(model_faa, dict_ids_file, output)[source]

create a new faa from the model_faa by converting the gene id with the dict_ids dict_ids: line = origin_id new_gene_id, sep =

Parameters:
  • model_faa (str) – path to faa file

  • dict_ids_file (str) – path to file containing link old to new ids

  • output (str) – path to new faa file

enhanced_meneco_output

Description:

The standard output of meneco return ids of reactions corresponding to the solution for gapfilling.

The ids are those from the sbml and so they are encoded.

This script extract the solution corresponding to the union of reactions “Computing union of reactions from all completion” Based on padmetRef return a file with more information for each reaction.

ex: RXN__45__5

RXN-5, common_name, ec-number, Formula (with id),Formula (with cname),Action,Comment Also, the output can be used as input of the script update_padmetSpec.py In the column Action: ‘add’ => To add the reaction, ‘’ => to do nothing

Comment: the reason of adding the reaction (ex: added for gap-filling by meneco)

usage:
    padmet enhanced_meneco_output --meneco_output=FILE --padmetRef=FILE --output=FILE [--json] [--reactions=STR] [-v]

options:
    -h --help     Show help.
    --meneco_output=FILE    pathname of a meneco run' result
    --padmetRef=FILE    path to padmet file corresponding to the database of reference (the repair network)
    --output=FILE    path to tsv output file
    --json  if meneco output in json format
    --reactions=STR set of reactions to extract (default=union) values : union, intersection, essential, minimal
        (works if meneco output given in json format)
padmet.utils.connection.enhanced_meneco_output.command_help()[source]

Show help for analysis command.

padmet.utils.connection.enhanced_meneco_output.enhanced_meneco_output(meneco_output_file, padmetRef, output, json_fmt: bool, reactions_to_extract: str, verbose=False)[source]

The standard output of meneco return ids of reactions corresponding to the solution for gapfilling. The ids are those from the sbml and so they are encoded. This script extract the solution corresponding to the union of reactions “Union of cardinality minimal completions” Based on padmetRef return a file with more information for each reaction.

ex: RXN__45__5 RXN-5, common_name, ec-number, Formula (with id),Formula (with cname),Action,Comment Also, the output can be used as input for manual_curation In the column Action: ‘add’ => To add the reaction, ‘’ => to do nothing Comment: the reason of adding the reaction (ex: added for gap-filling by meneco)

Parameters:
  • meneco_output_file (str) – pathname of a meneco run’ result

  • padmetRef (padmet.padmetRef) – path to padmet file corresponding to the database of reference (the repair network)

  • output (str) – path to tsv output file

  • json_fmt (bool) – True if the meneco output is in json format

  • reactions_to_extract (str) – What group of reactions to extract

  • verbose (bool) – if True print information

padmet.utils.connection.enhanced_meneco_output.enhanced_meneco_output_cli(command_args)[source]

extract_orthofinder

Description:

After running orthofinder on n fasta file, read the output file ‘Orthogroups.tsv’

Require a folder ‘orthology_based_folder’ with this archi:

|– model_a

– model_a.sbml

|– model_b

–model_b.sbml

And the name of the studied organism ‘study_id’

  1. Read the orthogroups file, extract orthogroups in dict ‘all_orthogroups’, and all org names

  2. In orthology folder search for sbml files ‘extension = .sbml’

  3. For each models regroup all information in a dict dict_data:

    {‘study_id’: study_id, ‘model_id’ : model_id, ‘sbml_template’: path to sbml of model’, ‘output’: path to the output sbml, ‘verbose’: bool, if true print information }

    The output is by default:

    output_orthofinder_from_’model_id’.sbml

  4. Store all previous dict_data in a list all_dict_data

  5. iter on dict from all_dict_data and use function dict_data_to_sbml

Use a dict of data dict_data and dict of orthogroups dict_orthogroup to create sbml files.

dict_data and dict_orthogroup are obtained with fun orthofinder_to_sbml

6./ Read dict_orthogroups and check if model associated to dict_data and study org share orthologue

7./ Read sbml of model, parse all reactions and get genes associated to reaction.

8./ For each reactions:

Parse genes associated to sub part (ex: (gene-a and gene-b) or gene-c) = [(gene-a,gene-b), gene-c]

Check if study org have orthologue with at least one sub part (gene-a, gene-b) or gene-c

if yes: add the reaction to the new sbml and change genes ids by study org genes ids

Create the new sbml file.

usage:
    padmet extract_orthofinder --sbml=FILE/DIR --orthologues=DIR --study_id=STR --output=DIR [--workflow=STR] [-v]
    padmet extract_orthofinder --sbml=DIR --orthogroups=FILE --study_id=STR --output=DIR [--workflow=STR] [-v]

option:
    -h --help    Show help.
    --sbml=DIR   Folder with sub folder named as models name within sbml file name as model_name.sbml
    --orthogroups=FILE   Output file of Orthofinder run Orthogroups.tsv
    --orthologues=DIR   Output directory of Orthofinder run Orthologues
    --study_id=ID   name of the studied organism
    --workflow=ID   worklow id in ['aureme','aucome']. specific run architecture where to search sbml files
   --output=DIR   folder where to create all sbml output files
    -v   print info
padmet.utils.connection.extract_orthofinder.command_help()[source]

Show help for analysis command.

padmet.utils.connection.extract_orthofinder.dict_data_to_sbml(dict_data, dict_orthogroups=None, dict_orthologues=None, strict_match=True)[source]

Use a dict of data dict_data and dict of orthogroups dict_orthogroup to create sbml files. dict_data and dict_orthogroup are obtained with fun orthofinder_to_sbml 1./ Read dict_orthogroups and check if model associated to dict_data and study org share orthologue 2./ Read sbml of model, parse all reactions and get genes associated to reaction. 3./ For each reactions:

Parse genes associated to sub part (ex: (gene-a and gene-b) or gene-c) = [(gene-a,gene-b), gene-c] Check if study org have orthologue with at least one sub part (gene-a, gene-b) or gene-c if yes: add the reaction to the new sbml and change genes ids by study org genes ids

4./ Create the new sbml file.

Parameters:
  • dict_data (dict) – {‘study_id’: study_id, ‘model_id’ : model_id, ‘sbml_template’: path to sbml of model’, ‘output’: path to the output sbml, ‘verbose’: bool, if true print information }

  • dict_orthogroup (dict) – k=orthogroup_id, v = {k = name, v = set of genes}

  • verbose (bool) – if True print information

padmet.utils.connection.extract_orthofinder.extract_orthofinder_cli(command_args)[source]
padmet.utils.connection.extract_orthofinder.get_sbml_files(sbml, workflow=None, verbose=False)[source]

#TODO

padmet.utils.connection.extract_orthofinder.orthogroups_to_sbml(orthogroups_file, all_model_sbml, output_folder, study_id, verbose=False)[source]

After running orthofinder on n fasta file, read the output file ‘Orthogroups.tsv’ Require a folder ‘orthology_based_folder’ with this archi: model_a

model_a.sbml

model_b

model_b.sbml

And the name of the studied organism ‘study_id’ 1. Read the orthogroups file, extract orthogroups in dict ‘all_orthogroups’, and all org names 2. In orthology folder search for sbml files ‘extension = .sbml’ 3. For each models regroup all information in a dict dict_data:

{‘study_id’: study_id, ‘model_id’ : model_id, ‘sbml_template’: path to sbml of model’, ‘output’: path to the output sbml, ‘verbose’: bool, if true print information } The output is by default: output_orthofinder_from_’model_id’.sbml

  1. Store all previous dict_data in a list all_dict_data

5. iter on dict from all_dict_data and use function dict_data_to_sbml This function will create a sbml from each model and conserve only reactions associated to ortholog genes For more information read the doc of func dict_data_to_sbml

Parameters:
  • orthogroups_file (str) – path of Orthofinder output file ‘Orthogroups.tsv’

  • orthology_based_folder (str) – path of folder with model’s sbml

  • output (str) – pathname of the output folder of all sbml extracted

  • study_id (str) – name of the studied organism

  • verbose (bool) – if True print information

padmet.utils.connection.extract_orthofinder.orthologue_to_sbml(orthologue_folder, all_model_sbml, output_folder, study_id, verbose=False)[source]

After running orthofinder on n fasta file, read the output files in ‘Orthologues’ Require a folder ‘orthology_based_folder’ with this archi: model_a

model_a.sbml

model_b

model_b.sbml

And the name of the studied organism ‘study_id’ 1. Read the orthogroups file, extract orthogroups in dict ‘all_orthogroups’, and all org names 2. In orthology folder search for sbml files ‘extension = .sbml’ 3. For each models regroup all information in a dict dict_data:

{‘study_id’: study_id, ‘model_id’ : model_id, ‘sbml_template’: path to sbml of model’, ‘output’: path to the output sbml, ‘verbose’: bool, if true print information } The output is by default: output_orthofinder_from_’model_id’.sbml

  1. Store all previous dict_data in a list all_dict_data

5. iter on dict from all_dict_data and use function dict_data_to_sbml This function will create a sbml from each model and conserve only reactions associated to ortholog genes For more information read the doc of func dict_data_to_sbml

Parameters:
  • orthologue_folder (str) – path of Orthofinder output folder ‘Orthologues’

  • orthology_based_folder (str) – path of folder with model’s sbml

  • output (str) – pathname of the output folder of all sbml extracted

  • study_id (str) – name of the studied organism

  • verbose (bool) – if True print information

extract_rxn_with_gene_assoc

Description:

From a given sbml file, create a sbml with only the reactions associated to a gene.

Need for a reaction, in section ‘note’, ‘GENE_ASSOCIATION’: ….

usage:
    padmet extract_rxn_with_gene_assoc --sbml=FILE --output=FILE [-v]

options:
    -h --help     Show help.
    --sbml=FILE    path to the sbml file
    --output=FILE    path to the sbml output (with only rxn with genes assoc)
    -v   print info
padmet.utils.connection.extract_rxn_with_gene_assoc.command_help()[source]

Show help for analysis command.

padmet.utils.connection.extract_rxn_with_gene_assoc.extract_rxn_with_gene_assoc(sbml, output, verbose=False)[source]

From a given sbml document, create a sbml with only the reactions associated to a gene. Need for a reaction, in section ‘note’, ‘GENE_ASSOCIATION’: ….

Parameters:
  • sbml_file (libsbml.document) – sbml document

  • output (str) – pathname of the output sbml

padmet.utils.connection.extract_rxn_with_gene_assoc.extract_rxn_with_gene_assoc_cli(command_args)[source]

gbk_to_faa

Description:

convert GBK to FAA with Bio package

usage:
    padmet gbk_to_faa    --gbk=FILE --output=FILE [--qualifier=STR] [-v]

option:
    -h --help    Show help.
    --gbk=FILE    path to the gbk file.
    --output=FILE    path to the output, a FAA file.
    --qualifier=STR    the qualifier of the gene id [default: locus_tag].
    -v   print info
padmet.utils.connection.gbk_to_faa.command_help()[source]

Show help for analysis command.

padmet.utils.connection.gbk_to_faa.gbk_to_faa(gbk_file, output, qualifier='locus_tag', verbose=True)[source]

convert GBK to FAA with Bio package

Parameters:
  • gbk_file (str) – path to the gbk file

  • output (str) – path to the output, a FAA file

  • qualifier (str) – he qualifier of the gene id

  • verbose (bool) – if True print information

padmet.utils.connection.gbk_to_faa.gbk_to_faa_cli(command_args)[source]

gene_to_targets

Description:

From a list of genes, get from the linked reactions the list of products.

R1 is linked to G1, R1 produces M1 and M2. output: M1,M2. Takes into account reversibility

usage:
    padmet gene_to_targets --padmetSpec=FILE --genes=FILE --output=FILE [-v]

options:
    -h --help     Show help
    --padmetSpec=FILE    path to the padmet file
    --genes=FILE   path to the file containing gene ids, one id by line
    --output=FILE    path to the output file containing all tagerts which can by produced by all reactions associated to the given genes
    -v   print info
padmet.utils.connection.gene_to_targets.command_help()[source]

Show help for analysis command.

padmet.utils.connection.gene_to_targets.gene_to_targets(padmet, genes_file, output, verbose=False)[source]

From a list of genes, get from the linked reactions the list of products. R1 is linked to G1, R1 produces M1 and M2. output: M1,M2. Takes into account reversibility

Parameters:
  • padmet (padmet.classes.PadmetSpec) – padmet to explore

  • genes_file (str) – path of genes file, 1 gene id by line

  • output (str) – pathname of the output file

  • verbose (bool) – if True print information

padmet.utils.connection.gene_to_targets.gene_to_targets_cli(command_args)[source]

get_metacyc_ontology

Description:

From the padmetRef of MetaCyc creates the MetaCyc ontology. At this moment, all the element of the tree begins with a ont_ and all the ‘+’ or ‘-’ are removed. This is a limitation from lxml tag.

usage:
    padmet get_metacyc_to_ontology -p=FILE -o=FILE

options:
    -h --help     Show help.
    -p=FILE    path of the padmet file of MetaCyc
    -o=FILE   pathname of the XML output file
padmet.utils.connection.get_metacyc_ontology.add_element_to_tree(element_ids, padmet_instance, ontology_elements, element_type)[source]
padmet.utils.connection.get_metacyc_ontology.command_help()[source]

Show help for analysis command.

padmet.utils.connection.get_metacyc_ontology.extract_element_ontology(metacyc_ontology_file, padmetRef_file, output_file)[source]
padmet.utils.connection.get_metacyc_ontology.get_metacyc_ontology_cli(command_args)[source]
padmet.utils.connection.get_metacyc_ontology.metacyc_to_ontology(padmetRef_file, output_file, ontology_root='FRAMES')[source]

Extract the ontology of MetaCyc from the padmetRef.

Parameters:
  • padmetRef_file (str) – path to padmetRef file

  • output_file (str) – pathname of the output sbml

  • ontology_root (str) – name of the roots to use to create the tree (FRAMES, Generalized-Reactions, Compounds, …)

padmet.utils.connection.get_metacyc_ontology.ontology_to_newick(metacyc_ontology_file, newick_output_file)[source]

metexploreviz_export

Description:

convert a padmet representing a metabolic network into a json compatible with MetExplore.

usage:

padmet metexploreviz_export –input=FILE –output=DIR [-v] [–focus=FILE]

options:

-h –help Show help. –input=FILE/FOLDER path of the padmet representing the network to convert –output=FILE/FOLDER path of json output file –focus=FILE/STR path of tabulated compounds/reaction/pathway or compounds name -v

padmet.utils.connection.metexploreviz_export.command_help()[source]

Show help for analysis command.

padmet.utils.connection.metexploreviz_export.create_json_from_padmet(input_file, verbose=False)[source]

Create JSON formatted for metexploreviz using a padmet file

Parameters:
  • input_file (str) – path to padmet input file

  • verbose (bool) – if True print information

Returns:

json_dicts – JSON formatted for metexploreviz

Return type:

dict

padmet.utils.connection.metexploreviz_export.create_json_from_sbml(input_file, verbose=False)[source]

Create JSON formatted for metexploreviz using a sbml file

Parameters:
  • input_file (str) – path to sbml input file

  • verbose (bool) – if True print information

Returns:

json_dicts – JSON formatted for metexploreviz

Return type:

dict

padmet.utils.connection.metexploreviz_export.metexploreviz_export(input_file_folder, output_file, focus, verbose=False)[source]

Create JSON formatted for metexploreviz using an inptu file or a folder

Parameters:
  • input_file_folder (str) – path to input file (either padmet or sbml) or a folder containing padmet or sbml

  • output_file (str) – path to JSON formatted for metexploreviz

  • verbose (bool) – if True print information

padmet.utils.connection.metexploreviz_export.metexploreviz_export_cli(command_args)[source]

modelSeed_to_padmet

Description:

From modelSeed reactions and pathways files creates a padmet file.

usage:
    padmet modelSeed_to_padmet --output=FILE --rxn_file=FILE --pwy_file=FILE [-v]

options:
    -h --help     Show help.
    --output=FILE    path of the padmet file to create
    --rxn_file=FILE   path to json file of modelSeed reactions
    --pwy_file=FILE   path to pathway reactions association from modelSeed
    -v   print info.
padmet.utils.connection.modelSeed_to_padmet.add_kegg_pwy(pwy_file, padmetRef, verbose=False)[source]

#TODO

padmet.utils.connection.modelSeed_to_padmet.command_help()[source]

Show help for analysis command.

padmet.utils.connection.modelSeed_to_padmet.modelSeed_to_padmet(rxn_file, pwy_file, output, verbose=False)[source]

#TODO

padmet.utils.connection.modelSeed_to_padmet.modelSeed_to_padmet_cli(command_args)[source]

padmet_to_asp

Description:

Convert PADMet to ASP following these predicats: common_name({reaction_id or enzyme_id or pathway_id or compound_id} , common_name) direction(reaction_id, reaction_direction). reaction_direction in[LEFT-TO-RIGHT,REVERSIBLE] ec_number(reaction_id, ec(x,x,x)). catalysed_by(reaction_id, enzyme_id). uniprotID(enzyme_id, uniprot_id). #if has has_xref and db = “UNIPROT” in_pathway(reaction_id, pathway_id). reactant(reaction_id, compound_id, stoechio_value). product(reaction_id, compound_id, stoechio_value). is_a(compound_id, class_id). is_a(pathway_id, pathway_id).

usage:
    padmet padmet_to_asp --padmet=FILE --output=FILE [-v]

option:
    -h --help     Show help.
    --padmet=FILE    path to padmet file to convert.
    --output=FILE    path to output file in lp format.
    -v    print info.
padmet.utils.connection.padmet_to_asp.asp_synt(pred, list_args)[source]

create a predicat for asp

example: asp_synt(“direction”,[“R1”,”REVERSIBLE”]) => “direction(‘R1’,’reversible’).”

Parameters:
  • pred (str) – the predicat

  • list_args (list) – list of atoms to put in the predicat

Returns:

the predicat ‘pred(‘’list_args[0]’’,’’list_args[1]’’,…,’’list_args[n]’’).’

Return type:

str

padmet.utils.connection.padmet_to_asp.command_help()[source]

Show help for analysis command.

padmet.utils.connection.padmet_to_asp.padmet_to_asp(padmet_file, output, verbose=False)[source]

Convert PADMet to ASP following these predicats: common_name({reaction_id or enzyme_id or pathway_id or compound_id} , common_name) direction(reaction_id, reaction_direction). reaction_direction in[LEFT-TO-RIGHT,REVERSIBLE] ec_number(reaction_id, ec(x,x,x)). catalysed_by(reaction_id, enzyme_id). uniprotID(enzyme_id, uniprot_id). #if has has_xref and db = “UNIPROT” in_pathway(reaction_id, pathway_id). reactant(reaction_id, compound_id, stoechio_value). product(reaction_id, compound_id, stoechio_value). is_a(compound_id, class_id). is_a(pathway_id, pathway_id).

Parameters:
  • padmet_file (str) – the path to padmet file to convert

  • output (str) – the path to the output to create

  • verbose (bool) – print informations

padmet.utils.connection.padmet_to_asp.padmet_to_asp_cli(command_args)[source]

padmet_to_matrix

Description:

Create a stoichiometry matrix from a padmet file.

The columns represent the reactions and rows represent metabolites.

S[i,j] contains the quantity of metabolite ‘i’ produced (negative for consumed) by reaction ‘j’.

usage:
    padmet padmet_to_matrix --padmet=FILE --output=FILE

option:
    -h --help    Show help.
    --padmet=FILE    path to the padmet file to convert.
    --output=FILE    path to the output file, col: rxn, row: metabo, sep = "        ".
padmet.utils.connection.padmet_to_matrix.command_help()[source]

Show help for analysis command.

padmet.utils.connection.padmet_to_matrix.padmet_to_matrix(padmet, output)[source]

Create a stoichiometry matrix from a padmet file. The columns represent the reactions and rows represent metabolites. S[i,j] contains the quantity of metabolite ‘i’ produced (negative for consumed) by reaction ‘j’.

Parameters:
  • padmet (padmet.PadmetSpec) – padmet instance

  • output – path to the output file, col: rxn, row: metabo, sep = “ “

padmet.utils.connection.padmet_to_matrix.padmet_to_matrix_cli(command_args)[source]

padmet_to_padmet

Description:

Allows to merge 1-n padmet. 1./ Update the ‘init_padmet’ with the ‘to_add’ padmet(s). to_add can be a file or a folder with only padmet files to add.

usage:
    padmet padmet_to_padmet --to_add=FILE/DIR --output=FILE  [-v]

options:
    -h --help     Show help.
    --to_add=FILE/DIR    path to the padmet file to add (sep: ,) or path to folder of padmet files.
    --output=FILE   path to the new padmet file
    -v   print info
padmet.utils.connection.padmet_to_padmet.command_help()[source]

Show help for analysis command.

padmet.utils.connection.padmet_to_padmet.padmet_to_padmet(to_add, output=None, verbose=False)[source]

Create a padmet by merging multiple other padmet files.

Parameters:
  • to_add (dir or str) – padmet directory or string with multiple padmet paths separated by ‘,’

  • output – path to the output file

  • verbose (bool) – verbose level of script

Returns:

padmet_init – padmet created from emrging of the other padmet

Return type:

PadmetSpec

padmet.utils.connection.padmet_to_padmet.padmet_to_padmet_cli(command_args)[source]

padmet_to_tsv

Description:

convert a padmet representing a database (padmetRef) and/or a padmet representing a model (padmetSpec) to tsv files for askomics.

1./ Folder creation given the output directory. Create this directory if required and create a folder padmetRef filename and/or padmetSpec filename

2./

2.1/ For padmetRef:

2.1.a/ Nodes

get all reactions nodes => extract data from misc with extract_nodes(rxn_nodes, “reaction”, “../rxn.tsv”)

get all compounds nodes => extract data from misc with extract_nodes(cpd_nodes, “compounds”, “../cpd.tsv”)

get all pathways nodes => extract data from misc with extract_nodes(pwy_nodes, “pathway”, “../pwy.tsv”)

get all xrefs nodes => extract data from misc with extract_nodes(xref_nodes, “xref”, “../xref.tsv”)

2.1.b/ Relations

for each rxn in rxn nodes:

get all rlt consumes/produces => create list of data with extract_rxn_cpd(rxn_cpd_rlt)

fieldnames = “rxn_cpd”,”concerns@reaction”,”consumes@compound”,”produces@compound”,”stoichiometry”,”compartment”

get all rlt is_in_pathway => create list of data with extract_rxn_pwy(rxn_pwy_rlt)

fieldnames = “rxn_pwy”,”concerns@reaction”,”in_pwy@pathway

get all rlt has_xref => create list of data with extract_entity_xref(rxn_xref_rlt)

for each cpd in cpd nodes:

get all rlt has_xref => update previous list of data with extract_entity_xref(cpd_xref_rlt)

fieldnames = “entity_xref”,”concerns@reaction”,”concerns@compound”,”has_xref@xref

usage:
    padmet padmet_to_tsv --padmetSpec=FILE [--padmetRef=FILE] --output_dir=DIR [-v]
    padmet padmet_to_tsv --padmetRef=FILE [--padmetSpec=FILE] --output_dir=DIR [-v]

options:
    -h --help     Show help.
    --padmetSpec=FILE    path of the padmet representing the network to convert
    --padmetRef=FILE    path of the padmet representing the database
    --output_dir=DIR
    -v
padmet.utils.connection.padmet_to_tsv.command_help()[source]

Show help for analysis command.

padmet.utils.connection.padmet_to_tsv.entity_xref_file(data, output)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.extract_entity_xref(entity_xref_rlt, padmet)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.extract_nodes(padmet, nodes, entity_id, output, opt_col={})[source]

for n nodes in nodes. for each node.misc = {A:[‘x’],B:[‘y’,’z’]} create a file with line = [node.id,A[0],B[0]],[node.id,””,B[1]] the order is defined in fieldnames. merge common name and synonyms in ‘name’

#TODO

padmet.utils.connection.padmet_to_tsv.extract_pwy(padmet)[source]

from padmet return a dict, k = pwy_id, v = set of rxn_id in pwy

#TODO

padmet.utils.connection.padmet_to_tsv.extract_rxn_cpd(rxn_cpd_rlt)[source]

for rlt in rxn_cpd_rlt, append in data: [rxn_id,cpd_id(consumed),’’,stoich,compartment] and/or [rxn_id,’’,cpd_id(produced),stoich,compartment]. The value in index 0 is a merge of all data to create a unique relation id

#TODO

padmet.utils.connection.padmet_to_tsv.extract_rxn_gene(rxn_gene_rlt)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.extract_rxn_pwy(rxn_pwy_rlt)[source]

for rlt in rxn_pwy_rlt, append in data: [rxn_id,pwy_id]. The value in index 0 is a merge of all data to create a unique relation id

#TODO

padmet.utils.connection.padmet_to_tsv.extract_rxn_rec(rxn_rec_rlt)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.padmet_to_tsv(padmetSpec_file, padmetRef_file, output_dir, verbose=False)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.padmet_to_tsv_cli(command_args)[source]
padmet.utils.connection.padmet_to_tsv.pwy_rate(padmetRef, padmetSpec, metabolic_network, output)[source]

pwy rate in padmetSpec is calculated based on padmetRef

#TODO

padmet.utils.connection.padmet_to_tsv.rxn_cpd_file(data, output)[source]

from data obtained with extract_rxn_cpd(), create file rxn_cpd

#TODO

padmet.utils.connection.padmet_to_tsv.rxn_gene_file(data, output)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.rxn_pwy_file(data, output)[source]

#TODO

padmet.utils.connection.padmet_to_tsv.rxn_rec_file(data, output)[source]

#TODO

pgdb_to_padmet

Description:

Read a PGDB folder (from BIOCYC/PATHWAYTOOLS) and create a padmet. 1./ To create a padmet without any genes information extracted use the first usage with:

pgdb: path to pgdb folder output: path to the padmet to create version: to specify the version of the pgdb (20.0, 22.0) db: to specify the name of the database (METACYC, ECOCYC, …) enhance: to also read the file metabolic-reaction.xml and add the ? to the padmet

2./ To create a padmet and add only reactions from pgdb if they are in padmetRef specifier.

Copy information of the reaction not from the pgdb but from the padmetRef. This allows to uniform reaction to the same version of metacyc represented in the padmetRef For example, in some case 2 pgdb from different version can contain different information for a same reaction, pathway… In this case use:

padmetRef: path to the padmet of reference

3./ To create a padmet wth genes information extracted use:

extract-gene

3.1/ To remove from the final padmet all reactions without genes associated use:

no-orphan

4./ To read the metabolic-reaction.xml file, a sbml with some missing reactions in PGDB use:

enhance

For more information of the parsing process read information below.

classes.dat: For each class: create new node / class = class UNIQUE-ID (1) => node.id = UNIQUE-ID COMMON-NAME (0-n) => node.Misc[‘COMMON-NAME’] = COMMON-NAME TYPES (0-n) => for each, check or create new node class, create rlt (node is_a_class types) SYNONYMS (0-n) => for each, create new node name, create rlt (node has_name synonyms)

compounds.dat: for each compound: create new node / class = compound UNIQUE-ID (1) => node.id = UNIQUE-ID COMMON-NAME (0-n) => node.Misc[‘COMMON-NAME’] = COMMON-NAME INCHI (0-1) {InChI=XXX} => node.misc[‘INCHI’: InChI=XXX] INCHI-KEY (0-1) {InChIKey=XXX} => node.misc[‘INCHI_KEY’: InChIKey=XXX] MOLECULAR-WEIGHT (0-1) => node.misc()[‘MOLECULAR_WEIGHT’] = MOLECULAR-WEIGHT SMILES (0-1) => node.misc()[‘SMILES’] = SMILES TYPES (0-n) => for each, check or create new node class, create rlt (node is_a_class types) SYNONYMS (0-n) => for each, create new node name, create rlt (node has_name name) DBLINKS (0-n) {(db “id” …)} => for each, create new node xref, create rlt (node has_xref xref)

proteins.dat: for each protein: create new node / class = protein UNIQUE-ID (1) => node.id = UNIQUE-ID COMMON-NAME (0-n) => node.Misc[‘COMMON-NAME’] = COMMON-NAME INCHI-KEY (0-1) {InChIKey=XXX} => node.misc[‘INCHI_KEY’: InChIKey=XXX] MOLECULAR-WEIGHT (0-1) => node.misc()[‘MOLECULAR_WEIGHT’] = MOLECULAR-WEIGHT SMILES (0-1) => node.misc()[‘SMILES’] = SMILES TYPES (0-n) => for each, check or create new node class, create rlt (node is_a_class types) SYNONYMS (0-n) => for each, create new node name, create rlt (node has_name name) DBLINKS (0-n) {(db “id” …)} => for each, create new node xref, create rlt (node has_xref xref) SPECIES (0-1) => for each, check or create new node class, create rlt (node is_in_species class)

reactions.dat: for each reaction: create new node / class = reaction + node.misc()[“DIRECTION”] = “UNKNOWN” by default UNIQUE-ID (1) => node.id = UNIQUE-ID COMMON-NAME (0-n) => node.Misc[‘COMMON-NAME’] = COMMON-NAME EC-NUMBER (0-n) => node.Misc[‘EC-NUMBER’] = EC-NUMBER REACTION-DIRECTION (0-1) => node.Misc[‘DIRECTION’] = reaction-direction, if REVERSIBLE, else: LEFT-TO-RIGHT RXN-LOCATIONS (0,n) => node.misc[‘COMPARTMENT’] = rxn-location TYPES (0-n) => check or create new node class, create rlt (node.id is_a_class types’s_node.id) DBLINKS (0-n) {(db “id” …)} => create new node xref, create rlt (node has_xref xref’s_node.id) SYNONYMS (0-n) => create new node name, create rlt (node has_name name’s_node.id) – for LEFT and RIGHT, also check 2 next lines if info about ‘coefficient’ or ‘compartment’ defaut value: coefficient/stoichiometry = 1, compartment = unknown also check if the direction is ‘RIGHT-TO-LEFT’, if yes, inverse consumes and produces relations then change direction to ‘LEFT-TO-RIGHT’ LEFT (1-n) => create rlt (node.id consumes left’s_node.id) RIGHT (1-n) => create rlt (node.id produces right’s_node.id)

enzrxns.dat: for each association enzyme/reaction: create new rlt / type = catalyses ENZYME (1) => stock enzyme as ‘enzyme catalyses’ REACTION (1-n) => for each reaction after, create relation ‘enzyme catalyses reaction’

pathways.dat: for each pathway: create new node / class = pathway UNIQUE-ID (1) => node._id = UNIQUE-ID TYPES (0-n) => check or create new node class, create rlt (node is_a_class types) COMMON-NAME (0-n) => node.Misc[‘COMMON-NAME’] = COMMON-NAME DBLINKS (0-n) {(db “id” …)} => create new node xref, create rlt (node has_xref xref) SYNONYMS (0-n) => create new node name, create rlt (node has_name name) IN-PATHWAY (0-n) => check or create new node pathway, create rlt (node is_in_pathway name) REACTION-LIST (0-n) => check or create new node pathway, create rlt (node is_in_pathway name)

usage:
    padmet pgdb_to_padmet --pgdb=DIR --output=FILE [--version=V] [--db=ID] [--padmetRef=FILE] [--source=STR] [-v]
                          [--enhance] [--prot-ids70]
    padmet pgdb_to_padmet --pgdb=DIR --output=FILE --extract-gene [--no-orphan] [--keep-self-rxn] [--version=V]
                          [--db=ID] [--padmetRef=FILE] [--source=STR] [--prot-ids70] [-v] [--enhance]

options:
    -h --help     Show help.
    --version=V    Xcyc version [default: N.A].
    --db=ID    Biocyc database corresponding to the pgdb (MetaCyc, ecocyc, ...) [default: N.A].
    --output=FILE    padmet file corresponding to the DB.
    --pgdb=DIR    directory containing all the .dat files of MetaCyc (data).
    --padmetRef=FILE    padmet of reference.
    --source=STR    Tag associated to the source of the reactions, used to ensure traceability [default: GENOME].
    --enhance    use the metabolic-reactions.xml file to enhance the database.
    --extract-gene    extract genes from genes_file (use if it's a specie's pgdb, if MetaCyc, do not use).
    --no-orhpan    remove reactions without gene association (use if it's a specie's pgdb, if MetaCyc, do not use).
    --keep-self-rxn    keep reactions with no reactants (use if it's a specie's pgdb, if MetaCyc, do not use).
    --prot-ids70    Will extract UNIPROT and PID ids linked to rxn from protein-seq-ids-reduced-70.dat file and
                    create fasta file from protein-seq-ids-reduced-70.seq file
    -v   print info.
padmet.utils.connection.pgdb_to_padmet.classes_parser(filePath, padmet, verbose=False)[source]

from class.dat: get for each class, the UNIQUE-ID, COMMON-NAME, TYPES, SYNONYMS, DBLINKS Create a class node with node.id = UNIQUE-ID, node.misc = {COMMON-NAME:[COMMON-NAMES]} - For each types: A type is in fact a class. this information is stocked in padmet as: is_a_class relation btw a node and a class_node check if the type is already in the padmet if not create a new class_node (var: subClass) with subClass_node.id = type Create a relation current node is_a_class type - For each “SYNONYMS”: this information is stocked in padmet as: has_name relation btw a node and a name_node create a new name_node with name_node.id = class_id+”_names” and name_node.misc = {LABEL:[synonyms]} Create a relation current node has_name name_node.id - For each “DBLINKS”: “DBLINKS” is parsed with regex_xref to get the db and the id this information is stocked in padmet as: has_xref relation btw a node and a xref_node create a new xref_node with xref_node.id = class_id+”_xrefs” and xref_node.misc = {db:[id]} Create a relation current node has_xref xref_node.id

Parameters:
  • filePath (str) – path to classes.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.command_help()[source]

Show help for analysis command.

padmet.utils.connection.pgdb_to_padmet.compounds_parser(filePath, padmet, verbose=False)[source]
Parameters:
  • filePath (str) – path to compounds.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.create_prot_ids_fasta(file_path: str)[source]
padmet.utils.connection.pgdb_to_padmet.enhance_db(metabolic_reactions, padmet, with_genes, verbose=False)[source]

Parse sbml metabolic_reactions and add reactions in padmet if with_genes: add also genes information

Parameters:
  • metabolic_reactions (str) – path to sbml metabolic-reactions.xml

  • padmet (padmet.PadmetRef) – padmet instance

  • with_genes (bool) – if true alos add genes information.

Returns:

padmet instance with pgdb within pgdb + metabolic-reactions.xml data

Return type:

padmet.padmetRef

padmet.utils.connection.pgdb_to_padmet.enzrxns_parser(filePath, padmet, dict_protein_gene_id, source, verbose=False)[source]
Parameters:
  • filePath (str) – path to enzrxns.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.extract_prot_ids(e_list: List[str]) Set[str][source]

Get the set of elements corresponding to an UNIPROT or PID ID from a list of elements of a line from the protein-seq-ids-reduced-70.dat file.

Parameters:

e_list (List[str]) – List of proteins ids elements composing a line of the protein-seq-ids-reduced-70.dat file.

Returns:

Set of UNIPROT or PID IDs composing a line of the protein-seq-ids-reduced-70.dat file.

Return type:

Set[str]

padmet.utils.connection.pgdb_to_padmet.from_pgdb_to_padmet(pgdb_folder, db='MetaCyc', version='NA', source='GENOME', extract_gene=False, no_orphan=False, no_self_producing_rxn=True, enhanced_db=False, padmetRef_file=None, verbose=False, output_file=None, prot_ids70: bool = False)[source]
Parameters:
  • pgdb_folder (str) – path to pgdb

  • db (str) – pgdb name, default is ‘NA’

  • version (str) – pgdb version, default is ‘NA’

  • source (str) – tag reactions for traceability, default is ‘GENOME’

  • extract_gene (bool) – if true extract genes information

  • no_orphan (bool) – if true, remove reactions without genes associated

  • no_self_producing_rxn (bool) – if true, remove reactions with no reactants (auto-producing reactions)

  • enhanced_db (bool) – if true, read metabolic-reactions.xml sbml file and add information in final padmet

  • padmetRef_file (str) – path to padmetRef corresponding to MetaCyc in padmet format

  • verbose (bool) – if True print information

  • output_file (str) – pathname of padmet output file

  • prot_ids70 (bool) – if True will extract UNIPROT and PID ids linked to rxn from protein-seq-ids-reduced-70.dat file and create fasta file from protein-seq-ids-reduced-70.seq file

Returns:

padmet instance with pgdb within pgdb data

Return type:

padmet.padmetRef

padmet.utils.connection.pgdb_to_padmet.genes_parser(filePath, padmet, verbose=False)[source]
Parameters:
  • filePath (str) – path to genes.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.map_gene_id(dict_protein_gene_id, map_gene_ids)[source]

Map gene ID created by Pathway Tools with gene ID from the data. Automatically Pathway Tools uppercased all the letter in gene ID. So we need to do this mapping to retrieve the unuppercased gene ID.

padmet.utils.connection.pgdb_to_padmet.pathways_parser(filePath, padmet, verbose=False)[source]
Parameters:
  • filePath (str) – path to pathways.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.pgdb_to_padmet_cli(command_args)[source]
padmet.utils.connection.pgdb_to_padmet.proteins_parser(filePath, padmet, compounds, rnas, id_classes, verbose=False)[source]
Parameters:
  • filePath (str) – path to proteins.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • compounds (list) – list of known compounds in the species

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.proteins_seq_ids_reduced_70_dat_parser(file_path: str) Dict[str, Set[str]][source]
padmet.utils.connection.pgdb_to_padmet.reactions_parser(filePath, padmet, extract_gene, source, rxn_prot_ids: Dict[str, Set[str]] = None, verbose=False)[source]

from reaction.dat: get for each reaction, the UNIQUE-ID, COMMON-NAME, TYPES, SYNONYMS, DBLINKS Create a reaction node with node.id = UNIQUE-ID, node.misc = {COMMON-NAME:[COMMON-NAMES]} - For each types: A type is in fact a class. this information is stocked in padmet as: is_a_class relation btw a node and a class_node check if the type is already in the padmet if not create a new class_node (var: subClass) with subClass_node.id = type Create a relation current node is_a_class type - For each “SYNONYMS”: this information is stocked in padmet as: has_name relation btw a node and a name_node create a new name_node with name_node.id = reaction_id+”_names” name_node.misc = {LABEL:[synonyms]} Create a relation current node has_name name_node.id - For each “DBLINKS”: “DBLINKS” is parsed with regex_xref to get the db and the id this information is stocked in padmet as: has_xref relation btw a node and a xref_node create a new xref_node with xref_node.id = reaction_id+”_xrefs” and xref_node.misc = {db:[id]} Create a relation current node has_xref xref_node.id

Parameters:
  • filePath (str) – path to reactions.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • rxn_prot_ids (Dict[str, Set[str]]) – Dictionary associating for each rxn, UNIPROT or PID ids extracted from protein-seq-ids-reduced-70.dat file

  • verbose (bool) – if True print information

padmet.utils.connection.pgdb_to_padmet.rnas_parser(filePath, padmet, verbose=False)[source]
Parameters:
  • filePath (str) – path to compounds.dat

  • padmet (padmet.PadmetRef) – padmet instance

  • verbose (bool) – if True print information

sbmlGenerator

Description:

The module sbmlGenerator contains functions to generate sbml files from padmet and txt usign the libsbml package

usage:
    padmet sbmlGenerator --padmet=FILE --output=FILE --sbml_lvl=STR [--model_id=STR] [--obj_fct=STR] [--mnx_chem_prop=FILE] [--mnx_chem_xref=FILE] [-v]
    padmet sbmlGenerator --padmet=FILE --output=FILE [--init_source=STR] [-v]
    padmet sbmlGenerator --compound=FILE --output=FILE [--padmetRef=FILE] [-v]
    padmet sbmlGenerator --reaction=FILE --output=FILE --padmetRef=FILE [-v]

option:
    -h --help    Show help.
    --padmet=FILE    path of the padmet file to convert into sbml
    --output=FILE    path of the sbml file to generate.
    --mnx_chem_prop=FILE    path of the MNX chemical compounds properties.
    --mnx_chem_xref=FILE    path of the mnx dict of chemical compounds id mapping.
    --reaction=FILE    path of file of reactions ids, one by line to convert to sbml.
    --compound=FILE    path of file of compounds ids, one by line to convert to sbml.
    --init_source=STR    Select the reactions of padmet to convert on sbml based on the source of the reactions, check relations rxn has_reconstructionData.
    --sbml_lvl=STR    sbml level of output. [default 3]
    --obj_fct=STR    id of the reaction objective.
    -v   print info.
padmet.utils.connection.sbmlGenerator.add_ga(rId_encoded, all_ga_subsets)[source]

if list_ga len == 1: only 1 list of gene: if len of this list is 1: just add gene, else create OR structure else: create OR structure, then for each list of gene for each ga in list_ga: if len == 1: if the only ga len == 1: just add gene, else create OR structure elif len > 1: create AND structure, then for each GA if len GA == 1: just add gene, else create OR structure if no suppdata, if linked_genes: if len linked_genes == 1: just add gene, else create OR structure #TODO

padmet.utils.connection.sbmlGenerator.check(value, message)[source]

If ‘value’ is None, prints an error message constructed using ‘message’ and then exits with status code 1. If ‘value’ is an integer, it assumes it is a libSBML return status code. If the code value is LIBSBML_OPERATION_SUCCESS, returns without further action; if it is not, prints an error message constructed using ‘message’ along with text from libSBML explaining the meaning of the code, and exits with status code 1.

padmet.utils.connection.sbmlGenerator.command_help()[source]

Show help for analysis command.

padmet.utils.connection.sbmlGenerator.compound_to_sbml(species_compart, output, verbose=False)[source]

convert a list of compounds to sbml format if compart_name is not None, then the compounds id will by: M_originalID_compart_name if verbose and specified padmetRef and/or padmetSpec: will check if compounds are in one of the padmet files Ids are encoded for sbml using functions sbmlPlugin.convert_to_coded_id

Parameters:
  • species_file (str) – pathname to the file containing the compounds ids and the compart, line = cpd-id compart.

  • output (str) – pathname to the sbml file to create

  • verbose (bool) – print informations

padmet.utils.connection.sbmlGenerator.create_annotation(inchi, ref_id)[source]

dict_data, k = url, v = id #TODO

padmet.utils.connection.sbmlGenerator.create_note(dict_data)[source]

#TODO

padmet.utils.connection.sbmlGenerator.from_init_source(padmet_file, init_source, output, verbose=False)[source]

#TODO

padmet.utils.connection.sbmlGenerator.padmet_to_sbml(padmet, output, model_id=None, obj_fct=None, sbml_lvl=3, mnx_chem_prop=None, mnx_chem_xref=None, verbose=False)[source]

Convert padmet file to sbml file. Specificity: - ids are encoded for sbml using functions sbmlPlugin.convert_to_coded_id

Parameters:
  • padmet (str or padmet.classes.PadmetSpec/PadmetRef) – the pathname to the padmet file to convert, or PadmetSpec/PadmetRef object

  • output (str) – the pathname to the sbml file to create

  • model_id (str or None) – model id to set in sbml file

  • obj_fct (str) – the identifier of the objection function, the reaction to test in FBA

  • sbml_lvl (int) – the sbml level

  • sbml_version (int) – the sbml version

  • verbose (bool) – print informations

padmet.utils.connection.sbmlGenerator.parse_mnx_chem_prop(mnx_chem_prop)[source]

#TODO

padmet.utils.connection.sbmlGenerator.parse_mnx_chem_xref(mnx_chem_xref)[source]

#TODO

padmet.utils.connection.sbmlGenerator.reaction_to_sbml(reactions, output, padmetRef, verbose=False)[source]

convert a list of reactions to sbml format based on a given padmet of reference. - ids are encoded for sbml using functions sbmlPlugin.convert_to_coded_id

Parameters:
  • reactions (list) – list of reactions ids

  • padmetRef (padmet.classes.PadmetRef) – padmet of reference

  • output (str) – the pathname to the sbml file to create

padmet.utils.connection.sbmlGenerator.sbmlGenerator_cli(command_args)[source]

sbml_to_curation_form

Description:

extract 1 reaction (if rxn_id) or a list of reactions (if rxn_file) from a sbml file to the form used in aureme for curation. For example use this script to extract specific missing reaction of a model to a just created metabolic network.

usage:
    padmet sbml_to_curation_form --sbml=FILE --output=FILE --rxn_id=ID [--comment=STR] [--extract-gene] [-v]
    padmet sbml_to_curation_form --sbml=FILE --output=FILE --rxn_file=FILE [--comment=STR] [--extract-gene] [-v]

options:
    -h --help     Show help.
    --sbml=FILE    path of the sbml.
    --output=FILE    form containing the reaction extracted, form used for manual curation in aureme.
    --rxn_id=FILE    id of one reaction to extract
    --rxn_file=FILE    file of reactions ids to extract, 1 id by line.
    --extract-gene    If true, extract also genes associated to reactions.
    --comment=STR    comment associated to the reactions in the form. Used to track sources of curation in aureme [default: "N.A"].
    -v   print info
padmet.utils.connection.sbml_to_curation_form.command_help()[source]

Show help for analysis command.

padmet.utils.connection.sbml_to_curation_form.sbml_to_curation(sbml_file, rxn_list, output, extract_gene=False, comment='N.A', verbose=False)[source]

Read a sbml file, check if each reaction ids are in the sbml, if no, raise ValueError Then create the form. this form can then be used with manual_curation.py

Parameters:
  • sbml_file (str) – path to sbml file

  • rxn_list (list) – list of reaction id, ids must be identic as in the sbml, carrefull to encoded ids.

  • output (str) – path to the form to create

  • extract_gene (bool) – if true extract genes association

  • comment (str) – Comment why the reaction will be added in the network for traceability.

  • verbose (bool) – if True print information

padmet.utils.connection.sbml_to_curation_form.sbml_to_curation_form_cli(command_args)[source]

sbml_to_padmet

Description:

There are 3 cases of convertion sbml to padmet:

1./ Creation of a reference database in padmet format from sbml(s) (or updating one with new(s) sbml(s)) First usage, padmetRef is the padmetRef to create or to update. If it’s an update case, the output can be used to create a new padmet, if output None, will overwritte the input padmetRef.

2./ Creation of a padmet representing an organism in padmet format from sbml(s) (or updating one with new(s) sbml(s)) 2.A/ Without a database of reference: Second usage, padmetSpec is the padmetSpec to create or update. If it’s an update case, the output can be used to create a new padmet, if output None, will overwritte the input padmetSpec.

2.B/ With a database of refence: Third usage, padmetSpec is the padmetSpec to create or update. If it’s an update case, the output can be used to create a new padmet, if output None, will overwritte the input padmetSpec. padmetRef is the padmet representing the database of reference.

It is possible to define a specific policy and info for the padmet. To learn more about policy and info check doc of lib.padmetRef/Spec. if the ids of reactions/compounds are not the same between padmetRef and the sbml, it is possible to use a dictionnary of association (sbml_id padmetRef_id) with one line = ‘id_sbml id_padmetRef’ Finally if a reaction from sbml is not in padmetRef, it is possible to force the copy and creating a new reaction in padmetSpec with the arg -f

usage:
    padmet sbml_to_padmet --sbml=DIR/FILE --padmetRef=FILE [--output=FILE] [--db=STR] [--version=STR] [-v]
    padmet sbml_to_padmet --sbml=DIR/FILE --padmetSpec=FILE [--output=FILE] [--source_tool=STR] [--source_category=STR] [--source_id=STR] [-v]
    padmet sbml_to_padmet --sbml=DIR/FILE --padmetSpec=FILE  --padmetRef=FILE  [--mapping=DIR/FILE] [--mapping_tag=STR] [--output=FILE] [--source_tool=STR] [--source_category=STR] [--source_id=STR] [-v] [-f]

options:
    -h --help     Show help.
    --padmetSpec=FILE    path to the padmet file to update with the sbml. If there's no padmetSpec, just specify the output
    --padmetRef=FILE    path to the padmet file representing to the database of reference (ex: metacyc_18.5.padmet)
    --sbml=FILE    1 sbml file to convert into padmetSpec (ex: my_network.xml/sbml) OR a directory with n SBML
    --output=FILE   pathanme to the new padmet file
    --mapping=FILE    dictionnary of association id_origin id_ref
    --mapping_tag=STR    if sbml is a folder, use a tag to define mapping files ex: org1.sbml and org1_dict.csv, '_dict.csv' will be the mapping tag. [default: _dict.csv]
    --db=STR    database name
    --version=STR    database version
    -v   print info
padmet.utils.connection.sbml_to_padmet.command_help()[source]

Show help for analysis command.

padmet.utils.connection.sbml_to_padmet.sbml_to_padmetRef(sbml, padmetRef_file, output=None, db='NA', version='NA', verbose=False)[source]
if padmetRef, not padmetSpec:

if padmetRef exist, instance PadmetRef else init PadmetRef update padmetRef

if padmetSpec:

if padmetRef, check if exist else raise Error if padmetSpec exist, instance PadmetSpec else init PadmetSpec update padmetSpec using padmetRef if padmetRef

#TODO

padmet.utils.connection.sbml_to_padmet.sbml_to_padmetSpec(sbml, padmetSpec_file, padmetRef_file=None, output=None, mapping=None, mapping_tag='_dict.csv', source_tool=None, source_category=None, db='NA', version='NA', verbose=False)[source]

Convert 1 - n sbml to padmet file. sbml var is file or dir padmetSpec_file: path to new padmet file to create or old padmet to update padmetRef_file: path to database of reference to use for data standardization output: path to new padmet file, if none, overwritte padmetSpec_file source_tool: tool used to create this sbml(s) ex Orthofinder source_category: Category of the tool ex: orthology if new padmet without padmetRef:

db: database used ex: metacyc, bigg version: version of the database, 23, 18…

if padmetRef, not padmetSpec:

if padmetRef exist, instance PadmetRef else init PadmetRef update padmetRef

if padmetSpec:

if padmetRef, check if exist else raise Error if padmetSpec exist, instance PadmetSpec else init PadmetSpec update padmetSpec using padmetRef if padmetRef

#TODO

padmet.utils.connection.sbml_to_padmet.sbml_to_padmet_cli(command_args)[source]

sbml_to_sbml

Description:

Create sbml from sbml. Use it to change sbml level.

usage:
    padmet sbml_to_sbml --input=FILE/FOLDER --output=FILE/FOLDER --new_sbml_lvl=STR [--cpu=INT]

option:
    -h --help    Show help.
    --input=FILE    path of the sbml file/folder to convert into sbml
    --output=FILE    path of the sbml file/folder to generate.
    --new_sbml_lvl=STR    level of the new sbml.
    --cpu=FILE    number of cpu used [default: 1].
    -v   print info.
padmet.utils.connection.sbml_to_sbml.command_help()[source]

Show help for analysis command.

padmet.utils.connection.sbml_to_sbml.from_sbml_to_sbml(input_sbml, output_sbml, new_sbml_level, cpu=1)[source]

Turn sbml to sbml.

Parameters:
  • input_sbml (str) – pathname to species sbml file/folder

  • output_sbml (str) – pathname to output sbml file/folder

  • new_sbml_level (int) – new sbml level

  • cpu (int) – number of cpu

Returns:

pathname to output sbml file/folder

Return type:

str

padmet.utils.connection.sbml_to_sbml.run_sbml_to_sbml(multiprocess_data)[source]

Turn sbml to sbml.

Parameters:

multiprocess_data (dict) – pathname to species sbml file, pathname to output sbml file, new sbml level

Returns:

True if sbml file exists

Return type:

bool

padmet.utils.connection.sbml_to_sbml.sbml_to_padmet(sbml, db, version, source_tool, source_category, source_id, mapping, verbose, padmet_id)[source]

#TODO

padmet.utils.connection.sbml_to_sbml.sbml_to_sbml_cli(command_args)[source]

wikiGenerator

Description:

Contains all necessary functions to generate wikiPages from a padmet file and update a wiki online. Require WikiManager module (with wikiMate,Vendor)

usage:
    padmet wikiGenerator --padmet=FILE/DIR --output=DIR --wiki_id=STR [--database=STR] [--padmetRef=FILE] [--log_file=FILE] [-v]
    padmet wikiGenerator --aureme_run=DIR --padmetSpec=ID -v

options:
    -h --help     Show help.
    --padmet=FILE    path to padmet file.
    --output=DIR    path to folder to create with all wikipages in subdir.
    --wiki_id=STR    id of the wiki.
    --padmetRef=FILE    path to padmet of reference, ex: metacyc_xx.padmet, if given, able to calcul pathway rate completion.
    --log_file=FILE    log file from an aureme run, use this file to create a wikipage with all the command used during the aureme run.
    --aureme_run=DIR    can use an aureme run as input, will use from config file information for model_id and log_file and padmetRef.
    -v    print info.
padmet.utils.connection.wikiGenerator.add_collapsible(text_array, title=None)[source]

#TODO

padmet.utils.connection.wikiGenerator.add_property(properties, prop_id, prop_values)[source]

#TODO

padmet.utils.connection.wikiGenerator.command_help()[source]

Show help for analysis command.

padmet.utils.connection.wikiGenerator.copy_io_files()[source]
padmet.utils.connection.wikiGenerator.createDirectory(output, verbose=False)[source]

create the folders genes, reactions, metabolites, pathways in the folder dirPath/ if already exist, it will replace old folders (and delete old files)

Parameters:

output (str) – path to output folder

padmet.utils.connection.wikiGenerator.create_biological_page(category, page_id, page_dict_data, total_padmet_data, ext_link, output_file, padmetRef=None, verbose=False)[source]

#TODO

padmet.utils.connection.wikiGenerator.create_log_page(log_file, output_folder)[source]

#TODO

padmet.utils.connection.wikiGenerator.create_main(total_padmet_data, wiki_id, output_file, verbose=False)[source]

#TODO

padmet.utils.connection.wikiGenerator.create_navigation_page(total_padmet_data, navigation_folder, verbose=False)[source]

#TODO

padmet.utils.connection.wikiGenerator.create_venn(total_padmet_data, output_file, verbose=False)[source]

#TODO

padmet.utils.connection.wikiGenerator.draw_ellipse(fig, ax, x, y, w, h, a, fillcolor)[source]
padmet.utils.connection.wikiGenerator.draw_text(fig, ax, x, y, text, color=[0, 0, 0, 1])[source]
padmet.utils.connection.wikiGenerator.extract_padmet_data(padmetFile, total_padmet_data, global_pwy_rxn_dict=None, padmetRef=None, verbose=False)[source]

total_padmet_data: k in [‘reaction’, ‘gene’, ‘organism’, ‘pathway’, …] if k = ‘reaction’, v = {‘misc’:{},’gene_assoc’:}

For reaction in padmetFile:
if reaction_id not in total_padmet_data[“reaction”].keys():

add total_padmet_data[“reaction”][reaction_id][padmet_source] = dict()

else, add data only if differents from first

#TODO

padmet.utils.connection.wikiGenerator.get_cmd_label(cmd)[source]

#TODO

padmet.utils.connection.wikiGenerator.get_labels(data, fill=['number'])[source]

get a dict of labels for groups in data example: In [12]: get_labels([range(10), range(5,15), range(3,8)], fill=[“number”]) Out[12]: {‘001’: ‘0’, ‘010’: ‘5’, ‘011’: ‘0’, ‘100’: ‘3’, ‘101’: ‘2’, ‘110’: ‘2’, ‘111’: ‘3’}

Parameters:
  • data (list) – data to get label for

  • fill – [“number”|”logic”|”percent”]

Returns:

a dict of labels for different sets

Return type:

dict

padmet.utils.connection.wikiGenerator.reduce_padmet_data(total_padmet_data, verbose=False)[source]

#TODO

padmet.utils.connection.wikiGenerator.update_basic_attrib(node, current_node_dict, padmet_source)[source]

#TODO

padmet.utils.connection.wikiGenerator.venn4(labels, names=['A', 'B', 'C', 'D'], **options)[source]

plots a 4-set Venn diagram

Parameters:
  • labels (dict) – a label dict where keys are identified via binary codes (‘0001’, ‘0010’, ‘0100’, …), hence a valid set could look like: {‘0001’: ‘text 1’, ‘0010’: ‘text 2’, ‘0100’: ‘text 3’, …}. unmentioned codes are considered as ‘’.

  • names (list) – group names

Returns:

(Figure, AxesSubplot), pyplot Figure and AxesSubplot object

Return type:

set

padmet.utils.connection.wikiGenerator.wikiGenerator(padmet, output, wiki_id, padmetRef=None, database=None, log_file=None, verbose=False)[source]

#TODO

padmet.utils.connection.wikiGenerator.wikiGenerator_cli(command_args)[source]

#TODO