Mercurial > repos > rakesh4osdd > clsi_profile
annotate asist_dynamic.py @ 9:b3c01b790314 draft
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
author | rakesh4osdd |
---|---|
date | Wed, 30 Jun 2021 06:37:12 +0000 |
parents | |
children |
rev | line source |
---|---|
9
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
1 #!/usr/bin/env python |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
2 # coding: utf-8 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
3 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
4 # In[1309]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
5 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
6 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
7 #ASIST program for phenotype based on Antibiotics profile |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
8 # create a profile based on selected antibiotics only |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
9 # rakesh4osdd@gmail.com, 14-June-2021 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
10 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
11 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
12 # In[1]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
13 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
14 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
15 import pandas as pd |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
16 import sys |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
17 import os |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
18 from collections import Counter |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
19 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
20 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
21 # In[176]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
22 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
23 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
24 input_file=sys.argv[1] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
25 output_file=sys.argv[2] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
26 #input_file='test-data/asist_input.csv' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
27 #output_file='test-data/asist_output.csv' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
28 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
29 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
30 # In[177]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
31 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
32 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
33 # strain_profile to phenotype condition |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
34 def s_phen(sus,res,intm,na,pb_sus): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
35 if (sus>0 and res==0 and na>=0): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
36 #print('Possible Susceptible') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
37 phen='Possible Susceptible' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
38 elif (sus>=0 and 3<=res<7 and na>=0 and pb_sus==0): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
39 #print('Possible MDR') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
40 phen='Possible MDR' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
41 elif (sus>=0 and 7<=res<9 and na>=0 and pb_sus==0): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
42 #print('Possible XDR') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
43 phen='Possible XDR' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
44 #special cases |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
45 elif (sus>=1 and res>0 and na>=0 and pb_sus==1): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
46 #print('Possible XDR') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
47 phen='Possible XDR' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
48 #special cases |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
49 elif (sus>0 and res==9 and na>=0): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
50 #print('Possible XDR') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
51 phen='Possible XDR' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
52 elif (sus==0 and res==9 and na>=0): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
53 #print('Possible TDR') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
54 phen='Possible TDR' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
55 else: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
56 #print('Strain could not be classified') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
57 phen='Strain could not be classified ('+ str(intm)+' | ' + str(na) +')' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
58 return(phen) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
59 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
60 #print(s_phen(1,9,0,0)) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
61 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
62 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
63 # In[178]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
64 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
65 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
66 # define Antibiotic groups as per antibiotic of CLSI breakpoints MIC |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
67 #Aminoglycoside |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
68 cat1=['Amikacin','Tobramycin','Gentamycin','Netilmicin'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
69 #Beta-lactams- Carbapenems |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
70 cat2=['Imipenem','Meropenam','Doripenem'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
71 #Fluoroquinolone |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
72 cat3=['Ciprofloxacin','Levofloxacin'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
73 #Beta-lactam inhibitor |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
74 cat4=['Piperacillin/tazobactam','Ticarcillin/clavulanicacid'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
75 #Cephalosporin |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
76 cat5=['Cefotaxime','Ceftriaxone','Ceftazidime','Cefepime'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
77 #Sulfonamides |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
78 cat6=['Trimethoprim/sulfamethoxazole'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
79 #Penicillins/beta-lactamase |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
80 cat7=['Ampicillin/sulbactam'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
81 #Polymyxins |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
82 cat8=['Colistin','Polymyxinb'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
83 #Tetracycline |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
84 cat9=['Tetracycline','Doxicycline','Minocycline'] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
85 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
86 def s_profiler(pd_series): |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
87 #print(type(pd_series),'\n', pd_series) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
88 #create a dictionary of dataframe series |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
89 cats={'s1':cat1,'s2':cat2,'s3':cat3,'s4':cat4,'s5':cat5,'s6':cat6,'s7':cat7,'s8':cat8,'s9':cat9} |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
90 # find the antibiotics name in input series |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
91 for cat in cats: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
92 #print(cats[cat]) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
93 cats[cat]=pd_series.filter(cats[cat]) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
94 #print(cats[cat]) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
95 #define res,sus,intm,na,pb_sus |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
96 res=0 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
97 sus=0 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
98 intm=0 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
99 na=0 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
100 pb_sus=0 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
101 # special case of 'Polymyxin b' for its value |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
102 if 'Polymyxinb' in pd_series: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
103 ctp=cats['s8']['Polymyxinb'].strip().lower() |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
104 if ctp == 'susceptible': |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
105 pb_sus=1 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
106 #print((ctp,p_sus)) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
107 # check all categories |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
108 for cat in cats: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
109 #ctp=cats['s8'].iloc[i:i+1].stack().value_counts().to_dict() |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
110 #print(ctp) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
111 # Pandas series |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
112 ct=cats[cat].value_counts().to_dict() |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
113 #print(ct) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
114 # remove whitespace and convert to lowercase words |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
115 ct = {k.strip().lower(): v for k, v in ct.items()} |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
116 #print(ct) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
117 k=Counter(ct) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
118 #j=Counter(ct)+Counter(j) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
119 #print(j) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
120 # category wise marking |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
121 if k['resistant']>=1: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
122 res=res+1 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
123 if k['susceptible']>=1: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
124 sus=sus+1 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
125 if k['intermediate']>=1: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
126 intm=intm+1 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
127 if k['na']>=1: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
128 na=na+1 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
129 #print(sus,res,intm,na,pb_sus) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
130 #print(s_phen(sus,res,intm,na,pb_sus)) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
131 return(s_phen(sus,res,intm,na,pb_sus)) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
132 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
133 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
134 # In[179]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
135 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
136 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
137 #input_file='input2.csv_table.csv' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
138 #output_file=input_file+'_output.txt' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
139 strain_profile=pd.read_csv(input_file, sep=',',na_filter=False,skipinitialspace = True) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
140 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
141 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
142 # In[180]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
143 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
144 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
145 old_strain_name=strain_profile.columns[0] |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
146 new_strain_name=old_strain_name.capitalize().strip().replace(' ', '') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
147 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
148 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
149 # In[181]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
150 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
151 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
152 # make header capitalization, remove leading,lagging, and multiple whitespace for comparision |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
153 strain_profile.columns=strain_profile.columns.str.capitalize().str.strip().str.replace('\s+', '', regex=True) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
154 #print(strain_profile.columns) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
155 #strain_profile.head() |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
156 #strain_profile.columns |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
157 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
158 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
159 # In[182]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
160 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
161 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
162 # add new column in dataframe on second position |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
163 strain_profile.insert(1, 'Strain phenotype','') |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
164 #strain_profile.head() |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
165 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
166 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
167 # In[183]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
168 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
169 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
170 strain_profile['Strain phenotype'] = strain_profile.apply(lambda x: (s_profiler(x)), axis=1) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
171 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
172 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
173 # In[184]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
174 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
175 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
176 #strain_profile.head() |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
177 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
178 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
179 # In[185]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
180 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
181 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
182 #rename headers for old name |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
183 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'} ) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
184 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
185 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
186 # In[186]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
187 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
188 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
189 #strain_profile.columns |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
190 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
191 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
192 # In[187]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
193 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
194 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
195 #strain_profile |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
196 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
197 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
198 # In[188]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
199 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
200 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
201 strain_profile.to_csv(output_file,na_rep='NA',index=False) |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
202 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
203 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
204 # In[189]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
205 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
206 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
207 # Open a file with access mode 'a' |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
208 with open(output_file, "a") as file_object: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
209 # Append 'hello' at the end of file |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
210 file_object.write("Note: \n1. 'MDR': Multidrug-resistant, 'XDR': Extensively drug-resistant, 'TDR':totally drug resistant, NA': Data Not Available.\n2. 'Strain could not be classified' numbers follow the format as ('Number of antibiotics categories count as Intermediate' | 'Number of antibiotics categories count as NA')") |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
211 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
212 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
213 # In[ ]: |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
214 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
215 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
216 |
b3c01b790314
"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8"
rakesh4osdd
parents:
diff
changeset
|
217 |