Skip to content

Commit

Permalink
Add ability to rewrite preset settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lszeremeta committed Apr 16, 2021
1 parent 68a3cfe commit f02facf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ usage: molstruct [-h] [--version] -f {jsonldhtml,jsonld,rdfa,microdata} [-i IDEN
[-iu IUPACNAME] [-mf MOLECULARFORMULA] [-w MOLECULARWEIGHT]
[-mw MONOISOTOPICMOLECULARWEIGHT] [-d DESCRIPTION]
[-dd DISAMBIGUATINGDESCRIPTION] [-img IMAGE] [-an ALTERNATENAME]
[-sa SAMEAS] [-p {drugbank-open}] [-c] [-s {iri,uuid,bnode}] [-b BASE]
[-sa SAMEAS] [-p {drugbank-open} | -c] [-s {iri,uuid,bnode}] [-b BASE]
[-vd VALUE_DELIMITER] [-l LIMIT]
file
```
Expand Down Expand Up @@ -107,7 +107,7 @@ Arguments for changing the default column names
### Additional settings arguments

* `-p {drugbank-open}`, `--preset {drugbank-open}` apply presets for individual CSV sources to avoid setting individual options manually ('drugbank-open' - [DrugBank CC0 Open Data dataset](https://go.drugbank.com/releases/latest#open-data))
* `-c`, `--columns` use only columns with renamed names
* `-c`, `--columns` use only columns with renamed names; not available when using a preset
* `-s {iri,uuid,bnode}`, `--subject {iri,uuid,bnode}` molecule subject type ('iri' by default)
* `-b BASE`, `--base BASE` molecule subject base for 'iri' subject type ('http://example.com/molecule#entity' by default)
* `-vd VALUE_DELIMITER`, `--value-delimiter VALUE_DELIMITER` value delimiter (' | ' by default)
Expand Down
22 changes: 11 additions & 11 deletions molstruct/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ def main():
help="sameAs column name ('" + n.COLUMNS['sameAs'] + "' by default), URL")

additional_settings = parser.add_argument_group('Additional settings arguments')
additional_settings.add_argument("-p", "--preset", choices=['drugbank-open'],
help="apply presets for individual CSV sources to avoid setting individual options manually ('drugbank-open' - DrugBank CC0 Open Data dataset)")
additional_settings.add_argument("-c", "--columns",
help="use only columns with renamed names",
action="store_true")
additional_exclusive = additional_settings.add_mutually_exclusive_group()
additional_exclusive.add_argument("-p", "--preset", choices=['drugbank-open'],
help="apply presets for individual CSV sources to avoid setting individual options manually ('drugbank-open' - DrugBank CC0 Open Data dataset)")
additional_exclusive.add_argument("-c", "--columns",
help="use only columns with renamed names; not available when using a preset",
action="store_true")
additional_settings.add_argument("-s", "--subject", choices=['iri', 'uuid', 'bnode'], default='iri',
help="molecule subject type ('iri' by default)")
additional_settings.add_argument("-b", "--base", type=str,
Expand All @@ -80,12 +81,11 @@ def main():

# set presets
if args.preset == 'drugbank-open':
args.value_delimiter = ' | '
args.columns = True
args.identifier = 'CAS'
args.name = 'Common name'
args.inChIKey = 'Standard InChI Key'
args.alternateName = 'Synonyms'
n.VALUE_DELIMITER = ' | '
n.COLUMNS['identifier'] = 'CAS'
n.COLUMNS['name'] = 'Common name'
n.COLUMNS['inChIKey'] = 'Standard InChI Key'
n.COLUMNS['alternateName'] = 'Synonyms'

# replace default base molecule IRI
if args.base:
Expand Down

0 comments on commit f02facf

Please sign in to comment.