comparison asist_dynamic.ipynb @ 4:3ea72fb2eaac draft

Deleted selected files test files
author rakesh4osdd
date Wed, 30 Jun 2021 05:48:04 +0000
parents c1a77856070c
children
comparison
equal deleted inserted replaced
3:734777d3c253 4:3ea72fb2eaac
25 "from collections import Counter" 25 "from collections import Counter"
26 ] 26 ]
27 }, 27 },
28 { 28 {
29 "cell_type": "code", 29 "cell_type": "code",
30 "execution_count": 176, 30 "execution_count": 162,
31 "id": "d66ec0d2", 31 "id": "d66ec0d2",
32 "metadata": {}, 32 "metadata": {},
33 "outputs": [], 33 "outputs": [],
34 "source": [ 34 "source": [
35 "input_file=sys.argv[1]\n", 35 "#input_file=sys.argv[1]\n",
36 "output_file=sys.argv[2]\n", 36 "#output_file=sys.argv[2]\n",
37 "#input_file='test-data/asist_input.csv'\n", 37 "input_file='test-data/strains_788_input_16k.csv'\n",
38 "#output_file='test-data/asist_output.csv'" 38 "output_file='/mnt/d/PhD_Work/Tina_Work/ASIST_Galaxy/ASIST/strains_788_output_16k.csv'\n",
39 ] 39 "#input_file='/mnt/d/PhD_Work/Tina_Work/ASIST_Galaxy/ASIST/asist_example15.csv'\n",
40 }, 40 "#output_file='/mnt/d/PhD_Work/Tina_Work/ASIST_Galaxy/ASIST/asist_example15_output.csv'"
41 { 41 ]
42 "cell_type": "code", 42 },
43 "execution_count": 177, 43 {
44 "cell_type": "code",
45 "execution_count": 163,
44 "id": "bf24c946", 46 "id": "bf24c946",
45 "metadata": {}, 47 "metadata": {},
46 "outputs": [], 48 "outputs": [],
47 "source": [ 49 "source": [
48 "# strain_profile to phenotype condition\n", 50 "# strain_profile to phenotype condition\n",
75 "#print(s_phen(1,9,0,0))" 77 "#print(s_phen(1,9,0,0))"
76 ] 78 ]
77 }, 79 },
78 { 80 {
79 "cell_type": "code", 81 "cell_type": "code",
80 "execution_count": 178, 82 "execution_count": 164,
81 "id": "8bad7d9d", 83 "id": "8bad7d9d",
82 "metadata": {}, 84 "metadata": {},
83 "outputs": [], 85 "outputs": [],
84 "source": [ 86 "source": [
85 "# define Antibiotic groups as per antibiotic of CLSI breakpoints MIC\n", 87 "# define Antibiotic groups as per antibiotic of CLSI breakpoints MIC\n",
150 " return(s_phen(sus,res,intm,na,pb_sus))" 152 " return(s_phen(sus,res,intm,na,pb_sus))"
151 ] 153 ]
152 }, 154 },
153 { 155 {
154 "cell_type": "code", 156 "cell_type": "code",
155 "execution_count": 179, 157 "execution_count": 165,
156 "id": "7629fc10", 158 "id": "7629fc10",
157 "metadata": {}, 159 "metadata": {},
158 "outputs": [], 160 "outputs": [],
159 "source": [ 161 "source": [
160 "#input_file='input2.csv_table.csv'\n", 162 "#input_file='input2.csv_table.csv'\n",
162 "strain_profile=pd.read_csv(input_file, sep=',',na_filter=False,skipinitialspace = True)" 164 "strain_profile=pd.read_csv(input_file, sep=',',na_filter=False,skipinitialspace = True)"
163 ] 165 ]
164 }, 166 },
165 { 167 {
166 "cell_type": "code", 168 "cell_type": "code",
167 "execution_count": 180, 169 "execution_count": 166,
168 "id": "bed1abba", 170 "id": "bed1abba",
169 "metadata": {}, 171 "metadata": {},
170 "outputs": [], 172 "outputs": [],
171 "source": [ 173 "source": [
172 "old_strain_name=strain_profile.columns[0]\n", 174 "old_strain_name=strain_profile.columns[0]\n",
173 "new_strain_name=old_strain_name.capitalize().strip().replace(' ', '')" 175 "new_strain_name=old_strain_name.capitalize().strip().replace(' ', '')"
174 ] 176 ]
175 }, 177 },
176 { 178 {
177 "cell_type": "code", 179 "cell_type": "code",
178 "execution_count": 181, 180 "execution_count": 167,
179 "id": "a64b5022", 181 "id": "a64b5022",
180 "metadata": {}, 182 "metadata": {},
181 "outputs": [], 183 "outputs": [],
182 "source": [ 184 "source": [
183 "# make header capitalization, remove leading,lagging, and multiple whitespace for comparision\n", 185 "# make header capitalization, remove leading,lagging, and multiple whitespace for comparision\n",
187 "#strain_profile.columns" 189 "#strain_profile.columns"
188 ] 190 ]
189 }, 191 },
190 { 192 {
191 "cell_type": "code", 193 "cell_type": "code",
192 "execution_count": 182, 194 "execution_count": 168,
193 "id": "caac57d7", 195 "id": "caac57d7",
194 "metadata": {}, 196 "metadata": {},
195 "outputs": [], 197 "outputs": [],
196 "source": [ 198 "source": [
197 "# add new column in dataframe on second position\n", 199 "# add new column in dataframe on second position\n",
199 "#strain_profile.head()" 201 "#strain_profile.head()"
200 ] 202 ]
201 }, 203 },
202 { 204 {
203 "cell_type": "code", 205 "cell_type": "code",
204 "execution_count": 183, 206 "execution_count": 169,
205 "id": "eb4b0c4d", 207 "id": "eb4b0c4d",
206 "metadata": { 208 "metadata": {
207 "scrolled": true 209 "scrolled": true
208 }, 210 },
209 "outputs": [], 211 "outputs": [],
211 "strain_profile['Strain phenotype'] = strain_profile.apply(lambda x: (s_profiler(x)), axis=1)" 213 "strain_profile['Strain phenotype'] = strain_profile.apply(lambda x: (s_profiler(x)), axis=1)"
212 ] 214 ]
213 }, 215 },
214 { 216 {
215 "cell_type": "code", 217 "cell_type": "code",
216 "execution_count": 184, 218 "execution_count": 170,
217 "id": "86441c0f", 219 "id": "86441c0f",
218 "metadata": {}, 220 "metadata": {},
219 "outputs": [], 221 "outputs": [],
220 "source": [ 222 "source": [
221 "#strain_profile.head()" 223 "#strain_profile.head()"
222 ] 224 ]
223 }, 225 },
224 { 226 {
225 "cell_type": "code", 227 "cell_type": "code",
226 "execution_count": 185, 228 "execution_count": 171,
227 "id": "75698be5", 229 "id": "75698be5",
228 "metadata": {}, 230 "metadata": {},
229 "outputs": [], 231 "outputs": [],
230 "source": [ 232 "source": [
231 "#rename headers for old name\n", 233 "#rename headers for old name\n",
232 "strain_profile=strain_profile.rename(columns = {new_strain_name:old_strain_name, 'Ticarcillin/clavulanicacid':'Ticarcillin/ clavulanic acid','Piperacillin/tazobactam':'Piperacillin/ tazobactam','Trimethoprim/sulfamethoxazole': 'Trimethoprim/ sulfamethoxazole','Ampicillin/sulbactam':'Ampicillin/ sulbactam', 'Polymyxinb': 'Polymyxin B'} )" 234 "strain_profile=strain_profile.rename(columns = {new_strain_name:old_strain_name, 'Ticarcillin/clavulanicacid':'Ticarcillin/ clavulanic acid','Piperacillin/tazobactam':'Piperacillin/ tazobactam','Trimethoprim/sulfamethoxazole': 'Trimethoprim/ sulfamethoxazole','Ampicillin/sulbactam':'Ampicillin/ sulbactam', 'Polymyxinb': 'Polymyxin B'} )"
233 ] 235 ]
234 }, 236 },
235 { 237 {
236 "cell_type": "code", 238 "cell_type": "code",
237 "execution_count": 186, 239 "execution_count": 172,
238 "id": "c14a13eb", 240 "id": "c14a13eb",
239 "metadata": { 241 "metadata": {
240 "scrolled": true 242 "scrolled": true
241 }, 243 },
242 "outputs": [], 244 "outputs": [],
244 "#strain_profile.columns" 246 "#strain_profile.columns"
245 ] 247 ]
246 }, 248 },
247 { 249 {
248 "cell_type": "code", 250 "cell_type": "code",
249 "execution_count": 187, 251 "execution_count": 173,
250 "id": "ff484767", 252 "id": "1b113050",
251 "metadata": {}, 253 "metadata": {},
252 "outputs": [], 254 "outputs": [],
253 "source": [ 255 "source": [
254 "#strain_profile" 256 "#strain_profile"
255 ] 257 ]
256 }, 258 },
257 { 259 {
258 "cell_type": "code", 260 "cell_type": "code",
259 "execution_count": 188, 261 "execution_count": 174,
260 "id": "5ab72211", 262 "id": "5ab72211",
261 "metadata": {}, 263 "metadata": {},
262 "outputs": [], 264 "outputs": [],
263 "source": [ 265 "source": [
264 "strain_profile.to_csv(output_file,na_rep='NA',index=False)" 266 "strain_profile.to_csv(output_file,na_rep='NA',index=False)"
265 ] 267 ]
266 }, 268 },
267 { 269 {
268 "cell_type": "code", 270 "cell_type": "code",
269 "execution_count": 189, 271 "execution_count": 175,
270 "id": "020dbe85", 272 "id": "c17c84c4",
271 "metadata": {}, 273 "metadata": {},
272 "outputs": [], 274 "outputs": [],
273 "source": [ 275 "source": [
274 "# Open a file with access mode 'a'\n", 276 "# Open a file with access mode 'a'\n",
275 "with open(output_file, \"a\") as file_object:\n", 277 "with open(output_file, \"a\") as file_object:\n",
278 ] 280 ]
279 }, 281 },
280 { 282 {
281 "cell_type": "code", 283 "cell_type": "code",
282 "execution_count": null, 284 "execution_count": null,
283 "id": "9c17e66a", 285 "id": "7e8e1fa8",
284 "metadata": {}, 286 "metadata": {},
285 "outputs": [], 287 "outputs": [],
286 "source": [] 288 "source": []
287 } 289 }
288 ], 290 ],