Пример #1
0
    def test_run(self):
        """test run"""
        sorted_bam = os.path.join(data_dir, "run.bam")
        ref_fasta = os.path.join(data_dir, "run.ref.fa")
        outprefix = "tmp.het_snp_caller.run"
        hsc = het_snp_caller.HetSnpCaller(sorted_bam, ref_fasta, outprefix)
        hsc.run()

        expected_per_contig = os.path.join(data_dir,
                                           "run.expect.per_contig.tsv")
        expected_summary = os.path.join(data_dir, "run.expect.summary.tsv")
        got_per_contig = outprefix + ".per_contig.tsv"
        got_summary = outprefix + ".summary.tsv"
        got_vcf = outprefix + ".het_calls.vcf"

        self.assertTrue(
            filecmp.cmp(expected_per_contig, got_per_contig, shallow=False))
        self.assertTrue(
            filecmp.cmp(expected_summary, got_summary, shallow=False))

        expected_lines = [
            "ref1\t251\t.\tC\tA,<*>\t0\t.\tDP=31;ADF=9,5,0;ADR=9,7,0;AD=18,12,0;I16=9,9,5,7,716,28496,479,19121,900,45000,528,23232,279,5591,203,4283;QS=0.599163,0.400837,0;VDB=0.670984;SGB=-0.680642;RPB=0.596826;MQB=2.89016e-05;MQSB=0.932405;BQB=0.994415;MQ0F=0\tPL\t251,0,255,255,255,255\n"
        ]
        with open(got_vcf) as f:
            got_lines = [x for x in f if not x.startswith("#")]
        self.assertEqual(expected_lines, got_lines)
        os.unlink(got_per_contig)
        os.unlink(got_summary)
        os.unlink(got_vcf)
Пример #2
0
    def test_run(self):
        """test run"""
        sorted_bam = os.path.join(data_dir, "run.bam")
        ref_fasta = os.path.join(data_dir, "run.ref.fa")
        outprefix = "tmp.het_snp_caller.run"
        hsc = het_snp_caller.HetSnpCaller(sorted_bam, ref_fasta, outprefix)
        hsc.run()

        expected_per_contig = os.path.join(data_dir,
                                           "run.expect.per_contig.tsv")
        expected_summary = os.path.join(data_dir, "run.expect.summary.tsv")
        got_per_contig = outprefix + ".per_contig.tsv"
        got_summary = outprefix + ".summary.tsv"
        got_vcf = outprefix + ".het_calls.vcf"

        self.assertTrue(
            filecmp.cmp(expected_per_contig, got_per_contig, shallow=False))
        self.assertTrue(
            filecmp.cmp(expected_summary, got_summary, shallow=False))
        expected_lines = [
            "ref1\t251\t.\tC\tA,<*>\t0\t.\tDP=31;ADF=9,5,0;ADR=9,8,0;AD=18,13,0;I16=9,9,5,8,720,28800,520,20800,900,45000,572,25168,279,5591,203,4283;QS=0.580645,0.419355,0;VDB=0.78464;SGB=-0.683931;RPBZ=0.621123;MQBZ=-5.47723;MQSBZ=-0.626654;BQBZ=0;SCBZ=0;FS=0;MQ0F=0\tPL\t255,0,255,255,255,255\n"
        ]
        with open(got_vcf) as f:
            got_lines = [x for x in f if not x.startswith("#")]
        self.assertEqual(expected_lines, got_lines)
        os.unlink(got_per_contig)
        os.unlink(got_summary)
        os.unlink(got_vcf)
Пример #3
0
    def run(self):
        try:
            os.mkdir(self.outdir)
        except:
            raise Exception("Error making output directory " + self.outdir)

        outprefix = os.path.join(self.outdir, "samtools_qc")
        samfile = os.path.join(self.outdir, "tmp.sam")
        SamtoolsQc._map_reads(self.ref_fasta, self.reads1, self.reads2,
                              samfile)
        SamtoolsQc._make_stats_and_plots(samfile, self.ref_fasta, outprefix)
        hsc = het_snp_caller.HetSnpCaller(
            samfile, self.ref_fasta, os.path.join(self.outdir, "het_snps"))
        hsc.run()
        self.stats = SamtoolsQc.stats_from_report(outprefix + ".stats")
        os.unlink(samfile)
Пример #4
0
    def run(self):
        try:
            os.mkdir(self.outdir)
        except:
            raise Error('Error making output directory ' + self.outdir)

        outprefix = os.path.join(self.outdir, 'samtools_qc')
        samfile = os.path.join(self.outdir, 'tmp.sam')
        SamtoolsQc._map_reads(self.ref_fasta, self.reads1, self.reads2,
                              samfile)
        SamtoolsQc._make_stats_and_plots(samfile, self.ref_fasta, outprefix)
        hsc = het_snp_caller.HetSnpCaller(
            samfile, self.ref_fasta, os.path.join(self.outdir, 'het_snps'))
        hsc.run()
        self.stats = SamtoolsQc.stats_from_report(outprefix + '.stats')
        os.unlink(samfile)