Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProMod3
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
ProMod3
Commits
b20a29fa
Commit
b20a29fa
authored
9 years ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Made description mandatory
parent
c601a8f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/doc/helper.rst
+2
-2
2 additions, 2 deletions
core/doc/helper.rst
core/pymod/core/pm3argparse.py
+5
-5
5 additions, 5 deletions
core/pymod/core/pm3argparse.py
core/tests/test_pm3argparse.py
+23
-17
23 additions, 17 deletions
core/tests/test_pm3argparse.py
with
30 additions
and
24 deletions
core/doc/helper.rst
+
2
−
2
View file @
b20a29fa
...
...
@@ -53,7 +53,7 @@ File Tests
(fh, fn) = tempfile.mkstemp(suffix='.pdb')
os.close(fh)
p = pm3argparse.PM3ArgumentParser()
p = pm3argparse.PM3ArgumentParser(
'Dummy'
)
p.add_argument('file', type=str)
opts = p.Parse([fn])
...
...
@@ -71,7 +71,7 @@ File Tests
from promod3.core import helper
from promod3.core import pm3argparse
p = pm3argparse.PM3ArgumentParser()
p = pm3argparse.PM3ArgumentParser(
__doc__
)
p.add_argument('file', type=str)
opts = p.Parse()
...
...
This diff is collapsed.
Click to expand it.
core/pymod/core/pm3argparse.py
+
5
−
5
View file @
b20a29fa
...
...
@@ -63,10 +63,14 @@ class PM3ArgumentParser(argparse.ArgumentParser):
:type: :class:`bool`
"""
def
__init__
(
self
,
action
=
True
,
descrip
tion
=
Non
e
):
def
__init__
(
self
,
description
,
ac
tion
=
Tru
e
):
"""
Create a new instance of :class:`~pm3argparse.PM3ArgumentParser`.
:param description: Help text for this script, handed down to
|descattr|_ of |argpinit|_.
:type description: :class:`str`
:param action: Indicates if the calling script is a |project| action.
This influences |progattr|_ of
:class:`~argparse.ArgumentParser` by clipping of the
...
...
@@ -75,10 +79,6 @@ class PM3ArgumentParser(argparse.ArgumentParser):
:class:`~argparse.ArgumentParser` kicks in.
:type action: :class:`bool`
:param description: Help text for this script, handed down to
|descattr|_ of |argpinit|_.
:type description: :class:`str`
:returns: :class:`argparse.ArgumentParser`.
"""
prog
=
None
...
...
This diff is collapsed.
Click to expand it.
core/tests/test_pm3argparse.py
+
23
−
17
View file @
b20a29fa
"""
Testing our own little argument parser.
"""
import
unittest
import
ost
from
promod3.core
import
pm3argparse
...
...
@@ -30,7 +34,7 @@ class PM3ArgParseTests(unittest.TestCase):
ost
.
PopLogSink
()
def
testUnrecognisedArguments
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
-x
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
2
)
...
...
@@ -40,22 +44,24 @@ class PM3ArgParseTests(unittest.TestCase):
'
arguments: -x
'
])
def
testActionSwitch
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--help
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
0
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
SCRIPT
'
],
[
'
usage: test_pm3argparse.py [-h]
\n\n
optional
'
+
[
'
usage: test_pm3argparse.py [-h]
\n\n
Testing our
'
+
'
own little argument parser.
\n\n
optional
'
+
'
arguments:
\n
-h, --help show this help message
'
+
'
and exit
'
])
self
.
log
.
messages
=
dict
()
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
True
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
True
)
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--help
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
0
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
SCRIPT
'
],
[
'
usage: t_pm3argparse.py [-h]
\n\n
optional
'
+
[
'
usage: t_pm3argparse.py [-h]
\n\n
Testing our own
'
+
'
little argument parser.
\n\n
optional
'
+
'
arguments:
\n
-h, --help show this help message
'
+
'
and exit
'
])
...
...
@@ -74,7 +80,7 @@ class PM3ArgParseTests(unittest.TestCase):
def
testAddAlignemntNoTrgPfx
(
self
):
# checking that we fail on missing 'trg:' prefix for arguments of
# --fasta
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -88,7 +94,7 @@ class PM3ArgParseTests(unittest.TestCase):
def
testAddAlignemntEmptyTrgPfx
(
self
):
# checking that we fail on empty 'trg:' prefix for arguments of
# --fasta
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -101,7 +107,7 @@ class PM3ArgParseTests(unittest.TestCase):
def
testAddAlignemntSwapTrgPfx
(
self
):
# checking that we fail on empty 'trg:' prefix for arguments of
# --fasta
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -113,7 +119,7 @@ class PM3ArgParseTests(unittest.TestCase):
def
testAddAlignmentNoFile
(
self
):
# check that we throw an error if a non-exisiting file is given
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -124,7 +130,7 @@ class PM3ArgParseTests(unittest.TestCase):
def
testAddAlignmentEmpty
(
self
):
# we want to fail if we get an empty FastA file
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -135,7 +141,7 @@ class PM3ArgParseTests(unittest.TestCase):
"
wrong format: data/fasta/alignment.fas
"
)
def
testAddAlignmentToMany
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -146,7 +152,7 @@ class PM3ArgParseTests(unittest.TestCase):
"
more than 2 sequences.
"
)
def
testAddAlignmentMissingTargetName
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -157,7 +163,7 @@ class PM3ArgParseTests(unittest.TestCase):
"
found in the alignment.
"
)
def
testAddAlignmentDifferentSeqLens
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
...
...
@@ -168,7 +174,7 @@ class PM3ArgParseTests(unittest.TestCase):
"
alignment have different length.
"
)
def
testAddAlignmentGzipIn
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
...
...
@@ -197,7 +203,7 @@ class PM3ArgParseTests(unittest.TestCase):
'
YHQMTAPLIGYYYYSKEAEAGNTKYAKVDGTKPV---AEVRADLEK
\n
'
)
def
testAddAlignmentSwitchSeqs
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
...
...
@@ -209,7 +215,7 @@ class PM3ArgParseTests(unittest.TestCase):
'
DDQEETVRKRLVEYHQMTAPLL--YYYYKEAEAGNTKYAKVDGTKPVAEV
'
+
'
RADLEKILG
'
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
...
...
@@ -222,7 +228,7 @@ class PM3ArgParseTests(unittest.TestCase):
'
RADLEKILG
'
)
def
testAddAlignment
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
__doc__
,
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment