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
324600c1
Commit
324600c1
authored
6 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
Adding iupac to smiles converter for #42
parent
77529bc7
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
Wizard form
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ippisite/ippidb/tests.py
+39
-0
39 additions, 0 deletions
ippisite/ippidb/tests.py
ippisite/ippidb/ws.py
+18
-0
18 additions, 0 deletions
ippisite/ippidb/ws.py
with
57 additions
and
0 deletions
ippisite/ippidb/tests.py
+
39
−
0
View file @
324600c1
...
...
@@ -404,3 +404,42 @@ class TestGetPDBUniProtMapping(TestCase):
def
test_entry_not_found
(
self
):
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
get_pdb_uniprot_mapping
,
'
Xu85
'
)
class
TestConvertIUPACToSMILESAndMore
(
TestCase
):
"""
Test converting a IUPAC to smiles and inchi with opsin web service
"""
def
test_valid
(
self
):
pairs
=
[
(
'
2,4,6-trinitrotoluene
'
,
{
"
inchi
"
:
"
InChI=1/C7H5N3O6/c1-4-6(9(13)14)2-5(8(11)12)3-7(4)10(15)16/h2-3H,1H3
"
,
"
stdinchi
"
:
"
InChI=1S/C7H5N3O6/c1-4-6(9(13)14)2-5(8(11)12)3-7(4)10(15)16/h2-3H,1H3
"
,
"
stdinchikey
"
:
"
SPSSULHKWOKEEL-UHFFFAOYSA-N
"
,
"
smiles
"
:
"
[N+](=O)([O-])C1=C(C)C(=CC(=C1)[N+](=O)[O-])[N+](=O)[O-]
"
,
}
),
(
'
3-{1-oxo-6-[4-(piperidin-4-yl)butanamido]-2,3-dihydro-1H-isoindol-2-yl}propanoic acid
'
,
{
"
inchi
"
:
"
InChI=1/C20H27N3O4/c24-18(3-1-2-14-6-9-21-10-7-14)22-16-5-4-15-13-23(11-8-19(25)26)20(27)17(15)12-16/h4-5,12,14,21H,1-3,6-11,13H2,(H,22,24)(H,25,26)/f/h22,25H
"
,
"
stdinchi
"
:
"
InChI=1S/C20H27N3O4/c24-18(3-1-2-14-6-9-21-10-7-14)22-16-5-4-15-13-23(11-8-19(25)26)20(27)17(15)12-16/h4-5,12,14,21H,1-3,6-11,13H2,(H,22,24)(H,25,26)
"
,
"
stdinchikey
"
:
"
HWRXVANHVCXVHA-UHFFFAOYSA-N
"
,
"
smiles
"
:
"
O=C1N(CC2=CC=C(C=C12)NC(CCCC1CCNCC1)=O)CCC(=O)O
"
}
)
]
for
iupac
,
dict_expected
in
pairs
:
dict_returned
=
ws
.
convert_iupac_to_smiles_and_inchi
(
iupac
)
self
.
assertEqual
(
dict_expected
,
dict_returned
)
self
.
assertEqual
(
dict_expected
[
"
smiles
"
],
ws
.
convert_iupac_to_smiles
(
iupac
))
def
test_invalide_entry
(
self
):
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
convert_iupac_to_smiles_and_inchi
,
'
3-{1-oxo-6-[4-(piperid
'
)
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
convert_iupac_to_smiles_and_inchi
,
None
)
This diff is collapsed.
Click to expand it.
ippisite/ippidb/ws.py
+
18
−
0
View file @
324600c1
...
...
@@ -4,6 +4,7 @@ iPPI-DB web-service client utility functions
import
json
import
xml.etree.ElementTree
as
ET
from
urllib
import
parse
as
urllib_parse
import
requests
from
bioservices.eutils
import
EUtils
...
...
@@ -363,3 +364,20 @@ def pdb_entry_exists(pdb_id):
return
False
else
:
return
True
def
convert_iupac_to_smiles
(
iupac
):
return
convert_iupac_to_smiles_and_inchi
(
iupac
)[
"
smiles
"
]
def
convert_iupac_to_smiles_and_inchi
(
iupac
):
if
iupac
is
None
:
raise
EntryNotFoundError
(
iupac
,
422
)
resp
=
requests
.
get
(
'
https://opsin.ch.cam.ac.uk/opsin/{}
'
.
format
(
urllib_parse
.
quote
(
iupac
,
safe
=
''
)))
if
resp
.
status_code
!=
200
:
raise
EntryNotFoundError
(
iupac
,
resp
.
status_code
)
ret
=
resp
.
json
()
ret
.
pop
(
"
cml
"
)
ret
.
pop
(
"
message
"
)
return
ret
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