diff --git a/CHANGELOG.md b/CHANGELOG.md index c561567..cbfc200 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Summary * [**Unreleased**](#unreleased) +* [**Release 2022-11-26 v0.0.38**](#release-2022-11-26-v0038) Added instructions, and console_script to run script, icite * [**Release 2022-09-27 v0.0.37**](#release-2022-09-27-v0037) Remove unused package in setup.py * [**Release 2022-07-03 v0.0.36**](#release-2022-07-03-v0036) Change citation count on GitHub repo card * [**Release 2022-04-28 v0.0.35**](#release-2022-04-28-v0035) More detailed GitHub repo card (project summary image) @@ -39,6 +40,11 @@ ### Unreleased +### release 2022-11-26 v0.0.38 +* ADDED instructions for loading locally to README.md [#43](https://github.com/dvklopfenstein/pmidcite/issues/43) +* ADDED entry_points, console_scripts, icite to setup.py [#42](https://github.com/dvklopfenstein/pmidcite/issues/42) +* CHANGED first make target to locally install pmidcite [#43](https://github.com/dvklopfenstein/pmidcite/issues/43) + ### release 2022-09-03 v0.0.37 FIXED: Remove unused package in setup.py (pmidcite.eutils.pubmed.mesh) diff --git a/README.md b/README.md index 04784b0..5db8879 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,16 @@ $ grep TOP log/icite/Osbourn_Anne.txt | awk '{print $7 " " $8}' | scatter.py ## Installation To install from [**PyPI**](https://pypi.org/project/pmidcite/) -```pip install pmidcite``` +```$ pip install pmidcite``` + +To install locally +``` +$ git clone https://github.com/dvklopfenstein/pmidcite.git +$ cd ./pmidcite +$ pip install . +``` + + ## Setup Save your literature search in a GitHub repo. diff --git a/makefile b/makefile index 63f555d..a86fc5c 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,18 @@ PYTHON = python3 -findpy: - find src -regextype posix-extended -regex ".*[a-z]+.py" +install: + pip install . + +py: + find src -name \*.py + +t: + find src/tests -regextype posix-extended -regex ".*[a-z]+.py" + +p: + find src/bin src/pmidcite -name \*.py + +d: find src -regextype posix-extended -regex "[a-z./]*" -type d diff0: @@ -17,6 +28,7 @@ pylint: chmod 755 tmp_pylint tmp_pylint + #### TESTS := \ #### src/tests/test_cfg_icite.py @@ -51,6 +63,7 @@ vim_md: # Needs wheel package to run bdist_wheel: pip3 install wheel .PHONY: build build: + # python3 -m pip install -U pip # python3 -m pip install --user --upgrade setuptools wheel make clean_dist $(PYTHON) setup.py sdist @@ -95,6 +108,7 @@ clean: rm -rf notebooks/icite rm -rf src/tests/icite make clobber_tmp + make clean_dist clobber_tmp: rm -rf ./icite diff --git a/setup.py b/setup.py index ab80ace..9bbf01e 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,6 @@ from os.path import join # from distutils.core import setup from glob import glob -from pathlib import PurePosixPath from setuptools import setup # import versioneer @@ -26,7 +25,7 @@ 'pmidcite.plot', ] -PACKAGE_DIRS = {p:join('src', PurePosixPath(*p.split('.'))) for p in PACKAGES} +PACKAGE_DIRS = {p:join('src', *p.split('.')) for p in PACKAGES} def get_long_description(): """Return the contents of the README.md as a string""" @@ -38,14 +37,21 @@ def get_long_description(): setup( name=NAME, ## version=versioneer.get_version(), - version='0.0.37', - author='DV Klopfenstein', + version='0.0.38', + author='DV Klopfenstein, PhD', author_email='dvklopfenstein@protonmail.com', ## cmdclass=versioneer.get_cmdclass(), packages=PACKAGES, package_dir=PACKAGE_DIRS, # https://stackoverflow.com/questions/18787036/difference-between-entry-points-console-scripts-and-scripts-in-setup-py + # https://stackoverflow.com/questions/45114076/python-setuptools-using-scripts-keyword-in-setup-py + # https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#scripts scripts=glob('src/bin/*.py'), + entry_points={ + 'console_scripts':[ + 'icite=src.bin.icite:main', + ], + }, # https://pypi.org/classifiers/ classifiers=[ 'Programming Language :: Python', diff --git a/src/pmidcite/__version__.py b/src/pmidcite/__version__.py index 4a758de..3378ddd 100644 --- a/src/pmidcite/__version__.py +++ b/src/pmidcite/__version__.py @@ -1,3 +1,3 @@ """Version of pmidcite project""" -__version__ = '0.0.37' +__version__ = '0.0.38' diff --git a/src/pmidcite/cfg.py b/src/pmidcite/cfg.py index 4b8aae5..c880c75 100644 --- a/src/pmidcite/cfg.py +++ b/src/pmidcite/cfg.py @@ -107,7 +107,7 @@ def _get_fullname(self, filename, dir_key): dirname = self.cfgparser['pmidcite'][dir_key] if dirname is None or dirname == 'None': return filename - if exists(dirname): + if dirname is not None and exists(dirname): return join(dirname, filename) cwd = getcwd() print('**WARNING: DIR NOT EXIST {DIR_TYPE}({DIR_NAME}) RETURNING CWD({CWD})'.format( @@ -159,7 +159,7 @@ def set_cfg(self, cfgfile=None): def rd_rc(self, prt=stdout, prt_fullname=True): """Read a configuration file""" - if exists(self.cfgfile): + if self.cfgfile is not None and exists(self.cfgfile): if prt: cfgfile = self.cfgfile if prt_fullname else basename(self.cfgfile) prt.write(' READ: {CFG}\n'.format(CFG=cfgfile)) diff --git a/src/pmidcite/icite/dnldr/pmid_dnlder_base.py b/src/pmidcite/icite/dnldr/pmid_dnlder_base.py index ce18a6a..e7511f4 100644 --- a/src/pmidcite/icite/dnldr/pmid_dnlder_base.py +++ b/src/pmidcite/icite/dnldr/pmid_dnlder_base.py @@ -132,6 +132,8 @@ def get_pmid2paper(self, pmids_top, pmid2note=None): """Get one NIHiCitePaper object for each user-specified PMID""" if not self.details_cites_refs: return self._geticitepapers_wo_assc(pmids_top, pmid2note) + #print('PPPPPPPPPPPPPPPPPPP', pmids_top) + #print('PPPPPPPPPPPPPPPPPPP', pmid2note) return self._geticitepapers_w_assc(pmids_top, pmid2note) #### s_geticitepaper = self._geticitepaper #### papers = [s_geticitepaper(p, '', pmid2note) for p in pmids_top] @@ -152,8 +154,12 @@ def _geticitepapers_w_assc(self, pmids_top, pmid2note=None): """Get one NIHiCitePaper object for each user-specified PMID w/cites and/or refs""" nihentries_top = self.get_icites(pmids_top) s_get_cites_refs = self.details_cites_refs + #print('AAAAAAAAAAAAAAAAAAAA', nihentries_top) top_n_assocs = [(e.pmid, e.get_assc_pmids(s_get_cites_refs)) for e in nihentries_top] # PMIDs that are associated with the top PMIDs (cited_by_clin, cited_by, references) + #print('AAAAAAAAAAAAAAAAAAAA', top_n_assocs) + #if not top_n_assocs: + # return {} pmids_assoc = set.union(*list(zip(*top_n_assocs))[1]) # Get associated PMIDs that were requested by the researcher nihentries_other = self.get_icites(pmids_assoc.difference(pmids_top)) diff --git a/src/pmidcite/pubmedqueryicite.py b/src/pmidcite/pubmedqueryicite.py index 8dbfbd7..a11166a 100644 --- a/src/pmidcite/pubmedqueryicite.py +++ b/src/pmidcite/pubmedqueryicite.py @@ -7,7 +7,7 @@ from collections import namedtuple from pmidcite.cfg import get_cfgparser from pmidcite.eutils.cmds.pubmed import PubMed -from pmidcite.cli.utils import wr_pmids +#### from pmidcite.cli.utils import wr_pmids from pmidcite.icite.downloader import get_downloader @@ -53,14 +53,14 @@ def querypubmed_runicite(self, filename, query, details_cites_refs=None): # https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch pmids = self.pubmed.dnld_query_pmids(query, num_ids_p_epost=100000) ## print('PMIDCITE QQQQQQQQQQQQQQQQQ {N} PMIDs'.format(N=len(pmids))) - fout_pmids = self.cfg.get_fullname_pmids(filename) + ## fout_pmids = self.cfg.get_fullname_pmids(filename) fout_icite = self.cfg.get_fullname_icite(filename) - # 2) Write PubMed PMIDs into a simple text file, one PMID per line - if fout_pmids != fout_icite: - if pmids: - wr_pmids(fout_pmids, pmids) - else: - print(' 0 PMIDs: NOT WRITING {TXT}'.format(TXT=fout_pmids)) + ##### 2) Write PubMed PMIDs into a simple text file, one PMID per line + ####if fout_pmids != fout_icite: + #### if pmids: + #### wr_pmids(fout_pmids, pmids) + #### else: + #### print(' 0 PMIDs: NOT WRITING {TXT}'.format(TXT=fout_pmids)) # 3) Run NIH's iCite on the PMIDs and write the results into a file if pmids: return self._wr_icite(fout_icite, pmids, details_cites_refs) diff --git a/src/tests/args_dflt.py b/src/tests/args_dflt.py index e46df3b..10cef8f 100644 --- a/src/tests/args_dflt.py +++ b/src/tests/args_dflt.py @@ -3,4 +3,4 @@ from argparse import Namespace # pylint: disable=line-too-long -ARGS = Namespace(O=False, append_outfile=None, dir_icite='./log/icite', dir_icite_py='None', dir_pubmed_txt='None', force_download=False, force_write=False, generate_rcfile=False, help=False, infile=None, load_citations=False, load_references=False, md=False, min1=2.1, min2=15.7, min3=70.0, min4=97.5, no_references=False, outfile=None, pmids=[1], print_header=False, print_keys=False, pubmed=False, verbose=False) +ARGS = Namespace(O=False, append_outfile=None, dir_icite='./log/icite', dir_icite_py='None', dir_pubmed_txt='None', force_download=False, force_write=False, generate_rcfile=False, print_rcfile=False, help=False, infile=None, load_citations=False, load_references=False, md=False, min1=2.1, min2=15.7, min3=70.0, min4=97.5, no_references=False, outfile=None, pmids=[1], print_header=False, print_keys=False, pubmed=False, verbose=False) diff --git a/src/tests/test_cli_icite.py b/src/tests/test_cli_icite.py index 04d83ff..a63346e 100755 --- a/src/tests/test_cli_icite.py +++ b/src/tests/test_cli_icite.py @@ -24,7 +24,7 @@ def test_cli_icite(): """Test the icite command-line options""" args = ARGS - print(args) + print('TEST ARGS test_cli_icite:', args) # icite # pylint: disable=protected-access