comparison umelt_service.py @ 6:f201e8c6e004 draft default tip

Uploaded
author ben-warren
date Mon, 07 Jul 2014 19:28:17 -0400
parents b321e0517be3
children
comparison
equal deleted inserted replaced
5:b321e0517be3 6:f201e8c6e004
20 data = urllib.urlencode(values) 20 data = urllib.urlencode(values)
21 req = urllib2.Request(url, data) 21 req = urllib2.Request(url, data)
22 try: 22 try:
23 response = urllib2.urlopen(req,timeout=timeout_sec) 23 response = urllib2.urlopen(req,timeout=timeout_sec)
24 except urllib2.HTTPError, e: 24 except urllib2.HTTPError, e:
25 print 'The server couldn\'t fulfill the request.' 25 print >> sys.stderr, 'The server couldn\'t fulfill the request.'
26 print 'Error code: ', e.code 26 print >> sys.stderr, 'Error code: ', e.code
27 except urllib2.URLError, e: 27 except urllib2.URLError, e:
28 print 'We failed to reach a server.' 28 print >> sys.stderr, 'We failed to reach a server.'
29 print 'Reason: ', e.reason 29 print >> sys.stderr, 'Reason: ', e.reason
30 else: 30 else:
31 melt_data = response.read() 31 melt_data = response.read()
32 tree = ET.fromstring(melt_data) 32 tree = ET.fromstring(melt_data)
33 helicity = [amp.find('helicity').text.split() for amp in tree.findall('amplicon')] 33 helicity = [amp.find('helicity').text.split() for amp in tree.findall('amplicon')]
34 hels = np.array(helicity[0], dtype=np.float32).transpose() 34 hels = np.array(helicity[0], dtype=np.float32).transpose()