Created
November 26, 2015 13:56
-
-
Save rokroskar/33ba0639cbfa1e919f04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 136, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import xml.etree.ElementTree as ET" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 137, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"with open('/Users/rok/Downloads/liquidnames.txt') as f: \n", | |
" liquid_names = {liquid_name.rstrip() for liquid_name in f.readlines()}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 138, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"tree = ET.parse('/Users/rok/Downloads/LiquidDescription.xml')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 139, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"root = tree.getroot()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 140, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"previous_length = 0\n", | |
"current_length = len(root)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 142, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"<Element 'liquid' at 0x1074148d0>\n", | |
"A-beta diluted sample 1/20\n", | |
"IBL Serum 1mm\n", | |
"Predilution Amyloid-beta\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1073f27d0>\n", | |
"B12 diluted samples\n", | |
"IBL Serum 1mm\n", | |
"Predilution Active B12\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072e1b90>\n", | |
"diluted samples_Test\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution_Test\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072e1290>\n", | |
"Dilution 1 Cystatin C CAL B\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071fe550>\n", | |
"Dilution 1 Cystatin C CAL D\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071d2950>\n", | |
"Dilution 1 Cystatin C CAL F\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071d2510>\n", | |
"Dilution 1 Cystatin C CONTROL High End\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071d2110>\n", | |
"Dilution 1 Cystatin C CONTROL Low End\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071c7f90>\n", | |
"Dilution 2 Cystatin C Cal A\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071c7d90>\n", | |
"Dilution 2 Cystatin C Cal C\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071c7210>\n", | |
"Dilution 2 Cystatin C Cal E\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071bc750>\n", | |
"Dilution 2 Cystatin C Control High\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071bcb90>\n", | |
"Dilution 2 Cystatin C Control Low\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071a8990>\n", | |
"Dilution 2 Cystatin C Samples\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071a8910>\n", | |
"DOP CAL A diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107237210>\n", | |
"DOP CAL C diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x10724c190>\n", | |
"DOP CAL E diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071351d0>\n", | |
"DOP CONTROL 1 diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107135990>\n", | |
"DOP CONTROL 2 diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107135e10>\n", | |
"DOP Sample diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107326d90>\n", | |
"GLUT CAL A\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1073301d0>\n", | |
"GLUT CAL C\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107330650>\n", | |
"GLUT CAL E\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1073462d0>\n", | |
"GLUT CONTROL 1\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107346690>\n", | |
"GLUT CONTROL 2\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107346ad0>\n", | |
"GLUT SAMPLE\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x10737b210>\n", | |
"hTau total dil samples ditis\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution hTau total_ditis_v1\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x10737b910>\n", | |
"hTau total diluted samples\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution hTau total_v2\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107390510>\n", | |
"hTau total diluted samples_Test4\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution hTau total_Test4\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x106f93ad0>\n", | |
"NAD diluted samples\n", | |
"IBL Water 1mm\n", | |
"Predilution Noradrenalin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072f8050>\n", | |
"Predil LC verify\n", | |
"IBL Water 1mm_tiptouch\n", | |
"predil_LC verify\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072f8510>\n", | |
"Predil Precise ditis\n", | |
"IBL Water 3mm_tiptouch\n", | |
"Predil Precise ditis\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072f8a90>\n", | |
"Predilution pTau\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution pTau_v1\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071ba0d0>\n", | |
"Test_Mix_Dilution\n", | |
"IBL Serum 1mm_mix@asp\n", | |
"Mix Test\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1073f2390>\n", | |
"Borrelia diluted samples\n", | |
"IBL Serum 2mm\n", | |
"Predilution Borrelia IgG\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072e17d0>\n", | |
"Dilution 1 Cystatin C CAL A\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071fe110>\n", | |
"Dilution 1 Cystatin C CAL E\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1072b5690>\n", | |
"Dilution 1 Cystatin C CONTROL Low\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071c7690>\n", | |
"Dilution 2 Cystatin C Cal B\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071bc210>\n", | |
"Dilution 2 Cystatin C Cal F\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071bc410>\n", | |
"Dilution 2 Cystatin C Control Low End\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107237290>\n", | |
"DOP CAL B diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107135310>\n", | |
"DOP CAL F diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107135bd0>\n", | |
"DOP CONTROL 2 End diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107326fd0>\n", | |
"GLUT CAL B\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1073308d0>\n", | |
"GLUT CAL F\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1073468d0>\n", | |
"GLUT CONTROL 2 end\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x10737b410>\n", | |
"hTau total dil samples ditis2\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution hTau total_ditis_v2\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071fe410>\n", | |
"Dilution 1 Cystatin C CAL C\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071c7a90>\n", | |
"Dilution 1 Cystatin C Sample\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071bc810>\n", | |
"Dilution 2 Cystatin C Control High End\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107237b10>\n", | |
"DOP CAL D diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107330410>\n", | |
"GLUT CAL D\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x10737be10>\n", | |
"hTau total diluted samples_Test3\n", | |
"IBL Water 1mm_mix@asp\n", | |
"Predilution hTau total_Test3\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071d2a10>\n", | |
"Dilution 1 Cystatin C CONTROL High\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107135750>\n", | |
"DOP CONTROL 1 End diluted\n", | |
"IBL Water 1mm\n", | |
"Predilution Dopamin\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x107346490>\n", | |
"GLUT CONTROL 1 end\n", | |
"IBL Serum 1mm\n", | |
"Predilution Glutamate\n", | |
"\n", | |
" \n", | |
"<Element 'liquid' at 0x1071c7890>\n", | |
"Dilution 2 Cystatin C Cal D\n", | |
"IBL Serum 1mm\n", | |
"Predilution Cystatin C\n", | |
"\n", | |
" \n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/Users/rok/miniconda/lib/python2.7/site-packages/ipykernel/__main__.py:5: DeprecationWarning: This method will be removed in future versions. Use 'list(elem)' or iteration over elem instead.\n" | |
] | |
} | |
], | |
"source": [ | |
"while current_length != previous_length:\n", | |
" for x in root: \n", | |
" if x.find('name').text in liquid_names:\n", | |
" print x\n", | |
" for child in x.getchildren() : \n", | |
" print child.text\n", | |
" root.remove(x)\n", | |
" previous_length = current_length\n", | |
" current_length = len(root)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 143, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 143, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"any([t.find('name') in liquid_names for t in root.getiterator()])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 144, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"328" | |
] | |
}, | |
"execution_count": 144, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"len(root)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment