Skip to content
Snippets Groups Projects
Commit fd9c1331 authored by Bienchen's avatar Bienchen
Browse files

Updated documentation

parent 40dcc42e
Branches
No related tags found
No related merge requests found
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<ul><li><a href="promod3.html">promod3</a></li> <ul><li><a href="promod3.html">promod3</a></li>
<ul><li><a href="promod3/core/argcheck.html">promod3.core.argcheck</a></li> <ul><li><a href="promod3/core/argcheck.html">promod3.core.argcheck</a></li>
<li><a href="promod3/core/helper.html">promod3.core.helper</a></li> <li><a href="promod3/core/helper.html">promod3.core.helper</a></li>
<li><a href="promod3/core/pm3argparse.html">promod3.core.pm3argparse</a></li>
<li><a href="promod3/rawmodel/_rawmodel.html">promod3.rawmodel._rawmodel</a></li> <li><a href="promod3/rawmodel/_rawmodel.html">promod3.rawmodel._rawmodel</a></li>
</ul><li><a href="test_actions.html">test_actions</a></li> </ul><li><a href="test_actions.html">test_actions</a></li>
</ul> </ul>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>promod3.core.pm3argparse &mdash; ProMod3 0 documentation</title>
<link rel="stylesheet" href="../../../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="top" title="ProMod3 0 documentation" href="../../../index.html" />
<link rel="up" title="promod3" href="../../promod3.html" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">ProMod3 0 documentation</a> &raquo;</li>
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &raquo;</li>
<li class="nav-item nav-item-2"><a href="../../promod3.html" accesskey="U">promod3</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<h1>Source code for promod3.core.pm3argparse</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Extensions for the argparse module.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">argparse</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">os</span>
<div class="viewcode-block" id="PM3ArgumentParser"><a class="viewcode-back" href="../../../core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser">[docs]</a><span class="k">class</span> <span class="nc">PM3ArgumentParser</span><span class="p">(</span><span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This class is a child of :class:`argparse.ArgumentParser`. It provides a</span>
<span class="sd"> set of standard arguments which can be activated, rather than added via the</span>
<span class="sd"> traditional way. This helps keeping up a common naming scheme throughout</span>
<span class="sd"> all |project| actions. As a real extension, this subclass provides checking</span>
<span class="sd"> of input parameters on :meth:`~pm3argparse.PM3ArgumentParser.Parse`. Beside</span>
<span class="sd"> this, everything you can do with a &#39;real&#39; :class:`~argparse.ArgumentParser`</span>
<span class="sd"> instance is possible here.</span>
<span class="sd"> A note on exit codes: if :meth:`~pm3argparse.PM3ArgumentParser.Parse` is</span>
<span class="sd"> called on unrecognised arguments, the script exits with a code 2 by</span>
<span class="sd"> :class:`argparse.ArgumentParser.parse_args()`.</span>
<span class="sd"> Attributes beyond :class:`argparse.ArgumentParser`:</span>
<span class="sd"> .. attribute:: action</span>
<span class="sd"> Indicates if the calling script is a |project| action.</span>
<span class="sd"> :type: :class:`bool`</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="PM3ArgumentParser.__init__"><a class="viewcode-back" href="../../../core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser.__init__">[docs]</a> <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Create a new instance of :class:`~pm3argparse.PM3ArgumentParser`.</span>
<span class="sd"> :param action: Indicates if the calling script is a |project| action.</span>
<span class="sd"> This influences |progattr|_ of</span>
<span class="sd"> :class:`~argparse.ArgumentParser` by clipping of the</span>
<span class="sd"> first 3 characters of the file name of the script. If</span>
<span class="sd"> ``False``, default behaviour of</span>
<span class="sd"> :class:`~argparse.ArgumentParser` kicks in.</span>
<span class="sd"> :type action: :class:`bool`</span>
<span class="sd"> :param description: Help text for this script, handed down to</span>
<span class="sd"> |descattr|_ of |argpinit|_.</span>
<span class="sd"> :type description: :class:`str`</span>
<span class="sd"> :returns: :class:`argparse.ArgumentParser`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">prog</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">action</span><span class="p">:</span>
<span class="n">prog</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">])[</span><span class="mi">3</span><span class="p">:]</span>
<span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog</span><span class="o">=</span><span class="n">prog</span><span class="p">,</span>
<span class="n">description</span><span class="o">=</span><span class="n">description</span><span class="p">,</span>
<span class="n">formatter_class</span><span class="o">=</span>\
<span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentDefaultsHelpFormatter</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">action</span> <span class="o">=</span> <span class="n">action</span>
</div>
<div class="viewcode-block" id="PM3ArgumentParser.Parse"><a class="viewcode-back" href="../../../core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser.Parse">[docs]</a> <span class="k">def</span> <span class="nf">Parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">namespace</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Parse an argument string.</span>
<span class="sd"> :param args: The argument string. As default |sysargv|_ is used.</span>
<span class="sd"> :type args: :class:`list`</span>
<span class="sd"> :param namespace: The same as for</span>
<span class="sd"> :meth:`argparse.ArgumentParser.parse_args`.</span>
<span class="sd"> :returns: If :attr:`namespace` is not given,</span>
<span class="sd"> :class:`argparse.Namespace`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">opts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">,</span> <span class="n">namespace</span><span class="o">=</span><span class="n">namespace</span><span class="p">)</span>
<span class="k">return</span> <span class="n">opts</span>
<span class="c"># LocalWords: param attr prog argparse ArgumentParser bool sys os init str</span>
<span class="c"># LocalWords: progattr descattr argpinit argv formatter meth args namespace</span>
<span class="c"># LocalWords: ArgumentDefaultsHelpFormatter sysargv</span></div></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../../../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2015, Bienchen.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.3</a>
</div>
</body>
</html>
\ No newline at end of file
...@@ -9,8 +9,8 @@ Introduction ...@@ -9,8 +9,8 @@ Introduction
For parsing command line arguments - For parsing command line arguments -
:py_docs:`optional <howto/argparse.html#introducing-optional-arguments>` and :py_docs:`optional <howto/argparse.html#introducing-optional-arguments>` and
:py_docs:`positional <howto/argparse.html#introducing-positional-arguments>` - :py_docs:`positional <howto/argparse.html#introducing-positional-arguments>` -
|project| tools should utilise Pythons own |project| tools should utilise its own
:py_docs:`argparse <library/argparse.html>` module. While this comes with a lot :mod:`~promod3.core.pm3argparse` module. While this comes with a lot
of functionality to fetch values from the command line comfortably, it has no of functionality to fetch values from the command line comfortably, it has no
means in checking/ verifying input. Some of the most common tests are covered means in checking/ verifying input. Some of the most common tests are covered
here. All tests are designed to exit a script on failure. here. All tests are designed to exit a script on failure.
...@@ -63,4 +63,6 @@ File Tests ...@@ -63,4 +63,6 @@ File Tests
.. autofunction:: FileExtension .. autofunction:: FileExtension
.. LocalWords: currentmodule py howto argparse .. LocalWords: currentmodule py howto argparse testcode argcheck os promod
.. LocalWords: tempfile fh fn ArgumentParser str args FileExists gz pdb
.. LocalWords: FileExtension mmcif doctest autofunction
...@@ -9,7 +9,9 @@ modeling per se but cover standard programming issues. ...@@ -9,7 +9,9 @@ modeling per se but cover standard programming issues.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
pm3argparse
argcheck argcheck
helper helper
......
:mod:`~promod3.core.pm3argparse` - Parsing Command Lines
================================================================================
.. currentmodule:: promod3.core.pm3argparse
.. module:: promod3.core.pm3argparse
Introduction
--------------------------------------------------------------------------------
A lot of the actions in |project| have a bunch of command line parameters/
arguments in common. For example we need an input alignment quite often and
usually for an alignment we need information on what is the target sequence,
what identifies a template sequence and eventually a hint on the format. That
means we need the same functionality on the command line in several actions.
There :class:`pm3argparse.PM3ArgumentParser` serves as a simplification. It
provides a set of standard arguments you just need to activate for your action
plus it comes with some verification functionality for input.
.. synopsis/ example
Argument Parser
--------------------------------------------------------------------------------
.. autoclass:: PM3ArgumentParser
:members:
.. automethod:: __init__
.. |descattr| replace:: :attr:`description`
.. |argpinit| replace:: :meth:`argparse.ArgumentParser.__init__`
.. |progattr| replace:: :attr:`prog`
.. |sysargv| replace:: :attr:`sys.argv`
.. LocalWords: currentmodule argparse ArgumentParser autoclass automethod
.. LocalWords: init descattr attr argpinit meth progattr prog
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<link rel="top" title="ProMod3 0 documentation" href="../index.html" /> <link rel="top" title="ProMod3 0 documentation" href="../index.html" />
<link rel="up" title="core - ProMod3 Core Functionality" href="index.html" /> <link rel="up" title="core - ProMod3 Core Functionality" href="index.html" />
<link rel="next" title="helper - Shared Functionality For the Everything" href="helper.html" /> <link rel="next" title="helper - Shared Functionality For the Everything" href="helper.html" />
<link rel="prev" title="core - ProMod3 Core Functionality" href="index.html" /> <link rel="prev" title="pm3argparse - Parsing Command Lines" href="pm3argparse.html" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9"> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<a href="helper.html" title="helper - Shared Functionality For the Everything" <a href="helper.html" title="helper - Shared Functionality For the Everything"
accesskey="N">next</a> |</li> accesskey="N">next</a> |</li>
<li class="right" > <li class="right" >
<a href="index.html" title="core - ProMod3 Core Functionality" <a href="pm3argparse.html" title="pm3argparse - Parsing Command Lines"
accesskey="P">previous</a> |</li> accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">ProMod3 0 documentation</a> &raquo;</li> <li class="nav-item nav-item-0"><a href="../index.html">ProMod3 0 documentation</a> &raquo;</li>
<li class="nav-item nav-item-1"><a href="../developers.html" >Documentation For Developes</a> &raquo;</li> <li class="nav-item nav-item-1"><a href="../developers.html" >Documentation For Developes</a> &raquo;</li>
...@@ -66,8 +66,8 @@ ...@@ -66,8 +66,8 @@
<p>For parsing command line arguments - <p>For parsing command line arguments -
<a class="reference external" href="https://docs.python.org/2.7/howto/argparse.html#introducing-optional-arguments">optional</a> and <a class="reference external" href="https://docs.python.org/2.7/howto/argparse.html#introducing-optional-arguments">optional</a> and
<a class="reference external" href="https://docs.python.org/2.7/howto/argparse.html#introducing-positional-arguments">positional</a> - <a class="reference external" href="https://docs.python.org/2.7/howto/argparse.html#introducing-positional-arguments">positional</a> -
ProMod3 tools should utilise Pythons own ProMod3 tools should utilise its own
<a class="reference external" href="https://docs.python.org/2.7/library/argparse.html">argparse</a> module. While this comes with a lot <a class="reference internal" href="pm3argparse.html#module-promod3.core.pm3argparse" title="promod3.core.pm3argparse"><code class="xref py py-mod docutils literal"><span class="pre">pm3argparse</span></code></a> module. While this comes with a lot
of functionality to fetch values from the command line comfortably, it has no of functionality to fetch values from the command line comfortably, it has no
means in checking/ verifying input. Some of the most common tests are covered means in checking/ verifying input. Some of the most common tests are covered
here. All tests are designed to exit a script on failure.</p> here. All tests are designed to exit a script on failure.</p>
...@@ -172,8 +172,8 @@ shell. <code class="docutils literal"><span class="pre">0</span></code> is tradi ...@@ -172,8 +172,8 @@ shell. <code class="docutils literal"><span class="pre">0</span></code> is tradi
</ul> </ul>
<h4>Previous topic</h4> <h4>Previous topic</h4>
<p class="topless"><a href="index.html" <p class="topless"><a href="pm3argparse.html"
title="previous chapter"><code class="docutils literal"><span class="pre">core</span></code> - ProMod3 Core Functionality</a></p> title="previous chapter"><code class="docutils literal"><span class="pre">pm3argparse</span></code> - Parsing Command Lines</a></p>
<h4>Next topic</h4> <h4>Next topic</h4>
<p class="topless"><a href="helper.html" <p class="topless"><a href="helper.html"
title="next chapter"><code class="docutils literal"><span class="pre">helper</span></code> - Shared Functionality For the Everything</a></p> title="next chapter"><code class="docutils literal"><span class="pre">helper</span></code> - Shared Functionality For the Everything</a></p>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="ProMod3 0 documentation" href="../index.html" /> <link rel="top" title="ProMod3 0 documentation" href="../index.html" />
<link rel="up" title="Documentation For Developes" href="../developers.html" /> <link rel="up" title="Documentation For Developes" href="../developers.html" />
<link rel="next" title="argcheck - Standard Tests For Command Line Arguments" href="argcheck.html" /> <link rel="next" title="pm3argparse - Parsing Command Lines" href="pm3argparse.html" />
<link rel="prev" title="SetCompoundsChemlib()" href="setcompoundschemlib.html" /> <link rel="prev" title="SetCompoundsChemlib()" href="setcompoundschemlib.html" />
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<a href="../py-modindex.html" title="Python Module Index" <a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li> >modules</a> |</li>
<li class="right" > <li class="right" >
<a href="argcheck.html" title="argcheck - Standard Tests For Command Line Arguments" <a href="pm3argparse.html" title="pm3argparse - Parsing Command Lines"
accesskey="N">next</a> |</li> accesskey="N">next</a> |</li>
<li class="right" > <li class="right" >
<a href="setcompoundschemlib.html" title="SetCompoundsChemlib()" <a href="setcompoundschemlib.html" title="SetCompoundsChemlib()"
...@@ -64,6 +64,11 @@ ...@@ -64,6 +64,11 @@
modeling per se but cover standard programming issues.</p> modeling per se but cover standard programming issues.</p>
<div class="toctree-wrapper compound"> <div class="toctree-wrapper compound">
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="pm3argparse.html"><code class="docutils literal"><span class="pre">pm3argparse</span></code> - Parsing Command Lines</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pm3argparse.html#introduction">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="pm3argparse.html#argument-parser">Argument Parser</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="argcheck.html"><code class="docutils literal"><span class="pre">argcheck</span></code> - Standard Tests For Command Line Arguments</a><ul> <li class="toctree-l1"><a class="reference internal" href="argcheck.html"><code class="docutils literal"><span class="pre">argcheck</span></code> - Standard Tests For Command Line Arguments</a><ul>
<li class="toctree-l2"><a class="reference internal" href="argcheck.html#introduction">Introduction</a></li> <li class="toctree-l2"><a class="reference internal" href="argcheck.html#introduction">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="argcheck.html#file-tests">File Tests</a></li> <li class="toctree-l2"><a class="reference internal" href="argcheck.html#file-tests">File Tests</a></li>
...@@ -88,8 +93,8 @@ modeling per se but cover standard programming issues.</p> ...@@ -88,8 +93,8 @@ modeling per se but cover standard programming issues.</p>
<p class="topless"><a href="setcompoundschemlib.html" <p class="topless"><a href="setcompoundschemlib.html"
title="previous chapter"><code class="docutils literal"><span class="pre">SetCompoundsChemlib()</span></code></a></p> title="previous chapter"><code class="docutils literal"><span class="pre">SetCompoundsChemlib()</span></code></a></p>
<h4>Next topic</h4> <h4>Next topic</h4>
<p class="topless"><a href="argcheck.html" <p class="topless"><a href="pm3argparse.html"
title="next chapter"><code class="docutils literal"><span class="pre">argcheck</span></code> - Standard Tests For Command Line Arguments</a></p> title="next chapter"><code class="docutils literal"><span class="pre">pm3argparse</span></code> - Parsing Command Lines</a></p>
<div role="note" aria-label="source link"> <div role="note" aria-label="source link">
<h3>This Page</h3> <h3>This Page</h3>
<ul class="this-page-menu"> <ul class="this-page-menu">
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pm3argparse - Parsing Command Lines &mdash; ProMod3 0 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="ProMod3 0 documentation" href="../index.html" />
<link rel="up" title="core - ProMod3 Core Functionality" href="index.html" />
<link rel="next" title="argcheck - Standard Tests For Command Line Arguments" href="argcheck.html" />
<link rel="prev" title="core - ProMod3 Core Functionality" href="index.html" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="argcheck.html" title="argcheck - Standard Tests For Command Line Arguments"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="core - ProMod3 Core Functionality"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">ProMod3 0 documentation</a> &raquo;</li>
<li class="nav-item nav-item-1"><a href="../developers.html" >Documentation For Developes</a> &raquo;</li>
<li class="nav-item nav-item-2"><a href="index.html" accesskey="U"><code class="docutils literal"><span class="pre">core</span></code> - ProMod3 Core Functionality</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-promod3.core.pm3argparse">
<span id="pm3argparse-parsing-command-lines"></span><h1><a class="reference internal" href="#module-promod3.core.pm3argparse" title="promod3.core.pm3argparse"><code class="xref py py-mod docutils literal"><span class="pre">pm3argparse</span></code></a> - Parsing Command Lines<a class="headerlink" href="#module-promod3.core.pm3argparse" title="Permalink to this headline"></a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>A lot of the actions in ProMod3 have a bunch of command line parameters/
arguments in common. For example we need an input alignment quite often and
usually for an alignment we need information on what is the target sequence,
what identifies a template sequence and eventually a hint on the format. That
means we need the same functionality on the command line in several actions.
There <code class="xref py py-class docutils literal"><span class="pre">pm3argparse.PM3ArgumentParser</span></code> serves as a simplification. It
provides a set of standard arguments you just need to activate for your action
plus it comes with some verification functionality for input.</p>
</div>
<div class="section" id="argument-parser">
<h2>Argument Parser<a class="headerlink" href="#argument-parser" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="promod3.core.pm3argparse.PM3ArgumentParser">
<em class="property">class </em><code class="descclassname">promod3.core.pm3argparse.</code><code class="descname">PM3ArgumentParser</code><span class="sig-paren">(</span><em>action=True</em>, <em>description=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/promod3/core/pm3argparse.html#PM3ArgumentParser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#promod3.core.pm3argparse.PM3ArgumentParser" title="Permalink to this definition"></a></dt>
<dd><p>This class is a child of <a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">argparse.ArgumentParser</span></code></a>. It provides a
set of standard arguments which can be activated, rather than added via the
traditional way. This helps keeping up a common naming scheme throughout
all ProMod3 actions. As a real extension, this subclass provides checking
of input parameters on <code class="xref py py-meth docutils literal"><span class="pre">Parse()</span></code>. Beside
this, everything you can do with a &#8216;real&#8217; <a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">ArgumentParser</span></code></a>
instance is possible here.</p>
<p>A note on exit codes: if <code class="xref py py-meth docutils literal"><span class="pre">Parse()</span></code> is
called on unrecognised arguments, the script exits with a code 2 by
<code class="xref py py-class docutils literal"><span class="pre">argparse.ArgumentParser.parse_args()</span></code>.</p>
<p>Attributes beyond <a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">argparse.ArgumentParser</span></code></a>:</p>
<dl class="attribute">
<dt id="promod3.core.pm3argparse.PM3ArgumentParser.action">
<code class="descname">action</code><a class="headerlink" href="#promod3.core.pm3argparse.PM3ArgumentParser.action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Indicates if the calling script is a ProMod3 action.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/2.7/library/functions.html#bool" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">bool</span></code></a></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="promod3.core.pm3argparse.PM3ArgumentParser.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>action=True</em>, <em>description=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/promod3/core/pm3argparse.html#PM3ArgumentParser.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#promod3.core.pm3argparse.PM3ArgumentParser.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Create a new instance of <code class="xref py py-class docutils literal"><span class="pre">PM3ArgumentParser</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>action</strong> (<a class="reference external" href="https://docs.python.org/2.7/library/functions.html#bool" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">bool</span></code></a>) &#8211; Indicates if the calling script is a ProMod3 action.
This influences <a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#prog"><code class="xref py py-attr docutils literal"><span class="pre">prog</span></code></a> of
<a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">ArgumentParser</span></code></a> by clipping of the
first 3 characters of the file name of the script. If
<code class="docutils literal"><span class="pre">False</span></code>, default behaviour of
<a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">ArgumentParser</span></code></a> kicks in.</li>
<li><strong>description</strong> (<a class="reference external" href="https://docs.python.org/2.7/library/functions.html#str" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>) &#8211; Help text for this script, handed down to
<a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#description"><code class="xref py py-attr docutils literal"><span class="pre">description</span></code></a> of <a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser"><code class="xref py py-meth docutils literal"><span class="pre">argparse.ArgumentParser.__init__()</span></code></a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">argparse.ArgumentParser</span></code></a>.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="promod3.core.pm3argparse.PM3ArgumentParser.Parse">
<code class="descname">Parse</code><span class="sig-paren">(</span><em>args=None</em>, <em>namespace=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/promod3/core/pm3argparse.html#PM3ArgumentParser.Parse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#promod3.core.pm3argparse.PM3ArgumentParser.Parse" title="Permalink to this definition"></a></dt>
<dd><p>Parse an argument string.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>args</strong> (<a class="reference external" href="https://docs.python.org/2.7/library/functions.html#list" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">list</span></code></a>) &#8211; The argument string. As default <a class="reference external" href="https://docs.python.org/2.7/library/sys.html#sys.argv"><code class="xref py py-attr docutils literal"><span class="pre">sys.argv</span></code></a> is used.</li>
<li><strong>namespace</strong> &#8211; The same as for
<a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser.parse_args" title="(in Python v2.7)"><code class="xref py py-meth docutils literal"><span class="pre">argparse.ArgumentParser.parse_args()</span></code></a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">If <code class="xref py py-attr docutils literal"><span class="pre">namespace</span></code> is not given,
<a class="reference external" href="https://docs.python.org/2.7/library/argparse.html#argparse.Namespace" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">argparse.Namespace</span></code></a>.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><code class="docutils literal"><span class="pre">pm3argparse</span></code> - Parsing Command Lines</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#argument-parser">Argument Parser</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter"><code class="docutils literal"><span class="pre">core</span></code> - ProMod3 Core Functionality</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="argcheck.html"
title="next chapter"><code class="docutils literal"><span class="pre">argcheck</span></code> - Standard Tests For Command Line Arguments</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/core/pm3argparse.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2015, Bienchen.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.3</a>
|
<a href="../_sources/core/pm3argparse.txt"
rel="nofollow">Page source</a></li>
</div>
</body>
</html>
\ No newline at end of file
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="core/setcompoundschemlib.html"><code class="docutils literal"><span class="pre">SetCompoundsChemlib()</span></code></a></li> <li class="toctree-l1"><a class="reference internal" href="core/setcompoundschemlib.html"><code class="docutils literal"><span class="pre">SetCompoundsChemlib()</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="core/index.html"><code class="docutils literal"><span class="pre">core</span></code> - ProMod3 Core Functionality</a><ul> <li class="toctree-l1"><a class="reference internal" href="core/index.html"><code class="docutils literal"><span class="pre">core</span></code> - ProMod3 Core Functionality</a><ul>
<li class="toctree-l2"><a class="reference internal" href="core/pm3argparse.html"><code class="docutils literal"><span class="pre">pm3argparse</span></code> - Parsing Command Lines</a></li>
<li class="toctree-l2"><a class="reference internal" href="core/argcheck.html"><code class="docutils literal"><span class="pre">argcheck</span></code> - Standard Tests For Command Line Arguments</a></li> <li class="toctree-l2"><a class="reference internal" href="core/argcheck.html"><code class="docutils literal"><span class="pre">argcheck</span></code> - Standard Tests For Command Line Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="core/helper.html"><code class="docutils literal"><span class="pre">helper</span></code> - Shared Functionality For the Everything</a></li> <li class="toctree-l2"><a class="reference internal" href="core/helper.html"><code class="docutils literal"><span class="pre">helper</span></code> - Shared Functionality For the Everything</a></li>
</ul> </ul>
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
<h1 id="index">Index</h1> <h1 id="index">Index</h1>
<div class="genindex-jumpbox"> <div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a> <a href="#_"><strong>_</strong></a>
| <a href="#A"><strong>A</strong></a>
| <a href="#B"><strong>B</strong></a> | <a href="#B"><strong>B</strong></a>
| <a href="#C"><strong>C</strong></a> | <a href="#C"><strong>C</strong></a>
| <a href="#F"><strong>F</strong></a> | <a href="#F"><strong>F</strong></a>
...@@ -65,13 +66,29 @@ ...@@ -65,13 +66,29 @@
| <a href="#T"><strong>T</strong></a> | <a href="#T"><strong>T</strong></a>
</div> </div>
<h2 id="_">_</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser.__init__">__init__() (promod3.core.pm3argparse.PM3ArgumentParser method)</a>
</dt>
</dl></td>
</tr></table>
<h2 id="A">A</h2> <h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr> <table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl> <td style="width: 33%" valign="top"><dl>
<dt><a href="core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser.action">action (promod3.core.pm3argparse.PM3ArgumentParser attribute)</a>
</dt>
<dt><a href="actions/index_dev.html#test_actions.ActionTestCase">ActionTestCase (class in test_actions)</a> <dt><a href="actions/index_dev.html#test_actions.ActionTestCase">ActionTestCase (class in test_actions)</a>
</dt> </dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt> <dt>
add_doc_dependency add_doc_dependency
...@@ -83,8 +100,6 @@ ...@@ -83,8 +100,6 @@
</dt> </dt>
</dl></dd> </dl></dd>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt> <dt>
add_doc_source add_doc_source
...@@ -208,6 +223,14 @@ ...@@ -208,6 +223,14 @@
<table style="width: 100%" class="indextable genindextable"><tr> <table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl> <td style="width: 33%" valign="top"><dl>
<dt><a href="core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser.Parse">Parse() (promod3.core.pm3argparse.PM3ArgumentParser method)</a>
</dt>
<dt><a href="core/pm3argparse.html#promod3.core.pm3argparse.PM3ArgumentParser">PM3ArgumentParser (class in promod3.core.pm3argparse)</a>
</dt>
<dt> <dt>
pm_action pm_action
</dt> </dt>
...@@ -233,6 +256,10 @@ ...@@ -233,6 +256,10 @@
</dt> </dt>
<dt><a href="core/pm3argparse.html#module-promod3.core.pm3argparse">promod3.core.pm3argparse (module)</a>
</dt>
<dt><a href="rawmodel/index.html#module-promod3.rawmodel">promod3.rawmodel (module)</a> <dt><a href="rawmodel/index.html#module-promod3.rawmodel">promod3.rawmodel (module)</a>
</dt> </dt>
......
No preview for this file type
...@@ -74,6 +74,11 @@ ...@@ -74,6 +74,11 @@
<td>&nbsp;&nbsp;&nbsp; <td>&nbsp;&nbsp;&nbsp;
<a href="core/index.html#module-promod3.core"><code class="xref">promod3.core</code></a></td><td> <a href="core/index.html#module-promod3.core"><code class="xref">promod3.core</code></a></td><td>
<em>Basic functionality, supporting standard tasks in your code.</em></td></tr> <em>Basic functionality, supporting standard tasks in your code.</em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="core/pm3argparse.html#module-promod3.core.pm3argparse"><code class="xref">promod3.core.pm3argparse</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1"> <tr class="cg-1">
<td></td> <td></td>
<td>&nbsp;&nbsp;&nbsp; <td>&nbsp;&nbsp;&nbsp;
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment