当前位置: 首页>>代码示例>>Python>>正文


Python TemporaryDir.close方法代码示例

本文整理汇总了Python中crumbs.utils.file_utils.TemporaryDir.close方法的典型用法代码示例。如果您正苦于以下问题:Python TemporaryDir.close方法的具体用法?Python TemporaryDir.close怎么用?Python TemporaryDir.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在crumbs.utils.file_utils.TemporaryDir的用法示例。


在下文中一共展示了TemporaryDir.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tophat_paired

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_tophat_paired(self):
        reference_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')
        reads_1_fpath = os.path.join(TEST_DATA_DIR, 'reads_1.fastq')
        reads_2_fpath = os.path.join(TEST_DATA_DIR, 'reads_2.fastq')
        try:
            directory = TemporaryDir()
            index_fpath = get_or_create_bowtie2_index(reference_fpath,
                                                      directory.name)
            map_with_tophat(index_fpath, directory.name,
                            paired_fpaths=[reads_1_fpath, reads_2_fpath])
            os.path.exists(os.path.join(directory.name, 'accepted_hits.bam'))
            self.fail('runtimeError expected')
        except RuntimeError:
            pass
        finally:
            directory.close()

        try:
            directory = TemporaryDir()
            index_fpath = get_or_create_bowtie2_index(reference_fpath,
                                                      directory.name)
            map_with_tophat(index_fpath, directory.name,
                            paired_fpaths=[reads_1_fpath, reads_2_fpath],
                            mate_inner_dist=350, mate_std_dev=50)
            os.path.exists(os.path.join(directory.name, 'accepted_hits.bam'))
        finally:
            directory.close()
开发者ID:JoseBlanca,项目名称:seq_crumbs,代码行数:29,代码来源:test_mapping.py

示例2: test_tophat

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
 def test_tophat(self):
     reference_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')
     reads_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fastq')
     directory = TemporaryDir()
     index_fpath = get_or_create_bowtie2_index(reference_fpath,
                                               directory.name)
     map_with_tophat(index_fpath, directory.name,
                     unpaired_fpath=reads_fpath)
     os.path.exists(os.path.join(directory.name, 'accepted_hits.bam'))
     directory.close()
开发者ID:JoseBlanca,项目名称:seq_crumbs,代码行数:12,代码来源:test_mapping.py

示例3: test_map_with_bowtie2

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_map_with_bowtie2(self):
        reference_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')
        reads_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fastq')
        directory = TemporaryDir()
        index_fpath = get_or_create_bowtie2_index(reference_fpath,
                                                  directory.name)
        bam_fhand = NamedTemporaryFile(suffix='.bam')
        map_with_bowtie2(index_fpath, bam_fhand.name,
                         unpaired_fpaths=[reads_fpath])

        directory.close()
开发者ID:bharatpatel,项目名称:seq_crumbs,代码行数:13,代码来源:test_mapping.py

示例4: test_map_with_bwa

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_map_with_bwa(self):
        reference_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')
        reads_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fastq')
        directory = TemporaryDir()
        index_fpath = get_or_create_bwa_index(reference_fpath, directory.name)
        bam_fhand = NamedTemporaryFile(suffix='.bam')
        map_with_bwasw(index_fpath, bam_fhand.name, unpaired_fpath=reads_fpath)
        out = subprocess.check_output([get_binary_path('samtools'), 'view',
                                       bam_fhand.name])
        assert  'TTCTGATTCAATCTACTTCAAAGTTGGCTTTATCAATAAG' in out

        directory.close()
开发者ID:bharatpatel,项目名称:seq_crumbs,代码行数:14,代码来源:test_mapping.py

示例5: test_plot_window

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_plot_window(self):
        iterator = itertools.chain(self.gen_windows(),
                                   self.gen_windows('ch2'))
        tempdir = TemporaryDir()
        out_base = join(tempdir.name, 'out')
        labels = OrderedDict({'val1': {'title': 'val1 title',
                                       'ylabel': 'val1 ylabel'},
                              'val2': {'title': 'val2 title',
                                       'ylabel': 'val2 ylabel'}})

        plot_in_genome(iterator, out_base=out_base, labels=labels)
        # raw_input(tempdir.name)
        tempdir.close()
开发者ID:JoseBlanca,项目名称:vcf_crumbs,代码行数:15,代码来源:test_plot.py

示例6: test_plot_window

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_plot_window(self):
        iterator = itertools.chain(self.gen_windows(), self.gen_windows("ch2"))
        tempdir = TemporaryDir()
        out_base = join(tempdir.name, "out")
        labels = OrderedDict(
            {
                "val1": {"title": "val1 title", "ylabel": "val1 ylabel"},
                "val2": {"title": "val2 title", "ylabel": "val2 ylabel"},
            }
        )

        plot_in_genome(iterator, out_base=out_base, labels=labels)
        # raw_input(tempdir.name)
        tempdir.close()
开发者ID:JoseBlanca,项目名称:seq_crumbs,代码行数:16,代码来源:test_plot.py

示例7: test_blastdb

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
 def test_blastdb():
     'It creates a blast database.'
     db_name = 'arabidopsis_genes'
     seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
     db_dir = TemporaryDir(prefix='blast_dbs_')
     try:
         db_path1 = get_or_create_blastdb(seq_fpath, directory=db_dir.name,
                                 dbtype='nucl')
         db_path = os.path.join(db_dir.name, db_name)
         assert 'CATAGGGTCACCAATGGC' in open(db_path1).read(100)
         assert db_path1 == db_path
         assert os.path.exists(db_path)
         index_fpath = os.path.join(db_dir.name, db_name + '.nsq')
         assert os.path.exists(index_fpath)
     finally:
         db_dir.close()
开发者ID:fastq,项目名称:seq_crumbs,代码行数:18,代码来源:test_blast.py

示例8: test_blast_search

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
 def test_blast_search(self):
     'It does a blast search'
     db_name = 'arabidopsis_genes'
     seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
     db_dir = TemporaryDir(prefix='blast_dbs_')
     try:
         db_fpath = get_or_create_blastdb(seq_fpath, directory=db_dir.name,
                                           dbtype='nucl')
         query_fhand = NamedTemporaryFile()
         query_fhand.write(open(seq_fpath).read(200))
         query_fhand.flush()
         out_fhand = NamedTemporaryFile()
         do_blast(seq_fpath, db_fpath, program='blastn',
                  out_fpath=out_fhand.name)
         assert '</BlastOutput>' in open(out_fhand.name).read()
     finally:
         db_dir.close()
开发者ID:charles-plessy,项目名称:seq_crumbs,代码行数:19,代码来源:test_blast.py

示例9: test_get_or_create_index

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_get_or_create_index(self):
        db_name = 'arabidopsis_genes'
        seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
        assert _bowtie2_index_exists(seq_fpath)

        directory = TemporaryDir()
        index_fpath = get_or_create_bowtie2_index(seq_fpath, directory.name)
        expected_index = os.path.join(directory.name,
                                      os.path.basename(db_name))
        assert index_fpath == expected_index
        assert _bowtie2_index_exists(index_fpath)

        # already exists
        index_fpath = get_or_create_bowtie2_index(seq_fpath, directory.name)
        assert index_fpath == expected_index
        assert _bowtie2_index_exists(index_fpath)
        directory.close()
开发者ID:JoseBlanca,项目名称:seq_crumbs,代码行数:19,代码来源:test_mapping.py

示例10: test_run_binary

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_run_binary(self):
        binary = join(VCF_BIN_DIR, 'annotate_snvs')
        assert 'usage' in check_output([binary, '-h'])

        config = '''[1]
    [[CloseToSnv]]
        distance = 60
        max_maf_depth = 0.7
[2]
    [[HighVariableRegion]]
        max_variability = 0.05
        window_in_bp = 101
        ref_fpath = '{sample_fasta}'
[3]
    [[CapEnzyme]]
        all_enzymes = True
        ref_fpath = '{sample_fasta}'

[4]
    [[HeterozigoteInSamples]]
        filter_id = 1
[5]
    [[IsVariableDepthAnnotator]]
        filter_id = 1
        samples = ['pep']
[6]
    [[LowComplexityRegionAnnotator]]
        ref_fpath = '{sample_fasta}'
'''
        config = config.format(sample_fasta=REF_FREEBAYES)

        config_fhand = NamedTemporaryFile(suffix='.config')
        config_fhand.write(config)
        config_fhand.flush()
        tmp_dir = TemporaryDir()
        cmd = [binary, FREEBAYES3_VCF_PATH, '-f', config_fhand.name,
               '-p', tmp_dir.name]
        # raw_input(' '.join(cmd))
        result = check_output(cmd)
        tmp_dir.close()
        # print result
        assert 'cs60_0.70\t' in result
        assert 'CAP=MmeI' in result
        assert 'HIS1=True' in result
        assert '\tPASS\t' in result
开发者ID:fw1121,项目名称:ngs_crumbs,代码行数:47,代码来源:test_vcf_annotation.py

示例11: test_get_or_create_blastdb

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_get_or_create_blastdb():
        blastdb = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')

        directory = TemporaryDir()
        assert not _blastdb_exists(blastdb, NUCL)
        get_or_create_blastdb(blastdb, NUCL, directory.name)
        new_blast_path = os.path.join(directory.name,
                                      os.path.basename(blastdb))
        assert _blastdb_exists(new_blast_path, NUCL)
        get_or_create_blastdb(blastdb, NUCL, directory.name)
        assert _blastdb_exists(new_blast_path, NUCL)
        directory.close()

        # already exists
        blastdb = os.path.join(TEST_DATA_DIR, 'blastdbs', 'arabidopsis_genes')
        assert _blastdb_exists(blastdb, NUCL)
        get_or_create_blastdb(blastdb, NUCL)
        assert _blastdb_exists(blastdb, NUCL)
开发者ID:fastq,项目名称:seq_crumbs,代码行数:20,代码来源:test_blast.py

示例12: test_add_rg_to_bam

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_add_rg_to_bam(self):
        reference_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')
        reads_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fastq')
        directory = TemporaryDir()
        index_fpath = get_or_create_bwa_index(reference_fpath, directory.name)
        bam_fhand = NamedTemporaryFile(suffix='.bam')
        lib_name = 'aa'
        log_fhand = NamedTemporaryFile()
        readgroup = {'ID': lib_name, 'PL': 'illumina', 'LB': lib_name,
                     'SM': '{0}_illumina_pe'.format(lib_name), 'PU': '0'}
        bwa = map_with_bwamem(index_fpath, unpaired_fpath=reads_fpath,
                              readgroup=readgroup, log_fpath=log_fhand.name)
        map_process_to_bam(bwa, bam_fhand.name)
        out = subprocess.check_output([get_binary_path('samtools'), 'view',
                                       '-h', bam_fhand.name], stderr=log_fhand)
        assert '@RG\tID:aa' in out
        assert 'TTCTGATTCAATCTACTTCAAAGTTGGCTTTATCAATAAG' in out

        directory.close()
开发者ID:JoseBlanca,项目名称:seq_crumbs,代码行数:21,代码来源:test_mapping.py

示例13: test_filter_by_bowtie2_bin

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_filter_by_bowtie2_bin():
        filter_bin = os.path.join(BIN_DIR, 'filter_by_bowtie2')
        assert 'usage' in check_output([filter_bin, '-h'])
        directory = TemporaryDir()
        index_fpath = get_or_create_bowtie2_index(os.path.join(TEST_DATA_DIR,
                                                          'arabidopsis_genes'),
                                                  directory=directory.name)

        fastq_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fastq')
        fasta_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fasta')
        for reads_fpath in [fastq_fpath, fasta_fpath]:
            out_fhand = NamedTemporaryFile(suffix='.seqs')
            filtered_fhand = NamedTemporaryFile(suffix='.seqs')
            cmd = [filter_bin, '-i', index_fpath, '-o', out_fhand.name,
                   '-e', filtered_fhand.name, reads_fpath]
            check_output(cmd)
            assert 'no_arabi' in open(out_fhand.name).read()
            assert 'read1' in open(filtered_fhand.name).read()
        directory.close()
开发者ID:milw,项目名称:seq_crumbs,代码行数:21,代码来源:test_filters.py

示例14: test_filter_by_bowtie2

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def test_filter_by_bowtie2():
        directory = TemporaryDir()
        index_fpath = get_or_create_bowtie2_index(os.path.join(TEST_DATA_DIR,
                                                          'arabidopsis_genes'),
                                                  directory=directory.name)
        fastq_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fastq')
        fasta_fpath = os.path.join(TEST_DATA_DIR, 'arabidopsis_reads.fasta')

        passed = ['no_arabi']
        for preffered_classes in [[SEQITEM], [SEQRECORD]]:
            for reads_fpath in [fastq_fpath, fasta_fpath]:
                seq_packets = read_seq_packets([open(reads_fpath)],
                                        prefered_seq_classes=preffered_classes)
                filter_packets = seq_to_filterpackets(seq_packets)
                filter_ = FilterBowtie2Match(index_fpath)
                filter_packet = list(filter_packets)[0]
                filter_packets = filter_(filter_packet)
                assert _seqs_to_names(filter_packets[SEQS_PASSED]) == passed
                assert _seqs_to_names(filter_packets[SEQS_FILTERED_OUT]) == [
                                                     'read1', 'read2', 'read3']
        directory.close()
开发者ID:milw,项目名称:seq_crumbs,代码行数:23,代码来源:test_filters.py

示例15: _look_for_blast_matches

# 需要导入模块: from crumbs.utils.file_utils import TemporaryDir [as 别名]
# 或者: from crumbs.utils.file_utils.TemporaryDir import close [as 别名]
    def _look_for_blast_matches(self, seq_fpath, oligos):
        "It looks for the oligos in the given sequence files"
        # we need to keep the blast_fhands, because they're temp files and
        # otherwise they might be removed
        temp_dir = TemporaryDir()
        dbpath = os.path.join(temp_dir.name, os.path.basename(seq_fpath))
        seqio([open(seq_fpath)], [open(dbpath, "w")], out_format="fasta", copy_if_same_format=False)

        blasts, blast_fhand = _do_blast_2(dbpath, oligos, params=self.params, program=self.program)
        if self.filters is not None:
            blasts = filter_alignments(blasts, config=self.filters)

        # Which are the regions covered in each sequence?
        indexed_match_parts = {}
        one_oligo = True if len(oligos) == 1 else False
        for blast in blasts:
            oligo = blast["query"]
            for match in blast["matches"]:
                read = match["subject"]
                if self.elongate_for_global:
                    elongate_match_parts_till_global(
                        match["match_parts"],
                        query_length=oligo["length"],
                        subject_length=read["length"],
                        align_completely=QUERY,
                    )

                # match_parts = [m['match_parts'] for m in blast['matches']]
                match_parts = match["match_parts"]
                if one_oligo:
                    indexed_match_parts[read["name"]] = match_parts
                else:
                    try:
                        indexed_match_parts[read["name"]].extend(match_parts)
                    except KeyError:
                        indexed_match_parts[read["name"]] = match_parts

        temp_dir.close()
        blast_fhand.close()
        return indexed_match_parts
开发者ID:charles-plessy,项目名称:seq_crumbs,代码行数:42,代码来源:blast.py


注:本文中的crumbs.utils.file_utils.TemporaryDir.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。