Ejemplo n.º 1
0
    def test_ref_assisted_assembly(self):
        novoalign = tools.novoalign.NovoalignTool()
        novoalign.install()

        # prep inputs
        orig_ref = os.path.join(util.file.get_test_input_path(), 'ebov-makona.fasta')
        refGenome = util.file.mkstempfname('.ref.fasta')
        shutil.copyfile(orig_ref, refGenome)
        novoalign.index_fasta(refGenome)
        inBam = os.path.join(util.file.get_test_input_path(), 'G5012.3.testreads.bam')
        outFasta = util.file.mkstempfname('.refined.fasta')

        # run refine_assembly
        args = [refGenome, inBam, outFasta, "--chr_names", 'G5012.3', "--min_coverage", '3', "--novo_params",
                "-r Random -l 30 -g 40 -x 20 -t 502"]
        args = assembly.parser_refine_assembly().parse_args(args)
        args.func_main(args)
        self.assertTrue(os.path.isfile(outFasta))
        self.assertTrue(os.path.getsize(outFasta) > 1000)

        # check assembly quality
        with open(outFasta, 'rt') as inf:
            seq = Bio.SeqIO.read(inf, 'fasta')
            self.assertGreater(len(seq), 17000)
            self.assertGreater(assembly.unambig_count(seq.seq), len(seq) * 0.95)
Ejemplo n.º 2
0
    def test_empty_input_succeed(self):
        novoalign = tools.novoalign.NovoalignTool()
        novoalign.install()

        # make the input fasta empty
        inFasta = util.file.mkstempfname('.input.fasta')
        util.file.touch(inFasta)
        novoalign.index_fasta(inFasta)

        inBam = os.path.join(util.file.get_test_input_path(), 'empty.bam')

        outFasta = util.file.mkstempfname('.refined.fasta')

        # run refine_assembly
        args = [
            inFasta, inBam, outFasta, "--chr_names", 'G5012.3',
            "--min_coverage", '3', "--novo_params",
            "-r Random -l 30 -g 40 -x 20 -t 502 -c {}".format(_CPUS)
        ]
        args = assembly.parser_refine_assembly(
            argparse.ArgumentParser()).parse_args(args)
        print(args)
        args.func_main(args)

        # the expected output is an empty fasta file
        self.assertTrue(os.path.isfile(outFasta))
        self.assertTrue(os.path.getsize(outFasta) == 0)
Ejemplo n.º 3
0
    def test_empty_input_bam_assembly(self):
        novoalign = tools.novoalign.NovoalignTool()
        novoalign.install()

        # prep inputs
        orig_ref = os.path.join(util.file.get_test_input_path(),
                                'ebov-makona.fasta')
        inFasta = util.file.mkstempfname('.ref.fasta')
        shutil.copyfile(orig_ref, inFasta)
        novoalign.index_fasta(inFasta)

        inBam = os.path.join(util.file.get_test_input_path(), 'empty.bam')

        outFasta = util.file.mkstempfname('.refined.fasta')

        # run refine_assembly
        args = [
            inFasta, inBam, outFasta, "--chr_names", 'G5012.3',
            "--min_coverage", '3', "--novo_params",
            "-r Random -l 30 -g 40 -x 20 -t 502"
        ]
        args = assembly.parser_refine_assembly(
            argparse.ArgumentParser()).parse_args(args)
        args.func_main(args)

        # the expected output is an empty fasta file
        self.assertTrue(os.path.isfile(outFasta))
        self.assertTrue(os.path.getsize(outFasta) == 0)
Ejemplo n.º 4
0
    def test_ref_assisted_assembly(self):
        novoalign = tools.novoalign.NovoalignTool()
        novoalign.install()

        # prep inputs
        orig_ref = os.path.join(util.file.get_test_input_path(), 'ebov-makona.fasta')
        refGenome = util.file.mkstempfname('.ref.fasta')
        shutil.copyfile(orig_ref, refGenome)
        novoalign.index_fasta(refGenome)
        inBam = os.path.join(util.file.get_test_input_path(), 'G5012.3.testreads.bam')
        outFasta = util.file.mkstempfname('.refined.fasta')

        # run refine_assembly
        args = [refGenome, inBam, outFasta, "--chr_names", 'G5012.3', "--min_coverage", '3', "--novo_params",
                "-r Random -l 30 -g 40 -x 20 -t 502"]
        args = assembly.parser_refine_assembly().parse_args(args)
        args.func_main(args)
        self.assertTrue(os.path.isfile(outFasta))
        self.assertTrue(os.path.getsize(outFasta) > 1000)

        # check assembly quality
        with open(outFasta, 'rt') as inf:
            seq = Bio.SeqIO.read(inf, 'fasta')
            self.assertGreater(len(seq), 17000)
            self.assertGreater(assembly.unambig_count(seq.seq), len(seq) * 0.95)
Ejemplo n.º 5
0
    def test_empty_input_fasta_assembly(self):
        novoalign = tools.novoalign.NovoalignTool()
        novoalign.install()

        # make the input fasta empty
        inFasta = util.file.mkstempfname('.input.fasta')
        util.file.touch(inFasta)
        novoalign.index_fasta(inFasta)

        inBam = os.path.join(util.file.get_test_input_path(), 'G5012.3.testreads.bam')

        outFasta = util.file.mkstempfname('.refined.fasta')

        # run refine_assembly
        args = [inFasta, inBam, outFasta, "--chr_names", 'G5012.3', "--min_coverage", '3', "--novo_params",
                "-r Random -l 30 -g 40 -x 20 -t 502 -c {}".format(_CPUS)]
        args = assembly.parser_refine_assembly(argparse.ArgumentParser()).parse_args(args)
        args.func_main(args)

        # the expected output is an empty fasta file
        self.assertTrue(os.path.isfile(outFasta))
        self.assertTrue(os.path.getsize(outFasta) == 0)
Ejemplo n.º 6
0
    def test_empty_input_bam_assembly(self):
        novoalign = tools.novoalign.NovoalignTool()
        novoalign.install()

        # prep inputs
        orig_ref = os.path.join(util.file.get_test_input_path(), 'ebov-makona.fasta')
        inFasta = util.file.mkstempfname('.ref.fasta')
        shutil.copyfile(orig_ref, inFasta)
        novoalign.index_fasta(inFasta)

        inBam = os.path.join(util.file.get_test_input_path(), 'empty.bam')
        
        outFasta = util.file.mkstempfname('.refined.fasta')

        # run refine_assembly
        args = [inFasta, inBam, outFasta, "--chr_names", 'G5012.3', "--min_coverage", '3', "--novo_params",
                "-r Random -l 30 -g 40 -x 20 -t 502"]
        args = assembly.parser_refine_assembly(argparse.ArgumentParser()).parse_args(args)
        args.func_main(args)

        # the expected output is an empty fasta file
        self.assertTrue(os.path.isfile(outFasta))
        self.assertTrue(os.path.getsize(outFasta) == 0)