Skip to content
Snippets Groups Projects
Commit 939603f5 authored by Vermaat's avatar Vermaat
Browse files

Add SOAP method getdbSNPDescriptions.

parent ebeeace5
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
from mutalyzer.util import monkey_patch_suds; monkey_patch_suds()
import sys
from suds.client import Client
URL = 'http://localhost/mutalyzer/services/?wsdl'
if len(sys.argv) < 2:
print 'Please provide a dbSNP rs number'
sys.exit(1)
c = Client(URL, cache=None)
o = c.service
# Example: rs9919552
print 'Getting HGVS descriptions for ' + sys.argv[1] + ' ...'
r = o.getdbSNPDescriptions(sys.argv[1])
if r:
for description in r.string:
print description
......@@ -913,6 +913,38 @@ class MutalyzerService(DefinitionBase):
return map(cache_entry_to_soap, cache)
#getCache
@soap(Mandatory.String, _returns = Array(Mandatory.String))
def getdbSNPDescriptions(self, rs_id):
"""
Lookup HGVS descriptions for a dbSNP rs identifier.
@arg rs_id: The dbSNP rs identifier, e.g. 'rs9919552'.
@type rs_id: string
@return: List of HGVS descriptions.
@rtype: list(string)
"""
output = Output(__file__, self._config.Output)
output.addMessage(__file__, -1, 'INFO',
'Received request getdbSNPDescription(%s)' % rs_id)
retriever = Retriever.Retriever(self._config.Retriever, output, None)
descriptions = retriever.snpConvert(rs_id)
output.addMessage(__file__, -1, 'INFO',
'Finished processing getdbSNPDescription(%s)' % rs_id)
# Todo: use SOAP Fault object here (see Trac issue #41).
messages = output.getMessages()
if messages:
error = 'The request could not be completed\n' \
+ '\n'.join(map(lambda m: str(m), output.getMessages()))
raise Exception(error)
return descriptions
#getdbSNPDescriptions
#MutalyzerService
......
......@@ -12,13 +12,25 @@ from mutalyzer.config import Config
from mutalyzer.output import Output
from mutalyzer.sync import CacheSync
from mutalyzer import Db
import logging; logging.raiseExceptions = 0
import logging
import urllib2
from suds.client import Client
from suds import WebFault
from nose.tools import *
# Suds logs an awful lot of things with level=DEBUG, including entire WSDL
# files and SOAP responses. On any error, this is all dumped to the console,
# which is very unconvenient. The following suppresses most of this.
logging.raiseExceptions = 0
logging.basicConfig(level=logging.INFO)
for logger in ('suds.metrics', 'suds.wsdl', 'suds.xsd.schema',
'suds.xsd.sxbasic', 'suds.xsd.sxbase', 'suds.xsd.query',
'suds.transport.http', 'suds.xsd.deplist', 'suds.mx.core',
'suds.mx.literal', 'suds.resolver'):
logging.getLogger(logger).setLevel(logging.ERROR)
WSDL_URL = 'http://localhost/mutalyzer/services/?wsdl'
......@@ -179,3 +191,14 @@ class TestWebservice():
r = self.client.service.getCache(created_since)
assert_equal(len(r.CacheEntry), len(cache))
def test_getdbsnpdescriptions(self):
"""
Running getdbSNPDescriptions method should give us the expected HGVS
descriptions for the given dbSNP id.
"""
r = self.client.service.getdbSNPDescriptions('rs9919552')
assert 'NC_000011.9:g.111959625C>T' in r.string
assert 'NG_012337.1:g.7055C>T' in r.string
assert 'NM_003002.2:c.204C>T' in r.string
assert 'NP_002993.1:p.Ser68=' in r.string
......@@ -202,11 +202,12 @@ class TestWSGI():
form = r.forms[0]
form['rsId'] = 'rs9919552'
r = form.submit()
#r.mustcontain('0 Errors',
# '0 Warnings',
# 'NG_012337.1:g.7055C>T',
# 'NM_003002.2:c.204C>T',
# 'NT_033899.8:g.15522041C>T')
r.mustcontain('0 Errors',
'0 Warnings',
'NC_000011.9:g.111959625C>T',
'NG_012337.1:g.7055C>T',
'NM_003002.2:c.204C>T',
'NP_002993.1:p.Ser68=')
def test_snp_converter_invalid(self):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment