# Version: MTBC.niid.3.20150403 #

# Original of the MTBC program is a part of KvarQ software
# developed and distributed by Andreas et al. 
# (http://www.swisstph.ch/kvarq) under GNU GPLv3.
# This version is a modified version of the MTBC program 
# in the testsuites in KverQ by National Institute of 
# Infectious Diseases Japan.
#
#    This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

VERSION = '2.0'
from kvarq.genes import COMPATIBILITY as GENES_COMPATIBILITY

from kvarq.genes import Genotype, Test, Reference, SNP, Testsuite
from kvarq.genes import TemplateFromGenome, Gene

from _util import ancestor

class ResistanceTestsuite(Testsuite):

    def __str__(self):
        return 'TB resistance mutations & mutation regions'

    def _analyse(self, coverages):
        ret = []

        # will be set to True if any of the regions / SNPs has maximum
        # variant base below 90% (no matter whether templates validate or not)
        mixed = False

        for test in self.tests:

            coverage = coverages[test]
            seq = test.template.seq()

            # a) SNPs
            if isinstance(test.template, SNP):
                minf = coverage.minf()
                if minf < 0.9:
                    mixed = True
                if test.template.validate(coverage):
                    ret.append(str(test))
                    ret[-1] += '=' + test.genotype.gene.mut2str(
                            test.template.start, test.template.base)
                    # show percentage of most prominent base at SNP position
                    # if it's below 90%
                    if minf < 0.9:
                        ret[-1] += ' (' + str(int(100 * minf)) + '%)'
                continue

            # b) regions
            if not mixed and coverage.minf() < 0.9:
                mixed = True
            mutations = test.template.mutations(coverage)
            output = []
            for pos, newbase in mutations:

                oldbase = seq[pos]
                output.append('%d%s%s'%(
                        pos + test.template.start, oldbase, newbase))

                if test.genotype.gene:
                    output[-1] += '=' + test.genotype.gene.mut2str(
                            pos + test.template.start, newbase)

                mutf = coverage.fractions_at(pos).values()[0]
                if mutf < 0.9:
                    output[-1] += ' (' + str(int(100 * minf)) + '%)'

            aa1 = test.template.transcribe()
            aa2 = test.template.transcribe(mutations)

            # ignore resistance mutations without aa change
            if test.genotype.gene.coding and aa1 == aa2:
                continue

            # notify if mutation is not in "poslist"
            if hasattr(test.template, 'poslist'):
                poslist = test.template.poslist
                if poslist and not [m for m in mutations
                        if m[0]+test.template.start in poslist]:
                    output.append('[NONE OF MUTATIONS DOCUMENTED IN REFERENCE]')

            ret.append(str(test.genotype) + ' [' + ' '.join(output) + ']')

        RRDR_tests = [test for test in self.tests if test.genotype==RRDR]
        assert len(RRDR_tests) == 1
        if coverages[RRDR_tests[0]].mean(include_margins=False) < 10:
            ret.append('remark: low coverage (RRDR below 10x)')
        if mixed:
            ret.append('remark: mixed coverage')

        return ret


class DrugResistance(Genotype):

    def __init__(self, drug, gene, remarks=None):
        identifier = drug + ' resistance'
        if remarks:
            identifier += ' ('+remarks+')'
        super(DrugResistance, self).__init__(identifier)
        self.drug = drug
        self.gene = gene
        self.remarks = remarks


# MDR : rifampicin + any of (isoniazid, ?)
# XDR : MDR + fluoroquinolone + injectable (aminoglycosides)

inhA = DrugResistance('Isoniazid', Gene(ancestor,'inhA', 1674202, 1675011, promoter_end=1673440))
katG = DrugResistance('Isoniazid', Gene(ancestor,'katG', 2153889, 2156111, plus_strand=False))
oxyRahpCintergenic =  DrugResistance('Isoniazid', Gene(ancestor,'OxyR-ahpC_intergenic', 2726088, 2726192))          # modified (04/01/2015)

rpoB = DrugResistance('Rifampicin', Gene(ancestor,'rpoB', 759807, 763325))          # modified (04/01/2015)
RRDR = DrugResistance('Rifampicin', Gene(ancestor,'rpoB', 759807, 763325), 'RRDR')
rpoA = DrugResistance('Rifampicin', Gene(ancestor,'rpoA', 3877464, 3878507, plus_strand=False), 'compensatory')
rpoC = DrugResistance('Rifampicin', Gene(ancestor,'rpoC', 763370, 767320), 'compensatory')

QRDR = DrugResistance('Fluoroquinolones', Gene(ancestor,'gyrA', 7302, 9818), 'QRDR')
gyrA = DrugResistance('Fluoroquinolones', Gene(ancestor,'gyrA', 7302, 9818))
gyrB = DrugResistance('Fluoroquinolones', Gene(ancestor,'gyrB', 5123, 7267))

rpsL = DrugResistance('Streptomycin', Gene(ancestor,'rpsL', 781560, 781934))

#TODO report position only, is in ribosomal RNA ...
rrsS = DrugResistance('Streptomycin', Gene(ancestor,'rrsS', 1471846, 1473382))
rrsK = DrugResistance('Kanamycin/Amikacin', Gene(ancestor,'rrsK', 1471846, 1473382))

embB = DrugResistance('Ethambutol', Gene(ancestor,'embB', 4246514, 4249810))

pncA = DrugResistance('Pyrazinamide', Gene(ancestor,'pncA', 2288681, 2289241, plus_strand=False))


comas12 = Reference('Comas et al 2012 Nat Gen: Compensatory mutations...')
ramaswamy98 = Reference('Ramaswamy et al., Tuber Lung Dis 1998')
sun08 = Reference('Sun et al., Antimicr Agents 2008')
tbdream = Reference('TBDReamDB')
sebastien = Reference('Sebastien')
sebastien_= Reference('Sebastien ?')
david = Reference('David')
tgstb1 = Reference('TGS-TB 04/01/2015')       # modified (04/01/2015)


resistance_SNPs = [

    Test(SNP(genome=ancestor, pos=6767, orig='G', base='A'), gyrB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=6768, orig='G', base='A'), gyrB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=7521, orig='G', base='T'), gyrA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7570, orig='C', base='T'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7572, orig='T', base='C'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7581, orig='G', base='A'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7581, orig='G', base='C'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7581, orig='G', base='T'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7582, orig='A', base='C'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7582, orig='A', base='G'), gyrA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=7606, orig='C', base='A'), gyrA, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=7677, orig='G', base='A'), gyrA, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=7678, orig='C', base='G'), gyrA, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=761082, orig='G', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761083, orig='G', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761085, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761085, orig='A', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761086, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761089, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761090, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761091, orig='C', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761093, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761094, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761095, orig='T', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761095, orig='T', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761097, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761097, orig='A', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761098, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761098, orig='G', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761100, orig='C', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761100, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761100, orig='C', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761101, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761101, orig='A', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761101, orig='A', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761102, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761103, orig='T', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761105, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761108, orig='G', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761108, orig='G', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761109, orig='G', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761109, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761109, orig='G', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761110, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761110, orig='A', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761110, orig='A', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761111, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761113, orig='A', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761114, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761115, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761115, orig='A', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761115, orig='A', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761116, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761116, orig='A', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761120, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761124, orig='C', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761125, orig='T', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761126, orig='G', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761128, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761128, orig='C', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761130, orig='G', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761131, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761134, orig='T', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761134, orig='T', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761136, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761137, orig='C', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761139, orig='C', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761139, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761139, orig='C', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761140, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761140, orig='A', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761140, orig='A', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761141, orig='C', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761141, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761142, orig='A', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761144, orig='G', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761146, orig='G', base='A'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761146, orig='G', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761155, orig='C', base='G'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761155, orig='C', base='T'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=761161, orig='T', base='C'), rpoB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=764669, orig='C', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764670, orig='C', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764817, orig='T', base='C'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764817, orig='T', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764819, orig='T', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764822, orig='G', base='A'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764822, orig='G', base='C'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764840, orig='A', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764841, orig='T', base='C'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=764918, orig='G', base='C'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=765461, orig='A', base='C'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=765462, orig='A', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=765463, orig='C', base='G'), rpoC, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=781687, orig='A', base='G'), rpsL, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=781821, orig='A', base='C'), rpsL, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=781822, orig='A', base='C'), rpsL, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=781822, orig='A', base='G'), rpsL, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=781822, orig='A', base='T'), rpsL, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472337, orig='C', base='A'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472337, orig='C', base='G'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472337, orig='C', base='T'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472358, orig='C', base='A'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472358, orig='C', base='G'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472358, orig='C', base='T'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472359, orig='A', base='C'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472359, orig='A', base='G'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472359, orig='A', base='T'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472362, orig='C', base='A'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472362, orig='C', base='G'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472362, orig='C', base='T'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472752, orig='A', base='C'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472752, orig='A', base='G'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1472752, orig='A', base='T'), rrsS, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473246, orig='A', base='C'), rrsK, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473246, orig='A', base='G'), rrsK, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473246, orig='A', base='T'), rrsK, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473246, orig='A', base='C'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473246, orig='A', base='G'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473246, orig='A', base='T'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473247, orig='C', base='A'), rrsK, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473247, orig='C', base='G'), rrsK, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473247, orig='C', base='T'), rrsK, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1473247, orig='C', base='A'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473247, orig='C', base='G'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473247, orig='C', base='T'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473329, orig='G', base='A'), rrsK, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473329, orig='G', base='C'), rrsK, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473329, orig='G', base='T'), rrsK, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473329, orig='G', base='A'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473329, orig='G', base='C'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1473329, orig='G', base='T'), rrsS, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1673425, orig='C', base='T'), inhA, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1673425, orig='C', base='A'), inhA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1673425, orig='C', base='G'), inhA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=1673432, orig='T', base='A'), inhA, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1673432, orig='T', base='C'), inhA, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=1673432, orig='T', base='G'), inhA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155167, orig='G', base='C'), katG, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155167, orig='G', base='T'), katG, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155168, orig='C', base='A'), katG, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155168, orig='C', base='G'), katG, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155168, orig='C', base='T'), katG, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155169, orig='T', base='G'), katG, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2155276, orig='C', base='T'), katG, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=2288688, orig='C', base='G'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288727, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288730, orig='G', base='A'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288757, orig='C', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288761, orig='C', base='G'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288764, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288766, orig='A', base='G'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288778, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288782, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288805, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288805, orig='G', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288817, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288817, orig='G', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288818, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288820, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288821, orig='G', base='A'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288824, orig='G', base='T'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288826, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288826, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288827, orig='C', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288827, orig='C', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288829, orig='C', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288832, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288839, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288841, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288844, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288853, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288859, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288880, orig='C', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288895, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288902, orig='T', base='G'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288930, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288933, orig='G', base='C'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288933, orig='G', base='T'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288937, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288945, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288945, orig='G', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288953, orig='C', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288954, orig='C', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288960, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288960, orig='G', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288988, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2288997, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289016, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289028, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289030, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289039, orig='C', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289040, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289040, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289043, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289046, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289054, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289068, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289070, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289073, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289073, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289081, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289082, orig='G', base='T'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289090, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289090, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289103, orig='T', base='C'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289105, orig='G', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289119, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289119, orig='G', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289138, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289141, orig='T', base='G'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289180, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289186, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289192, orig='C', base='T'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289202, orig='A', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289206, orig='G', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289206, orig='G', base='T'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289207, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289207, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289213, orig='T', base='G'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289222, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289231, orig='A', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289235, orig='C', base='G'), pncA, tgstb1),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289252, orig='T', base='A'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2289252, orig='T', base='C'), pncA, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2726146, orig='G', base='A'), oxyRahpCintergenic, tgstb1),	# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=2726154, orig='C', base='T'), oxyRahpCintergenic, tgstb1),	# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=3877949, orig='T', base='C'), rpoA, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=3877949, orig='T', base='G'), rpoA, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=3877960, orig='A', base='C'), rpoA, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=3877960, orig='A', base='G'), rpoA, comas12),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247429, orig='A', base='C'), embB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247429, orig='A', base='G'), embB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247429, orig='A', base='T'), embB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=4247431, orig='G', base='A'), embB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247431, orig='G', base='C'), embB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247431, orig='G', base='T'), embB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247469, orig='A', base='C'), embB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=4247469, orig='A', base='G'), embB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=4247729, orig='G', base='A'), embB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=4247730, orig='G', base='C'), embB, tbdream),			# KvarQ default
    Test(SNP(genome=ancestor, pos=4247730, orig='G', base='A'), embB, tbdream),			# TGS-TB (04/01/2015)
    Test(SNP(genome=ancestor, pos=4248003, orig='A', base='G'), embB, tbdream),			# KvarQ default
]

resistance_regions = [

    Test(TemplateFromGenome(genome=ancestor, start=2155167, stop=2155169, direction='-', aa_pos0=(2155167-2153889)/3 +1), katG, ramaswamy98),
    Test(TemplateFromGenome(genome=ancestor, start=761082, stop=761162), RRDR, ramaswamy98),
    Test(TemplateFromGenome(genome=ancestor, start=7521, stop=7583, poslist=[7521, 7522, 7523, 7569, 7570, 7571, 7572, 7573, 7574, 7581, 7582, 7583]), QRDR, sun08),
    Test(TemplateFromGenome(genome=ancestor, start=2288681, stop=2289241, direction='-'), pncA, david),

]


resistance = ResistanceTestsuite( resistance_SNPs + resistance_regions, VERSION )