From b9a0f05b9d0fb4fd16b6455e46843735f38fe58a Mon Sep 17 00:00:00 2001 From: David Brooks Date: Fri, 1 Nov 2024 21:13:33 +1300 Subject: [PATCH] Only render paths whose taxon matches the map being built unless `--all-path-taxons` option is set (#101). --- README.rst | 5 +++-- mapmaker/__main__.py | 6 ++++-- mapmaker/properties/__init__.py | 11 ++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index e95fda56..99cbedf1 100644 --- a/README.rst +++ b/README.rst @@ -107,7 +107,7 @@ Command line help usage: mapmaker [-h] [-v] [--log LOG_FILE] [--show-deprecated] [--silent] [--verbose] - [--clean-connectivity] [--background-tiles] [--disconnected-paths] + [--all-path-taxons] [--background-tiles] [--clean-connectivity] [--disconnected-paths] [--force] [--id ID] [--ignore-git] [--ignore-sckan] [--invalid-neurons] [--no-path-layout] [--publish SPARC_DATASET] [--sckan-version {production,staging}] [--authoring] [--debug] @@ -130,9 +130,10 @@ Command line help --verbose Show progress bars Map generation: - --clean-connectivity Refresh local connectivity knowledge from SciCrunch + --all-path-taxons Include paths whose taxons don't match the map's taxon --background-tiles Generate image tiles of map's layers (may take a while...) + --clean-connectivity Refresh local connectivity knowledge from SciCrunch --disconnected-paths Include paths that are disconnected in the map --force Generate the map even if it already exists --id ID Set explicit ID for flatmap, overriding manifest diff --git a/mapmaker/__main__.py b/mapmaker/__main__.py index 37fd4e1e..13e84b1e 100644 --- a/mapmaker/__main__.py +++ b/mapmaker/__main__.py @@ -43,10 +43,12 @@ def arg_parser(): help="Show progress bars") generation_options = parser.add_argument_group('Map generation') - generation_options.add_argument('--clean-connectivity', dest='cleanConnectivity', action='store_true', - help='Refresh local connectivity knowledge from SciCrunch') + generation_options.add_argument('--all-path-taxons', dest='allPathTaxons', action='store_true', + help="Include paths whose taxons don't match the map's taxon") generation_options.add_argument('--background-tiles', dest='backgroundTiles', action='store_true', help="Generate image tiles of map's layers (may take a while...)") + generation_options.add_argument('--clean-connectivity', dest='cleanConnectivity', action='store_true', + help='Refresh local connectivity knowledge from SciCrunch') generation_options.add_argument('--disconnected-paths', dest='disconnectedPaths', action='store_true', help="Include paths that are disconnected in the map") generation_options.add_argument('--force', action='store_true', diff --git a/mapmaker/properties/__init__.py b/mapmaker/properties/__init__.py index c2b1513d..5340ae73 100644 --- a/mapmaker/properties/__init__.py +++ b/mapmaker/properties/__init__.py @@ -38,6 +38,10 @@ #=============================================================================== +MAMMALIAN_TAXON = 'NCBITaxon:40674' + +#=============================================================================== + class PropertiesStore(object): def __init__(self, flatmap: "FlatMap", manifest: "Manifest"): self.__flatmap = flatmap @@ -94,7 +98,12 @@ def __init__(self, flatmap: "FlatMap", manifest: "Manifest"): if (path_knowledge.get('pathDisconnected', False) and not settings.get('disconnectedPaths', False)): continue phenotype_sex = path_knowledge.get('biologicalSex') - if manifest.biological_sex is None or phenotype_sex is None or (manifest.biological_sex == phenotype_sex): + path_taxons = path_knowledge.get('taxons') + if ((manifest.biological_sex is None or phenotype_sex is None + or manifest.biological_sex == phenotype_sex) + and (settings.get('allPathTaxons', False) + or manifest.models is None or path_taxons is None + or manifest.models in path_taxons or MAMMALIAN_TAXON in path_taxons)): self.__pathways.add_connectivity_path(connectivity_path, self, path_filter=path_filter, traced_paths=traced_paths)