Ejemplo n.º 1
0
class Test_ForQuiverService(unittest.TestCase):
    """Test pbtools.pbalign.forquiverservice.forquiver."""
    def setUp(self):
        self.rootDir = "/mnt/secondary-siv/secondarytest/" + \
                       "testdata/BlasrTestData/pbalign"
        self.inCmpFile = path.join(self.rootDir, "data/testforquiver.cmp.h5")
        #self.outCmpFile = path.join(self.rootDir, "out/testforquiver.cmp.h5")
        self.outCmpFile = mkstemp(suffix=".cmp.h5")[1]

        copyfile(self.inCmpFile, self.outCmpFile)
        self.basFile = path.join(self.rootDir, "data/lambda_bax.fofn")

        refpath = "/mnt/secondary/Smrtanalysis/opt/" + \
                  "smrtanalysis/common/references/lambda/"

        self.fileNames = PBAlignFiles()
        self.fileNames.SetInOutFiles(self.basFile, refpath,
                                     self.outCmpFile, None, None)
        self.options = Opt()
        self.obj = ForQuiverService(self.fileNames, self.options)

    def tearDown(self):
        remove(self.outCmpFile)

    def test_run(self):
        """Test ForQuiverService.__init__()."""
        self.obj.run()
Ejemplo n.º 2
0
    def setUp(self):
        self.rootDir = "/mnt/secondary-siv/secondarytest/" + \
                       "testdata/BlasrTestData/pbalign"
        self.inCmpFile = path.join(self.rootDir, "data/testforquiver.cmp.h5")
        #self.outCmpFile = path.join(self.rootDir, "out/testforquiver.cmp.h5")
        self.outCmpFile = mkstemp(suffix=".cmp.h5")[1]

        copyfile(self.inCmpFile, self.outCmpFile)
        self.basFile = path.join(self.rootDir, "data/lambda_bax.fofn")

        refpath = "/mnt/secondary/Smrtanalysis/opt/" + \
                  "smrtanalysis/common/references/lambda/"

        self.fileNames = PBAlignFiles()
        self.fileNames.SetInOutFiles(self.basFile, refpath,
                                     self.outCmpFile, None, None)
        self.options = Opt()
        self.obj = ForQuiverService(self.fileNames, self.options)
Ejemplo n.º 3
0
    def run(self):
        """
        The main function, it is called by PBToolRunner.start().
        """
        startTime = time.time()
        logging.info("pbalign version: {version}".format(version=__VERSION__))
        logging.debug("Original arguments: " + str(self._argumentList))

        # Create an AlignService by algorithm name.
        self._alnService = self._createAlignService(self.args.algorithm,
                                                    self.args,
                                                    self.fileNames,
                                                    self._tempFileManager)

        # Make sane.
        self._makeSane(self.args, self.fileNames)

        # Run align service.
        try:
            self._alnService.run()
        except RuntimeError:
            return 1

        # Create a temporary filtered SAM file as output for FilterService.
        self.fileNames.filteredSam = self._tempFileManager.\
            RegisterNewTmpFile(suffix=".sam")

        # Call filter service.
        self._filterService = FilterService(self.fileNames.alignerSamOut,
                                            self.fileNames.targetFileName,
                                            self.fileNames.filteredSam,
                                            self._alnService.name,
                                            self._alnService.scoreSign,
                                            self.args,
                                            self.fileNames.adapterGffFileName)
        try:
            self._filterService.run()
        except RuntimeError:
            return 1

        # Output all hits either in SAM or CMP.H5.
        try:
            useSmrtTitle = False
            if (self.args.algorithm != "blasr" or
                self.fileNames.inputFileFormat == FILE_FORMATS.FASTA):
                useSmrtTitle = True

            self._output(
                self.fileNames.filteredSam,
                self.fileNames.targetFileName,
                self.fileNames.outputFileName,
                self.args.readType,
                useSmrtTitle)
        except RuntimeError:
            return 1

        # Call post service for quiver.
        if self.args.forQuiver:
            postService = ForQuiverService(self.fileNames,
                                           self.args)
            try:
                postService.run()
            except RuntimeError:
                return 1

        # Delete temporay files anyway to make
        self._cleanUp(False if (hasattr(self.args, "keepTmpFiles") and
                               self.args.keepTmpFiles is True) else True)

        endTime = time.time()
        logging.info("Total time: {:.2f} s.".format(float(endTime - startTime)))
        return 0