Skip to content

Commit 3581487

Browse files
committed
updates to paper
1 parent fb25fca commit 3581487

File tree

4 files changed

+11
-46
lines changed

4 files changed

+11
-46
lines changed

docs/paper.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ genescape tree -m lipid --micov 2 genes2.txt -o output.pdf
139139

140140
The filtering process will result in a smaller tree with 18 nodes and 29 edges, focused on the functions that contain the word "lipid":
141141

142-
![Filtering a large graph for a specific term \label{fig:filter}][img_filter]{height="216pt"}
142+
![Filtering a large graph for a specific term \label{fig:filter}][img_filter]
143143

144144
[img_filter]: images/gs_output_3.png
145145

src/genescape/main.py

+1-41
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def build(idx_fname=None, obo_fname=None, gaf_fname=None, stats=False, dump=Fals
179179
fnames = [
180180
('obo', obo_fname),
181181
('gaf', gaf_fname),
182-
('idx', idx_fname),
183182
]
184183

185184
check_files(fnames)
@@ -198,7 +197,7 @@ def build(idx_fname=None, obo_fname=None, gaf_fname=None, stats=False, dump=Fals
198197

199198

200199
@run.command()
201-
@click.option("-i", "--index", "idx_fname", default="", help="Index file")
200+
@click.option("-i", "--idx", "idx_fname", default="", help="Index file")
202201
@click.option("--host", "host", default="127.0.0.1", help="Hostname to bind to")
203202
@click.option("--port", "port", default=8000, type=int, help="Port number")
204203
@click.option("-r", "--reload", "reload", is_flag=True, help="Reload the webserver on changes")
@@ -225,45 +224,6 @@ def web(idx_fname='', host='localhost', port=8000, reload=False, test=False):
225224
shiny.run_app("genescape.shiny.tree.app:app", host=host, port=port, reload=reload)
226225

227226

228-
@run.command()
229-
@click.argument("words", default=None, nargs=-1)
230-
@click.option("-i", "--index", "idx_fname", default="", help="Index file (genescape.json.gz)")
231-
@click.help_option("-h", "--help")
232-
def show(words, idx_fname=''):
233-
res = resources.init()
234-
idx_fname = idx_fname or res.INDEX_FILE
235-
236-
utils.info(f"index: {idx_fname}")
237-
238-
idx = nexus.load_index(idx_fname)
239-
obo = idx[nexus.OBO_KEY]
240-
go2sym = idx[nexus.GO2SYM]
241-
name2sym = idx[nexus.NAME2SYM]
242-
243-
obo = idx[nexus.OBO_KEY]
244-
245-
graph = nexus.build_graph(idx)
246-
247-
valid = list(filter(lambda x: x in obo, words))
248-
missing = set(words) - set(valid)
249-
250-
if missing:
251-
utils.error(f"Words not found: {missing}")
252-
253-
# The database info
254-
info = idx[nexus.INFO_KEY]
255-
256-
for word in valid:
257-
data = graph.nodes[word]
258-
vals = go2sym[word]
259-
# data['symbols'] = vals
260-
data['parents'] = list(graph.predecessors(word))
261-
data['children'] = list(graph.successors(word))
262-
data['info'] = info
263-
text = json.dumps(data, indent=4)
264-
print(text)
265-
266-
267227
if __name__ == '__main__':
268228
# sys.argv.extend( ("build", "--stats"))
269229

src/genescape/resources.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import toml
1212

1313
from genescape import utils
14+
from pprint import pprint
1415

1516
CURR_DIR = Path(os.path.dirname(__file__))
1617

@@ -90,6 +91,7 @@ def pieces(elem):
9091
def find_index(self, code=None):
9192
code = code or self.DEFAULT_CODE
9293
if code not in self.INDEX_MAP:
94+
pprint(self.INDEX_MAP)
9395
raise Exception(f"Code not found: {code}")
9496
return self.INDEX_MAP[code][2]
9597

@@ -103,7 +105,7 @@ def update_from_env(self, key="GENESCAPE_INDEX"):
103105
"""
104106
value = os.environ.get(key, None)
105107
if value:
106-
108+
utils.info(f"Environment: {value}")
107109
code, label, path = value.split(":")
108110

109111
path = Path(path)
@@ -118,6 +120,7 @@ def update_from_env(self, key="GENESCAPE_INDEX"):
118120
# Recreate the index map
119121
self.INDEX_MAP = dict(map(lambda x: (x[0], x), current))
120122

123+
121124
# Reset the resource directory
122125
def reset_dir(cnf=None):
123126
"""

src/genescape/shiny/tree/app.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# Load the default resources.
1515
res = resources.init()
1616

17-
1817
def random_gene_list(res, N=50):
1918
"""
2019
Returns a random gene list.
@@ -24,6 +23,9 @@ def random_gene_list(res, N=50):
2423
return "\n".join(sym)
2524

2625

26+
# Update the index location from environment
27+
res.update_from_env()
28+
2729
# This is the global database choices
2830
DATABASE_CHOICES = dict()
2931

@@ -291,6 +293,8 @@ async def submit():
291293
await create_tree()
292294

293295
async def create_tree():
296+
global res
297+
294298
limit = 10
295299
# Emulate some sort of progress bar
296300
with ui.Progress(min=1, max=limit) as p:
@@ -311,8 +315,6 @@ async def create_tree():
311315
pattern = input.pattern()
312316
root = input.root()
313317

314-
# Initialize the resources.
315-
res = resources.init()
316318

317319
# Locate the database from the index.
318320
idx_fname = res.find_index(db_code)

0 commit comments

Comments
 (0)