annotate clsi_profile.py @ 11:7dcc0e93288b draft default tip

"planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f590c3b1d71a9b8f2030909fa488b4ac0c3caed8-dirty"
author rakesh4osdd
date Wed, 30 Jun 2021 07:13:29 +0000
parents 3c27e5c2a8e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
1 #!/usr/bin/env python
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
2 # coding: utf-8
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
3
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
4 # In[7]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
5
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
6
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
7 # ASIST module2 | map AST result to the CLSI breakporints with combination antibiotics
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
8 # By rakesh4osdd@gmail.com, 06-Jun-2021
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
9 import pandas as pd
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
10 import re
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
11 import sys
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
12
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
13
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
14 # In[8]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
15
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
16
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
17 #print(pd.__version__, re.__version__)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
18
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
19
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
20 # In[9]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
21
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
22
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
23 # compare two MIC value strings
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
24 def check_mic(mic1,mic2,mic_type):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
25 #print(mic1,mic2,mic_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
26 try:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
27 if '/' in mic1:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
28 m1a = mic1.split('/')[0]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
29 m1b = mic1.split('/')[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
30 if float(m1a)==0 or float(m1b)==0:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
31 strain_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
32 return(strain_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
33 elif '/' in mic2:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
34 m1a = mic1
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
35 if float(m1a)==0:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
36 strain_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
37 return(strain_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
38 m1b = '1'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
39 elif float(mic1)==0:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
40 strain_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
41 return(strain_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
42 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
43 m1a = mic1
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
44
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
45 if '-' in mic2:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
46 m2a = mic2.split('-')[0]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
47 m2b = mic2.split('-')[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
48
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
49 except ValueError:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
50 strain_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
51 return(strain_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
52 try:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
53 if '-' in mic2 and mic_type == 'i': # for intermediate only
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
54 if '/' in mic2:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
55 m2a = mic2.split('-')[0].split('/')[0]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
56 m2b = mic2.split('-')[0].split('/')[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
57 m2aa = mic2.split('-')[1].split('/')[0]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
58 m2bb = mic2.split('-')[1].split('/')[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
59 if (float(m2aa)>=float(m1a)>=float(m2a) and float(m2bb)>=float(m1b)>=float(m2b)):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
60 #print('intermediate')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
61 m_type='Intermediate'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
62 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
63 #print('not define')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
64 m_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
65 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
66 m2a = mic2.split('-')[0]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
67 m2b = mic2.split('-')[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
68 if (float(m2b)>=float(m1a)>=float(m2a)):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
69 #print('intermediate')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
70 m_type='Intermediate'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
71 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
72 #print('not define')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
73 m_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
74 #print (m1a,m1b,m2a,m2b,m2aa,m2bb)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
75 elif '/' in mic2:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
76 m2a = mic2.split('/')[0]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
77 m2b = mic2.split('/')[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
78 #print(m1a,m1b,m2a,m2b,mic_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
79 if (mic_type=='s' and (float(m1a)<=float(m2a) and float(m1b)<=float(m2b))):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
80 m_type='Susceptible'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
81 elif (mic_type=='r' and (float(m1a)>=float(m2a) and float(m1b)>=float(m2b))):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
82 m_type='Resistant'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
83 elif (mic_type=='i' and (float(m1a)==float(m2a) and float(m1b)==float(m2b))):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
84 m_type='Intermediate'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
85 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
86 m_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
87 elif '-' in mic2:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
88 m_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
89 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
90 m2a=mic2
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
91 if (mic_type=='s' and (float(m1a)<=float(m2a))):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
92 m_type='Susceptible'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
93 elif (mic_type=='r' and (float(m1a)>=float(m2a))):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
94 m_type='Resistant'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
95 elif (mic_type=='i' and (float(m1a)==float(m2a))):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
96 m_type='Intermediate'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
97 else:
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
98 m_type='Strain could not be classified'
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
99 except IndexError:
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
100 strain_type='Strain could not be classified'
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
101 return(strain_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
102
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
103 return(m_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
104
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
105 #check_mic('65','32-64','i')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
106
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
107
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
108 # In[10]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
109
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
110
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
111 # compare MIC value in pandas list
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
112 def sus_res_int(mic):
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
113 #print(mic)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
114 o_mic = mic[0].replace(' ', '')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
115 s_mic = mic[1].replace(' ', '')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
116 r_mic = mic[2].replace(' ', '')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
117 i_mic = mic[3].replace(' ', '')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
118 try:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
119 if check_mic(o_mic,s_mic,'s')=='Susceptible':
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
120 strain_type='Susceptible'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
121 elif check_mic(o_mic,r_mic,'r')=='Resistant':
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
122 strain_type='Resistant'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
123 elif check_mic(o_mic,i_mic,'i')=='Intermediate':
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
124 strain_type='Intermediate'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
125 else:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
126 strain_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
127 except ValueError:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
128 strain_type='Strain could not be classified'
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
129 return(strain_type)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
130
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
131 #mic=['128','16/4','128/4','32/4-64/4']
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
132 #sus_res_int(mic)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
133
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
134
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
135 # In[11]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
136
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
137
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
138 # for input argument
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
139 input_user = sys.argv[1]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
140 input_clsi = sys.argv[2]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
141 output_table = sys.argv[3]
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
142
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
143
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
144 # In[49]:
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
145
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
146
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
147 """input_user='~/Jupyterlab_notebook/ASIST_module/strain_profiles_16k.csv.csv'
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
148 #input_user='test-data/input2.csv'
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
149 input_clsi='test-data/clsi.csv'
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
150 output_profile='test-data/input2_profile.csv'
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
151 #output_table='test-data/input2_table.csv'
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
152 output_table='/home/rakesh/Jupyterlab_notebook/ASIST_module/strain_profiles_16k_table.csv'"""
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
153
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
154
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
155 # In[60]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
156
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
157
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
158 # read user AST data with selected 3 columns
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
159 strain_mic=pd.read_csv(input_user, sep=',', usecols =['Strain name', 'Antibiotics', 'MIC'],na_filter=False)
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
160 #strain_mic
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
161
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
162
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
163 # In[61]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
164
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
165
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
166 clsi_bp=pd.read_csv(input_clsi,sep=',')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
167
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
168 #clsi_bp[clsi_bp[['Antibiotics', 'Susceptible']].duplicated()].shape
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
169
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
170
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
171 # In[62]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
172
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
173
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
174 #clsi_bp
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
175 #strain_mic
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
176
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
177
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
178 # In[64]:
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
179
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
180
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
181 # warn user for duplicate files
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
182 input_dups=strain_mic[strain_mic[['Strain name','Antibiotics']].duplicated()]
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
183 if (input_dups.shape[0] == 0):
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
184 #print( "No duplicates")
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
185 pass
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
186 else:
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
187 with open(output_table, "w") as file_object:
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
188 # Append 'hello' at the end of file
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
189 file_object.write('S.No.,Strain name,Antibiotics,MIC\nInput File Error: Please remove duplicate/mutiple MIC values for same combination of Strain name and Antibiotics from input file\n')
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
190 input_dups.to_csv(output_table,na_rep='NA', mode='a')
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
191 exit()
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
192
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
193
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
194 # In[17]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
195
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
196
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
197 # convert MIC to numbers sMIC, rMIC
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
198 clsi_bp['s_mic'] =clsi_bp[['Susceptible']].applymap(lambda x: (re.sub(r'[^0-9.\/-]', '', x)))
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
199 clsi_bp['r_mic'] =clsi_bp[['Resistant']].applymap(lambda x: (re.sub(r'[^0-9.\/-]', '', x)))
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
200 clsi_bp['i_mic'] = clsi_bp[['Intermediate']].applymap(lambda x: (re.sub(r'[^0-9.\/-]', '', x)))
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
201
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
202
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
203 # In[18]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
204
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
205
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
206 #clsi_bp['i_mic'] = clsi_bp[['Intermediate']].applymap(lambda x: (re.sub(r'[^0-9.\/-]', '', x)))
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
207
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
208
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
209 # In[19]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
210
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
211
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
212 # Read only numbers in MIC values
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
213 #try:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
214 strain_mic['o_mic']=strain_mic[['MIC']].applymap(lambda x: (re.sub(r'[^0-9.\/]','', x)))
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
215 #except TypeError:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
216 # print('Waring: Error in MIC value')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
217
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
218
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
219 # In[20]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
220
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
221
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
222 #strain_mic
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
223
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
224
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
225 # In[21]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
226
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
227
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
228 # capitalize each Antibiotic Name for comparision with removing whitespace
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
229 strain_mic['Strain name']=strain_mic['Strain name'].str.capitalize().str.replace(" ","")
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
230 strain_mic['Antibiotics']=strain_mic['Antibiotics'].str.capitalize().str.replace(" ","")
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
231
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
232 clsi_bp['Antibiotics']=clsi_bp['Antibiotics'].str.capitalize().str.replace(" ","")
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
233
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
234
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
235 # In[22]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
236
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
237
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
238 #find duplicate values in input files
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
239 dups=strain_mic[strain_mic[['Strain name', 'Antibiotics']].duplicated(keep=False)]
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
240 if dups.shape[0] != 0:
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
241 print ('Please provide a single MIC value in input file for given duplicates combination of \'Strain name and Antibiotics\' to use the tool:-\n',dups)
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
242 #exit()
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
243 else:
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
244 #compare CLSI Antibiotics only
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
245 #result=pd.merge(strain_mic, clsi_bp, on='Antibiotics',how='inner', indicator=True)[['Strain name','Antibiotics', 'MIC', 'o_mic', 's_mic', 'r_mic','_merge']]
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
246 try:
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
247 result=pd.merge(strain_mic, clsi_bp, on='Antibiotics',how='inner')[['Strain name','Antibiotics', 'MIC', 'o_mic', 's_mic', 'r_mic','i_mic']]
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
248 except KeyError:
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
249 print('Waring: Error in input Values')
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
250
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
251
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
252 # In[23]:
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
253
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
254
5
3c27e5c2a8e9 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit d4b81c15919b4b87d215eaf1b792c8f251665647"
rakesh4osdd
parents: 4
diff changeset
255 dups.head()
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
256
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
257
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
258 # In[132]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
259
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
260
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
261 #compare MIC values and assign Susceptible and Resistant to Strain
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
262 #try:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
263 result[['CLSI_profile']] = result[['o_mic','s_mic','r_mic','i_mic']].apply(sus_res_int,axis = 1)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
264 #except ValueError:
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
265 # print('Waring: Error in input MIC value')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
266
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
267
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
268 # In[133]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
269
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
270
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
271 #result
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
272
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
273
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
274 # In[134]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
275
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
276
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
277 #result[['Strain name', 'Antibiotics', 'MIC','s_mic','r_mic','CLSI_profile']].to_csv(output_profile,sep=',', index=False, encoding='utf-8-sig')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
278
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
279
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
280 # In[135]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
281
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
282
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
283 #create a pivot table for ASIST
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
284 table=result[['Strain name', 'Antibiotics','CLSI_profile']].drop_duplicates()
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
285 result_table=pd.pivot_table(table, values ='CLSI_profile', index =['Strain name'],columns =['Antibiotics'], aggfunc = lambda x: ' '.join(x))
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
286
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
287
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
288 # In[136]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
289
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
290
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
291 #result_table
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
292
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
293
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
294 # In[137]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
295
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
296
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
297 #result_table.to_csv(output_table,na_rep='NA')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
298
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
299
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
300 # In[138]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
301
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
302
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
303 # reorder the Antibiotics for ASIST
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
304 clsi_ab=['Amikacin','Tobramycin','Gentamycin','Netilmicin','Imipenem','Meropenem','Doripenem','Ciprofloxacin','Levofloxacin',
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
305 'Piperacillin/tazobactam','Ticarcillin/clavulanicacid','Cefotaxime','Ceftriaxone','Ceftazidime','Cefepime',
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
306 'Trimethoprim/sulfamethoxazole','Ampicillin/sulbactam','Colistin','Polymyxinb','Tetracycline','Doxicycline ',
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
307 'Minocycline']
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
308 result_selected=result_table.filter(clsi_ab)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
309
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
310
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
311 # In[139]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
312
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
313
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
314 #print(result_selected.shape, result_table.shape)
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
315
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
316
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
317 # In[140]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
318
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
319
3
683299422575 "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit f085b88bf75f7b45ac3b0c4e1c39214c0ac0b67d"
rakesh4osdd
parents: 0
diff changeset
320 #result_selected.insert(0,'Resistance_phenotype','')
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
321
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
322
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
323 # In[141]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
324
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
325
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
326 #rename headers
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
327 result_selected=result_selected.rename(columns = {'Ticarcillin/clavulanicacid':'Ticarcillin/clavulanic acid','Piperacillin/tazobactam':'Piperacillin/ tazobactam','Trimethoprim/sulfamethoxazole': 'Trimethoprim/ sulfamethoxazole','Ampicillin/sulbactam':'Ampicillin/ sulbactam', 'Polymyxinb': 'Polymyxin B'} )
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
328
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
329
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
330 # In[142]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
331
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
332
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
333 #result_selected
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
334
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
335
4
2a5861818faf "planemo upload for repository https://github.com/rakesh4osdd/asist/tree/master commit 7169e85ac6d230af9309b0deacecd4dc61e0a915"
rakesh4osdd
parents: 3
diff changeset
336 # In[144]:
0
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
337
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
338
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
339 result_selected.to_csv(output_table,na_rep='NA')
62226cd1acb5 "planemo upload for repository https://github.com/rakesh4osdd/clsi_profile/tree/master commit ae6f2bc197b28000c56f6368ad044b350bc34f6a"
rakesh4osdd
parents:
diff changeset
340