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


Python Reads.save方法代码示例

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


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

示例1: testSaveToFileDescriptor

# 需要导入模块: from dark.reads import Reads [as 别名]
# 或者: from dark.reads.Reads import save [as 别名]
 def testSaveToFileDescriptor(self):
     """
     A Reads instance must save to a file-like object if not passed a string
     filename.
     """
     reads = Reads()
     read1 = Read('id1', 'AT')
     read2 = Read('id2', 'AC')
     reads.add(read1)
     reads.add(read2)
     fp = StringIO()
     reads.save(fp)
     self.assertEqual('>id1\nAT\n>id2\nAC\n', fp.getvalue())
开发者ID:sophiemathias,项目名称:dark-matter,代码行数:15,代码来源:test_reads.py

示例2: testSaveAsFASTA

# 需要导入模块: from dark.reads import Reads [as 别名]
# 或者: from dark.reads.Reads import save [as 别名]
 def testSaveAsFASTA(self):
     """
     A Reads instance must be able to save in FASTA format.
     """
     reads = Reads()
     read1 = Read('id1', 'AT')
     read2 = Read('id2', 'AC')
     reads.add(read1)
     reads.add(read2)
     mockOpener = mockOpen()
     with patch('__builtin__.open', mockOpener, create=True):
         reads.save('filename', 'fasta')
     handle = mockOpener()
     self.assertEqual([call('>id1\nAT\n'), call('>id2\nAC\n')],
                      handle.write.call_args_list)
开发者ID:sophiemathias,项目名称:dark-matter,代码行数:17,代码来源:test_reads.py

示例3: testSaveWithUppercaseFormat

# 需要导入模块: from dark.reads import Reads [as 别名]
# 或者: from dark.reads.Reads import save [as 别名]
 def testSaveWithUppercaseFormat(self):
     """
     A Reads instance must save correctly when the format string is
     given in upper case.
     """
     reads = Reads()
     read1 = Read('id1', 'AT')
     read2 = Read('id2', 'AC')
     reads.add(read1)
     reads.add(read2)
     mockOpener = mockOpen()
     with patch('__builtin__.open', mockOpener, create=True):
         reads.save('filename', 'FASTA')
     handle = mockOpener()
     self.assertEqual([call('>id1\nAT\n'), call('>id2\nAC\n')],
                      handle.write.call_args_list)
开发者ID:sophiemathias,项目名称:dark-matter,代码行数:18,代码来源:test_reads.py

示例4: _writeFASTA

# 需要导入模块: from dark.reads import Reads [as 别名]
# 或者: from dark.reads.Reads import save [as 别名]
    def _writeFASTA(self, i, image):
        """
        Write a FASTA file containing the set of reads that hit a sequence.

        @param i: The number of the image in self._images.
        @param image: A member of self._images.
        @return: A C{dark.reads.Reads} instance holding the reads for the
            image title.
        """
        reads = Reads()
        title = image['title']
        titleAlignments = self._titlesAlignments[title]
        for titleAlignment in titleAlignments:
            reads.add(titleAlignment.read)
        filename = '%s/%d.fasta' % (self._outputDir, i)
        reads.save(filename, 'fasta')
        return reads
开发者ID:sophiemathias,项目名称:dark-matter,代码行数:19,代码来源:html.py

示例5: add

# 需要导入模块: from dark.reads import Reads [as 别名]
# 或者: from dark.reads.Reads import save [as 别名]
    def add(self, pathogenName, sampleName):
        """
        Add a (pathogen name, sample name) combination and get its FASTA/FASTQ
        file name and unique read count. Write the FASTA/FASTQ file if it does
        not already exist. Save the unique read count into
        C{self._proteinGrouper}.

        @param pathogenName: A C{str} pathogen name.
        @param sampleName: A C{str} sample name.
        @return: A C{str} giving the FASTA/FASTQ file name holding all the
            reads (without duplicates, by id) from the sample that matched the
            proteins in the given pathogen.
        """
        pathogenIndex = self._pathogens.setdefault(pathogenName,
                                                   len(self._pathogens))
        sampleIndex = self._samples.setdefault(sampleName, len(self._samples))

        try:
            return self._readsFilenames[(pathogenIndex, sampleIndex)]
        except KeyError:
            reads = Reads()
            for proteinMatch in self._proteinGrouper.pathogenNames[
                    pathogenName][sampleName]['proteins'].values():
                for read in self._readsClass(proteinMatch['readsFilename']):
                    reads.add(read)
            saveFilename = join(
                proteinMatch['outDir'],
                'pathogen-%d-sample-%d.%s' % (pathogenIndex, sampleIndex,
                                              self._format))
            reads.filter(removeDuplicatesById=True)
            nReads = reads.save(saveFilename, format_=self._format)
            # Save the unique read count into self._proteinGrouper
            self._proteinGrouper.pathogenNames[
                pathogenName][sampleName]['uniqueReadCount'] = nReads
            self._readsFilenames[(pathogenIndex, sampleIndex)] = saveFilename
            return saveFilename
开发者ID:bamueh,项目名称:dark-matter,代码行数:38,代码来源:proteins.py

示例6: map

# 需要导入模块: from dark.reads import Reads [as 别名]
# 或者: from dark.reads.Reads import save [as 别名]
if args.alignmentFile:
    args.align = True

if args.align:
    len1, len2 = map(len, reads)
    if len1 == len2:
        print('Pre-alignment, sequence lengths were identical: %s' % len1)
    else:
        print('Pre-alignment, sequence lengths: %d, %d (difference %d)' % (
            len1, len2, abs(len1 - len2)))

    # Align.
    reads = needle(reads)

    if args.alignmentFile:
        assert reads.save(args.alignmentFile) == 2

offsets = (parseRangeString(args.sites, convertToZeroBased=True)
           if args.sites else None)

read1, read2 = reads
len1, len2 = map(len, reads)
identicalLengths = len1 == len2

# Sanity check.
if args.align:
    assert identicalLengths

match = compareDNAReads(read1, read2, matchAmbiguous=(not args.strict),
                        offsets=offsets)
开发者ID:acorg,项目名称:dark-matter,代码行数:32,代码来源:compare-sequences.py


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