From f0fde5622f50b5092155c23d2d1fff9c3f1d07fb Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:24:44 +0100 Subject: [PATCH 01/26] Update autodoc API documentation page --- docs/source/api.rst | 59 ++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index bfccda0..9760a86 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -10,55 +10,28 @@ API documentation This part of the documentation is automatically generated from the ChemSpiPy source code and comments. .. automodule:: chemspipy.api -.. autoclass:: chemspipy.ChemSpider() - .. automethod:: get_compound(csid) - .. automethod:: get_compounds(csids) - .. automethod:: search(query, order=None, direction=ASCENDING, raise_errors=False) - .. automethod:: simple_search(query) - .. automethod:: get_record_mol(csid, calc3d=False) - .. automethod:: get_compound_thumbnail(csid) - .. automethod:: get_databases() - .. automethod:: get_compound_info(csid) - .. automethod:: get_extended_compound_info(csid) - .. automethod:: get_extended_compound_info_list(csids) - .. automethod:: get_extended_mol_compound_info_list(csids, mol_type=MOL2D, include_reference_counts=False, include_external_references=False) - .. automethod:: request(api, endpoint, **params) - .. automethod:: construct_api_url(api, endpoint, **params) - .. automethod:: async_simple_search(query) - .. automethod:: async_simple_search_ordered(query, order=CSID, direction=ASCENDING) - .. automethod:: get_async_search_status(rid) - .. automethod:: get_async_search_status_and_count(rid) - .. automethod:: get_async_search_result(rid) - .. automethod:: get_async_search_result_part(rid, start=0, count=-1) - .. automethod:: simple_search_by_formula(formula) - .. automethod:: simple_search_by_mass(mass, mass_range) - -.. autodata:: chemspipy.api.MOL2D -.. autodata:: chemspipy.api.MOL3D -.. autodata:: chemspipy.api.BOTH -.. autodata:: chemspipy.api.ASCENDING -.. autodata:: chemspipy.api.DESCENDING -.. autodata:: chemspipy.api.CSID -.. autodata:: chemspipy.api.MASS_DEFECT -.. autodata:: chemspipy.api.MOLECULAR_WEIGHT -.. autodata:: chemspipy.api.REFERENCE_COUNT -.. autodata:: chemspipy.api.DATASOURCE_COUNT -.. autodata:: chemspipy.api.PUBMED_COUNT -.. autodata:: chemspipy.api.RSC_COUNT + .. autoclass:: ChemSpider() + :members: + + .. autodata:: ASCENDING + .. autodata:: DESCENDING + .. autodata:: RECORD_ID + .. autodata:: MASS_DEFECT + .. autodata:: MOLECULAR_WEIGHT + .. autodata:: REFERENCE_COUNT + .. autodata:: DATASOURCE_COUNT + .. autodata:: PUBMED_COUNT + .. autodata:: RSC_COUNT + .. autodata:: ORDERS + .. autodata:: DIRECTIONS + .. autodata:: FIELDS .. automodule:: chemspipy.objects -.. autoclass:: chemspipy.Compound() :members: .. automodule:: chemspipy.search -.. autoclass:: chemspipy.Results() :members: .. automodule:: chemspipy.errors -.. autoexception:: chemspipy.errors.ChemSpiPyError() -.. autoexception:: chemspipy.errors.ChemSpiPyParseError() -.. autoexception:: chemspipy.errors.ChemSpiPyAuthError() -.. autoexception:: chemspipy.errors.ChemSpiPyNotFoundError() -.. autoexception:: chemspipy.errors.ChemSpiPyTimeoutError() -.. autoexception:: chemspipy.errors.ChemSpiPyServerError() + :members: From 2b3c9eb3f849e564775f71714c21d490858bd8dc Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:24:56 +0100 Subject: [PATCH 02/26] Remove classifiers that get outdated --- setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.py b/setup.py index 046d179..8cedc24 100644 --- a/setup.py +++ b/setup.py @@ -32,11 +32,7 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Bio-Informatics', 'Topic :: Scientific/Engineering :: Chemistry', From f82611fbd7fc5f56617606c852c60a5490d27ac4 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:42:36 +0100 Subject: [PATCH 03/26] Rearrange docs directory --- .gitignore | 4 +- docs/Makefile | 179 +-------------- docs/{source => }/api.rst | 0 docs/conf.py | 180 +++++++++++++++ docs/{source => }/guide/advanced.rst | 0 docs/{source => }/guide/compound.rst | 0 docs/guide/contributing.rst | 3 + docs/{source => }/guide/gettingstarted.rst | 0 docs/{source => }/guide/install.rst | 0 docs/{source => }/guide/intro.rst | 2 +- docs/{source => }/guide/misc.rst | 0 docs/{source => }/guide/searching.rst | 0 docs/{source => }/index.rst | 2 +- docs/source/conf.py | 246 --------------------- docs/source/guide/contributing.rst | 3 - 15 files changed, 198 insertions(+), 421 deletions(-) rename docs/{source => }/api.rst (100%) create mode 100644 docs/conf.py rename docs/{source => }/guide/advanced.rst (100%) rename docs/{source => }/guide/compound.rst (100%) create mode 100644 docs/guide/contributing.rst rename docs/{source => }/guide/gettingstarted.rst (100%) rename docs/{source => }/guide/install.rst (100%) rename docs/{source => }/guide/intro.rst (97%) rename docs/{source => }/guide/misc.rst (100%) rename docs/{source => }/guide/searching.rst (100%) rename docs/{source => }/index.rst (93%) delete mode 100644 docs/source/conf.py delete mode 100644 docs/source/guide/contributing.rst diff --git a/.gitignore b/.gitignore index be1907c..8dd84d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ __pycache__/ *.py[cod] -build/ -dist/ +/docs/_build/ +/dist/ *.egg-info/ .coverage .coverage.* diff --git a/docs/Makefile b/docs/Makefile index c46fa04..6d0b339 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,177 +1,20 @@ -# Makefile for Sphinx documentation +# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext +SPHINXPROJ = ChemSpiPy +SOURCEDIR = . +BUILDDIR = _build +# Put it first so that "make" without argument is like "make help". help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ChemSpiPy.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ChemSpiPy.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/ChemSpiPy" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ChemSpiPy" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -xml: - $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml - @echo - @echo "Build finished. The XML files are in $(BUILDDIR)/xml." +.PHONY: help Makefile -pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/docs/source/api.rst b/docs/api.rst similarity index 100% rename from docs/source/api.rst rename to docs/api.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..5eebac2 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,180 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. + +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('..')) + + +# -- Project information ----------------------------------------------------- + +project = 'ChemSpiPy' +copyright = '2018, Matt Swain' +author = 'Matt Swain' + +# The short X.Y version +version = '' +# The full version, including alpha/beta/rc tags +release = '1.0.5' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.viewcode', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path . +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# -- Options for HTML output ------------------------------------------------- + +# on_rtd is whether we are on readthedocs.org +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +# html_theme = 'alabaster' + +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'ChemSpiPydoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'ChemSpiPy.tex', 'ChemSpiPy Documentation', + 'Matt Swain', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'chemspipy', 'ChemSpiPy Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'ChemSpiPy', 'ChemSpiPy Documentation', + author, 'ChemSpiPy', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for intersphinx extension --------------------------------------- + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} + +# Sort autodoc members by the order they appear in the source code +autodoc_member_order = 'bysource' + +# Concatenate the class and __init__ docstrings together +autoclass_content = 'both' diff --git a/docs/source/guide/advanced.rst b/docs/guide/advanced.rst similarity index 100% rename from docs/source/guide/advanced.rst rename to docs/guide/advanced.rst diff --git a/docs/source/guide/compound.rst b/docs/guide/compound.rst similarity index 100% rename from docs/source/guide/compound.rst rename to docs/guide/compound.rst diff --git a/docs/guide/contributing.rst b/docs/guide/contributing.rst new file mode 100644 index 0000000..2b6578f --- /dev/null +++ b/docs/guide/contributing.rst @@ -0,0 +1,3 @@ +.. _contributing: + +.. include:: ../../CONTRIBUTING.rst diff --git a/docs/source/guide/gettingstarted.rst b/docs/guide/gettingstarted.rst similarity index 100% rename from docs/source/guide/gettingstarted.rst rename to docs/guide/gettingstarted.rst diff --git a/docs/source/guide/install.rst b/docs/guide/install.rst similarity index 100% rename from docs/source/guide/install.rst rename to docs/guide/install.rst diff --git a/docs/source/guide/intro.rst b/docs/guide/intro.rst similarity index 97% rename from docs/source/guide/intro.rst rename to docs/guide/intro.rst index a61a267..6accd72 100644 --- a/docs/source/guide/intro.rst +++ b/docs/guide/intro.rst @@ -23,7 +23,7 @@ All operations require an API key. To obtain one, `Register for a RSC Developers ChemSpiPy license ----------------- -.. include:: ../../../LICENSE +.. include:: ../../LICENSE .. _`ChemSpider website`: http://www.chemspider.com .. _`full documentation for the ChemSpider APIs`: https://developer.rsc.org/compounds-v1/apis diff --git a/docs/source/guide/misc.rst b/docs/guide/misc.rst similarity index 100% rename from docs/source/guide/misc.rst rename to docs/guide/misc.rst diff --git a/docs/source/guide/searching.rst b/docs/guide/searching.rst similarity index 100% rename from docs/source/guide/searching.rst rename to docs/guide/searching.rst diff --git a/docs/source/index.rst b/docs/index.rst similarity index 93% rename from docs/source/index.rst rename to docs/index.rst index b6d548b..b326928 100644 --- a/docs/source/index.rst +++ b/docs/index.rst @@ -1,4 +1,4 @@ -.. ChemSpiPy documentation master file, created by sphinx-quickstart on Mon Sep 15 10:51:47 2014. +.. ChemSpiPy documentation master file ChemSpiPy ========= diff --git a/docs/source/conf.py b/docs/source/conf.py deleted file mode 100644 index e885122..0000000 --- a/docs/source/conf.py +++ /dev/null @@ -1,246 +0,0 @@ -# -*- coding: utf-8 -*- -# -# ChemSpiPy documentation build configuration file, created by sphinx-quickstart on Mon Sep 15 10:51:47 2014. -# This file is execfile()d with the current directory set to its containing dir. -# Note that not all possible configuration values are present in this autogenerated file. -# All configuration values have a default; values that are commented out serve to show the default. - -import sys -import os - -# on_rtd is whether we are on readthedocs.org -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' - -# If extensions (or modules to document with autodoc) are in another directory, add these directories to sys.path here. -# If the directory is relative to the documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../..')) - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions coming with Sphinx -# (named 'sphinx.ext.*') or your custom ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'ChemSpiPy' -copyright = u'2018, Matt Swain' - -# The version info for the project you're documenting, acts as replacement for |version| and |release|, also used in -# various other places throughout the built documents. -# The short X.Y version. -version = '1.0.5' -# The full version, including alpha/beta/rc tags. -release = '1.0.5' - -# The language for content autogenerated by Sphinx. Refer to documentation for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and directories to ignore when looking for source -# files. -exclude_patterns = [] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for a list of builtin themes. -if not on_rtd: # only import and set the theme if we're building docs locally - import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - -#html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme further. For a list of options available -# for each theme, see the documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the docs. This file should be a Windows icon -# file (.ico) being 16x16 or 32x32 pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, relative to this directory. They are -# copied after the builtin static files, so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Add any extra paths that contain custom files (such as robots.txt or .htaccess) here, relative to this directory. -# These files are copied directly to the root of the documentation. -#html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will contain a tag referring to it. The -# value of this option must be the base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'ChemSpiPydoc' - - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -'papersize': 'a4paper', - -# The font size ('10pt', '11pt' or '12pt'). -'pointsize': '12pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto, manual, or own class]). -latex_documents = [ - ('index', 'ChemSpiPy.tex', u'ChemSpiPy Documentation', u'Matt Swain', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, not chapters. -latex_use_parts = False - -# If true, show page references after internal links. -latex_show_pagerefs = True - -# If true, show URL addresses after external links. -latex_show_urls = True - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -latex_domain_indices = False - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'chemspipy', u'ChemSpiPy Documentation', [u'Matt Swain'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, dir menu entry, description, category) -texinfo_documents = [ - ('index', 'ChemSpiPy', u'ChemSpiPy Documentation', u'Matt Swain', 'ChemSpiPy', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} - -# Sort autodoc members by the order they appear in the source code -autodoc_member_order = 'bysource' - -# Concatenate the class and __init__ docstrings together -autoclass_content = 'both' diff --git a/docs/source/guide/contributing.rst b/docs/source/guide/contributing.rst deleted file mode 100644 index 544fcf3..0000000 --- a/docs/source/guide/contributing.rst +++ /dev/null @@ -1,3 +0,0 @@ -.. _contributing: - -.. include:: ../../../CONTRIBUTING.rst From 54746a246ae48881b3705d729de919e15b9531a0 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:46:28 +0100 Subject: [PATCH 04/26] Remove inheritance in ChemSpiPy object --- chemspipy/api.py | 125 +++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 75 deletions(-) diff --git a/chemspipy/api.py b/chemspipy/api.py index 8019ff4..c178bbd 100644 --- a/chemspipy/api.py +++ b/chemspipy/api.py @@ -86,7 +86,15 @@ ] -class BaseChemSpider(object): +class ChemSpider(object): + """Provides access to the ChemSpider API. + + Usage:: + + >>> from chemspipy import ChemSpider + >>> cs = ChemSpider('') + + """ def __init__(self, api_key, user_agent=None, api_url=API_URL, api_version=API_VERSION): """ @@ -105,6 +113,9 @@ def __init__(self, api_key, user_agent=None, api_url=API_URL, api_version=API_VE self.api_key = api_key self.api_version = api_version + def __repr__(self): + return 'ChemSpider()' + def request(self, method, api, namespace, endpoint, params=None, json=None): """Make a request to the ChemSpider API. @@ -169,9 +180,41 @@ def post(self, api, namespace, endpoint, json=None): """ return self.request('POST', api=api, namespace=namespace, endpoint=endpoint, json=json) + def get_compound(self, csid): + """Return a Compound object for a given ChemSpider ID. Security token is required. + + :param string|int csid: ChemSpider ID. + :return: The Compound with the specified ChemSpider ID. + :rtype: :class:`~chemspipy.Compound` + """ + return Compound(self, csid) + + def get_compounds(self, csids): + """Return a list of Compound objects, given a list ChemSpider IDs. Security token is required. + + :param list[string|int] csids: List of ChemSpider IDs. + :return: List of Compounds with the specified ChemSpider IDs. + :rtype: list[:class:`~chemspipy.Compound`] + """ + return [Compound(self, csid) for csid in csids] + + def search(self, query, order=None, direction=ASCENDING, raise_errors=False): + """Search ChemSpider for the specified query and return the results. Security token is required. -class LookupsApi(BaseChemSpider): - """""" + The accepted values for ``order`` are: :data:`~chemspipy.api.RECORD_ID`, :data:`~chemspipy.api.MASS_DEFECT`, + :data:`~chemspipy.api.MOLECULAR_WEIGHT`, :data:`~chemspipy.api.REFERENCE_COUNT`, + :data:`~chemspipy.api.DATASOURCE_COUNT`, :data:`~chemspipy.api.PUBMED_COUNT` or + :data:`~chemspipy.api.RSC_COUNT`. + + :param string|int query: Search query. + :param string order: (Optional) Field to sort the result by. + :param string direction: (Optional) :data:`~chemspipy.api.ASCENDING` or :data:`~chemspipy.api.DESCENDING`. + :param bool raise_errors: (Optional) If True, raise exceptions. If False, store on Results ``exception`` + property. + :return: Search Results list. + :rtype: chemspipy.search.Results + """ + return Results(self, self.filter_name, (query, order, direction), raise_errors=raise_errors) def get_datasources(self): """Get the list of datasources in ChemSpider. @@ -185,10 +228,6 @@ def get_datasources(self): response = self.get(api='compounds', namespace='lookups', endpoint='datasources') return response['dataSources'] - -class RecordsApi(BaseChemSpider): - """""" - def get_details(self, record_id, fields=FIELDS): """Get details for a compound record. @@ -258,10 +297,6 @@ def get_mol(self, record_id): response = self.get(api='compounds', namespace='records', endpoint=endpoint) return response['sdf'] - -class FilterApi(BaseChemSpider): - """""" - def filter_element(self, include_elements, exclude_elements=None, include_all=False, complexity=None, isotopic=None, order=None, direction=None): """Search compounds by element. @@ -596,10 +631,6 @@ def filter_results_sdf(self, query_id): response = self.get(api='compounds', namespace='filter', endpoint=endpoint) return zlib.decompress(base64.b64decode(response['results']), 16 + zlib.MAX_WBITS) - -class ToolsApi(BaseChemSpider): - """""" - def convert(self, input, input_format, output_format): """Convert a chemical from one format to another. @@ -632,9 +663,6 @@ def validate_inchikey(self, inchikey): except errors.ChemSpiPyHTTPError: return False - -class MassSpecApi(BaseChemSpider): - def get_databases(self): """Get the list of datasources in ChemSpider.""" warnings.warn('Use get_datasources instead of get_databases.', DeprecationWarning) @@ -682,9 +710,6 @@ def get_record_mol(self, csid, calc3d=False): warnings.warn('calc3d parameter for get_record_mol is no longer supported.', DeprecationWarning) return self.get_mol(record_id=csid) - -class SearchApi(BaseChemSpider): - def async_simple_search(self, query): """Search ChemSpider with arbitrary query, returning results in order of the best match found. @@ -692,6 +717,9 @@ def async_simple_search(self, query): Security token is required. + .. deprecated:: 2.0.0 + Use :py:meth:`~chemspipy.api.ChemSpider.filter_name` instead. + :param string query: Search query - a name, SMILES, InChI, InChIKey, CSID, etc. :return: Transaction ID. :rtype: string @@ -786,7 +814,7 @@ def get_compound_thumbnail(self, csid): def simple_search(self, query): """Search ChemSpider with arbitrary query. - .. deprecated:: 2.0 + .. deprecated:: 2.0.0 Use :meth:`~chemspipy.api.ChemSpider.search` instead. :param string query: Search query - a chemical name. @@ -795,56 +823,3 @@ def simple_search(self, query): """ warnings.warn('Use search instead of simple_search.', DeprecationWarning) return self.search(query=query) - - -class CustomApi(BaseChemSpider): - - def get_compound(self, csid): - """Return a Compound object for a given ChemSpider ID. Security token is required. - - :param string|int csid: ChemSpider ID. - :return: The Compound with the specified ChemSpider ID. - :rtype: :class:`~chemspipy.Compound` - """ - return Compound(self, csid) - - def get_compounds(self, csids): - """Return a list of Compound objects, given a list ChemSpider IDs. Security token is required. - - :param list[string|int] csids: List of ChemSpider IDs. - :return: List of Compounds with the specified ChemSpider IDs. - :rtype: list[:class:`~chemspipy.Compound`] - """ - return [Compound(self, csid) for csid in csids] - - def search(self, query, order=None, direction=ASCENDING, raise_errors=False): - """Search ChemSpider for the specified query and return the results. Security token is required. - - The accepted values for ``order`` are: :data:`~chemspipy.api.RECORD_ID`, :data:`~chemspipy.api.MASS_DEFECT`, - :data:`~chemspipy.api.MOLECULAR_WEIGHT`, :data:`~chemspipy.api.REFERENCE_COUNT`, - :data:`~chemspipy.api.DATASOURCE_COUNT`, :data:`~chemspipy.api.PUBMED_COUNT` or - :data:`~chemspipy.api.RSC_COUNT`. - - :param string|int query: Search query. - :param string order: (Optional) Field to sort the result by. - :param string direction: (Optional) :data:`~chemspipy.api.ASCENDING` or :data:`~chemspipy.api.DESCENDING`. - :param bool raise_errors: (Optional) If True, raise exceptions. If False, store on Results ``exception`` - property. - :return: Search Results list. - :rtype: chemspipy.search.Results - """ - return Results(self, self.filter_name, (query, order, direction), raise_errors=raise_errors) - - -class ChemSpider(CustomApi, FilterApi, LookupsApi, RecordsApi, ToolsApi, MassSpecApi, SearchApi): - """Provides access to the ChemSpider API. - - Usage:: - - >>> from chemspipy import ChemSpider - >>> cs = ChemSpider('') - - """ - - def __repr__(self): - return 'ChemSpider()' From 6c2e8cc18a35cd6736d8a68e6cd9390a67e9ca71 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:46:49 +0100 Subject: [PATCH 05/26] Import FIELDS in the base __init__ module --- chemspipy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chemspipy/__init__.py b/chemspipy/__init__.py index 99c9663..4e2f077 100644 --- a/chemspipy/__init__.py +++ b/chemspipy/__init__.py @@ -19,6 +19,6 @@ from .api import ChemSpider, MOL2D, MOL3D, BOTH, ASCENDING, DESCENDING, RECORD_ID, CSID, MASS_DEFECT, MOLECULAR_WEIGHT -from .api import REFERENCE_COUNT, DATASOURCE_COUNT, PUBMED_COUNT, RSC_COUNT +from .api import REFERENCE_COUNT, DATASOURCE_COUNT, PUBMED_COUNT, RSC_COUNT, FIELDS from .objects import Compound from .search import Results From d4fd25dc6d93d919de7237aa7e2bf386001fa658 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:53:14 +0100 Subject: [PATCH 06/26] Fix api links in docs --- chemspipy/api.py | 12 ++++++------ docs/guide/compound.rst | 16 ++++++++-------- docs/guide/gettingstarted.rst | 2 +- docs/guide/searching.rst | 12 ++++++------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/chemspipy/api.py b/chemspipy/api.py index c178bbd..ee92a3e 100644 --- a/chemspipy/api.py +++ b/chemspipy/api.py @@ -185,7 +185,7 @@ def get_compound(self, csid): :param string|int csid: ChemSpider ID. :return: The Compound with the specified ChemSpider ID. - :rtype: :class:`~chemspipy.Compound` + :rtype: :class:`~chemspipy.objects.Compound` """ return Compound(self, csid) @@ -194,7 +194,7 @@ def get_compounds(self, csids): :param list[string|int] csids: List of ChemSpider IDs. :return: List of Compounds with the specified ChemSpider IDs. - :rtype: list[:class:`~chemspipy.Compound`] + :rtype: list[:class:`~chemspipy.objects.Compound`] """ return [Compound(self, csid) for csid in csids] @@ -212,7 +212,7 @@ def search(self, query, order=None, direction=ASCENDING, raise_errors=False): :param bool raise_errors: (Optional) If True, raise exceptions. If False, store on Results ``exception`` property. :return: Search Results list. - :rtype: chemspipy.search.Results + :rtype: :class:`~chemspipy.search.Results` """ return Results(self, self.filter_name, (query, order, direction), raise_errors=raise_errors) @@ -772,7 +772,7 @@ def get_async_search_result(self, rid): :param string rid: A transaction ID, returned by an asynchronous search method. :return: A list of Compounds. - :rtype: list[:class:`~chemspipy.Compound`] + :rtype: list[:class:`~chemspipy.objects.Compound`] """ warnings.warn('Use filter_results instead of get_async_search_result.', DeprecationWarning) results = self.filter_results(query_id=rid) @@ -785,7 +785,7 @@ def get_async_search_result_part(self, rid, start=0, count=-1): :param int start: The number of results to skip. :param int count: The number of results to return. -1 returns all through to end. :return: A list of Compounds. - :rtype: list[:class:`~chemspipy.Compound`] + :rtype: list[:class:`~chemspipy.objects.Compound`] """ warnings.warn('Use filter_results instead of get_async_search_result_part.', DeprecationWarning) if count == -1: @@ -819,7 +819,7 @@ def simple_search(self, query): :param string query: Search query - a chemical name. :return: Search Results list. - :rtype: chemspipy.search.Results + :rtype: :class:`~chemspipy.search.Results` """ warnings.warn('Use search instead of simple_search.', DeprecationWarning) return self.search(query=query) diff --git a/docs/guide/compound.rst b/docs/guide/compound.rst index 7c17c4a..658e251 100644 --- a/docs/guide/compound.rst +++ b/docs/guide/compound.rst @@ -3,24 +3,24 @@ Compound ======== -Many ChemSpiPy search methods return :class:`~chemspipy.Compound` objects, which provide more functionality that a +Many ChemSpiPy search methods return :class:`~chemspipy..api.Compound` objects, which provide more functionality that a simple list of ChemSpider IDs. The primary benefit is allowing easy access to further compound properties after performing a search. Creating a Compound ------------------- -The easiest way to create a :class:`~chemspipy.Compound` for a given ChemSpider ID is to use the ``get_compound`` -method:: +The easiest way to create a :class:`~chemspipy.objects.Compound` for a given ChemSpider ID is to use the +``get_compound`` method:: >>> compound = cs.get_compound(2157) -Alternatively, a :class:`~chemspipy.Compound` can be instantiated directly:: +Alternatively, a :class:`~chemspipy.objects.Compound` can be instantiated directly:: >>> compound = Compound(cs, 2157) -Either way, no requests are made to the ChemSpider servers until specific :class:`~chemspipy.Compound` properties are -requested:: +Either way, no requests are made to the ChemSpider servers until specific :class:`~chemspipy.objects.Compound` +properties are requested:: >>> print(compound.molecular_formula) C_{9}H_{8}O_{4} @@ -65,8 +65,8 @@ Compound properties Implementation details ---------------------- -Each :class:`~chemspipy.Compound` object is a simple wrapper around a ChemSpider ID. Behind the scenes, the property -methods use the ``get_compound_info``, ``get_extended_compound_info``, ``get_record_mol`` and +Each :class:`~chemspipy.objects.Compound` object is a simple wrapper around a ChemSpider ID. Behind the scenes, the +property methods use the ``get_compound_info``, ``get_extended_compound_info``, ``get_record_mol`` and ``get_compound_thumbnail`` API methods to retrieve the relevant information. It is possible to use these API methods directly if required:: diff --git a/docs/guide/gettingstarted.rst b/docs/guide/gettingstarted.rst index a3a8fe4..852abfc 100644 --- a/docs/guide/gettingstarted.rst +++ b/docs/guide/gettingstarted.rst @@ -33,7 +33,7 @@ Let's get the Compound with `ChemSpider ID 2157`_:: >>> c = cs.get_compound(2157) -Now we have a :class:`~chemspipy.Compound` object called ``c``. We can get various identifiers and calculated +Now we have a :class:`~chemspipy.objects.Compound` object called ``c``. We can get various identifiers and calculated properties from this object:: >>> print(c.molecular_formula) diff --git a/docs/guide/searching.rst b/docs/guide/searching.rst index e9923d2..1c8d910 100644 --- a/docs/guide/searching.rst +++ b/docs/guide/searching.rst @@ -21,8 +21,8 @@ provide any type of query, and ChemSpider will interpret it and provide the most The supported query types include systematic names, synonyms, trade names, registry numbers, molecular formula, SMILES, InChI and InChIKey. -The :class:`~chemspipy.Results` object that is returned can be treated just like any regular python list. For example, -you can iterate over the results:: +The :class:`~chemspipy.search.Results` object that is returned can be treated just like any regular python list. For +example, you can iterate over the results:: >>> for result in cs.search('Glucose'): ... print(result.csid) @@ -33,8 +33,8 @@ you can iterate over the results:: 9312824 9484839 -The :class:`~chemspipy.Results` object also provides the time take to perform the search, and a message that explains -how the query type was resolved:: +The :class:`~chemspipy.search.Results` object also provides the time take to perform the search, and a message that +explains how the query type was resolved:: >>> r = cs.search('Glucose') >>> print(r.duration) @@ -48,8 +48,8 @@ Asynchronous searching Certain types of search can sometimes take slightly longer, which can be inconvenient if the search method blocks the Python interpreter until the search results are returned. Fortunately, the ChemSpiPy search method works asynchronously. -Once a search is executed, ChemSpiPy immediately returns the :class:`~chemspipy.Results` object, which is actually -empty at first:: +Once a search is executed, ChemSpiPy immediately returns the :class:`~chemspipy.search.Results` object, which is +actually empty at first:: >>> results = cs.search('O=C(OCC)C') >>> print(results.ready()) From 298366e3074847e3827b55f50a47ca00b5fa1f47 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 12:55:55 +0100 Subject: [PATCH 07/26] Update supported python versions --- docs/guide/install.rst | 2 +- docs/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 37509f3..01abeb8 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -3,7 +3,7 @@ Installation ============ -ChemSpiPy supports Python versions 2.7, 3.2, 3.3 and 3.4. +ChemSpiPy supports Python versions 2.7 and 3.5+. There are two required dependencies: `six`_ and `requests`_. diff --git a/docs/index.rst b/docs/index.rst index b326928..4bc6651 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,7 +22,7 @@ Features - Download compound records as a MOL file with 2D or 3D coordinates. - Get a 2D compound depiction as a PNG image. - Complete interface to every endpoint of the ChemSpider Web APIs. -- Supports Python versions 2.7 – 3.4. +- Supports Python versions 2.7 and 3.5+. User guide ---------- From c615945918f09df4b8abd1fa092e445d93d56488 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 16:27:19 +0100 Subject: [PATCH 08/26] Add conda install instructions --- README.rst | 7 ++++++- docs/guide/install.rst | 33 ++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index ef9fdf0..f07dc95 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,12 @@ depiction and retrieval of chemical properties:: Installation ------------ -Install ChemSpiPy using pip:: +Install ChemSpiPy using conda:: + + conda install -c conda-forge chemspipy + + +or using pip:: pip install chemspipy diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 01abeb8..da483d2 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -7,10 +7,26 @@ ChemSpiPy supports Python versions 2.7 and 3.5+. There are two required dependencies: `six`_ and `requests`_. -Option 1: Use pip (recommended) -------------------------------- +Option 1: Use conda (recommended) +--------------------------------- -The easiest and recommended way to install is using pip:: +The easiest and recommended way to install is using conda. `Anaconda Python`_ is a self-contained Python environment +that is particularly useful for scientific applications. If you don't already have it, start by installing `Miniconda`_, +which includes a complete Python distribution and the conda package manager. Choose the Python 3 version, unless you +have a particular reason why you must use Python 2. + +To install ChemSpiPy, at the command line, run:: + + conda config --add channels conda-forge + conda install chemspipy + +This will add the `conda-forge`_ channel to your conda config, then install ChemSpiPy and all its dependencies into your +conda environment. + +Option 2: Use pip +----------------- + +An alternative method is to install using pip:: pip install chemspipy @@ -19,10 +35,10 @@ available to all your python scripts. It should also ensure that the dependencie If you don't already have pip installed, you can `install it using get-pip.py`_:: - curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py -Option 2: Download the latest release +Option 3: Download the latest release ------------------------------------- Alternatively, `download the latest release`_ manually and install yourself:: @@ -34,7 +50,7 @@ Alternatively, `download the latest release`_ manually and install yourself:: The setup.py command will install ChemSpiPy in your `site-packages` folder so it is automatically available to all your python scripts. -Option 3: Clone the repository +Option 4: Clone the repository ------------------------------ The latest development version of ChemSpiPy is always `available on GitHub`_. This version is not guaranteed to be @@ -46,6 +62,9 @@ stable, but may include new features that have not yet been released. Simply clo .. _`six`: http://pythonhosted.org/six/ .. _`requests`: http://docs.python-requests.org/ -.. _`install it using get-pip.py`: http://www.pip-installer.org/en/latest/installing.html +.. _`Anaconda Python`: https://www.anaconda.com/distribution/ +.. _`Miniconda`: https://conda.io/miniconda.html +.. _`conda-forge`: https://conda-forge.org/ +.. _`install it using get-pip.py`: https://pip.pypa.io/en/stable/installing/ .. _`download the latest release`: https://github.com/mcs07/ChemSpiPy/releases/ .. _`available on GitHub`: https://github.com/mcs07/ChemSpiPy From 8795ba1ad08a56d3613e08ef043118559b818c1e Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 16:44:39 +0100 Subject: [PATCH 09/26] Update links in docs --- CONTRIBUTING.rst | 4 +--- README.rst | 14 +++++++------- docs/guide/advanced.rst | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 97521a4..a7ed60a 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -53,15 +53,13 @@ Tips - Include docstrings as described in `PEP257`_. - Try and include tests that cover your changes. - Try to write `good commit messages`_. -- Consider `squashing your commits`_ with rebase. - Read the GitHub help page on `Using pull requests`_. .. _`Issue Tracker`: https://github.com/mcs07/ChemSpiPy/issues .. _`source code`: https://github.com/mcs07/ChemSpiPy .. _`Fork the ChemSpiPy repository on GitHub`: https://github.com/mcs07/ChemSpiPy/fork .. _`Submit a pull request`: https://github.com/mcs07/ChemSpiPy/compare/ -.. _`squashing your commits`: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html .. _`PEP8`: https://www.python.org/dev/peps/pep-0008 .. _`PEP257`: https://www.python.org/dev/peps/pep-0257 -.. _`good commit messages`: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html +.. _`good commit messages`: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html .. _`Using pull requests`: https://help.github.com/articles/using-pull-requests diff --git a/README.rst b/README.rst index f07dc95..a5d7564 100644 --- a/README.rst +++ b/README.rst @@ -1,16 +1,16 @@ ChemSpiPy ========= -.. image:: http://img.shields.io/pypi/v/ChemSpiPy.svg?style=flat +.. image:: https://img.shields.io/pypi/v/ChemSpiPy.svg?style=flat :target: https://pypi.python.org/pypi/ChemSpiPy -.. image:: http://img.shields.io/pypi/l/ChemSpiPy.svg?style=flat +.. image:: https://img.shields.io/pypi/l/ChemSpiPy.svg?style=flat :target: https://github.com/mcs07/ChemSpiPy/blob/master/LICENSE -.. image:: http://img.shields.io/travis/mcs07/ChemSpiPy/master.svg?style=flat +.. image:: https://img.shields.io/travis/mcs07/ChemSpiPy/master.svg?style=flat :target: https://travis-ci.org/mcs07/ChemSpiPy -.. image:: http://img.shields.io/coveralls/mcs07/ChemSpiPy/master.svg?style=flat +.. image:: https://img.shields.io/coveralls/mcs07/ChemSpiPy/master.svg?style=flat :target: https://coveralls.io/r/mcs07/ChemSpiPy?branch=master ChemSpiPy provides a way to interact with ChemSpider in Python. It allows chemical searches, chemical file downloads, @@ -38,7 +38,7 @@ Alternatively, try one of the other `installation options`_. Documentation ------------- -Full documentation is available at http://chemspipy.readthedocs.io. +Full documentation is available at https://chemspipy.readthedocs.io/en/stable/. The `general documentation for the ChemSpider API`_ is also a useful resource. @@ -55,9 +55,9 @@ ChemSpiPy is licensed under the `MIT license`_. This project was originally forked from `ChemSpiPy by Cameron Neylon`_, which has been released into the public domain. -.. _`installation options`: http://chemspipy.readthedocs.io/en/latest/guide/install.html +.. _`installation options`: https://chemspipy.readthedocs.io/en/stable/guide/install.html .. _`source code`: https://github.com/mcs07/ChemSpiPy .. _`Issue Tracker`: https://github.com/mcs07/ChemSpiPy/issues .. _`MIT license`: https://github.com/mcs07/ChemSpiPy/blob/master/LICENSE .. _`ChemSpiPy by Cameron Neylon`: https://github.com/cameronneylon/ChemSpiPy -.. _`general documentation for the ChemSpider API`: http://www.chemspider.com/AboutServices.aspx +.. _`general documentation for the ChemSpider API`: https://developer.rsc.org/compounds-v1/apis diff --git a/docs/guide/advanced.rst b/docs/guide/advanced.rst index 176f4b0..632bb7a 100644 --- a/docs/guide/advanced.rst +++ b/docs/guide/advanced.rst @@ -38,4 +38,4 @@ ChemSpiPy can generate logging statements if required. Just set the desired logg The logger is named 'chemspipy'. There is more information on logging in the `Python logging documentation`_. -.. _`Python logging documentation`: http://docs.python.org/2/howto/logging.html +.. _`Python logging documentation`: https://docs.python.org/3/howto/logging.html From 4f8b0f4a6bacb577b0e9d562e6ffbb688283f7f7 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 16:53:30 +0100 Subject: [PATCH 10/26] Use conda in contributing guide --- CONTRIBUTING.rst | 10 +++++----- environment.yml | 15 +++++++++++---- requirements/common.txt | 2 -- requirements/dev.txt | 7 ------- 4 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 requirements/common.txt delete mode 100644 requirements/dev.txt diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index a7ed60a..79140ec 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -22,11 +22,12 @@ Quick guide to contributing 1. `Fork the ChemSpiPy repository on GitHub`_, then clone your fork to your local machine:: git clone https://github.com//ChemSpiPy.git + cd ChemSpiPy -2. Install the development requirements:: +2. Install the development requirements into a `conda environment`_:: - cd chemspipy - pip install -r requirements/dev.txt + conda env create -n chemspipy -f environment.yml + source activate chemspipy 3. Create a new branch for your changes:: @@ -36,8 +37,6 @@ Quick guide to contributing pytest - The final line of the output should be ``OK``. - 5. Commit your changes and push to your fork on GitHub:: git add . @@ -58,6 +57,7 @@ Tips .. _`Issue Tracker`: https://github.com/mcs07/ChemSpiPy/issues .. _`source code`: https://github.com/mcs07/ChemSpiPy .. _`Fork the ChemSpiPy repository on GitHub`: https://github.com/mcs07/ChemSpiPy/fork +.. _`conda environment`: https://conda.io/docs/ .. _`Submit a pull request`: https://github.com/mcs07/ChemSpiPy/compare/ .. _`PEP8`: https://www.python.org/dev/peps/pep-0008 .. _`PEP257`: https://www.python.org/dev/peps/pep-0257 diff --git a/environment.yml b/environment.yml index 41f6b9e..daccb12 100644 --- a/environment.yml +++ b/environment.yml @@ -1,7 +1,14 @@ name: chemspipy channels: -- mcs07 -- defaults + - conda-forge + - defaults dependencies: -- requests=2.13.0 -- six=1.10.0 + - bumpversion=0.5.3 + - coverage=4.5.1 + - coveralls=1.3.0 + - requests=2.19.1 + - pytest=3.6.2 + - six=1.11.0 + - sphinx=1.7.5 + - sphinx_rtd_theme=0.4.1 + diff --git a/requirements/common.txt b/requirements/common.txt deleted file mode 100644 index 2bf2942..0000000 --- a/requirements/common.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests==2.5.0 -six==1.8.0 diff --git a/requirements/dev.txt b/requirements/dev.txt deleted file mode 100644 index 2effced..0000000 --- a/requirements/dev.txt +++ /dev/null @@ -1,7 +0,0 @@ --r common.txt -bumpversion==0.5.0 -coverage==3.7.1 -coveralls==0.4.4 -pytest==3.0.7 -Sphinx==1.2.3 -sphinx-rtd-theme==0.1.6 From 40f592761d11a84f5ac2cdedfdbdb15cb416789f Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 17:00:40 +0100 Subject: [PATCH 11/26] Update MANIFEST.in --- MANIFEST.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 829ceb6..1748937 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include *.rst +include CHANGELOG.md +include environment.yml include LICENSE recursive-include tests *.py recursive-include docs * -recursive-include requirements *.txt -prune docs/build +prune docs/_build From df2a7369ea63aea4dcc4d29bdb44bd71d6ae6b2d Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 17:37:53 +0100 Subject: [PATCH 12/26] Update getting started code samples --- docs/guide/gettingstarted.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/guide/gettingstarted.rst b/docs/guide/gettingstarted.rst index 852abfc..4b5207a 100644 --- a/docs/guide/gettingstarted.rst +++ b/docs/guide/gettingstarted.rst @@ -39,9 +39,9 @@ properties from this object:: >>> print(c.molecular_formula) C_{9}H_{8}O_{4} >>> print(c.molecular_weight) - 180.15742 + 180.1574 >>> print(c.smiles) - CC(=O)OC1=CC=CC=C1C(=O)O + CC(=O)Oc1ccccc1C(=O)O >>> print(c.common_name) Aspirin @@ -56,8 +56,14 @@ What if you don't know the ChemSpider ID of the Compound you want? Instead use t Compound(58238) Compound(71358) Compound(96749) + Compound(2006622) + Compound(5341883) + Compound(5360239) + Compound(9129332) + Compound(9281077) Compound(9312824) Compound(9484839) + Compound(9655623) The ``search`` method accepts any identifer that ChemSpider can interpret, including names, registry numbers, SMILES and InChI. From 89f523fe6eff3f8a3ec4c771dfb75ba72a429f3d Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 17:40:45 +0100 Subject: [PATCH 13/26] Update compound docs --- chemspipy/objects.py | 15 +++++-- docs/guide/compound.rst | 94 ++++++++++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 36 deletions(-) diff --git a/chemspipy/objects.py b/chemspipy/objects.py index 093f96f..0fe17e7 100644 --- a/chemspipy/objects.py +++ b/chemspipy/objects.py @@ -45,18 +45,27 @@ def _repr_png_(self): @property def record_id(self): - """Compound record ID.""" + """Compound record ID. + + :rtype: int + """ return self._record_id @property def csid(self): - """ChemSpider ID.""" + """ChemSpider ID. + + :rtype: int + """ warnings.warn('Use record_id instead of csid.', DeprecationWarning) return self._record_id @property def image_url(self): - """Return the URL of a PNG image of the 2D chemical structure.""" + """Return the URL of a PNG image of the 2D chemical structure. + + :rtype: string + """ return 'http://www.chemspider.com/ImagesHandler.ashx?id=%s' % self.record_id @memoized_property diff --git a/docs/guide/compound.rst b/docs/guide/compound.rst index 658e251..5081b13 100644 --- a/docs/guide/compound.rst +++ b/docs/guide/compound.rst @@ -3,15 +3,15 @@ Compound ======== -Many ChemSpiPy search methods return :class:`~chemspipy..api.Compound` objects, which provide more functionality that a -simple list of ChemSpider IDs. The primary benefit is allowing easy access to further compound properties after +Many ChemSpiPy search methods return :class:`~chemspipy.objects.Compound` objects, which provide more functionality that +a simple list of ChemSpider IDs. The primary benefit is allowing easy access to further compound properties after performing a search. Creating a Compound ------------------- The easiest way to create a :class:`~chemspipy.objects.Compound` for a given ChemSpider ID is to use the -``get_compound`` method:: +:meth:`~chemspipy.api.ChemSpider.get_compound` method:: >>> compound = cs.get_compound(2157) @@ -25,9 +25,9 @@ properties are requested:: >>> print(compound.molecular_formula) C_{9}H_{8}O_{4} >>> print(compound.molecular_weight) - 180.15742 + 180.1574 >>> print(compound.smiles) - CC(=O)OC1=CC=CC=C1C(=O)O + CC(=O)Oc1ccccc1C(=O)O >>> print(compound.common_name) Aspirin @@ -39,38 +39,66 @@ Searching for Compounds See the :ref:`searching documentation ` for full details. +Implementation details +---------------------- + +Each :class:`~chemspipy.objects.Compound` object is a simple wrapper around a ChemSpider ID. Behind the scenes, the +property methods use the :meth:`~chemspipy.api.ChemSpider.get_details`, :meth:`~chemspipy.api.ChemSpider.convert`, +:meth:`~chemspipy.api.ChemSpider.get_image`, and :meth:`~chemspipy.api.ChemSpider.get_external_references` API methods +to retrieve the relevant information. It is possible to use these API methods directly if required:: + + >>> info = cs.get_details(2157) + >>> print(info.keys()) + dict_keys(['id', 'smiles', 'formula', 'averageMass', 'molecularWeight', 'monoisotopicMass', 'nominalMass', 'commonName', 'referenceCount', 'dataSourceCount', 'pubMedCount', 'rscCount', 'mol2D', 'mol3D']) + >>> print(info['smiles']) + CC(=O)Oc1ccccc1C(=O)O + +Results are returned as a python dictionary that is derived directly from the ChemSpider API JSON response. + Compound properties ------------------- -- ``csid``: ChemSpider ID. -- ``image_url``: URL of a PNG image of the 2D chemical structure. -- ``molecular_formula``: Molecular formula. -- ``smiles``: SMILES string. -- ``stdinchi``: Standard InChI string. -- ``stdinchikey``: Standard InChIKey. -- ``inchi``: InChI string. -- ``inchikey``: InChIKey. -- ``average_mass``: Average mass. -- ``molecular_weight``: Molecular weight. -- ``monoisotopic_mass``: Monoisotopic mass. -- ``nominal_mass``: Nominal mass. -- ``alogp``: AlogP. -- ``xlogp``: XlogP. -- ``common_name``: Common Name. -- ``mol_2d``: MOL file containing 2D coordinates. -- ``mol_3d``: MOL file containing 3D coordinates. -- ``mol_raw``: Unprocessed MOL file. -- ``image``: 2D depiction as binary data in PNG format. +.. class:: chemspipy.objects.Compound + :noindex: -Implementation details ----------------------- + .. autoattribute:: record_id + :noindex: -Each :class:`~chemspipy.objects.Compound` object is a simple wrapper around a ChemSpider ID. Behind the scenes, the -property methods use the ``get_compound_info``, ``get_extended_compound_info``, ``get_record_mol`` and -``get_compound_thumbnail`` API methods to retrieve the relevant information. It is possible to use these API methods -directly if required:: + .. autoattribute:: image_url + :noindex: + + .. autoattribute:: molecular_formula + :noindex: + + .. autoattribute:: inchi + :noindex: + + .. autoattribute:: inchikey + :noindex: + + .. autoattribute:: average_mass + :noindex: + + .. autoattribute:: molecular_weight + :noindex: + + .. autoattribute:: monoisotopic_mass + :noindex: + + .. autoattribute:: nominal_mass + :noindex: + + .. autoattribute:: common_name + :noindex: + + .. autoattribute:: mol_2d + :noindex: + + .. autoattribute:: mol_3d + :noindex: - >>> info = cs.get_extended_compound_info(2157) - {u'smiles': u'CC(=O)Oc1ccccc1C(=O)O', u'common_name': u'Aspirin', u'nominal_mass': 180.0, u'molecular_formula': u'C_{9}H_{8}O_{4}', u'inchikey': u'BSYNRYMUTXBXSQ-UHFFFAOYAW', u'molecular_weight': 180.1574, u'inchi': u'InChI=1/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)', u'average_mass': 180.1574, u'csid': 2157, u'alogp': 0.0, u'xlogp': 0.0, u'monoisotopic_mass': 180.042252} + .. autoattribute:: image + :noindex: -Results are returned as a python dictionary that is derived directly from the ChemSpider API XML response. + .. autoattribute:: external_references + :noindex: From 8f52ce469b5bb4a800b1b17cb6fcc27edfe2c58c Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 23 Aug 2018 17:48:47 +0100 Subject: [PATCH 14/26] Update searching docs --- docs/guide/searching.rst | 48 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/docs/guide/searching.rst b/docs/guide/searching.rst index 1c8d910..68dd2fb 100644 --- a/docs/guide/searching.rst +++ b/docs/guide/searching.rst @@ -14,7 +14,7 @@ provide any type of query, and ChemSpider will interpret it and provide the most >>> cs.search('O=C(OCC)C') Results([Compound(8525)]) >>> cs.search('glucose') - Results([Compound(5589), Compound(58238), Compound(71358), Compound(96749), Compound(9312824), Compound(9484839)]) + Results([Compound(5589), Compound(58238), Compound(71358), Compound(96749), Compound(2006622), Compound(5341883), Compound(5360239), Compound(9129332), Compound(9281077), Compound(9312824), Compound(9484839), Compound(9655623)]) >>> cs.search('2157') Results([Compound(2157)]) @@ -25,22 +25,28 @@ The :class:`~chemspipy.search.Results` object that is returned can be treated ju example, you can iterate over the results:: >>> for result in cs.search('Glucose'): - ... print(result.csid) + ... print(result.record_id) 5589 58238 71358 96749 + 2006622 + 5341883 + 5360239 + 9129332 + 9281077 9312824 9484839 + 9655623 -The :class:`~chemspipy.search.Results` object also provides the time take to perform the search, and a message that +The :class:`~chemspipy.search.Results` object also provides the time taken to perform the search, and a message that explains how the query type was resolved:: >>> r = cs.search('Glucose') >>> print(r.duration) - u'0:00:00.017' + 0:00:00.513406 >>> print(r.message) - u'Found by approved synonym' + Found by approved synonym Asynchronous searching ---------------------- @@ -56,44 +62,32 @@ actually empty at first:: False In a background thread, ChemSpiPy is making the search request and waiting for the response. But in the meantime, it is -possible to continue performing other tasks in the main Python interpreter process. Call ``ready()`` at any -point to check if the results have been returned and are available. +possible to continue performing other tasks in the main Python interpreter process. Call +:meth:`~chemspipy.search.Results.ready()` at any point to check if the results have been returned and are available. Any attempt to access the results will just block until the results are ready, like a simple synchronous search. To -manually block the main thread until the results are ready, use the ``wait()`` method:: +manually block the main thread until the results are ready, use the :meth:`~chemspipy.search.Results.wait()` method:: >>> results.wait() >>> results.ready() True -For more detailed information about the status of a search, use the ``status`` property:: +For more detailed information about the status of a search, use the :attr:`~chemspipy.search.Results.status` property:: >>> results.status - u'Created' + 'Created' >>> results.wait() >>> results.status - u'ResultReady' + 'Complete' -The possible statuses are ``Unknown``, ``Created``, ``Scheduled``, ``Processing``, ``Suspended``, -``PartialResultReady``, ``ResultReady``. - -Simple search -------------- - -The asynchronous search is designed to be simple as possible, but it's possible that the additional overhead might be -overkill in some cases. The ``simple_search`` method provides a simpler synchronous alternative. Use it in the same way:: - - >>> cs.simple_search('Glucose') - [Compound(5589), Compound(58238), Compound(71358), Compound(96749), Compound(9312824), Compound(9484839)] - -In this case, the main Python thread will be blocked until the search results are returned, and the results actually are -just in a regular Python list. A maximum of 100 results are returned. +The possible statuses are ``Created``, ``Failed``, ``Unknown``, ``Suspended``, ``Complete``. Search by formula ----------------- -Searching by molecular formula is supported by the main ``search`` method, but there is the possibility that a formula -could be interpreted as a name or SMILES or another query type. To specifically search by formula, use:: +Searching by molecular formula is supported by the main :meth:`~chemspipy.api.ChemSpider.search()` method, but there is +the possibility that a formula could be interpreted as a name or SMILES or another query type. To specifically search +by formula, use:: >>> cs.search_by_formula('C44H30N4Zn') [Compound(436642), Compound(3232330), Compound(24746832), Compound(26995124)] From 2ae4d8ab6f96fff64f79768bb0b2e3d9ff8c3a65 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sat, 8 Sep 2018 15:43:09 +0100 Subject: [PATCH 15/26] Add deprecation notes to docstrings --- chemspipy/api.py | 62 ++++++++++++++++++++++++++++++++------------ chemspipy/objects.py | 9 +++++++ 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/chemspipy/api.py b/chemspipy/api.py index ee92a3e..6762a1c 100644 --- a/chemspipy/api.py +++ b/chemspipy/api.py @@ -181,7 +181,7 @@ def post(self, api, namespace, endpoint, json=None): return self.request('POST', api=api, namespace=namespace, endpoint=endpoint, json=json) def get_compound(self, csid): - """Return a Compound object for a given ChemSpider ID. Security token is required. + """Return a Compound object for a given ChemSpider ID. :param string|int csid: ChemSpider ID. :return: The Compound with the specified ChemSpider ID. @@ -190,7 +190,7 @@ def get_compound(self, csid): return Compound(self, csid) def get_compounds(self, csids): - """Return a list of Compound objects, given a list ChemSpider IDs. Security token is required. + """Return a list of Compound objects, given a list ChemSpider IDs. :param list[string|int] csids: List of ChemSpider IDs. :return: List of Compounds with the specified ChemSpider IDs. @@ -199,7 +199,7 @@ def get_compounds(self, csids): return [Compound(self, csid) for csid in csids] def search(self, query, order=None, direction=ASCENDING, raise_errors=False): - """Search ChemSpider for the specified query and return the results. Security token is required. + """Search ChemSpider for the specified query and return the results. The accepted values for ``order`` are: :data:`~chemspipy.api.RECORD_ID`, :data:`~chemspipy.api.MASS_DEFECT`, :data:`~chemspipy.api.MOLECULAR_WEIGHT`, :data:`~chemspipy.api.REFERENCE_COUNT`, @@ -664,12 +664,20 @@ def validate_inchikey(self, inchikey): return False def get_databases(self): - """Get the list of datasources in ChemSpider.""" + """Get the list of datasources in ChemSpider. + + .. deprecated:: 2.0.0 + Use :py:meth:`~chemspipy.api.ChemSpider.get_datasources` instead. + + """ warnings.warn('Use get_datasources instead of get_databases.', DeprecationWarning) return self.get_datasources() def get_extended_compound_info(self, csid): - """Get extended record details for a CSID. Security token is required. + """Get extended record details for a CSID. + + .. deprecated:: 2.0.0 + Use :py:meth:`~chemspipy.api.ChemSpider.get_details` instead. :param string|int csid: ChemSpider ID. """ @@ -677,7 +685,10 @@ def get_extended_compound_info(self, csid): return self.get_details(record_id=csid) def get_extended_compound_info_list(self, csids): - """Get extended record details for a list of CSIDs. Security token is required. + """Get extended record details for a list of CSIDs. + + .. deprecated:: 2.0.0 + Use :py:meth:`~chemspipy.api.ChemSpider.get_details_batch` instead. :param list[string|int] csids: ChemSpider IDs. """ @@ -688,7 +699,10 @@ def get_extended_mol_compound_info_list(self, csids, mol_type=MOL2D, include_ref include_external_references=False): """Get extended record details (including MOL) for a list of CSIDs. - A maximum of 250 CSIDs can be fetched per request. Security token is required. + A maximum of 250 CSIDs can be fetched per request. + + .. deprecated:: 2.0.0 + Use :py:meth:`~chemspipy.api.ChemSpider.get_details_batch` instead. :param list[string|int] csids: ChemSpider IDs. :param string mol_type: :data:`~chemspipy.api.MOL2D`, :data:`~chemspipy.api.MOL3D` or @@ -700,7 +714,10 @@ def get_extended_mol_compound_info_list(self, csids, mol_type=MOL2D, include_ref return self.get_details_batch(record_ids=csids) def get_record_mol(self, csid, calc3d=False): - """Get ChemSpider record in MOL format. Security token is required. + """Get ChemSpider record in MOL format. + + .. deprecated:: 2.0.0 + Use :py:meth:`~chemspipy.api.ChemSpider.get_mol` instead. :param string|int csid: ChemSpider ID. :param bool calc3d: Whether 3D coordinates should be calculated before returning record data. @@ -715,8 +732,6 @@ def async_simple_search(self, query): This method returns a transaction ID which can be used with other methods to get search status and results. - Security token is required. - .. deprecated:: 2.0.0 Use :py:meth:`~chemspipy.api.ChemSpider.filter_name` instead. @@ -732,7 +747,8 @@ def async_simple_search_ordered(self, query, order=CSID, direction=ASCENDING): This method returns a transaction ID which can be used with other methods to get search status and results. - Security token is required. + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.filter_name` instead. :param string query: Search query - a name, SMILES, InChI, InChIKey, CSID, etc. :param string order: (Optional) Field to sort the result by. @@ -746,7 +762,8 @@ def async_simple_search_ordered(self, query, order=CSID, direction=ASCENDING): def get_async_search_status(self, rid): """Check the status of an asynchronous search operation. - Security token is required. + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.filter_status` instead. :param string rid: A transaction ID, returned by an asynchronous search method. :return: Unknown, Created, Scheduled, Processing, Suspended, PartialResultReady, ResultReady, Failed, @@ -759,7 +776,8 @@ def get_async_search_status(self, rid): def get_async_search_status_and_count(self, rid): """Check the status of an asynchronous search operation. If ready, a count and message are also returned. - Security token is required. + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.filter_status` instead. :param string rid: A transaction ID, returned by an asynchronous search method. :rtype: dict @@ -768,7 +786,10 @@ def get_async_search_status_and_count(self, rid): return self.filter_status(query_id=rid) def get_async_search_result(self, rid): - """Get the results from a asynchronous search operation. Security token is required. + """Get the results from a asynchronous search operation. + + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.filter_results` instead. :param string rid: A transaction ID, returned by an asynchronous search method. :return: A list of Compounds. @@ -779,7 +800,10 @@ def get_async_search_result(self, rid): return [Compound(self, record_id) for record_id in results] def get_async_search_result_part(self, rid, start=0, count=-1): - """Get a slice of the results from a asynchronous search operation. Security token is required. + """Get a slice of the results from a asynchronous search operation. + + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.filter_results` instead. :param string rid: A transaction ID, returned by an asynchronous search method. :param int start: The number of results to skip. @@ -794,7 +818,10 @@ def get_async_search_result_part(self, rid, start=0, count=-1): return [Compound(self, record_id) for record_id in results] def get_compound_info(self, csid): - """Get SMILES, StdInChI and StdInChIKey for a given CSID. Security token is required. + """Get SMILES, StdInChI and StdInChIKey for a given CSID. + + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.get_details` instead. :param string|int csid: ChemSpider ID. :rtype: dict @@ -805,6 +832,9 @@ def get_compound_info(self, csid): def get_compound_thumbnail(self, csid): """Get PNG image as binary data. + .. deprecated:: 2.0.0 + Use :meth:`~chemspipy.api.ChemSpider.get_image` instead. + :param string|int csid: ChemSpider ID. :rtype: bytes """ diff --git a/chemspipy/objects.py b/chemspipy/objects.py index 0fe17e7..187e672 100644 --- a/chemspipy/objects.py +++ b/chemspipy/objects.py @@ -55,6 +55,9 @@ def record_id(self): def csid(self): """ChemSpider ID. + .. deprecated:: 2.0.0 + Use :py:attr:`~chemspipy.objects.Compound.record_id` instead. + :rtype: int """ warnings.warn('Use record_id instead of csid.', DeprecationWarning) @@ -95,6 +98,9 @@ def smiles(self): def stdinchi(self): """Return the Standard InChI for this Compound. + .. deprecated:: 2.0.0 + Use :py:attr:`~chemspipy.objects.Compound.inchi` instead. + :rtype: string """ warnings.warn('Use inchi instead of stdinchi.', DeprecationWarning) @@ -104,6 +110,9 @@ def stdinchi(self): def stdinchikey(self): """Return the Standard InChIKey for this Compound. + .. deprecated:: 2.0.0 + Use :py:attr:`~chemspipy.objects.Compound.inchikey` instead. + :rtype: string """ warnings.warn('Use inchikey instead of stdinchikey.', DeprecationWarning) From 495b79b3875f68a101cf121729deff39df85afec Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sat, 8 Sep 2018 15:58:01 +0100 Subject: [PATCH 16/26] Add external references docs --- chemspipy/objects.py | 2 +- docs/guide/compound.rst | 22 ++++++++++++++++++++++ docs/guide/misc.rst | 4 +++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/chemspipy/objects.py b/chemspipy/objects.py index 187e672..9769011 100644 --- a/chemspipy/objects.py +++ b/chemspipy/objects.py @@ -202,6 +202,6 @@ def image(self): def external_references(self): """Return external references for this Compound. - :rtype: list[string] + :rtype: list[dict] """ return self._cs.get_external_references(self.record_id) diff --git a/docs/guide/compound.rst b/docs/guide/compound.rst index 5081b13..77e9e8b 100644 --- a/docs/guide/compound.rst +++ b/docs/guide/compound.rst @@ -34,6 +34,28 @@ properties are requested:: Properties are cached locally after the first time they are retrieved, speeding up subsequent access and reducing the number of unnecessary requests to the ChemSpider servers. +External References +------------------- + +Get a list of all external references for a given compound using the +:attr:`~chemspipy.objects.Compound.external_references` property:: + + >>> refs = compound.external_references + >>> print(len(refs)) + 28181 + >>> print(refs[0]) + {'source': 'ChemBank', 'sourceUrl': 'http://chembank.broadinstitute.org/', 'externalId': 'DivK1c_000555', 'externalUrl': 'http://chembank.broad.harvard.edu/chemistry/viewMolecule.htm?cbid=1171'} + +Each reference is a dict with details for an external source. The list of references can be very large and slow to +retrieve for popular compounds, so it is possible to filter it by datasource. To do this, use the +:meth:`~chemspipy.api.ChemSpider.get_external_references` method directly:: + + >>> refs = cs.get_external_references(2157, datasources=['PubChem']) + >>> print(refs) + [{'source': 'PubChem', 'sourceUrl': 'http://pubchem.ncbi.nlm.nih.gov/', 'externalId': 2244, 'externalUrl': 'http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=2244'}] + +See the :ref:`Data Sources ` documentation for how to get a list of all available data sources. + Searching for Compounds ----------------------- diff --git a/docs/guide/misc.rst b/docs/guide/misc.rst index b946bb6..439b1c2 100644 --- a/docs/guide/misc.rst +++ b/docs/guide/misc.rst @@ -3,7 +3,9 @@ Miscellaneous ============= -Data sources +.. _datasources: + +Data Sources ------------ Get a list of data sources in ChemSpider:: From 4c089873f13993defbc81658aec67f70ce0f6e8e Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sat, 8 Sep 2018 16:02:46 +0100 Subject: [PATCH 17/26] Title case headings --- docs/api.rst | 2 +- docs/guide/advanced.rst | 2 +- docs/guide/compound.rst | 4 ++-- docs/guide/gettingstarted.rst | 8 ++++---- docs/guide/install.rst | 4 ++-- docs/guide/intro.rst | 4 ++-- docs/guide/searching.rst | 8 ++++---- docs/index.rst | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 9760a86..e32ac97 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,6 +1,6 @@ .. _api: -API documentation +API Documentation ================= .. sectionauthor:: Matt Swain diff --git a/docs/guide/advanced.rst b/docs/guide/advanced.rst index 632bb7a..86370d6 100644 --- a/docs/guide/advanced.rst +++ b/docs/guide/advanced.rst @@ -3,7 +3,7 @@ Advanced ======== -Keep your API key secret +Keep Your API Key Secret ------------------------ Be careful not to include your API key when sharing code. A simple way to ensure this doesn't happen by accident is to diff --git a/docs/guide/compound.rst b/docs/guide/compound.rst index 77e9e8b..412c449 100644 --- a/docs/guide/compound.rst +++ b/docs/guide/compound.rst @@ -61,7 +61,7 @@ Searching for Compounds See the :ref:`searching documentation ` for full details. -Implementation details +Implementation Details ---------------------- Each :class:`~chemspipy.objects.Compound` object is a simple wrapper around a ChemSpider ID. Behind the scenes, the @@ -77,7 +77,7 @@ to retrieve the relevant information. It is possible to use these API methods di Results are returned as a python dictionary that is derived directly from the ChemSpider API JSON response. -Compound properties +Compound Properties ------------------- .. class:: chemspipy.objects.Compound diff --git a/docs/guide/gettingstarted.rst b/docs/guide/gettingstarted.rst index 4b5207a..ef445e5 100644 --- a/docs/guide/gettingstarted.rst +++ b/docs/guide/gettingstarted.rst @@ -1,17 +1,17 @@ .. _gettingstarted: -Getting started +Getting Started =============== This page gives a introduction on how to get started with ChemSpiPy. -Before we start +Before We Start --------------- - Make sure you have :ref:`installed ChemSpiPy `. - :ref:`Obtain an API key ` from the ChemSpider web site. -First steps +First Steps ----------- Start by importing ChemSpider:: @@ -45,7 +45,7 @@ properties from this object:: >>> print(c.common_name) Aspirin -Search for a name +Search for a Name ----------------- What if you don't know the ChemSpider ID of the Compound you want? Instead use the ``search`` method:: diff --git a/docs/guide/install.rst b/docs/guide/install.rst index da483d2..a3fc2f9 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -38,7 +38,7 @@ If you don't already have pip installed, you can `install it using get-pip.py`_: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py -Option 3: Download the latest release +Option 3: Download the Latest Release ------------------------------------- Alternatively, `download the latest release`_ manually and install yourself:: @@ -50,7 +50,7 @@ Alternatively, `download the latest release`_ manually and install yourself:: The setup.py command will install ChemSpiPy in your `site-packages` folder so it is automatically available to all your python scripts. -Option 4: Clone the repository +Option 4: Clone the Repository ------------------------------ The latest development version of ChemSpiPy is always `available on GitHub`_. This version is not guaranteed to be diff --git a/docs/guide/intro.rst b/docs/guide/intro.rst index 6accd72..84237fc 100644 --- a/docs/guide/intro.rst +++ b/docs/guide/intro.rst @@ -12,7 +12,7 @@ documentation before getting started with ChemSpiPy to get an idea of what sort .. _apikey: -Obtaining an API key +Obtaining an API Key -------------------- The Royal Society of Chemistry web services are currently available as an Open Developer Preview. During the preview you @@ -20,7 +20,7 @@ can make 1000 calls per month. For an increased allowance, contact `api@rsc.org` All operations require an API key. To obtain one, `Register for a RSC Developers account`_ and then `Add a new key`_. -ChemSpiPy license +ChemSpiPy License ----------------- .. include:: ../../LICENSE diff --git a/docs/guide/searching.rst b/docs/guide/searching.rst index 68dd2fb..dcbbd28 100644 --- a/docs/guide/searching.rst +++ b/docs/guide/searching.rst @@ -5,7 +5,7 @@ Searching ChemSpiPy provides a number of different ways to search ChemSpider. -Compound search +Compound Search --------------- The main ChemSpiPy search method functions in a similar way to the main search box on the ChemSpider website. Just @@ -48,7 +48,7 @@ explains how the query type was resolved:: >>> print(r.message) Found by approved synonym -Asynchronous searching +Asynchronous Searching ---------------------- Certain types of search can sometimes take slightly longer, which can be inconvenient if the search method blocks the @@ -82,7 +82,7 @@ For more detailed information about the status of a search, use the :attr:`~chem The possible statuses are ``Created``, ``Failed``, ``Unknown``, ``Suspended``, ``Complete``. -Search by formula +Search by Formula ----------------- Searching by molecular formula is supported by the main :meth:`~chemspipy.api.ChemSpider.search()` method, but there is @@ -92,7 +92,7 @@ by formula, use:: >>> cs.search_by_formula('C44H30N4Zn') [Compound(436642), Compound(3232330), Compound(24746832), Compound(26995124)] -Search by mass +Search by Mass -------------- It is also possible to search ChemSpider by mass by specifying a certain range:: diff --git a/docs/index.rst b/docs/index.rst index 4bc6651..9e20a91 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -24,7 +24,7 @@ Features - Complete interface to every endpoint of the ChemSpider Web APIs. - Supports Python versions 2.7 and 3.5+. -User guide +User Guide ---------- A step-by-step guide to getting started with ChemSpiPy. @@ -41,7 +41,7 @@ A step-by-step guide to getting started with ChemSpiPy. guide/advanced guide/contributing -API documentation +API Documentation ----------------- Comprehensive API documentation with information on every function, class and method. From 4f2de57490260a7d6baf5afdbf03a03e38004221 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 17:19:29 +0100 Subject: [PATCH 18/26] Add convert docs --- docs/guide/misc.rst | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/guide/misc.rst b/docs/guide/misc.rst index 439b1c2..9df0e80 100644 --- a/docs/guide/misc.rst +++ b/docs/guide/misc.rst @@ -8,7 +8,26 @@ Miscellaneous Data Sources ------------ -Get a list of data sources in ChemSpider:: +Get a list of data sources in ChemSpider using the :meth:`~chemspipy.api.ChemSpider.get_datasources` method: >>> cs.get_datasources() ['Abacipharm', 'Abblis Chemicals', 'Abcam', 'ABI Chemicals', 'Abmole Bioscience', 'ACB Blocks', 'Accela ChemBio', ... ] + +Format Conversion +----------------- + +Convert between different molecular representations using the :meth:`~chemspipy.api.ChemSpider.convert` method:: + + >>> cs.convert('c1ccccc1', 'SMILES', 'InChI') + 'InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H' + +Allowed conversions: + +- From ``InChI`` to ``InChIKey`` +- From ``InChI`` to ``Mol`` +- From ``InChI`` to ``SMILES`` +- From ``InChIKey`` to ``InChI`` +- From ``InChIKey`` to ``Mol`` +- From ``Mol`` to ``InChI`` +- From ``Mol`` to ``InChIKey`` +- From ``SMILES`` to ``InChI`` From b7029bbf45cee96e355eecadeb2cc2bbd019b630 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 18:57:17 +0100 Subject: [PATCH 19/26] Move license to its own docs page --- docs/guide/intro.rst | 5 ----- docs/index.rst | 9 +++++++++ docs/notes/license.rst | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 docs/notes/license.rst diff --git a/docs/guide/intro.rst b/docs/guide/intro.rst index 84237fc..ac33647 100644 --- a/docs/guide/intro.rst +++ b/docs/guide/intro.rst @@ -20,11 +20,6 @@ can make 1000 calls per month. For an increased allowance, contact `api@rsc.org` All operations require an API key. To obtain one, `Register for a RSC Developers account`_ and then `Add a new key`_. -ChemSpiPy License ------------------ - -.. include:: ../../LICENSE - .. _`ChemSpider website`: http://www.chemspider.com .. _`full documentation for the ChemSpider APIs`: https://developer.rsc.org/compounds-v1/apis .. _`api@rsc.org`: api@rsc.org diff --git a/docs/index.rst b/docs/index.rst index 9e20a91..f960161 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -50,3 +50,12 @@ Comprehensive API documentation with information on every function, class and me :maxdepth: 2 api + +Additional Notes +---------------- + +.. toctree:: + :maxdepth: 2 + + notes/license + diff --git a/docs/notes/license.rst b/docs/notes/license.rst new file mode 100644 index 0000000..24b76c5 --- /dev/null +++ b/docs/notes/license.rst @@ -0,0 +1,18 @@ +.. _license: + +License +======= + +Authors +------- + +ChemSpiPy is developed and maintained by Matt Swain and community contributors. + +See a full list of contributors on the `GitHub Contributors page`_. + +ChemSpiPy License +----------------- + +.. include:: ../../LICENSE + +.. _`GitHub Contributors page`: https://github.com/mcs07/ChemSpiPy/graphs/contributors From ffd0158f7c8e676310f0b87d26ebaa4c32f09a1a Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 18:57:49 +0100 Subject: [PATCH 20/26] Include change log in docs using m2r sphinx extension --- docs/conf.py | 7 +++++-- docs/index.rst | 1 + docs/notes/changelog.rst | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 docs/notes/changelog.rst diff --git a/docs/conf.py b/docs/conf.py index 5eebac2..3fa2e87 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,6 +42,7 @@ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode', + 'm2r', ] # Add any paths that contain templates here, relative to this directory. @@ -50,8 +51,8 @@ # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ['.rst', '.md'] +# source_suffix = '.rst' # The master toctree document. master_doc = 'index' @@ -178,3 +179,5 @@ # Concatenate the class and __init__ docstrings together autoclass_content = 'both' + +m2r_anonymous_references = True diff --git a/docs/index.rst b/docs/index.rst index f960161..d7bcbf0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -57,5 +57,6 @@ Additional Notes .. toctree:: :maxdepth: 2 + notes/changelog notes/license diff --git a/docs/notes/changelog.rst b/docs/notes/changelog.rst new file mode 100644 index 0000000..fd82037 --- /dev/null +++ b/docs/notes/changelog.rst @@ -0,0 +1,3 @@ +.. _changelog: + +.. mdinclude:: ../../CHANGELOG.md From 2f7b1aa70d9ccad879038326833920ad586bda87 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 18:58:45 +0100 Subject: [PATCH 21/26] Add migration guide to docs --- docs/index.rst | 1 + docs/notes/migrating.rst | 68 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 docs/notes/migrating.rst diff --git a/docs/index.rst b/docs/index.rst index d7bcbf0..a9bc5eb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -58,5 +58,6 @@ Additional Notes :maxdepth: 2 notes/changelog + notes/migrating notes/license diff --git a/docs/notes/migrating.rst b/docs/notes/migrating.rst new file mode 100644 index 0000000..1360bf8 --- /dev/null +++ b/docs/notes/migrating.rst @@ -0,0 +1,68 @@ +.. _migrating: + +Migration Guide +=============== + +Upgrading to version 2.x +------------------------ + +The RSC released an entirely new REST API in 2018, necessitating a number of changes to ChemSpiPy. Where possible, +backwards compatibility has been maintained, but many methods are deprecated and some have been removed entirely. + +ChemSpider Object +~~~~~~~~~~~~~~~~~ + +- Instantiate the :class:`~chemspipy.api.ChemSpider` with a required ``api_key`` parameter instead of the optional + ``security_token`` parameter. + +- Deprecated methods: + + - ``get_databases`` → :meth:`~chemspipy.api.ChemSpider.get_datasources` + - ``get_extended_compound_info`` → :meth:`~chemspipy.api.ChemSpider.get_details` + - ``get_extended_compound_info_list`` → :meth:`~chemspipy.api.ChemSpider.get_details_batch` + - ``get_extended_mol_compound_info_list`` → :meth:`~chemspipy.api.ChemSpider.get_details_batch` + - ``get_record_mol`` → :meth:`~chemspipy.api.ChemSpider.get_mol` + - ``async_simple_search`` → :meth:`~chemspipy.api.ChemSpider.filter_name` + - ``async_simple_search_ordered`` → :meth:`~chemspipy.api.ChemSpider.filter_name` + - ``get_async_search_status`` → :meth:`~chemspipy.api.ChemSpider.filter_status` + - ``get_async_search_status_and_count`` → :meth:`~chemspipy.api.ChemSpider.filter_status` + - ``get_async_search_result`` → :meth:`~chemspipy.api.ChemSpider.filter_results` + - ``get_async_search_result_part`` → :meth:`~chemspipy.api.ChemSpider.filter_results` + - ``get_compound_info`` → :meth:`~chemspipy.api.ChemSpider.get_details` + - ``get_compound_thumbnail`` → :meth:`~chemspipy.api.ChemSpider.get_image` + - ``simple_search`` → :meth:`~chemspipy.api.ChemSpider.search` + +- Removed methods: + + - ``get_original_mol`` + - ``get_all_spectra_info`` + - ``get_spectrum_info`` + - ``get_compound_spectra_info`` + - ``get_spectra_info_list`` + +Compound Object +~~~~~~~~~~~~~~~ + +- Non-standard InChI and InChIKey are no longer available. All are now 'standard'. Deprecated properties: + + - ``stdinchi`` → :attr:`~chemspipy.objects.Compound.inchi` + - ``stdinchikey`` → :attr:`~chemspipy.objects.Compound.inchikey` + +- Removed properties: + + - ``xlogp`` + - ``alogp`` + - ``mol_3d`` + - ``mol_raw`` + +Spectrum Object +~~~~~~~~~~~~~~~ + +- ``Spectrum`` object has been removed entirely. + +:mod:`~chemspipy.api` Module +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- Removed ``DIMENSIONS`` mapping. +- Replaced :attr:`~chemspipy.api.FIELDS` mapping with a list of available properties fields. +- Removed ``xml_to_dict`` function. From 589505415dfc110b426e6c132a73daaf2e50377c Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 18:59:29 +0100 Subject: [PATCH 22/26] Update change log --- CHANGELOG.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc3ef1..5ec2110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,32 +1,43 @@ # Change Log -## [v1.0.5](https://github.com/mcs07/ChemSpiPy/releases/tag/v1.0.5) (2017-03-29) -[Full Changelog](https://github.com/mcs07/ChemSpiPy/compare/v1.0.4...v1.0.5) +## [v2.0.0](https://github.com/mcs07/ChemSpiPy/tree/v2.0.0) (2018-09-09) +[Full Changelog](https://github.com/mcs07/ChemSpiPy/compare/v1.0.5...v2.0.0) + +**Implemented enhancements:** + +- Switch to new RSC REST API [\#12](https://github.com/mcs07/ChemSpiPy/pull/12) ([mcs07](https://github.com/mcs07)) **Closed issues:** -- Add support for https [\#5](https://github.com/mcs07/ChemSpiPy/issues/5) +- Make conda-forge recipe [\#13](https://github.com/mcs07/ChemSpiPy/issues/13) +- return \# of data sources in search results [\#10](https://github.com/mcs07/ChemSpiPy/issues/10) -**Merged pull requests:** +## [v1.0.5](https://github.com/mcs07/ChemSpiPy/tree/v1.0.5) (2017-03-29) +[Full Changelog](https://github.com/mcs07/ChemSpiPy/compare/v1.0.4...v1.0.5) + +**Implemented enhancements:** - Switch to pytest [\#7](https://github.com/mcs07/ChemSpiPy/pull/7) ([mcs07](https://github.com/mcs07)) + +**Fixed bugs:** + +- Add support for https [\#5](https://github.com/mcs07/ChemSpiPy/issues/5) - Use https by default - fixes \#5 [\#6](https://github.com/mcs07/ChemSpiPy/pull/6) ([mcs07](https://github.com/mcs07)) + +**Merged pull requests:** + - Improve handling of invalid tokens [\#4](https://github.com/mcs07/ChemSpiPy/pull/4) ([mcs07](https://github.com/mcs07)) -## [v1.0.4](https://github.com/mcs07/ChemSpiPy/releases/tag/v1.0.4) (2015-06-13) +## [v1.0.4](https://github.com/mcs07/ChemSpiPy/tree/v1.0.4) (2015-06-13) [Full Changelog](https://github.com/mcs07/ChemSpiPy/compare/v1.0.3...v1.0.4) -## [v1.0.3](https://github.com/mcs07/ChemSpiPy/releases/tag/v1.0.3) (2015-03-05) +## [v1.0.3](https://github.com/mcs07/ChemSpiPy/tree/v1.0.3) (2015-03-05) [Full Changelog](https://github.com/mcs07/ChemSpiPy/compare/v1.0.2...v1.0.3) -## [v1.0.2](https://github.com/mcs07/ChemSpiPy/releases/tag/v1.0.2) (2015-03-04) +## [v1.0.2](https://github.com/mcs07/ChemSpiPy/tree/v1.0.2) (2015-03-04) [Full Changelog](https://github.com/mcs07/ChemSpiPy/compare/v1.0.1...v1.0.2) -## [v1.0.1](https://github.com/mcs07/ChemSpiPy/releases/tag/v1.0.1) (2014-09-15) -**Merged pull requests:** +## [v1.0.1](https://github.com/mcs07/ChemSpiPy/tree/v1.0.1) (2014-09-15) +**Implemented enhancements:** - Fix for UTF-8 encoding error \(and some other tweaks\)... [\#2](https://github.com/mcs07/ChemSpiPy/pull/2) ([nickfyson](https://github.com/nickfyson)) - - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file From 28a0e9a74cb4c6c593827937905c57728341f6d5 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 19:01:41 +0100 Subject: [PATCH 23/26] Move contributing docs to additional notes section --- docs/index.rst | 6 +++--- docs/{guide => notes}/contributing.rst | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename docs/{guide => notes}/contributing.rst (100%) diff --git a/docs/index.rst b/docs/index.rst index a9bc5eb..c64465c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -39,7 +39,6 @@ A step-by-step guide to getting started with ChemSpiPy. guide/searching guide/misc guide/advanced - guide/contributing API Documentation ----------------- @@ -57,7 +56,8 @@ Additional Notes .. toctree:: :maxdepth: 2 - notes/changelog - notes/migrating notes/license + notes/contributing + notes/migrating + notes/changelog diff --git a/docs/guide/contributing.rst b/docs/notes/contributing.rst similarity index 100% rename from docs/guide/contributing.rst rename to docs/notes/contributing.rst From 73270504c29c55dd694aec5f0d9ed82f6130de6d Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 19:03:27 +0100 Subject: [PATCH 24/26] Add useful links to main docs index --- docs/index.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index c64465c..fb18615 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -61,3 +61,17 @@ Additional Notes notes/migrating notes/changelog +Useful links +------------ + +- `ChemSpiPy on GitHub`_ +- `ChemSpiPy on PyPI`_ +- `Issue tracker`_ +- `Release history`_ +- `ChemSpiPy Travis CI`_ + +.. _`ChemSpiPy on GitHub`: https://github.com/mcs07/ChemSpiPy +.. _`ChemSpiPy on PyPI`: https://pypi.python.org/pypi/ChemSpiPy +.. _`Issue tracker`: https://github.com/mcs07/ChemSpiPy/issues +.. _`Release history`: https://github.com/mcs07/ChemSpiPy/releases +.. _`ChemSpiPy Travis CI`: https://travis-ci.org/mcs07/ChemSpiPy From 501c02bfeeeab39f6ff346ff08619623c5dfd084 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 19:08:37 +0100 Subject: [PATCH 25/26] Link to GitHub source with sphinx linkcode instead of viewcode --- docs/conf.py | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 3fa2e87..069ea6a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,6 +12,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import inspect import os import sys sys.path.insert(0, os.path.abspath('..')) @@ -41,7 +42,7 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', + 'sphinx.ext.linkcode', 'm2r', ] @@ -181,3 +182,45 @@ autoclass_content = 'both' m2r_anonymous_references = True + + +# Function courtesy of NumPy to return URLs containing line numbers +def linkcode_resolve(domain, info): + """Determine the URL corresponding to Python object.""" + if domain != 'py': + return None + + modname = info['module'] + fullname = info['fullname'] + + submod = sys.modules.get(modname) + if submod is None: + return None + + obj = submod + for part in fullname.split('.'): + try: + obj = getattr(obj, part) + except: + return None + + try: + fn = inspect.getsourcefile(obj) + except: + fn = None + if not fn: + return None + + try: + source, lineno = inspect.findsource(obj) + except: + lineno = None + + if lineno: + linespec = '#L{}'.format(lineno + 1) + else: + linespec = "" + + fn = os.path.relpath(fn, start=os.path.abspath('..')) + + return 'http://github.com/mcs07/ChemSpiPy/blob/master/{}{}'.format(fn, linespec) From 8c2af46c81eb82196afa7eb8ee80deaf8e8ef478 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Sun, 9 Sep 2018 19:11:26 +0100 Subject: [PATCH 26/26] Add m2r to environment.yml --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index daccb12..16d40d3 100644 --- a/environment.yml +++ b/environment.yml @@ -6,6 +6,7 @@ dependencies: - bumpversion=0.5.3 - coverage=4.5.1 - coveralls=1.3.0 + - m2r=0.2.0 - requests=2.19.1 - pytest=3.6.2 - six=1.11.0