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
af547e54
Commit
af547e54
authored
9 years ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
--fasta option
parent
0a3ee11f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/tests/data/fasta/1ake.fas
+2
-2
2 additions, 2 deletions
core/tests/data/fasta/1ake.fas
core/tests/test_pm3argparse.py
+215
-40
215 additions, 40 deletions
core/tests/test_pm3argparse.py
extras/pre_commit/pm3_csc/filecheck/pylintrc
+1
-1
1 addition, 1 deletion
extras/pre_commit/pm3_csc/filecheck/pylintrc
with
218 additions
and
43 deletions
core/tests/data/fasta/1ake.fas
+
2
−
2
View file @
af547e54
> 1AKE.B
MRIILLGAPGAGKGTQAQFIMEKYGIPQISTGDMLRAAVKSGSELGKQAKDIMDAGKLVTDELVIALVKERIAQEDCRNG
FLLDGFPRTIPQADAMKEAGINVDYVLEFDVPDELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGEELTTRKDDQ
EETVRKRLVEYHQMTAPLIGYYSKEAEAGNTKYAKVDGTKPV---AEVRADLEKILG
EETVRKRLVEYHQMTAPLIGYY
YY
SKEAEAGNTKYAKVDGTKPV---AEVRADLEKILG
> target
-------APGAGKGTQAQFIMEKYGIPQISTGGGLRAAVKS---LGKQAKDIMDAGKLVTDELVIALVKERIAQEDCRNG
FLLDGFPRTIPQADAMKEAGINVDYVLEF----ELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGEELTTRKDDQ
EETVRKRLVEYHQMTAPLLYYYYKEAEAGNTKYAKVDGTKPVAEVRADLEKILG---
EETVRKRLVEYHQMTAPLL
--
YYYYKEAEAGNTKYAKVDGTKPVAEVRADLEKILG---
This diff is collapsed.
Click to expand it.
core/tests/test_pm3argparse.py
+
215
−
40
View file @
af547e54
import
unittest
,
sys
import
unittest
import
ost
from
promod3.core
import
pm3argparse
#argparse writes to stdout/ stderr so we need to fetch it
class
_FetchStd
(
object
):
def
__init__
(
self
):
self
.
buffer
=
list
()
def
write
(
self
,
line
):
self
.
buffer
.
append
(
line
.
strip
())
class
_FetchLog
(
ost
.
LogSink
):
"""
Capturing output of the OST logger
"""
def
__init__
(
self
):
ost
.
LogSink
.
__init__
(
self
)
self
.
messages
=
dict
()
def
flush
(
self
):
pass
def
LogMessage
(
self
,
message
,
severity
):
levels
=
[
'
ERROR
'
,
'
WARNING
'
,
'
SCRIPT
'
,
'
INFO
'
,
'
VERBOSE
'
,
'
DEBUG
'
,
'
TRACE
'
]
level
=
levels
[
severity
]
if
not
level
in
self
.
messages
.
keys
():
self
.
messages
[
level
]
=
list
()
self
.
messages
[
level
].
append
(
message
.
strip
())
class
PM3ArgParseTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
original_stderr
=
sys
.
stderr
self
.
original_stdout
=
sys
.
stdout
sys
.
stderr
=
_FetchStd
()
sys
.
stdout
=
_FetchStd
()
self
.
log
=
_FetchLog
()
ost
.
PushLogSink
(
self
.
log
)
ost
.
PushVerbosityLevel
(
2
)
def
tearDown
(
self
):
sys
.
stderr
=
self
.
original_stderr
sys
.
stdout
=
self
.
original_stdout
ost
.
PopVerbosityLevel
()
ost
.
PopLogSink
()
def
testUnrecognisedArguments
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
with
self
.
assertRaises
(
SystemExit
)
as
ec
:
with
self
.
assertRaises
(
SystemExit
)
as
ec
d
:
parser
.
Parse
([
'
-x
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
2
)
self
.
assertEqual
(
sys
.
stderr
.
buffer
,
[
'
usage: test_pm3argparse.py [-h]
'
,
'
test_pm3argparse.py: error:
'
+
'
unrecognized arguments: -x
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
2
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
],
[
'
usage: test_pm3argparse.py [-h]
'
,
'
test_pm3argparse.py: error: unrecognized
'
+
'
arguments: -x
'
])
def
testActionSwitch
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
with
self
.
assertRaises
(
SystemExit
)
as
ec
:
with
self
.
assertRaises
(
SystemExit
)
as
ec
d
:
parser
.
Parse
([
'
--help
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
0
)
self
.
assertEqual
(
s
ys
.
stdout
.
buffer
,
[
'
usage: test_pm3argparse.py
'
+
'
[-h]
\n\n
optional
arguments:
\n
'
+
'
-h, --help show this help
'
+
'
message
and exit
'
])
self
.
assertEqual
(
ec
d
.
exception
.
code
,
0
)
self
.
assertEqual
(
s
elf
.
log
.
messages
[
'
SCRIPT
'
],
[
'
usage: test_pm3argparse.py
[-h]
\n\n
optional
'
+
'
arguments:
\n
-h, --help show this help
message
'
+
'
and exit
'
])
s
ys
.
stdout
.
buffer
=
lis
t
()
s
elf
.
log
.
messages
=
dic
t
()
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
True
)
with
self
.
assertRaises
(
SystemExit
)
as
ec
:
with
self
.
assertRaises
(
SystemExit
)
as
ec
d
:
parser
.
Parse
([
'
--help
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
0
)
self
.
assertEqual
(
s
ys
.
stdout
.
buffer
,
[
'
usage: t_pm3argparse.py
'
+
'
[-h]
\n\n
optional
arguments:
\n
'
+
'
-h, --help show this help
'
+
'
message
and exit
'
])
self
.
assertEqual
(
ec
d
.
exception
.
code
,
0
)
self
.
assertEqual
(
s
elf
.
log
.
messages
[
'
SCRIPT
'
],
[
'
usage: t_pm3argparse.py
[-h]
\n\n
optional
'
+
'
arguments:
\n
-h, --help show this help
message
'
+
'
and exit
'
])
def
testDescription
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
,
description
=
'
This is a test.
'
)
with
self
.
assertRaises
(
SystemExit
)
as
ec
:
with
self
.
assertRaises
(
SystemExit
)
as
ec
d
:
parser
.
Parse
([
'
--help
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
0
)
self
.
assertEqual
(
sys
.
stdout
.
buffer
,
[
'
usage: test_pm3argparse.py
'
+
'
[-h]
\n\n
This is a
'
+
'
test.
\n\n
optional arguments:
\n
'
+
'
-h, --help show this help
'
+
'
message and exit
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
0
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
SCRIPT
'
],
[
'
usage: test_pm3argparse.py [-h]
\n\n
This is a
'
+
'
test.
\n\n
optional arguments:
\n
-h, --help show
'
+
'
this help message and exit
'
])
def
testAddAlignemntNoTrgPfx
(
self
):
# checking that we fail on missing 'trg:' prefix for arguments of
# --fasta
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
foo
'
,
'
bar
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
11
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta
'
requires one
"
+
"
argument prefixed with
'
trg:
'
marking the target
"
+
"
sequence name
"
)
def
testAddAlignemntEmptyTrgPfx
(
self
):
# checking that we fail on empty 'trg:' prefix for arguments of
# --fasta
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
trg:
'
,
'
bar
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
14
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta
'
requires
"
+
"
argument
'
trg:
'
defining the target sequence name,
"
+
"
empty one found:
'
trg: bar
'"
)
def
testAddAlignemntSwapTrgPfx
(
self
):
# checking that we fail on empty 'trg:' prefix for arguments of
# --fasta
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
bar
'
,
'
trg:
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
14
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta
'
requires
"
+
"
argument
'
trg:
'
defining the target sequence name,
"
+
"
empty one found:
'
bar trg:
'"
)
def
testAddAlignmentNoFile
(
self
):
# check that we throw an error if a non-exisiting file is given
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
trg:foo
'
,
'
notexistingfile.fas
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
12
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"
Alignment file does not exist: notexistingfile.fas
"
)
def
testAddAlignmentEmpty
(
self
):
# we want to fail if we get an empty FastA file
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
trg:foo
'
,
'
data/fasta/alignment.fas
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
15
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta
'
refers to an empty file or its in the
"
+
"
wrong format: data/fasta/alignment.fas
"
)
def
testAddAlignmentToMany
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake_3.fas
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
16
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta trg:target
"
+
"
data/fasta/1ake_3.fas
'
points to an alignment with
"
+
"
more than 2 sequences.
"
)
def
testAddAlignmentMissingTargetName
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
trg:trg
'
,
'
data/fasta/1ake.fas
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
17
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta trg:trg
"
+
"
data/fasta/1ake.fas
'
does not define a target name
"
+
"
found in the alignment.
"
)
def
testAddAlignmentDifferentSeqLens
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
with
self
.
assertRaises
(
SystemExit
)
as
ecd
:
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake_nel.fas
'
])
self
.
assertEqual
(
ecd
.
exception
.
code
,
18
)
self
.
assertEqual
(
self
.
log
.
messages
[
'
ERROR
'
][
0
],
"'
--fasta trg:target
"
+
"
data/fasta/1ake_nel.fas
'
: sequences in the
"
+
"
alignment have different length.
"
)
def
testAddAlignmentGzipIn
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake.fas.gz
'
,
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake.fas
'
])
self
.
assertEqual
(
str
(
opts
.
alignments
[
0
]),
'
target APGAGKGTQAQFIMEKYG
'
+
'
IPQISTGGGLRAAVKS---LGKQAKDIMDAGKLVTDELVIALVKERIAQED
'
+
'
CRN
\n
1AKE.B APGAGKGTQAQFIMEKYGIPQISTGDMLRAAVKSGSEL
'
+
'
GKQAKDIMDAGKLVTDELVIALVKERIAQEDCRN
\n\n
target GFLLD
'
+
'
GFPRTIPQADAMKEAGINVDYVLEF----ELIVDRIVGRRVHAPSGRVYHV
'
+
'
KFNPPKVEGKDDVTGE
\n
1AKE.B GFLLDGFPRTIPQADAMKEAGINVD
'
+
'
YVLEFDVPDELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGE
\n\n
'
+
'
target ELTTRKDDQEETVRKRLVEYHQMTAPLLYYYYKEAEAGNTKYA
'
+
'
KVDGTKPVAEVRADLEKILG
\n
1AKE.B ELTTRKDDQEETVRKRLVEYH
'
+
'
QMTAPLIGYYSKEAEAGNTKYAKVDGTKPV---AEVRADLEK
\n
'
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetSequence
(
1
).
offset
,
7
)
self
.
assertEqual
(
str
(
opts
.
alignments
[
1
]),
'
target APGAGKGTQAQFIMEKYG
'
+
'
IPQISTGGGLRAAVKS---LGKQAKDIMDAGKLVTDELVIALVKERIAQED
'
+
'
CRN
\n
1AKE.B APGAGKGTQAQFIMEKYGIPQISTGDMLRAAVKSGSEL
'
+
'
GKQAKDIMDAGKLVTDELVIALVKERIAQEDCRN
\n\n
target GFLLD
'
+
'
GFPRTIPQADAMKEAGINVDYVLEF----ELIVDRIVGRRVHAPSGRVYHV
'
+
'
KFNPPKVEGKDDVTGE
\n
1AKE.B GFLLDGFPRTIPQADAMKEAGINVD
'
+
'
YVLEFDVPDELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGE
\n\n
'
+
'
target ELTTRKDDQEETVRKRLVEYHQMTAPLL--YYYYKEAEAGNTK
'
+
'
YAKVDGTKPVAEVRADLEKILG
\n
1AKE.B ELTTRKDDQEETVRKRLVE
'
+
'
YHQMTAPLIGYYYYSKEAEAGNTKYAKVDGTKPV---AEVRADLEK
\n
'
)
def
testAddAlignmentSwitchSeqs
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake.fas
'
])
self
.
assertEqual
(
str
(
opts
.
alignments
[
0
].
GetSequence
(
0
)),
'
APGAGKGTQAQFIMEKYGIPQISTGGGLRAAVKS---LGKQAKDIMDAGK
'
+
'
LVTDELVIALVKERIAQEDCRNGFLLDGFPRTIPQADAMKEAGINVDYVL
'
+
'
EF----ELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGEELTTRK
'
+
'
DDQEETVRKRLVEYHQMTAPLL--YYYYKEAEAGNTKYAKVDGTKPVAEV
'
+
'
RADLEKILG
'
)
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake_sw.fas
'
])
self
.
assertEqual
(
str
(
opts
.
alignments
[
0
].
GetSequence
(
0
)),
'
APGAGKGTQAQFIMEKYGIPQISTGGGLRAAVKS---LGKQAKDIMDAGK
'
+
'
LVTDELVIALVKERIAQEDCRNGFLLDGFPRTIPQADAMKEAGINVDYVL
'
+
'
EF----ELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGEELTTRK
'
+
'
DDQEETVRKRLVEYHQMTAPLL--YYYYKEAEAGNTKYAKVDGTKPVAEV
'
+
'
RADLEKILG
'
)
def
testAddAlignment
(
self
):
parser
=
pm3argparse
.
PM3ArgumentParser
(
action
=
False
)
parser
.
AddAlignment
()
parser
.
AssembleParser
()
opts
=
parser
.
Parse
([
'
--fasta
'
,
'
trg:target
'
,
'
data/fasta/1ake.fas
'
])
self
.
assertEqual
(
len
(
opts
.
alignments
),
1
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetLength
(),
209
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetSequenceOffset
(
0
),
0
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetSequenceOffset
(
1
),
7
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetSequence
(
0
).
gapless_string
,
'
APGAGKGTQAQFIMEKYGIPQISTGGGLRAAVKSLGKQAKDIMDAGKLVT
'
+
'
DELVIALVKERIAQEDCRNGFLLDGFPRTIPQADAMKEAGINVDYVLEFE
'
+
'
LIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDVTGEELTTRKDDQEETV
'
+
'
RKRLVEYHQMTAPLLYYYYKEAEAGNTKYAKVDGTKPVAEVRADLEKILG
'
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetSequence
(
0
).
name
,
'
target
'
)
self
.
assertEqual
(
opts
.
alignments
[
0
].
GetSequence
(
1
).
name
,
'
1AKE.B
'
)
self
.
assertEqual
(
opts
.
aln_sources
[
0
],
'
data/fasta/1ake.fas
'
)
if
__name__
==
"
__main__
"
:
from
ost
import
testutils
...
...
This diff is collapsed.
Click to expand it.
extras/pre_commit/pm3_csc/filecheck/pylintrc
+
1
−
1
View file @
af547e54
...
...
@@ -290,7 +290,7 @@ max-attributes=7
min-public-methods=2
# Maximum number of public methods for a class (see R0904).
max-public-methods=2
0
max-public-methods=2
1
[IMPORTS]
...
...
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