Im trying to classify my list into three type: XDR - A strain must be resistant to:
MDR + CIPROFLOXACIN/MOXIFLOXACIN/OFLOXACIN/LEVOFLOXACIN + AMYCACIN/CAPREOMYCIN/KANAMYCIN-> means ISONIAZID + RIFAMPICIN + any of these or two or three or all (CIPROFLOXACIN/MOXIFLOXACIN/OFLOXACIN/LEVOFLOXACIN) + any of these or two or three or all (AMYCACIN/CAPREOMYCIN/KANAMYCIN)
PRE-XDR - A strain must be resistant to:
MDR + CIPROFLOXACIN/MOXIFLOXACIN/OFLOXACIN/LEVOFLOXACIN -> means ISONIAZID + RIFAMPICIN + any of these or two or three or all (CIPROFLOXACIN/MOXIFLOXACIN/OFLOXACIN/LEVOFLOXACIN)
MDR - A strain must be resistant to:
ISONIAZID + RIFAMPICIN
and if it is resistant to any one/two/three of these or all of these in
addition to ISONIAZID + RIFAMPICIN than again it is MDR:-
PYRAZINAMIDE, ETHIONAMIDE, STREPTOMYCIN, ETHAMBUTOL
SUSCEPTIBLE - A strain must be Susceptible to all drugs
I tried the code as follows for MDR:
tail -n +2 drug.txt |\
awk '{a[$1] = a[$1]","$2};END{for(i in a)print i"\t"a[i]}'|\
grep -P "\t,ISONIAZID,RIFAMPICIN$"
It gave me MDR starins correctly but than i had to first remove all Susceptible strains and applied it to Resistant one only.
But when i applied the code for Pre-XDR:
tail -n +2 drug.txt |\
awk '{a[$1] = a[$1]","$2};END{for(i in a)print i"\t"a[i]}'|\
grep -P
"\t,ISONIAZID,RIFAMPICIN|CIPROFLOXACIN|MOXIFLOXACIN|OFLOXACIN|LEVOFLOXACIN"
It is giving me the result as below:
SRR671821 ,CAPREOMYCIN,ETHAMBUTOL,ETHIONAMIDE,ISONIAZID,KANAMYCIN,OFLOXACIN,RIFAMPICIN,STREPTOMYCIN
SRR671863 ,CAPREOMYCIN,ETHAMBUTOL,ISONIAZID,KANAMYCIN,OFLOXACIN,RIFAMPICIN
SRR671822 ,ETHAMBUTOL,ISONIAZID,OFLOXACIN,RIFAMPICIN,STREPTOMYCIN
SRR671864 ,CAPREOMYCIN,ETHAMBUTOL,ISONIAZID,KANAMYCIN,OFLOXACIN,RIFAMPICIN
Which is not correct for Pre-XDR.
So I'm looking for a the drugs if match than look for resistant and susceptible if these criteria match with any of the mention type (MDR,XDR...) it put those under that in a new file. Can anyone help? my file druglist.sxls
MDR eg from the file attached is:
ERR038736 ISONIAZID RESISTANT
ERR038736 RIFAMPICIN RESISTANT
ERR038737 ISONIAZID RESISTANT
ERR038737 RIFAMPICIN RESISTANT
SRR1270146 AMIKACIN SUSCEPTIBLE
SRR1270146 CAPREOMYCIN SUSCEPTIBLE
SRR1270146 CYCLOSERINE SUSCEPTIBLE
SRR1270146 ETHAMBUTOL RESISTANT
SRR1270146 ETHIONAMIDE SUSCEPTIBLE
SRR1270146 ISONIAZID RESISTANT
SRR1270146 KANAMYCIN SUSCEPTIBLE
SRR1270146 PARA-AMINOSALICYLIC ACID SUSCEPTIBLE
SRR1270146 PYRAZINAMIDE RESISTANT
SRR1270146 RIFAMPICIN RESISTANT
SRR1270146 STREPTOMYCIN RESISTANT