gsrap 0.10.1__tar.gz → 0.10.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. {gsrap-0.10.1 → gsrap-0.10.2}/PKG-INFO +2 -2
  2. gsrap-0.10.2/README.md +1 -0
  3. {gsrap-0.10.1 → gsrap-0.10.2}/pyproject.toml +1 -1
  4. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/.ipynb_checkpoints/__init__-checkpoint.py +11 -13
  5. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/__init__.py +11 -13
  6. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/biomass-checkpoint.py +1 -1
  7. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/coeffs-checkpoint.py +1 -1
  8. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/downloads-checkpoint.py +3 -3
  9. gsrap-0.10.2/src/gsrap/commons/.ipynb_checkpoints/escherutils-checkpoint.py +258 -0
  10. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/medium-checkpoint.py +1 -1
  11. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/metrics-checkpoint.py +10 -10
  12. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/biomass.py +1 -1
  13. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/coeffs.py +1 -1
  14. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/downloads.py +3 -3
  15. gsrap-0.10.2/src/gsrap/commons/escherutils.py +258 -0
  16. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/medium.py +1 -1
  17. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/metrics.py +10 -10
  18. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/annotation-checkpoint.py +16 -6
  19. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/introduce-checkpoint.py +35 -35
  20. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/parsedb-checkpoint.py +19 -10
  21. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/repeating-checkpoint.py +12 -13
  22. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/annotation.py +16 -6
  23. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/introduce.py +35 -35
  24. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/parsedb.py +19 -10
  25. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/repeating.py +12 -13
  26. gsrap-0.10.1/README.md +0 -1
  27. gsrap-0.10.1/src/gsrap/commons/.ipynb_checkpoints/escherutils-checkpoint.py +0 -112
  28. gsrap-0.10.1/src/gsrap/commons/escherutils.py +0 -112
  29. {gsrap-0.10.1 → gsrap-0.10.2}/LICENSE.txt +0 -0
  30. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/.ipynb_checkpoints/PM1-checkpoint.csv +0 -0
  31. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/.ipynb_checkpoints/PM2A-checkpoint.csv +0 -0
  32. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/.ipynb_checkpoints/PM3B-checkpoint.csv +0 -0
  33. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/.ipynb_checkpoints/PM4A-checkpoint.csv +0 -0
  34. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/PM1.csv +0 -0
  35. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/PM2A.csv +0 -0
  36. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/PM3B.csv +0 -0
  37. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/PM4A.csv +0 -0
  38. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/__init__.py +0 -0
  39. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/kegg_compound_to_others.pickle +0 -0
  40. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/assets/kegg_reaction_to_others.pickle +0 -0
  41. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/__init__-checkpoint.py +0 -0
  42. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/excelhub-checkpoint.py +0 -0
  43. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/figures-checkpoint.py +0 -0
  44. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/fluxbal-checkpoint.py +0 -0
  45. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/keggutils-checkpoint.py +0 -0
  46. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/logutils-checkpoint.py +0 -0
  47. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/memoteutils-checkpoint.py +0 -0
  48. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/.ipynb_checkpoints/sbmlutils-checkpoint.py +0 -0
  49. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/__init__.py +0 -0
  50. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/excelhub.py +0 -0
  51. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/figures.py +0 -0
  52. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/fluxbal.py +0 -0
  53. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/keggutils.py +0 -0
  54. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/logutils.py +0 -0
  55. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/memoteutils.py +0 -0
  56. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/commons/sbmlutils.py +0 -0
  57. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/getmaps/.ipynb_checkpoints/__init__-checkpoint.py +0 -0
  58. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/getmaps/.ipynb_checkpoints/getmaps-checkpoint.py +0 -0
  59. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/getmaps/.ipynb_checkpoints/kdown-checkpoint.py +0 -0
  60. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/getmaps/__init__.py +0 -0
  61. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/getmaps/getmaps.py +0 -0
  62. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/getmaps/kdown.py +0 -0
  63. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/__init__-checkpoint.py +0 -0
  64. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/biologcuration-checkpoint.py +0 -0
  65. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/gapfill-checkpoint.py +0 -0
  66. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/gapfillutils-checkpoint.py +0 -0
  67. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/mkmodel-checkpoint.py +0 -0
  68. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/polishing-checkpoint.py +0 -0
  69. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/.ipynb_checkpoints/pruner-checkpoint.py +0 -0
  70. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/__init__.py +0 -0
  71. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/biologcuration.py +0 -0
  72. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/gapfill.py +0 -0
  73. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/gapfillutils.py +0 -0
  74. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/mkmodel.py +0 -0
  75. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/polishing.py +0 -0
  76. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/mkmodel/pruner.py +0 -0
  77. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/__init__-checkpoint.py +0 -0
  78. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/completeness-checkpoint.py +0 -0
  79. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/cycles-checkpoint.py +0 -0
  80. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/.ipynb_checkpoints/manual-checkpoint.py +0 -0
  81. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/__init__.py +0 -0
  82. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/completeness.py +0 -0
  83. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/cycles.py +0 -0
  84. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/parsedb/manual.py +0 -0
  85. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/__init__-checkpoint.py +0 -0
  86. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/biosynth-checkpoint.py +0 -0
  87. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/cnps-checkpoint.py +0 -0
  88. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/essentialgenes-checkpoint.py +0 -0
  89. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/growthfactors-checkpoint.py +0 -0
  90. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/precursors-checkpoint.py +0 -0
  91. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/runsims-checkpoint.py +0 -0
  92. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/simplegrowth-checkpoint.py +0 -0
  93. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/.ipynb_checkpoints/singleomission-checkpoint.py +0 -0
  94. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/__init__.py +0 -0
  95. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/biosynth.py +0 -0
  96. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/cnps.py +0 -0
  97. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/essentialgenes.py +0 -0
  98. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/growthfactors.py +0 -0
  99. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/precursors.py +0 -0
  100. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/runsims.py +0 -0
  101. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/simplegrowth.py +0 -0
  102. {gsrap-0.10.1 → gsrap-0.10.2}/src/gsrap/runsims/singleomission.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gsrap
3
- Version: 0.10.1
3
+ Version: 0.10.2
4
4
  Summary:
5
5
  License: GNU General Public License v3.0
6
6
  License-File: LICENSE.txt
@@ -27,5 +27,5 @@ Requires-Dist: pandas (>=2.0.0)
27
27
  Requires-Dist: xlsxwriter (>=3.1.0)
28
28
  Description-Content-Type: text/markdown
29
29
 
30
- Source code for `gsrap`.
30
+ Source code for `gsrap`.
31
31
 
gsrap-0.10.2/README.md ADDED
@@ -0,0 +1 @@
1
+ Source code for `gsrap`.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gsrap"
3
- version = "0.10.1"
3
+ version = "0.10.2"
4
4
  description = ""
5
5
  authors = ["Gioele Lazzari"]
6
6
  license = "GNU General Public License v3.0"
@@ -9,21 +9,18 @@ import atexit
9
9
  import os
10
10
 
11
11
 
12
-
13
12
  import cobra
14
13
 
15
14
 
16
15
  from .commons import get_logger
17
16
  from .commons import set_usual_formatter
18
17
  from .commons import set_header_trailer_formatter
19
-
20
18
  from .getmaps import getmaps_command
21
19
  from .parsedb import parsedb_command
22
20
  from .mkmodel import mkmodel_command
23
21
  from .runsims import runsims_command
24
22
 
25
23
 
26
-
27
24
  cobra_config = cobra.Configuration()
28
25
  solver_name = str(cobra_config.solver.log).split(' ')[1]
29
26
  solver_name = solver_name.replace("optlang.", '')
@@ -69,20 +66,21 @@ def main():
69
66
  parsedb_parser.add_argument("-o", "--outdir", metavar='', type=str, default='./', help="Main output directory (will be created if not existing).")
70
67
  parsedb_parser.add_argument("-i", "--inmaps", metavar='', type=str, default='./gsrap.maps', help="Input file 'gsrap.maps' previously produced using the 'getmaps' subcommand.")
71
68
  parsedb_parser.add_argument("-p", "--progress", action='store_true', help="Show progress for each map.")
72
- parsedb_parser.add_argument("--module", action='store_true', help="Show progress for each module of each map (use only with --progress).")
73
- parsedb_parser.add_argument("-f", "--focus", metavar='', type=str, default='-', help="Focus on a particular map/module (use only with --progress).")
69
+ parsedb_parser.add_argument("--module", action='store_true', help="Show progress for each module of each map (use with --progress).")
70
+ parsedb_parser.add_argument("-f", "--focus", metavar='', type=str, default='-', help="Focus on a particular map/module obtaining codes of missing reactions (use with --progress).")
74
71
  parsedb_parser.add_argument("-m", "--media", metavar='', type=str, default='M9,M9an,M9photo', help="Media to use during growth simulations (comma-separated IDs).")
75
- parsedb_parser.add_argument("-z", "--initialize", metavar='', type=str, default='-', help="Initialize the universe on the provided medium. By default, the first medium in --media is used. Use 'none' to avoid initialization.")
72
+ parsedb_parser.add_argument("-z", "--initialize", metavar='', type=str, default='-', help="Initialize the universe on the provided medium. If not provided, the first medium in --media is used. Provide 'None' to avoid initialization.")
76
73
  parsedb_parser.add_argument("--precursors", action='store_true', help="Verify biosynthesis of biomass precursors and show blocked ones.")
77
74
  parsedb_parser.add_argument("--biosynth", action='store_true', help="Check biosynthesis of all metabolites and detect dead-ends.")
78
- parsedb_parser.add_argument("-t", "--taxon", metavar='', type=str, default='-', help="High-level taxon of interest. If provided, it must follow the syntax '{level}:{name}', where {level} is 'kingdom' or 'phylum'.")
79
- parsedb_parser.add_argument("-e", "--eggnog", nargs='+', metavar='', type=str, default='-', help="Path to the optional eggnog-mapper annotation table(s).")
80
- parsedb_parser.add_argument("-k", "--keggorg", metavar='', type=str, default='-', help="A single KEGG Organism code. If provided, it takes precedence over --eggnog.")
81
- parsedb_parser.add_argument("--goodbefore", metavar='', type=str, default='-', help="Syntax is {pure_mid}-{rid1}-{rid2}. From top to bottom, build the universe until reaction {rid1}, transport {rid2} and metabolite {pure_mid} are reached.")
82
- parsedb_parser.add_argument("--onlyauthor", metavar='', type=str, default='-', help="Build the universe by parsing contents of the specified author ID only. Contents affected by --goodbefore are parsed anyway.")
83
- parsedb_parser.add_argument("--nofigs", action='store_true', help="Do not generate figures.")
84
- parsedb_parser.add_argument("-j", "--justparse", action='store_true', help="Just parse the database without performing extra activities (saves time during universe expansion).")
75
+ parsedb_parser.add_argument("-e", "--eggnog", nargs='+', metavar='', type=str, default='-', help="Path to optional eggnog-mapper annotation table(s). If provided, --progress will be based on such table(s) instead of the entire KEGG.")
76
+ parsedb_parser.add_argument("-t", "--taxon", metavar='', type=str, default='-', help="Optional high-level taxon of interest accounted during the parsing. If provided, --progress will be based on such taxon instead of the entire KEGG (takes precedence over --eggnog). The syntax '{level}:{name}' must be honored, where {level} is 'kingdom' or 'phylum'.")
77
+ parsedb_parser.add_argument("-k", "--keggorg", metavar='', type=str, default='-', help="Optional single KEGG Organism code accounted during parsing. If provided, --progress will be based on such organism instead of the entire KEGG (takes precedence over --taxon and --eggnog).")
78
+ parsedb_parser.add_argument("--goodbefore", metavar='', type=str, default='-', help="Used to skip rows of M-R-T sheets during parsing. The syntax '{pure_mid}-{rid1}-{rid2}' must be honored. From top to bottom, build the universe until reaction {rid1}, transport {rid2} and metabolite {pure_mid} are reached.")
79
+ parsedb_parser.add_argument("--onlycurator", metavar='', type=str, default='-', help="Build the universe by parsing contents of the specified curator ID only. Contents affected by --goodbefore are parsed anyway.")
80
+ parsedb_parser.add_argument("--nofigs", action='store_true', help="Do not generate figures in th Excel output.")
81
+ parsedb_parser.add_argument("-j", "--justparse", action='store_true', help="Parse the database without performing extra activities (saves time).")
85
82
  parsedb_parser.add_argument("-d", "--keepdisconn", action='store_true', help="Do not remove disconnected metabolites.")
83
+ parsedb_parser.add_argument("--escherzip", metavar='', type=str, default='-', help="Optional path to the zipped 'escher' folder downloaded from Google Drive.")
86
84
 
87
85
 
88
86
 
@@ -9,21 +9,18 @@ import atexit
9
9
  import os
10
10
 
11
11
 
12
-
13
12
  import cobra
14
13
 
15
14
 
16
15
  from .commons import get_logger
17
16
  from .commons import set_usual_formatter
18
17
  from .commons import set_header_trailer_formatter
19
-
20
18
  from .getmaps import getmaps_command
21
19
  from .parsedb import parsedb_command
22
20
  from .mkmodel import mkmodel_command
23
21
  from .runsims import runsims_command
24
22
 
25
23
 
26
-
27
24
  cobra_config = cobra.Configuration()
28
25
  solver_name = str(cobra_config.solver.log).split(' ')[1]
29
26
  solver_name = solver_name.replace("optlang.", '')
@@ -69,20 +66,21 @@ def main():
69
66
  parsedb_parser.add_argument("-o", "--outdir", metavar='', type=str, default='./', help="Main output directory (will be created if not existing).")
70
67
  parsedb_parser.add_argument("-i", "--inmaps", metavar='', type=str, default='./gsrap.maps', help="Input file 'gsrap.maps' previously produced using the 'getmaps' subcommand.")
71
68
  parsedb_parser.add_argument("-p", "--progress", action='store_true', help="Show progress for each map.")
72
- parsedb_parser.add_argument("--module", action='store_true', help="Show progress for each module of each map (use only with --progress).")
73
- parsedb_parser.add_argument("-f", "--focus", metavar='', type=str, default='-', help="Focus on a particular map/module (use only with --progress).")
69
+ parsedb_parser.add_argument("--module", action='store_true', help="Show progress for each module of each map (use with --progress).")
70
+ parsedb_parser.add_argument("-f", "--focus", metavar='', type=str, default='-', help="Focus on a particular map/module obtaining codes of missing reactions (use with --progress).")
74
71
  parsedb_parser.add_argument("-m", "--media", metavar='', type=str, default='M9,M9an,M9photo', help="Media to use during growth simulations (comma-separated IDs).")
75
- parsedb_parser.add_argument("-z", "--initialize", metavar='', type=str, default='-', help="Initialize the universe on the provided medium. By default, the first medium in --media is used. Use 'none' to avoid initialization.")
72
+ parsedb_parser.add_argument("-z", "--initialize", metavar='', type=str, default='-', help="Initialize the universe on the provided medium. If not provided, the first medium in --media is used. Provide 'None' to avoid initialization.")
76
73
  parsedb_parser.add_argument("--precursors", action='store_true', help="Verify biosynthesis of biomass precursors and show blocked ones.")
77
74
  parsedb_parser.add_argument("--biosynth", action='store_true', help="Check biosynthesis of all metabolites and detect dead-ends.")
78
- parsedb_parser.add_argument("-t", "--taxon", metavar='', type=str, default='-', help="High-level taxon of interest. If provided, it must follow the syntax '{level}:{name}', where {level} is 'kingdom' or 'phylum'.")
79
- parsedb_parser.add_argument("-e", "--eggnog", nargs='+', metavar='', type=str, default='-', help="Path to the optional eggnog-mapper annotation table(s).")
80
- parsedb_parser.add_argument("-k", "--keggorg", metavar='', type=str, default='-', help="A single KEGG Organism code. If provided, it takes precedence over --eggnog.")
81
- parsedb_parser.add_argument("--goodbefore", metavar='', type=str, default='-', help="Syntax is {pure_mid}-{rid1}-{rid2}. From top to bottom, build the universe until reaction {rid1}, transport {rid2} and metabolite {pure_mid} are reached.")
82
- parsedb_parser.add_argument("--onlyauthor", metavar='', type=str, default='-', help="Build the universe by parsing contents of the specified author ID only. Contents affected by --goodbefore are parsed anyway.")
83
- parsedb_parser.add_argument("--nofigs", action='store_true', help="Do not generate figures.")
84
- parsedb_parser.add_argument("-j", "--justparse", action='store_true', help="Just parse the database without performing extra activities (saves time during universe expansion).")
75
+ parsedb_parser.add_argument("-e", "--eggnog", nargs='+', metavar='', type=str, default='-', help="Path to optional eggnog-mapper annotation table(s). If provided, --progress will be based on such table(s) instead of the entire KEGG.")
76
+ parsedb_parser.add_argument("-t", "--taxon", metavar='', type=str, default='-', help="Optional high-level taxon of interest accounted during the parsing. If provided, --progress will be based on such taxon instead of the entire KEGG (takes precedence over --eggnog). The syntax '{level}:{name}' must be honored, where {level} is 'kingdom' or 'phylum'.")
77
+ parsedb_parser.add_argument("-k", "--keggorg", metavar='', type=str, default='-', help="Optional single KEGG Organism code accounted during parsing. If provided, --progress will be based on such organism instead of the entire KEGG (takes precedence over --taxon and --eggnog).")
78
+ parsedb_parser.add_argument("--goodbefore", metavar='', type=str, default='-', help="Used to skip rows of M-R-T sheets during parsing. The syntax '{pure_mid}-{rid1}-{rid2}' must be honored. From top to bottom, build the universe until reaction {rid1}, transport {rid2} and metabolite {pure_mid} are reached.")
79
+ parsedb_parser.add_argument("--onlycurator", metavar='', type=str, default='-', help="Build the universe by parsing contents of the specified curator ID only. Contents affected by --goodbefore are parsed anyway.")
80
+ parsedb_parser.add_argument("--nofigs", action='store_true', help="Do not generate figures in th Excel output.")
81
+ parsedb_parser.add_argument("-j", "--justparse", action='store_true', help="Parse the database without performing extra activities (saves time).")
85
82
  parsedb_parser.add_argument("-d", "--keepdisconn", action='store_true', help="Do not remove disconnected metabolites.")
83
+ parsedb_parser.add_argument("--escherzip", metavar='', type=str, default='-', help="Optional path to the zipped 'escher' folder downloaded from Google Drive.")
86
84
 
87
85
 
88
86
 
@@ -28,7 +28,7 @@ def get_biomass_dict(logger, universe, dbexp):
28
28
  fraction_to_precursors = dict()
29
29
  for fraction in ['DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA']:
30
30
  fraction_db = dbexp[fraction]
31
- fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'author', 'units'])
31
+ fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'curator', 'units'])
32
32
  precursors = [f"{i}_c" for i in fraction_db.index.dropna()]
33
33
  for i in precursors:
34
34
  if i not in universal_mids:
@@ -26,7 +26,7 @@ def check_exp_biomass_data(logger, dbexp, biomass):
26
26
  ftd = dict() # fraction_to_decimals
27
27
  for sheet in ['MWF', 'DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA']:
28
28
  fraction_db = dbexp[sheet][biomass].dropna() # they should be str
29
- fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'author', 'units'])
29
+ fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'curator', 'units'])
30
30
  ftd[sheet] = {i: Decimal(val) for i, val in fraction_db.items() if Decimal(val) != Decimal('0.0')} # convert to dict
31
31
  if sum(ftd[sheet].values()) != Decimal('1.0'): # check if the sum gives 1 (g/gDW or mol/mol depending on 'sheet')
32
32
  logger.error(f"Biomass data provided in sheet '{sheet}' for ID '{biomass}' does not sum up to 1.0. Missing mass is {Decimal('1.0')-sum(ftd[sheet].values())}.")
@@ -41,7 +41,7 @@ def get_dbuni(logger):
41
41
 
42
42
 
43
43
  sheet_id = "1dXJBIFjCghrdvQtxEOYlVNWAQU4mK-nqLWyDQeUZqek"
44
- #sheet_id = "1dCVOOnpNg7rK3iZmTDz3wybW7YrUNoClnqezT9Q5bpc" # alternative
44
+ #sheet_id = "15fIBewG1B1jIbg1_9pMnyPJL7LWCLMD8s_vlf3ZUno0" # alternative
45
45
  url = f"https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=xlsx"
46
46
  response = requests.get(url) # download the requested file
47
47
  if response.status_code == 200:
@@ -100,7 +100,7 @@ def get_dbexp(logger):
100
100
 
101
101
  # check table presence
102
102
  sheet_names = exceldb.sheet_names
103
- for i in ['media', 'PM1', 'PM2A', 'PM3B', 'PM4A', 'MWF', 'DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA', 'authors']:
103
+ for i in ['media', 'PM1', 'PM2A', 'PM3B', 'PM4A', 'MWF', 'DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA', 'curators']:
104
104
  if i not in sheet_names:
105
105
  logger.error(f"Sheet '{i}' is missing!")
106
106
  return 1
@@ -119,7 +119,7 @@ def get_dbexp(logger):
119
119
  dbexp['PROTS'] = exceldb.parse('PROTS')
120
120
  dbexp['LIPIDS_PL'] = exceldb.parse('LIPIDS_PL')
121
121
  dbexp['LIPIDS_FA'] = exceldb.parse('LIPIDS_FA')
122
- dbexp['authors'] = exceldb.parse('authors')
122
+ dbexp['curators'] = exceldb.parse('curators')
123
123
 
124
124
 
125
125
  # format tables (media):
@@ -0,0 +1,258 @@
1
+ import warnings
2
+ import logging
3
+ import threading
4
+ import zipfile
5
+ from pathlib import Path
6
+ import tempfile
7
+ import json
8
+ import os
9
+ import shutil
10
+
11
+ import cobra
12
+ from escher import Builder
13
+
14
+ from .downloads import SimpleLoadingWheel
15
+
16
+
17
+
18
+ def print_json_tree(data, level=0, max_level=2):
19
+ # explore contents of a json object
20
+
21
+ if level > max_level:
22
+ return
23
+ indent = ' ' * level
24
+ if isinstance(data, dict):
25
+ for key, value in data.items():
26
+ print(f"{indent}{key}")
27
+ print_tree(value, level + 1, max_level)
28
+ elif isinstance(data, list):
29
+ for i, item in enumerate(data):
30
+ print(f"{indent}[{i}]")
31
+ print_tree(item, level + 1, max_level)
32
+
33
+
34
+
35
+ def subset_for_focus(universe, rids_in_group, outdir, focus):
36
+
37
+ universe_focus = universe.copy()
38
+ to_remove = [r for r in universe_focus.reactions if r.id not in rids_in_group]
39
+
40
+
41
+ # trick to avoid the WARNING "cobra/core/group.py:147: UserWarning: need to pass in a list"
42
+ # triggered when trying to remove reactions that are included in groups.
43
+ with warnings.catch_warnings(): # temporarily suppress warnings for this block
44
+ warnings.simplefilter("ignore") # ignore all warnings
45
+ cobra_logger = logging.getLogger("cobra.util.solver")
46
+ old_level = cobra_logger.level
47
+ cobra_logger.setLevel(logging.ERROR)
48
+
49
+ universe_focus.remove_reactions(to_remove, remove_orphans=True)
50
+
51
+ # restore original behaviour:
52
+ cobra_logger.setLevel(old_level)
53
+
54
+
55
+ # save the subset for drawing in Escher!
56
+ cobra.io.save_json_model(universe_focus, f'{outdir}/focus_{focus}.json')
57
+
58
+
59
+
60
+ def count_undrawn_rids_focus(logger, universe, lastmap, focus, outdir):
61
+
62
+
63
+ # there could be no tracked folder / no versions for this group
64
+ if lastmap == None:
65
+ return
66
+
67
+
68
+ # get modeled reads for this --focus:
69
+ rids_in_group = set()
70
+ try: gr = universe.groups.get_by_id(focus)
71
+ except:
72
+ logger.warning(f"Group '{focus}' not found!")
73
+ return
74
+ for r in gr.members:
75
+ rids_in_group.add(r.id)
76
+
77
+
78
+ # get rids on Escher:
79
+ drawn_rids = set()
80
+ for key, value in lastmap['json'][1]['reactions'].items():
81
+ drawn_rids.add(value['bigg_id'])
82
+
83
+
84
+ # get remaining rids for this map:
85
+ remainings = rids_in_group - drawn_rids
86
+ remainings_krs = set()
87
+ for rid in remainings:
88
+ r = universe.reactions.get_by_id(rid)
89
+ if 'kegg.reaction' in r.annotation.keys():
90
+ krs = r.annotation['kegg.reaction']
91
+ for kr in krs:
92
+ remainings_krs.add(kr)
93
+
94
+
95
+ if len(remainings) > 0:
96
+ if focus != 'gr_transport':
97
+ logger.warning(f"Current '{lastmap['filename']}' is {len(remainings)} reactions behind: {' '.join(list(remainings_krs))}.")
98
+ else:
99
+ logger.warning(f"Current '{lastmap['filename']}' is {len(remainings)} reactions behind.") # usually no kegg codes for tranport reactions
100
+
101
+
102
+ # subset the universe to ease the drawing:
103
+ next_version_filename = f"{focus}-v{(int(lastmap['filename'].rsplit('-v',1)[-1].replace('.json', ''))+1)}.json"
104
+ logger.warning(f"Writing model '{outdir}/focus_{focus}.json' to ease the drawing of '{next_version_filename}'...")
105
+
106
+
107
+ t1 = threading.Thread(target = subset_for_focus, args=(
108
+ universe, rids_in_group, outdir, focus))
109
+ t1.start()
110
+ slw = SimpleLoadingWheel(msg="Please wait... ")
111
+ while t1.is_alive():
112
+ slw.proceed()
113
+ slw.clear()
114
+
115
+
116
+ logger.warning(f"'{outdir}/focus_{focus}.json' created!")
117
+ else:
118
+ logger.info(f"Current '{lastmap['filename']}' is 0 reactions behind. Thank you ♥")
119
+
120
+
121
+
122
+ def parse_zipped_escher(logger, universe, escherzip, outdir):
123
+ # used to parse the zipped 'escher' folder downloaded from Google Drive.
124
+ # 'escherzip' is the path to zipped folder.
125
+
126
+
127
+ logger.info("Processing collection of hand-drawn Escher maps...")
128
+
129
+
130
+ # prepare empty logs folder
131
+ shutil.rmtree(f'{outdir}/escherapps', ignore_errors=True)
132
+ os.makedirs(f'{outdir}/escherapps', exist_ok=True)
133
+
134
+
135
+ drawngid_to_maps = dict()
136
+ drawnrid_to_maps = dict()
137
+ drawnpuremid_to_maps = dict()
138
+ with tempfile.TemporaryDirectory() as tmp_dir:
139
+
140
+ # check path existance:
141
+ zip_path = Path(escherzip) # convert to Path for convenience
142
+ if not zip_path.exists():
143
+ logger.error(f"Zipped escher does not exist at provided path '{zip_path}'.")
144
+ return 1
145
+
146
+ # extract in a auto-deleting temporary directory
147
+ with zipfile.ZipFile(zip_path, "r") as z:
148
+ z.extractall(tmp_dir)
149
+
150
+ # extract the inner child dirs:
151
+ tmp_dir = Path(tmp_dir)
152
+ child_dirs = [p for p in tmp_dir.iterdir() if p.is_dir()]
153
+ escher_dir = child_dirs[0] # the top-level folder in the ZIP
154
+ inner_child_dirs = [p for p in escher_dir.iterdir() if p.is_dir()]
155
+
156
+ # iterate the inner child dirs:
157
+ for map_dir in inner_child_dirs:
158
+ map_id = map_dir.name.rsplit('/',1)[-1]
159
+ map_files = [f for f in map_dir.iterdir() if f.is_file()]
160
+ map_files_name = set([f.name.rsplit('/',1)[-1].split('-v',1)[0] for f in map_files])
161
+
162
+ # check presence of maps:
163
+ if len(map_files_name) == 0:
164
+ # still no maps in this folder
165
+ continue
166
+
167
+ # check name consistency:
168
+ if len(map_files_name) != 1:
169
+ logger.error(f"Name inconsistency in folder '{map_dir_name}'!")
170
+ return 1
171
+
172
+ # check consistency with the folder
173
+ if list(map_files_name)[0] != map_id:
174
+ logger.error(f"Versions in '{map_id}' refer to a different map!")
175
+
176
+ # get latest version
177
+ map_versions = [int(f.name.rsplit('/',1)[-1].split('-v',1)[-1].replace('.json','')) for f in map_files]
178
+ latest_version = max(map_versions)
179
+
180
+
181
+ # read json (last version) to fill the dict
182
+ latest_filepath = str(map_dir / f"{map_id}-v{latest_version}.json")
183
+ with open(latest_filepath, 'r') as file:
184
+ json_data = json.load(file)
185
+
186
+ # get elements on Escher:
187
+ map_drawngids = set()
188
+ map_drawnrids = set()
189
+ map_drawnpuremids = set()
190
+ for key, value in json_data[1]['reactions'].items():
191
+ map_drawnrids.add(value['bigg_id'])
192
+ for i in value['genes']:
193
+ map_drawngids.add(i['bigg_id'])
194
+ #for i in value['metabolites']:
195
+ # puremeid = i['bigg_id'].rsplit('_',1)[0]
196
+ # map_drawnpuremids.add(puremeid)
197
+ for key, value in json_data[1]['nodes'].items():
198
+ if value['node_type'] == 'metabolite':
199
+ puremeid = value['bigg_id'].rsplit('_',1)[0]
200
+ map_drawnpuremids.add(puremeid)
201
+
202
+ # populat dicts
203
+ for drawngid in map_drawngids:
204
+ if drawngid not in drawngid_to_maps.keys():
205
+ drawngid_to_maps[drawngid] = set()
206
+ drawngid_to_maps[drawngid].add(map_id)
207
+ for drawnrid in map_drawnrids:
208
+ if drawnrid not in drawnrid_to_maps.keys():
209
+ drawnrid_to_maps[drawnrid] = set()
210
+ drawnrid_to_maps[drawnrid].add(map_id)
211
+ for drawnpuremid in map_drawnpuremids:
212
+ if drawnpuremid not in drawnpuremid_to_maps.keys():
213
+ drawnpuremid_to_maps[drawnpuremid] = set()
214
+ drawnpuremid_to_maps[drawnpuremid].add(map_id)
215
+
216
+
217
+ # read json (last version) to create the escher app
218
+ builder = Builder(
219
+ map_json = latest_filepath,
220
+ model_json = None,
221
+ )
222
+ builder.never_ask_before_quit = True
223
+ builder.scroll_behavior = 'zoom'
224
+
225
+ builder.menu = 'all'
226
+ builder.enable_editing = False
227
+
228
+ builder.enable_keys = False # switch not working
229
+ builder.enable_search = True # switch not working
230
+ builder.full_screen_button = True # switch not working
231
+
232
+ builder.highlight_missing = True
233
+ builder.show_gene_reaction_rules = True
234
+ builder.enable_tooltips = 'label'
235
+
236
+ builder.save_html(f"{outdir}/escherapps/{map_id}.html")
237
+
238
+
239
+ # apply annotation to universe
240
+ for g in universe.genes:
241
+ if g.id in drawngid_to_maps.keys():
242
+ g.annotation['drawn_in_maps'] = list(drawngid_to_maps[g.id])
243
+ else:
244
+ g.annotation['drawn_in_maps'] = []
245
+ for r in universe.reactions:
246
+ if r.id in drawnrid_to_maps.keys():
247
+ r.annotation['drawn_in_maps'] = list(drawnrid_to_maps[r.id])
248
+ else:
249
+ r.annotation['drawn_in_maps'] = []
250
+ for m in universe.metabolites:
251
+ puremid = m.id.rsplit('_',1)[0]
252
+ if puremid in drawnpuremid_to_maps.keys():
253
+ m.annotation['drawn_in_maps'] = list(drawnpuremid_to_maps[puremid])
254
+ else:
255
+ m.annotation['drawn_in_maps'] = []
256
+
257
+
258
+ return universe
@@ -12,7 +12,7 @@ def apply_medium_given_column(logger, model, medium, column, is_reference=False)
12
12
  # retrieve metadata
13
13
  description = column.iloc[0]
14
14
  doi = column.iloc[1]
15
- author = column.iloc[2]
15
+ curator = column.iloc[2]
16
16
  units = column.iloc[3]
17
17
 
18
18
 
@@ -58,8 +58,8 @@ def show_contributions(logger, db, goodbefore):
58
58
  return 0
59
59
 
60
60
 
61
- # create a counter for each author
62
- cnt = {author: 0 for author in db['curators']['username']}
61
+ # create a counter for each curator
62
+ cnt = {curator: 0 for curator in db['curators']['username']}
63
63
  cnt_tot = 0
64
64
 
65
65
 
@@ -67,9 +67,9 @@ def show_contributions(logger, db, goodbefore):
67
67
  if type(row['curator']) != str:
68
68
  logger.error(f"Missing curator in tab 'R', rid '{row['rid']}'.")
69
69
  return 1
70
- for author in row['curator'].split(';'):
71
- author = author.rstrip().strip()
72
- cnt[author] += 1
70
+ for curator in row['curator'].split(';'):
71
+ curator = curator.rstrip().strip()
72
+ cnt[curator] += 1
73
73
  cnt_tot += 1
74
74
 
75
75
 
@@ -77,18 +77,18 @@ def show_contributions(logger, db, goodbefore):
77
77
  if type(row['curator']) != str:
78
78
  logger.error(f"Missing curator in tab 'T', rid '{row['rid']}'.")
79
79
  return 1
80
- for author in row['curator'].split(';'):
81
- author = author.rstrip().strip()
82
- cnt[author] += 1
80
+ for curator in row['curator'].split(';'):
81
+ curator = curator.rstrip().strip()
82
+ cnt[curator] += 1
83
83
  cnt_tot += 1
84
84
 
85
85
 
86
86
  # compute percentages:
87
- pct = {author: cnt[author]/cnt_tot*100 for author in cnt.keys()}
87
+ pct = {curator: cnt[curator]/cnt_tot*100 for curator in cnt.keys()}
88
88
  # sort in descending order:
89
89
  pct = dict(sorted(pct.items(), key=lambda item: item[1], reverse=True))
90
90
  # convert to string:
91
- pct = {author: f'{round(pct[author],2)}%' for author in pct.keys()}
91
+ pct = {curator: f'{round(pct[curator],2)}%' for curator in pct.keys()}
92
92
  logger.debug(f"Contributions: {pct}.")
93
93
 
94
94
 
@@ -28,7 +28,7 @@ def get_biomass_dict(logger, universe, dbexp):
28
28
  fraction_to_precursors = dict()
29
29
  for fraction in ['DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA']:
30
30
  fraction_db = dbexp[fraction]
31
- fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'author', 'units'])
31
+ fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'curator', 'units'])
32
32
  precursors = [f"{i}_c" for i in fraction_db.index.dropna()]
33
33
  for i in precursors:
34
34
  if i not in universal_mids:
@@ -26,7 +26,7 @@ def check_exp_biomass_data(logger, dbexp, biomass):
26
26
  ftd = dict() # fraction_to_decimals
27
27
  for sheet in ['MWF', 'DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA']:
28
28
  fraction_db = dbexp[sheet][biomass].dropna() # they should be str
29
- fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'author', 'units'])
29
+ fraction_db = fraction_db.iloc[4:] # ignore ['description', 'doi', 'curator', 'units'])
30
30
  ftd[sheet] = {i: Decimal(val) for i, val in fraction_db.items() if Decimal(val) != Decimal('0.0')} # convert to dict
31
31
  if sum(ftd[sheet].values()) != Decimal('1.0'): # check if the sum gives 1 (g/gDW or mol/mol depending on 'sheet')
32
32
  logger.error(f"Biomass data provided in sheet '{sheet}' for ID '{biomass}' does not sum up to 1.0. Missing mass is {Decimal('1.0')-sum(ftd[sheet].values())}.")
@@ -41,7 +41,7 @@ def get_dbuni(logger):
41
41
 
42
42
 
43
43
  sheet_id = "1dXJBIFjCghrdvQtxEOYlVNWAQU4mK-nqLWyDQeUZqek"
44
- #sheet_id = "1dCVOOnpNg7rK3iZmTDz3wybW7YrUNoClnqezT9Q5bpc" # alternative
44
+ #sheet_id = "15fIBewG1B1jIbg1_9pMnyPJL7LWCLMD8s_vlf3ZUno0" # alternative
45
45
  url = f"https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=xlsx"
46
46
  response = requests.get(url) # download the requested file
47
47
  if response.status_code == 200:
@@ -100,7 +100,7 @@ def get_dbexp(logger):
100
100
 
101
101
  # check table presence
102
102
  sheet_names = exceldb.sheet_names
103
- for i in ['media', 'PM1', 'PM2A', 'PM3B', 'PM4A', 'MWF', 'DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA', 'authors']:
103
+ for i in ['media', 'PM1', 'PM2A', 'PM3B', 'PM4A', 'MWF', 'DNA', 'RNA', 'PROTS', 'LIPIDS_PL', 'LIPIDS_FA', 'curators']:
104
104
  if i not in sheet_names:
105
105
  logger.error(f"Sheet '{i}' is missing!")
106
106
  return 1
@@ -119,7 +119,7 @@ def get_dbexp(logger):
119
119
  dbexp['PROTS'] = exceldb.parse('PROTS')
120
120
  dbexp['LIPIDS_PL'] = exceldb.parse('LIPIDS_PL')
121
121
  dbexp['LIPIDS_FA'] = exceldb.parse('LIPIDS_FA')
122
- dbexp['authors'] = exceldb.parse('authors')
122
+ dbexp['curators'] = exceldb.parse('curators')
123
123
 
124
124
 
125
125
  # format tables (media):