diff --git a/docs/.buildinfo b/docs/.buildinfo index 6fef2c1..951a945 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 0ffcf54393a856012dadc0b1563f2c43 +config: bf1d0a21c26d9c55c442915740521680 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_modules/bed_reader/_open_bed.html b/docs/_modules/bed_reader/_open_bed.html index 5876fa5..38ccbe2 100644 --- a/docs/_modules/bed_reader/_open_bed.html +++ b/docs/_modules/bed_reader/_open_bed.html @@ -3,16 +3,16 @@ - bed_reader._open_bed — Bed Reader 1.0.1-beta.2 documentation + bed_reader._open_bed — Bed Reader 1.0.1-beta.5 documentation - - - + + + @@ -30,7 +30,7 @@ Bed Reader
- 1.0.1-beta.2 + 1.0.1-beta.5
@@ -183,7 +183,9 @@

Source code for bed_reader._open_bed

     return 8_000_000
 
 
-
[docs]class open_bed: +
+[docs] +class open_bed: """ Open a PLINK .bed file, local or cloud, for reading. @@ -433,7 +435,9 @@

Source code for bed_reader._open_bed

         else:
             return Path(input)
 
-
[docs] def read( +
+[docs] + def read( self, index: Optional[Any] = None, dtype: Optional[Union[type, str]] = "float32", @@ -599,7 +603,6 @@

Source code for bed_reader._open_bed

                 reader, location_str, is_cloud = self._pick_reader(dtype)
 
                 if not is_cloud:
-                    # cmk test this
                     reader(
                         location_str,
                         self.cloud_options,
@@ -612,7 +615,6 @@ 

Source code for bed_reader._open_bed

                         num_threads=num_threads,
                     )
                 else:
-                    # cmk test this
                     reader(
                         location_str,
                         self.cloud_options,
@@ -685,6 +687,7 @@ 

Source code for bed_reader._open_bed

 
         return val
+ def _pick_reader(self, dtype): if dtype == np.int8: file_reader = read_i8 @@ -932,7 +935,9 @@

Source code for bed_reader._open_bed

             self.property_item(key)
         return self.properties_dict
 
-
[docs] def property_item(self, name: str) -> np.ndarray: +
+[docs] + def property_item(self, name: str) -> np.ndarray: """ Retrieve one property by name. @@ -969,6 +974,7 @@

Source code for bed_reader._open_bed

             self._read_fam_or_bim(suffix=mm.suffix)
         return self.properties_dict[name]
+ @property def chromosome(self) -> np.ndarray: """ @@ -1461,7 +1467,9 @@

Source code for bed_reader._open_bed

                     output = np.array(output, dtype=mm.dtype)
             self.properties_dict[key] = output
 
-
[docs] def read_sparse( +
+[docs] + def read_sparse( self, index: Optional[Any] = None, dtype: Optional[Union[type, str]] = "float32", @@ -1702,7 +1710,6 @@

Source code for bed_reader._open_bed

                     batch_index = sid_index[batch_slice]
 
                     if not is_cloud:
-                        # cmk test this
                         reader(
                             location_str,
                             self.cloud_options,
@@ -1715,7 +1722,6 @@ 

Source code for bed_reader._open_bed

                             num_threads=num_threads,
                         )
                     else:
-                        # cmk test this
                         reader(
                             location_str,
                             self.cloud_options,
@@ -1751,7 +1757,6 @@ 

Source code for bed_reader._open_bed

                     batch_index = iid_index[batch_slice]
 
                     if not is_cloud:
-                        # cmk test this
                         reader(
                             location_str,
                             self.cloud_options,
@@ -1764,7 +1769,6 @@ 

Source code for bed_reader._open_bed

                             num_threads=num_threads,
                         )
                     else:
-                        # cmk test this
                         reader(
                             location_str,
                             self.cloud_options,
@@ -1796,6 +1800,7 @@ 

Source code for bed_reader._open_bed

                 (data, indices, indptr), (len(iid_index), len(sid_index))
             )
+ def sparsify(self, val, order, minor_index, batch_slice, data, indices, indptr): flatten = np.ravel(val, order=order) nz_indices = np.flatnonzero(flatten).astype(np.int32) @@ -1812,6 +1817,7 @@

Source code for bed_reader._open_bed

         indptr[1:][batch_slice] = np.cumsum(counts_with_initial)[1:]
+ def _read_csv(filepath, delimiter=None, dtype=None, usecols=None): # Prepare the usecols by ensuring it is a list of indices usecols_indices = list(usecols) diff --git a/docs/_modules/index.html b/docs/_modules/index.html index 38df1f6..6fef918 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -3,16 +3,16 @@ - Overview: module code — Bed Reader 1.0.1-beta.2 documentation + Overview: module code — Bed Reader 1.0.1-beta.5 documentation - - - + + + @@ -30,7 +30,7 @@ Bed Reader
- 1.0.1-beta.2 + 1.0.1-beta.5
diff --git a/docs/_sources/index.rst.txt b/docs/_sources/index.rst.txt index 476cf5e..fe2120b 100644 --- a/docs/_sources/index.rst.txt +++ b/docs/_sources/index.rst.txt @@ -11,6 +11,7 @@ ################################ .. currentmodule:: bed_reader + Read and write the PLINK BED format, simply and efficiently. Features: diff --git a/docs/_static/basic.css b/docs/_static/basic.css index 7577acb..30fee9d 100644 --- a/docs/_static/basic.css +++ b/docs/_static/basic.css @@ -237,6 +237,10 @@ a.headerlink { visibility: hidden; } +a:visited { + color: #551A8B; +} + h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, @@ -670,6 +674,16 @@ dd { margin-left: 30px; } +.sig dd { + margin-top: 0px; + margin-bottom: 0px; +} + +.sig dl { + margin-top: 0px; + margin-bottom: 0px; +} + dl > dd:last-child, dl > dd:last-child > :last-child { margin-bottom: 0; @@ -738,6 +752,14 @@ abbr, acronym { cursor: help; } +.translated { + background-color: rgba(207, 255, 207, 0.2) +} + +.untranslated { + background-color: rgba(255, 207, 207, 0.2) +} + /* -- code displays --------------------------------------------------------- */ pre { diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 28c7d6b..fa1bd15 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,6 +1,5 @@ -var DOCUMENTATION_OPTIONS = { - URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '1.0.1-beta.2', +const DOCUMENTATION_OPTIONS = { + VERSION: '1.0.1-beta.5', LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/_static/searchtools.js b/docs/_static/searchtools.js index 97d56a7..7918c3f 100644 --- a/docs/_static/searchtools.js +++ b/docs/_static/searchtools.js @@ -57,12 +57,12 @@ const _removeChildren = (element) => { const _escapeRegExp = (string) => string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string -const _displayItem = (item, searchTerms) => { +const _displayItem = (item, searchTerms, highlightTerms) => { const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; - const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT; const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; + const contentRoot = document.documentElement.dataset.content_root; const [docName, title, anchor, descr, score, _filename] = item; @@ -75,20 +75,24 @@ const _displayItem = (item, searchTerms) => { if (dirname.match(/\/index\/$/)) dirname = dirname.substring(0, dirname.length - 6); else if (dirname === "index/") dirname = ""; - requestUrl = docUrlRoot + dirname; + requestUrl = contentRoot + dirname; linkUrl = requestUrl; } else { // normal html builders - requestUrl = docUrlRoot + docName + docFileSuffix; + requestUrl = contentRoot + docName + docFileSuffix; linkUrl = docName + docLinkSuffix; } let linkEl = listItem.appendChild(document.createElement("a")); linkEl.href = linkUrl + anchor; linkEl.dataset.score = score; linkEl.innerHTML = title; - if (descr) + if (descr) { listItem.appendChild(document.createElement("span")).innerHTML = " (" + descr + ")"; + // highlight search terms in the description + if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js + highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); + } else if (showSearchSummary) fetch(requestUrl) .then((responseData) => responseData.text()) @@ -97,6 +101,9 @@ const _displayItem = (item, searchTerms) => { listItem.appendChild( Search.makeSearchSummary(data, searchTerms) ); + // highlight search terms in the summary + if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js + highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); }); Search.output.appendChild(listItem); }; @@ -115,14 +122,15 @@ const _finishSearch = (resultCount) => { const _displayNextItem = ( results, resultCount, - searchTerms + searchTerms, + highlightTerms, ) => { // results left, load the summary and display it // this is intended to be dynamic (don't sub resultsCount) if (results.length) { - _displayItem(results.pop(), searchTerms); + _displayItem(results.pop(), searchTerms, highlightTerms); setTimeout( - () => _displayNextItem(results, resultCount, searchTerms), + () => _displayNextItem(results, resultCount, searchTerms, highlightTerms), 5 ); } @@ -360,7 +368,7 @@ const Search = { // console.info("search results:", Search.lastresults); // print the results - _displayNextItem(results, results.length, searchTerms); + _displayNextItem(results, results.length, searchTerms, highlightTerms); }, /** diff --git a/docs/_static/sphinx_highlight.js b/docs/_static/sphinx_highlight.js index aae669d..8a96c69 100644 --- a/docs/_static/sphinx_highlight.js +++ b/docs/_static/sphinx_highlight.js @@ -29,14 +29,19 @@ const _highlight = (node, addItems, text, className) => { } span.appendChild(document.createTextNode(val.substr(pos, text.length))); + const rest = document.createTextNode(val.substr(pos + text.length)); parent.insertBefore( span, parent.insertBefore( - document.createTextNode(val.substr(pos + text.length)), + rest, node.nextSibling ) ); node.nodeValue = val.substr(0, pos); + /* There may be more occurrences of search term in this node. So call this + * function recursively on the remaining fragment. + */ + _highlight(rest, addItems, text, className); if (isInSVG) { const rect = document.createElementNS( @@ -140,5 +145,10 @@ const SphinxHighlight = { }, }; -_ready(SphinxHighlight.highlightSearchWords); -_ready(SphinxHighlight.initEscapeListener); +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); diff --git a/docs/cloud_urls.html b/docs/cloud_urls.html index 0523cc2..b8f3bc3 100644 --- a/docs/cloud_urls.html +++ b/docs/cloud_urls.html @@ -4,16 +4,16 @@ - Cloud URL Examples — Bed Reader 1.0.1-beta.2 documentation + Cloud URL Examples — Bed Reader 1.0.1-beta.5 documentation - - - + + + @@ -32,7 +32,7 @@ Bed Reader
- 1.0.1-beta.2 + 1.0.1-beta.5
@@ -79,7 +79,7 @@
-

Cloud URL Examples

+

Cloud URL Examples

Table of Contents:

  • Http

  • @@ -93,7 +93,7 @@

    Cloud URL Examples -

    Http

    +

    Http

    You can read *.bed files from web sites directly. For small files, access will be fast. For medium-sized files, you may need to extend the default timeout.

    Reading from large files can also be practical and even fast under these conditions:

    @@ -199,11 +199,11 @@

    Cloud URL Examples -

    Local File

    +

    Local File

    We can specify a local file as if it is in the cloud. This is a great way to test cloud functions. For real work and better efficiency, however, use the file’s path rather than its URL.

    -

    Local File URL

    +

    Local File URL

    The URL for a local file takes the form file:///{encoded_file_name}. No cloud options are needed.

    Example:

    >>> import numpy as np
    @@ -227,7 +227,7 @@ 

    Local File URL -

    AWS S3

    +

    AWS S3

    Let’s look next at reading a file (or part of a file) from AWS S3.

    The URL for an AWS S3 file takes the form s3://{bucket_name}/{s3_path}.

    AWS forbids putting some needed information in the URL. Instead, that information must go into a string-to-string diff --git a/docs/genindex.html b/docs/genindex.html index 59e7536..d89bf0e 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -3,16 +3,16 @@ - Index — Bed Reader 1.0.1-beta.2 documentation + Index — Bed Reader 1.0.1-beta.5 documentation - - - + + + @@ -30,7 +30,7 @@ Bed Reader

    - 1.0.1-beta.2 + 1.0.1-beta.5
    diff --git a/docs/index.html b/docs/index.html index 6b37149..573e350 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,16 +4,16 @@ - bed_reader Documentation — Bed Reader 1.0.1-beta.2 documentation + bed_reader Documentation — Bed Reader 1.0.1-beta.5 documentation - - - + + + @@ -32,7 +32,7 @@ Bed Reader
    - 1.0.1-beta.2 + 1.0.1-beta.5
    @@ -82,7 +82,7 @@ https://github.com/fastlmm/bed-reader/actions/workflows/ci.yml/badge.svg?branch=master https://img.shields.io/pypi/pyversions/bed-reader
    -

    bed_reader Documentation

    +

    bed_reader Documentation

    Read and write the PLINK BED format, simply and efficiently.

    Features:

      @@ -93,7 +93,7 @@

    • Read data locally or from the cloud, efficiently and directly.

    -

    Install

    +

    Install

    Full version: With all optional dependencies:

    pip install bed-reader[samples,sparse]
     
    @@ -104,7 +104,7 @@

    Install -

    Usage

    +

    Usage

    Read genotype data from a .bed file.

    >>> import numpy as np
     >>> from bed_reader import open_bed, sample_file
    @@ -156,7 +156,7 @@ 

    Usage