Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
iPPIDB
ippidb-web
Commits
011dac85
Commit
011dac85
authored
6 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
add functions to generate InChi and InChiKey
part of #80 Former-commit-id: e53db3ee8f88b741ef33e30884f3cf57aff072cb
parent
df7a69e9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ippisite/ippidb/tests.py
+17
-1
17 additions, 1 deletion
ippisite/ippidb/tests.py
ippisite/ippidb/utils.py
+18
-0
18 additions, 0 deletions
ippisite/ippidb/utils.py
with
35 additions
and
1 deletion
ippisite/ippidb/tests.py
+
17
−
1
View file @
011dac85
...
...
@@ -4,7 +4,7 @@ from django.test import TestCase
from
openbabel
import
vectorUnsignedInt
from
.models
import
Compound
,
CompoundTanimoto
,
create_tanimoto
from
.utils
import
FingerPrinter
,
mol2smi
,
smi2mol
from
.utils
import
FingerPrinter
,
mol2smi
,
smi2mol
,
smi2inchi
,
smi2inchikey
class
MolSmiTestCase
(
TestCase
):
"""
...
...
@@ -22,6 +22,22 @@ class MolSmiTestCase(TestCase):
def
test_smi2mol2smi
(
self
):
self
.
assertTrue
(
re
.
compile
(
self
.
mol_str
).
match
(
smi2mol
(
self
.
smiles_str
)))
class
SmiInchi
(
TestCase
):
"""
Test INCHI and INCHIKEY generation functions
"""
def
setUp
(
self
):
self
.
smiles_str
=
"
CC(C)C(=O)C1=C(C(=C(C(=C1)C(=O)C2=CC=C(C=C2)OC3=CC=CC=C3)O)O)O
"
self
.
inchi_str
=
"
InChI=1S/C23H20O6/c1-13(2)19(24)17-12-18(22(27)23(28)21(17)26)20(25)14-8-10-16(11-9-14)29-15-6-4-3-5-7-15/h3-13,26-28H,1-2H3
"
self
.
inchikey_str
=
"
CVVQMBDTMYUWTR-UHFFFAOYSA-N
"
def
test_smi2inchi
(
self
):
self
.
assertEqual
(
smi2inchi
(
self
.
smiles_str
),
self
.
inchi_str
)
def
test_smi2inchikey
(
self
):
self
.
assertEqual
(
smi2inchikey
(
self
.
smiles_str
),
self
.
inchikey_str
)
class
FingerPrinterTestCase
(
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
ippisite/ippidb/utils.py
+
18
−
0
View file @
011dac85
...
...
@@ -16,6 +16,24 @@ def smi2mol(smi_string):
pybel
.
_operations
[
'
gen2D
'
].
Do
(
m
.
OBMol
)
return
m
.
write
(
format
=
'
mol
'
)
smi2inchi_conv
=
ob
.
OBConversion
()
smi2inchi_conv
.
SetInAndOutFormats
(
"
smi
"
,
"
inchi
"
)
def
smi2inchi
(
smi_string
):
mol
=
ob
.
OBMol
()
smi2inchi_conv
.
ReadString
(
mol
,
smi_string
)
return
smi2inchi_conv
.
WriteString
(
mol
).
strip
()
smi2inchikey_conv
=
ob
.
OBConversion
()
smi2inchikey_conv
.
SetInAndOutFormats
(
"
smi
"
,
"
inchi
"
)
smi2inchikey_conv
.
SetOptions
(
"
K
"
,
smi2inchikey_conv
.
OUTOPTIONS
)
def
smi2inchikey
(
smi_string
):
mol
=
ob
.
OBMol
()
smi2inchikey_conv
.
ReadString
(
mol
,
smi_string
)
return
smi2inchikey_conv
.
WriteString
(
mol
).
strip
()
class
FingerPrinter
(
object
):
def
__init__
(
self
,
name
=
"
FP4
"
):
...
...
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