Skip to content

Commit

Permalink
double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Dec 12, 2023
1 parent ca506ad commit fcbe595
Show file tree
Hide file tree
Showing 25 changed files with 2,736 additions and 2,736 deletions.
86 changes: 43 additions & 43 deletions docs/scripts/generate_normalize_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from gene.schemas import UnmergedNormalizationService

COLORS = [
'#F8766D',
'#00BA38',
'#00B9E3',
"#F8766D",
"#00BA38",
"#00B9E3",
]


Expand All @@ -30,50 +30,50 @@ def create_gjgf(result: UnmergedNormalizationService) -> Dict:
:param result: result from Unmerged Normalization search
"""
graph = {
'graph': {
'label': 'tmp',
'nodes': {},
'edges': [],
'metadata': {
'arrow_size': 15,
'node_size': 15,
'node_label_size': 20,
'edge_size': 2,
"graph": {
"label": "tmp",
"nodes": {},
"edges": [],
"metadata": {
"arrow_size": 15,
"node_size": 15,
"node_label_size": 20,
"edge_size": 2,
},
}
}

for i, (_, matches) in enumerate(result.source_matches.items()):
for match in matches.records:
graph['graph']['nodes'][match.concept_id] = {
'metadata': {
'color': COLORS[i],
'hover': f'{match.concept_id}\n{match.symbol}\n<i>{match.label}</i>',
'click': f"<p color='black'>{json.dumps(match.model_dump(), indent=2)}</p>",
graph["graph"]["nodes"][match.concept_id] = {
"metadata": {
"color": COLORS[i],
"hover": f"{match.concept_id}\n{match.symbol}\n<i>{match.label}</i>",
"click": f"<p color='black'>{json.dumps(match.model_dump(), indent=2)}</p>",
}
}
for xref in match.xrefs:
graph['graph']['edges'].append(
{'source': match.concept_id, 'target': xref}
graph["graph"]["edges"].append(
{"source": match.concept_id, "target": xref}
)

included_edges = []
for edge in graph['graph']['edges']:
for edge in graph["graph"]["edges"]:
if (
edge['target'] in graph['graph']['nodes']
and edge['source'] in graph['graph']['nodes']
edge["target"] in graph["graph"]["nodes"]
and edge["source"] in graph["graph"]["nodes"]
):
included_edges.append(edge)
graph['graph']['edges'] = included_edges
graph["graph"]["edges"] = included_edges

included_nodes = {k['source'] for k in graph['graph']['edges']}.union(
{k['target'] for k in graph['graph']['edges']}
included_nodes = {k["source"] for k in graph["graph"]["edges"]}.union(
{k["target"] for k in graph["graph"]["edges"]}
)
new_nodes = {}
for key, value in graph['graph']['nodes'].items():
for key, value in graph["graph"]["nodes"].items():
if key in included_nodes:
new_nodes[key] = value
graph['graph']['nodes'] = new_nodes
graph["graph"]["nodes"] = new_nodes

return graph

Expand All @@ -82,45 +82,45 @@ def gen_norm_figure() -> None:
"""Generate normalized graph figure for docs."""
q = QueryHandler(create_db())

otx2p1 = 'OTX2P1'
otx2p2 = 'OTX2P2'
otx2p1 = "OTX2P1"
otx2p2 = "OTX2P2"

otx2p1_result = q.normalize_unmerged(otx2p1)
otx2p2_result = q.normalize_unmerged(otx2p2)

otx2p1_graph = create_gjgf(otx2p1_result)
otx2p2_graph = create_gjgf(otx2p2_result)

nodes = otx2p1_graph['graph']['nodes']
nodes.update(otx2p2_graph['graph']['nodes'])
nodes = otx2p1_graph["graph"]["nodes"]
nodes.update(otx2p2_graph["graph"]["nodes"])

graph = {
'graph': {
'label': f'Reference network for {otx2p1} and {otx2p2}',
'metadata': otx2p1_graph['graph']['metadata'],
'nodes': nodes,
'edges': otx2p1_graph['graph']['edges'] + otx2p2_graph['graph']['edges'],
"graph": {
"label": f"Reference network for {otx2p1} and {otx2p2}",
"metadata": otx2p1_graph["graph"]["metadata"],
"nodes": nodes,
"edges": otx2p1_graph["graph"]["edges"] + otx2p2_graph["graph"]["edges"],
}
}

fig = gv.d3(
data=graph,
graph_height=250,
node_hover_neighborhood=True,
node_label_font='arial',
node_label_font="arial",
)
fig.export_html(
(
APP_ROOT.parents[0]
/ 'docs'
/ 'source'
/ '_static'
/ 'html'
/ 'normalize_example.html'
/ "docs"
/ "source"
/ "_static"
/ "html"
/ "normalize_example.html"
).absolute(),
overwrite=True,
)


if __name__ == '__main__':
if __name__ == "__main__":
gen_norm_figure()
20 changes: 10 additions & 10 deletions src/gene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
APP_ROOT = Path(__file__).resolve().parent

logging.basicConfig(
filename='gene.log', format='[%(asctime)s] - %(name)s - %(levelname)s : %(message)s'
filename="gene.log", format="[%(asctime)s] - %(name)s - %(levelname)s : %(message)s"
)
logger = logging.getLogger('gene')
logger = logging.getLogger("gene")
logger.setLevel(logging.DEBUG)
logger.handlers = []

logging.getLogger('boto3').setLevel(logging.INFO)
logging.getLogger('botocore').setLevel(logging.INFO)
logging.getLogger('urllib3').setLevel(logging.INFO)
logging.getLogger('python_jsonschema_objects').setLevel(logging.INFO)
logging.getLogger('biocommons.seqrepo.seqaliasdb.seqaliasdb').setLevel(logging.INFO)
logging.getLogger('biocommons.seqrepo.fastadir.fastadir').setLevel(logging.INFO)
logging.getLogger("boto3").setLevel(logging.INFO)
logging.getLogger("botocore").setLevel(logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)
logging.getLogger("python_jsonschema_objects").setLevel(logging.INFO)
logging.getLogger("biocommons.seqrepo.seqaliasdb.seqaliasdb").setLevel(logging.INFO)
logging.getLogger("biocommons.seqrepo.fastadir.fastadir").setLevel(logging.INFO)


SEQREPO_ROOT_DIR = Path(
environ.get('SEQREPO_ROOT_DIR', '/usr/local/share/seqrepo/latest')
environ.get("SEQREPO_ROOT_DIR", "/usr/local/share/seqrepo/latest")
)


Expand Down Expand Up @@ -59,5 +59,5 @@ class DownloadException(Exception): # noqa: N818
NAMESPACE_LOOKUP = {
v.value.lower(): NamespacePrefix[k].value
for k, v in SourceIDAfterNamespace.__members__.items()
if v.value != ''
if v.value != ""
}
Loading

0 comments on commit fcbe595

Please sign in to comment.