-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 63b6523
Showing
177 changed files
with
52,833 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<!DOCTYPE html> | ||
<html class="writer-html5" lang="en" > | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>gnomad.resources.config — gnomad master documentation</title> | ||
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> | ||
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> | ||
<link rel="stylesheet" href="../../../_static/theme_overrides.css" type="text/css" /> | ||
<!--[if lt IE 9]> | ||
<script src="../../../_static/js/html5shiv.min.js"></script> | ||
<![endif]--> | ||
|
||
<script src="../../../_static/jquery.js"></script> | ||
<script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script> | ||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script> | ||
<script src="../../../_static/doctools.js"></script> | ||
<script src="../../../_static/sphinx_highlight.js"></script> | ||
<script src="../../../_static/js/theme.js"></script> | ||
<link rel="index" title="Index" href="../../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../../search.html" /> | ||
</head> | ||
|
||
<body class="wy-body-for-nav"> | ||
<div class="wy-grid-for-nav"> | ||
<nav data-toggle="wy-nav-shift" class="wy-nav-side"> | ||
<div class="wy-side-scroll"> | ||
<div class="wy-side-nav-search" > | ||
|
||
|
||
|
||
<a href="../../../index.html" class="icon icon-home"> | ||
gnomad | ||
</a> | ||
<div role="search"> | ||
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get"> | ||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> | ||
<input type="hidden" name="check_keywords" value="yes" /> | ||
<input type="hidden" name="area" value="default" /> | ||
</form> | ||
</div> | ||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../getting_started.html">Getting Started</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Examples</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../api_reference/index.html">API Reference</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../resource_sources.html">Resource Sources</a></li> | ||
<li class="toctree-l1"><a class="reference external" href="https://github.com/broadinstitute/gnomad_methods/releases">Change Log</a></li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
</nav> | ||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > | ||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i> | ||
<a href="../../../index.html">gnomad</a> | ||
</nav> | ||
|
||
<div class="wy-nav-content"> | ||
<div class="rst-content"> | ||
<div role="navigation" aria-label="Page navigation"> | ||
<ul class="wy-breadcrumbs"> | ||
<li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li> | ||
<li class="breadcrumb-item"><a href="../../index.html">Module code</a></li> | ||
<li class="breadcrumb-item active">gnomad.resources.config</li> | ||
<li class="wy-breadcrumbs-aside"> | ||
</li> | ||
</ul> | ||
<hr/> | ||
</div> | ||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> | ||
<div itemprop="articleBody"> | ||
|
||
<h1>Source code for gnomad.resources.config</h1><div class="highlight"><pre> | ||
<span></span><span class="sd">"""Configuration for loading resources."""</span> | ||
|
||
<span class="kn">import</span> <span class="nn">logging</span> | ||
<span class="kn">import</span> <span class="nn">os</span> | ||
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span> | ||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span> | ||
|
||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span> | ||
|
||
|
||
<div class="viewcode-block" id="GnomadPublicResourceSource"><a class="viewcode-back" href="../../../api_reference/resources/config.html#gnomad.resources.config.GnomadPublicResourceSource">[docs]</a><span class="k">class</span> <span class="nc">GnomadPublicResourceSource</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""Sources for public gnomAD resources."""</span> | ||
|
||
<span class="n">GNOMAD</span> <span class="o">=</span> <span class="s2">"gnomAD"</span> | ||
<span class="n">GOOGLE_CLOUD_PUBLIC_DATASETS</span> <span class="o">=</span> <span class="s2">"Google Cloud Public Datasets"</span> | ||
<span class="n">REGISTRY_OF_OPEN_DATA_ON_AWS</span> <span class="o">=</span> <span class="s2">"Registry of Open Data on AWS"</span> | ||
<span class="n">AZURE_OPEN_DATASETS</span> <span class="o">=</span> <span class="s2">"Azure Open Datasets"</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="get_default_public_resource_source"><a class="viewcode-back" href="../../../api_reference/resources/config.html#gnomad.resources.config.get_default_public_resource_source">[docs]</a><span class="k">def</span> <span class="nf">get_default_public_resource_source</span><span class="p">()</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="n">GnomadPublicResourceSource</span><span class="p">,</span> <span class="nb">str</span><span class="p">]:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Get the default source for public gnomAD resources.</span> | ||
|
||
<span class="sd"> The default source is determined by...</span> | ||
|
||
<span class="sd"> - If the ``GNOMAD_DEFAULT_PUBLIC_RESOURCE_SOURCE`` environment variable is set, use the source configured there.</span> | ||
<span class="sd"> - Otherwise, if Hail determines that is is running in a cloud provider's Spark environment, use the source from that cloud provider.</span> | ||
<span class="sd"> For example, use Azure Open Datasets if running on an Azure HDInsight cluster.</span> | ||
<span class="sd"> - Otherwise, use Google Cloud Public Datasets.</span> | ||
|
||
<span class="sd"> :returns: Default resource source</span> | ||
<span class="sd"> """</span> | ||
<span class="n">default_source_from_env</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">"GNOMAD_DEFAULT_PUBLIC_RESOURCE_SOURCE"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">default_source_from_env</span><span class="p">:</span> | ||
<span class="c1"># Convert to a GnomadPublicResourceSource enum if possible</span> | ||
<span class="k">try</span><span class="p">:</span> | ||
<span class="n">default_source</span> <span class="o">=</span> <span class="n">GnomadPublicResourceSource</span><span class="p">(</span><span class="n">default_source_from_env</span><span class="p">)</span> | ||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span> | ||
<span class="s2">"Using configured source for gnomAD resources: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">default_source</span><span class="o">.</span><span class="n">value</span> | ||
<span class="p">)</span> | ||
<span class="k">return</span> <span class="n">default_source</span> | ||
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> | ||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span> | ||
<span class="s2">"Using configured custom source for gnomAD resources: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> | ||
<span class="n">default_source_from_env</span><span class="p">,</span> | ||
<span class="p">)</span> | ||
<span class="k">return</span> <span class="n">default_source_from_env</span> | ||
|
||
<span class="k">try</span><span class="p">:</span> | ||
<span class="kn">from</span> <span class="nn">hail.utils</span> <span class="kn">import</span> <span class="n">guess_cloud_spark_provider</span> | ||
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span> | ||
<span class="k">pass</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="n">cloud_spark_provider</span> <span class="o">=</span> <span class="n">guess_cloud_spark_provider</span><span class="p">()</span> | ||
<span class="n">default_resource_sources_by_provider</span> <span class="o">=</span> <span class="p">{</span> | ||
<span class="s2">"dataproc"</span><span class="p">:</span> <span class="n">GnomadPublicResourceSource</span><span class="o">.</span><span class="n">GOOGLE_CLOUD_PUBLIC_DATASETS</span><span class="p">,</span> | ||
<span class="s2">"hdinsight"</span><span class="p">:</span> <span class="n">GnomadPublicResourceSource</span><span class="o">.</span><span class="n">AZURE_OPEN_DATASETS</span><span class="p">,</span> | ||
<span class="p">}</span> | ||
<span class="k">if</span> <span class="n">cloud_spark_provider</span><span class="p">:</span> | ||
<span class="k">try</span><span class="p">:</span> | ||
<span class="n">default_source_from_provider</span> <span class="o">=</span> <span class="n">default_resource_sources_by_provider</span><span class="p">[</span> | ||
<span class="n">cloud_spark_provider</span> | ||
<span class="p">]</span> | ||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span> | ||
<span class="s2">"Using default source for gnomAD resources based on cloud"</span> | ||
<span class="s2">" provider: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> | ||
<span class="n">default_source_from_provider</span><span class="p">,</span> | ||
<span class="p">)</span> | ||
<span class="k">return</span> <span class="n">default_source_from_provider</span> | ||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> | ||
<span class="k">pass</span> | ||
|
||
<span class="k">return</span> <span class="n">GnomadPublicResourceSource</span><span class="o">.</span><span class="n">GOOGLE_CLOUD_PUBLIC_DATASETS</span></div> | ||
|
||
|
||
<span class="k">class</span> <span class="nc">_GnomadPublicResourceConfiguration</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""Configuration for public gnomAD resources."""</span> | ||
|
||
<span class="n">_source</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">GnomadPublicResourceSource</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> | ||
|
||
<span class="nd">@property</span> | ||
<span class="k">def</span> <span class="nf">source</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="n">GnomadPublicResourceSource</span><span class="p">,</span> <span class="nb">str</span><span class="p">]:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Get the source for public gnomAD resource files.</span> | ||
|
||
<span class="sd"> This is used to determine which URLs gnomAD resources will be loaded from.</span> | ||
|
||
<span class="sd"> :returns: Source name or path to root of resources directory</span> | ||
<span class="sd"> """</span> | ||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">_source</span> <span class="o">=</span> <span class="n">get_default_public_resource_source</span><span class="p">()</span> | ||
|
||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source</span> | ||
|
||
<span class="nd">@source</span><span class="o">.</span><span class="n">setter</span> | ||
<span class="k">def</span> <span class="nf">source</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">GnomadPublicResourceSource</span><span class="p">,</span> <span class="nb">str</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Set the default source for resource files.</span> | ||
|
||
<span class="sd"> This is used to determine which URLs gnomAD resources will be loaded from.</span> | ||
|
||
<span class="sd"> :param source: Source name or path to root of resources directory</span> | ||
<span class="sd"> """</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">_source</span> <span class="o">=</span> <span class="n">source</span> | ||
|
||
|
||
<span class="n">gnomad_public_resource_configuration</span> <span class="o">=</span> <span class="n">_GnomadPublicResourceConfiguration</span><span class="p">()</span> | ||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
<footer> | ||
|
||
<hr/> | ||
|
||
<div role="contentinfo"> | ||
<p></p> | ||
</div> | ||
|
||
|
||
|
||
</footer> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
<script> | ||
jQuery(function () { | ||
SphinxRtdTheme.Navigation.enable(true); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.