# Path: nanopore/mappers/lastz.py
# class Lastz(AbstractMapper):
#     def run(self, args=""):
#         tempFastqFile = os.path.join(self.getLocalTempDir(), "temp.fastq")
#         normaliseQualValues(self.readFastqFile, tempFastqFile)
#         system("lastz %s[multiple] %s %s --format=sam > %s" % (self.referenceFastaFile, tempFastqFile, args, self.outputSamFile))
#         try:
#             pysam.Samfile(self.outputSamFile, "r" ).close()
#         except ValueError:
#             #Hack to make lastz work, creating SQ lines when no alignments are found
#             fH = open(self.outputSamFile, 'a')
#             for name, seq in fastaRead(open(self.referenceFastaFile, 'r')):
#                 fH.write("@SQ\tSN:%s\tLN:%s\n" % (name.split()[0], len(seq)))
#             fH.close()
# 
# Path: nanopore/analyses/utils.py
# def pathToBaseNanoporeDir():
#     import nanopore
#     i = absSymPath(nanopore.__file__)
#     return os.path.split(os.path.split(i)[0])[0]


from nanopore.mappers.lastz import Lastz
from nanopore.analyses.utils import pathToBaseNanoporeDir
import pysam
import os


class LastzParams(Lastz):
    def run(self):
        #scoreFile = os.path.join(pathToBaseNanoporeDir(), "nanopore", "mappers", "last_em_575_M13_2D_scores.txt")
        #Lastz.run(self, args="--hspthresh=1200 --gappedthresh=1500  --seed=match12 --scores=%s" % scoreFile)
        Lastz.run(self, args="--hspthresh=1800 --gap=100,100")
        
class LastzParamsChain(LastzParams):
    def run(self):
        LastzParams.run(self)
        self.chainSamFile()
        
class LastzParamsRealign(LastzParams):
    def run(self):
        LastzParams.run(self)
        self.realignSamFile()
        
class LastzParamsRealignEm(LastzParams):
    def run(self):
        LastzParams.run(self)
        self.realignSamFile(doEm=True)
        

# Path: nanopore/mappers/lastz.py
# class Lastz(AbstractMapper):
#     def run(self, args=""):
#         tempFastqFile = os.path.join(self.getLocalTempDir(), "temp.fastq")
#         normaliseQualValues(self.readFastqFile, tempFastqFile)
#         system("lastz %s[multiple] %s %s --format=sam > %s" % (self.referenceFastaFile, tempFastqFile, args, self.outputSamFile))
#         try:
#             pysam.Samfile(self.outputSamFile, "r" ).close()
#         except ValueError:
#             #Hack to make lastz work, creating SQ lines when no alignments are found
#             fH = open(self.outputSamFile, 'a')
#             for name, seq in fastaRead(open(self.referenceFastaFile, 'r')):
#                 fH.write("@SQ\tSN:%s\tLN:%s\n" % (name.split()[0], len(seq)))
#             fH.close()
# 
# Path: nanopore/analyses/utils.py
# def pathToBaseNanoporeDir():
#     import nanopore
#     i = absSymPath(nanopore.__file__)
#     return os.path.split(os.path.split(i)[0])[0]


# Path: nanopore/mappers/lastzParams.py
from nanopore.mappers.lastz import Lastz
from nanopore.analyses.utils import pathToBaseNanoporeDir
import pysam
import os



class LastzParams(Lastz):
    def run(self):
        #scoreFile = os.path.join(pathToBaseNanoporeDir(), "nanopore", "mappers", "last_em_575_M13_2D_scores.txt")
        #Lastz.run(self, args="--hspthresh=1200 --gappedthresh=1500  --seed=match12 --scores=%s" % scoreFile)
        Lastz.run(self, args="--hspthresh=1800 --gap=100,100")
        
class LastzParamsChain(LastzParams):
    def run(self):
        LastzParams.run(self)
        self.chainSamFile()
        
class LastzParamsRealign(LastzParams):
    def run(self):
        LastzParams.run(self)
        self.realignSamFile()
        
class LastzParamsRealignEm(LastzParams):
    def run(self):
        LastzParams.run(self)
        self.realignSamFile(doEm=True)
        

class LastzParamsRealignTrainedModel(LastzParams):