[MOBY-dev] bioMoby Python, dynamic typing and multithreading (client side)

ywong at infobiogen.fr ywong at infobiogen.fr
Tue Jan 11 14:28:30 UTC 2005


Hello and Happy new year ^O^

I have made some modifications on the API of bioMoby Python (however, I
haven't commited the changes yet as I have to review the documentation)

The modifications are:
-Multithreading on the client side of service execution (no need to wait
the end of the execution of a service before invoking another, it is
useful when you have different services to query at the same time (as an
HTTP transaction is rather slow, we can use that time to send other
queries)

The syntax would look like this:

firstService=Service(wsdl)
firstService.start(mobyQueries, timeout=50)
secondService=Service(wsdl)
secondService.start(mobyQueries, timeout=50)
thirdService=Service(wsdl)
thirdService.start(mobyQueries, timeout=50)

firstService.join()
secondService.join()
thirdService.join()

A property in Service class will allow user to manipulate directly the
thread object which will enable rendez-vous techniques, locks, and so
on...

Webservices are already slow, if we can send several queries at different
services at the same time, it won't be a luxury I believe...

-Use of Python's ability for dynamic typing to build classes from scratch
(even methods!):
No need of moby2python to generate classes from bioMoby definition. It is
now the job of mobyUnmarshaller.


from bioMoby import mobyUnmarshaller

um=MobyUnmarshaller()
r=um.loads(<an moby XML object>)
r will contain a generated python instance of a Class with attributes
generated from the XML (only attributes, partial deserialization)

for serialization:
m=MobyMarshaller()

m.dumps(a Python Object)
<a Moby XML compliant object>

an example:

a=(1,2,3,4,5)

m.dumps(a)

'<moby:Tuple moby:namespace=""><moby:Element><moby:Integer
>1</moby:Integer></moby:Element><moby:Element><moby:Integer
>2</moby:Integer></moby:Element><moby:Element><moby:Integer
>3</moby:Integer></moby:Element><moby:Element><moby:Integer
>4</moby:Integer></moby:Element><moby:Element><moby:Integer
>5</moby:Integer></moby:Element></moby:Tuple>'

It also works for objects:

class DNASequence(object):
    def __init__(self, sequence):
        self.SequenceString=sequence
        self.Length=len(sequence)

seq=DNASequence("ACGTAGCATGCTAGCTAGCTAGCATGCT")
m.dumps(seq)

<moby:DNASequence ><moby:Integer >28</moby:Integer><moby:String
>ACGTAGCATGCTAGCTAGCTAGCATGCT</moby:String></moby:DNASequence>




More information about the MOBY-dev mailing list