Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
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
openstructure
Commits
c23afeb3
Unverified
Commit
c23afeb3
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
test: SCHWED-6117 tests for reserved and obsolete skips
parent
3219b797
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/conop/tests/test_complib.py
+59
-9
59 additions, 9 deletions
modules/conop/tests/test_complib.py
modules/conop/tests/testfiles/test_compounds.cif
+1913
-531
1913 additions, 531 deletions
modules/conop/tests/testfiles/test_compounds.cif
with
1972 additions
and
540 deletions
modules/conop/tests/test_complib.py
+
59
−
9
View file @
c23afeb3
...
...
@@ -6,19 +6,25 @@ import tempfile
import
warnings
def
CreateComplib
(
compound_dict_path
,
chemlib_out_path
,
extra_args
=
None
):
prefix_path
=
ost
.
GetPrefixPath
()
chemdict_tool_path
=
os
.
path
.
join
(
prefix_path
,
"
bin
"
,
"
chemdict_tool
"
)
if
not
os
.
path
.
exists
(
chemdict_tool_path
):
raise
RuntimeError
(
"
Expect chemdict_tool:
"
,
chemdict_tool_path
)
cmd
=
[
chemdict_tool_path
,
"
create
"
,
compound_dict_path
,
chemlib_out_path
]
if
extra_args
:
cmd
+=
extra_args
subprocess
.
run
(
cmd
,
stdout
=
subprocess
.
PIPE
)
class
TestCompLib
(
unittest
.
TestCase
):
@classmethod
def
setUpClass
(
cls
):
prefix_path
=
ost
.
GetPrefixPath
()
chemdict_tool_path
=
os
.
path
.
join
(
prefix_path
,
"
bin
"
,
"
chemdict_tool
"
)
if
not
os
.
path
.
exists
(
chemdict_tool_path
):
raise
RuntimeError
(
"
Expect chemdict_tool:
"
,
chemdict_tool_path
)
cls
.
tmp_dir
=
tempfile
.
TemporaryDirectory
()
compound
s
_path
=
os
.
path
.
join
(
"
testfiles
"
,
"
test_compounds.cif
"
)
compound
_dict
_path
=
os
.
path
.
join
(
"
testfiles
"
,
"
test_compounds.cif
"
)
complib_path
=
os
.
path
.
join
(
cls
.
tmp_dir
.
name
,
"
test_complib.dat
"
)
cmd
=
[
chemdict_tool_path
,
"
create
"
,
compounds_path
,
complib_path
]
subprocess
.
run
(
cmd
)
CreateComplib
(
compound_dict_path
,
complib_path
)
cls
.
complib
=
conop
.
CompoundLib
.
Load
(
complib_path
)
@classmethod
...
...
@@ -29,11 +35,11 @@ class TestCompLib(unittest.TestCase):
complib
=
self
.
complib
comp_001
=
complib
.
FindCompound
(
"
001
"
)
comp_
hello
=
complib
.
FindCompound
(
"
hello
"
)
comp_
A1LU6
=
complib
.
FindCompound
(
"
A1LU6
"
)
comp_yolo
=
complib
.
FindCompound
(
"
yolo
"
)
self
.
assertFalse
(
comp_001
is
None
)
self
.
assertFalse
(
comp_
hello
is
None
)
self
.
assertFalse
(
comp_
A1LU6
is
None
)
self
.
assertTrue
(
comp_yolo
is
None
)
def
test_smiles
(
self
):
...
...
@@ -68,6 +74,50 @@ class TestCompLib(unittest.TestCase):
if
lib_version
<
ost
.
__version__
:
warnings
.
warn
(
"
Using old version of the compound library: %s
"
%
lib_version
)
def
test_ignore_reserved
(
self
):
compound_dict_path
=
os
.
path
.
join
(
"
testfiles
"
,
"
test_compounds.cif
"
)
complib_no_reserved_path
=
os
.
path
.
join
(
self
.
tmp_dir
.
name
,
"
test_complib_no_reserved.dat
"
)
CreateComplib
(
compound_dict_path
,
complib_no_reserved_path
,
[
"
-i
"
])
complib_no_reserved
=
conop
.
CompoundLib
.
Load
(
complib_no_reserved_path
)
# 01-98 are reserved
assert
self
.
complib
.
FindCompound
(
"
98
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
98
"
)
is
None
# DRG, INH and LIG are reserved
assert
self
.
complib
.
FindCompound
(
"
DRG
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
DRG
"
)
is
None
assert
self
.
complib
.
FindCompound
(
"
INH
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
INH
"
)
is
None
assert
self
.
complib
.
FindCompound
(
"
LIG
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
LIG
"
)
is
None
# OX is obsolete but not reserved
assert
complib_no_reserved
.
FindCompound
(
"
OX
"
)
is
not
None
# 00, 000, 001, 010, 986, 98B are not reserved
assert
complib_no_reserved
.
FindCompound
(
"
00
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
000
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
001
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
010
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
986
"
)
is
not
None
assert
complib_no_reserved
.
FindCompound
(
"
98B
"
)
is
not
None
def
test_ignore_obsolete
(
self
):
compound_dict_path
=
os
.
path
.
join
(
"
testfiles
"
,
"
test_compounds.cif
"
)
complib_no_obsolete_path
=
os
.
path
.
join
(
self
.
tmp_dir
.
name
,
"
test_complib_no_obsolete.dat
"
)
CreateComplib
(
compound_dict_path
,
complib_no_obsolete_path
,
[
"
-o
"
])
complib_no_obsolete
=
conop
.
CompoundLib
.
Load
(
complib_no_obsolete_path
)
# 01-98, DRG, INH and LIG are reserved but not obsolete
assert
complib_no_obsolete
.
FindCompound
(
"
98
"
)
is
not
None
assert
complib_no_obsolete
.
FindCompound
(
"
DRG
"
)
is
not
None
assert
complib_no_obsolete
.
FindCompound
(
"
INH
"
)
is
not
None
assert
complib_no_obsolete
.
FindCompound
(
"
LIG
"
)
is
not
None
# OX is obsolete
assert
complib_no_obsolete
.
FindCompound
(
"
OX
"
)
is
None
if
__name__
==
"
__main__
"
:
from
ost
import
testutils
...
...
This diff is collapsed.
Click to expand it.
modules/conop/tests/testfiles/test_compounds.cif
+
1913
−
531
View file @
c23afeb3
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