def execute(self, executable): """The method execute checks which program has to be executed and executes this program :param executable: the argument of the commandline which determines which program has to be executed :type executable: str """ if executable == "haplotyping": if Grid.useGrid == True: Haplotyper.executeBeagleCluster(self.pool) else: Haplotyper.executeBeagleMultiThread(self.pool) elif executable == "snvCalling": if Program.config.snvCaller == "samtools": # @UndefinedVariable SamtoolsMpileup.executeSamtoolsMultiThreaded(self.pool) elif Program.config.snvCaller == "GATK": # @UndefinedVariable Gatk.Gatk(self.pool).callSnvs() elif executable == "mapping": mapper = Mapper.Mapper() for sample in self.samples: mapper.map(sample) elif executable == "allelicDiversity": if Program.config.gffFile == None: # @UndefinedVariable print("When calculating the allelic diversity, a gff file is needed, this option can be set with the option --gff <file>") exit() allelicDiverityCalculator = AllelicDiversity.AllelicDiversity(self.pool, Program.config.gffFile) # @UndefinedVariable allelicDiverityCalculator.getAllelicDiversity() elif executable == "findLoci": if Program.config.phenoData == None: # @UndefinedVariable print("When finding loci, a csv file is needed with the phenotype data, this option can be set with the option --phen <file>") exit() if Program.config.gffFile == None: # @UndefinedVariable print("When finding loci, a file with phenotype data is needed, this option can be set with the option --gff <file>") exit() lociFinder = LociFinder.LociFinder() lociFinder.findLoci(self.pool)
def testSamtoolsMpileupMultiThread(self): expOutFile = "../testFiles/output/testPool/testPool_SL2.40ch11_22900-24100.vcf" SamtoolsMpileup.executeSamtoolsMultiThreaded(TestSnvCaller.testPool) outputFile = TestSnvCaller.testPool.vcf["SL2.40ch11_22900-24100"].fileName self.assertEqual( os.path.abspath(outputFile), os.path.abspath(expOutFile), os.path.abspath(outputFile) + " not is " + os.path.abspath(expOutFile), ) # Check if the file contains exactly one snp self.checkNoOfSnps(expOutFile)
def testSamtoolsMpileupMultiThread(self): expOutFile = "../testFiles/output/testPool/testPool_SL2.40ch11_22900-24100.vcf" SamtoolsMpileup.executeSamtoolsMultiThreaded(TestSnvCaller.testPool) outputFile = TestSnvCaller.testPool.vcf[ "SL2.40ch11_22900-24100"].fileName self.assertEqual( os.path.abspath(outputFile), os.path.abspath(expOutFile), os.path.abspath(outputFile) + " not is " + os.path.abspath(expOutFile)) #Check if the file contains exactly one snp self.checkNoOfSnps(expOutFile)
def testSamtoolsMpileupSingleThread(self): Grid.useGrid = False SamtoolsMpileup.SamtoolsMpileup(TestSnvCaller.testPool).callSnvs() outputFile = TestSnvCaller.testPool.vcf[None].fileName self.assertEqual( os.path.abspath(outputFile), os.path.abspath(TestSnvCaller.expVcfFile), os.path.abspath(outputFile) + " not is " + os.path.abspath(TestSnvCaller.expVcfFile)) #Check if the file contains exactly one snp self.checkNoOfSnps(TestSnvCaller.expVcfFile)
def execute(self, executable): """The method execute checks which program has to be executed and executes this program :param executable: the argument of the commandline which determines which program has to be executed :type executable: str """ if executable == "haplotyping": if Grid.useGrid == True: Haplotyper.executeBeagleCluster(self.pool) else: Haplotyper.executeBeagleMultiThread(self.pool) elif executable == "snvCalling": if Program.config.snvCaller == "samtools": # @UndefinedVariable SamtoolsMpileup.executeSamtoolsMultiThreaded(self.pool) elif Program.config.snvCaller == "GATK": # @UndefinedVariable Gatk.Gatk(self.pool).callSnvs() elif executable == "mapping": mapper = Mapper.Mapper() for sample in self.samples: mapper.map(sample) elif executable == "allelicDiversity": if Program.config.gffFile == None: # @UndefinedVariable print( "When calculating the allelic diversity, a gff file is needed, this option can be set with the option --gff <file>" ) exit() allelicDiverityCalculator = AllelicDiversity.AllelicDiversity( self.pool, Program.config.gffFile) # @UndefinedVariable allelicDiverityCalculator.getAllelicDiversity() elif executable == "findLoci": if Program.config.phenoData == None: # @UndefinedVariable print( "When finding loci, a csv file is needed with the phenotype data, this option can be set with the option --phen <file>" ) exit() if Program.config.gffFile == None: # @UndefinedVariable print( "When finding loci, a file with phenotype data is needed, this option can be set with the option --gff <file>" ) exit() lociFinder = LociFinder.LociFinder() lociFinder.findLoci(self.pool)
def testSamtoolsPath(self): SnvCaller.converting = "not done" gzFile = "../testFiles/input/test.fq.gz" refGzFile = "../testFiles/input/revTest.fq.gz" TestSnvCaller.sample.bam = None TestSnvCaller.sample.setForwardFq(gzFile) TestSnvCaller.sample.setReversedFq(refGzFile) TestSnvCaller.sample.reversedFq.forward = False samt = SamtoolsMpileup.SamtoolsMpileup(TestSnvCaller.testPool) samt.callSnvs() outputFile = TestSnvCaller.testPool.vcf[None].fileName self.assertEqual( os.path.abspath(outputFile), os.path.abspath(TestSnvCaller.expVcfFile), os.path.abspath(outputFile) + " not is " + os.path.abspath(TestSnvCaller.expVcfFile)) #Check if the file contains exactly one snp self.checkNoOfSnps(TestSnvCaller.expVcfFile)
def testSamtoolsMultiple(self): #add an extra sample to the pool TestSnvCaller.sample2 = Sample.Sample(TestSnvCaller.testPool, "testLib2") TestSnvCaller.sample2.bam = BamFile.BamFile(TestSnvCaller.testPool, TestSnvCaller.sample2, TestSnvCaller.inputBam) TestSnvCaller.testPool.addSample(TestSnvCaller.sample2) #Execute and check execution output SamtoolsMpileup.SamtoolsMpileup(TestSnvCaller.testPool).callSnvs() outputFile = TestSnvCaller.testPool.vcf[None].fileName self.assertEqual( os.path.abspath(outputFile), os.path.abspath(TestSnvCaller.expVcfFile), os.path.abspath(outputFile) + " not is " + os.path.abspath(TestSnvCaller.expVcfFile)) #Check if the file contains exactly one snp self.checkNoOfSnps(TestSnvCaller.expVcfFile)