Example #1
0
 def testSimple(self):
     """
     A simple example must work as expected.
     """
     counts = Counter()
     counts['A'] += 1
     counts['G'] += 2
     self.assertEqual('A:1 G:2', baseCountsToStr(counts))
Example #2
0
 def testSimple(self):
     """
     A simple example must work as expected.
     """
     counts = Counter()
     counts['A'] += 1
     counts['G'] += 2
     self.assertEqual('A:1 G:2',
                      baseCountsToStr(counts))
Example #3
0
    for column in sam.pileup(reference=referenceId):
        bases = Counter()
        for read in column.pileups:
            if filterRead(read):
                base = read.alignment.query_sequence[read.query_position]
                bases[base] += 1

        baseCount = sum(bases.values())

        if printStats:
            counts.append(baseCount)

        if printOffsets:
            print(
                '%d: %d %s' %
                (column.reference_pos + 1, baseCount, baseCountsToStr(bases)))

if printStats:
    referenceLength = referenceLengths[referenceId]
    print('Reference id: %s' % referenceId)
    print('Reference length: %d' % referenceLength)
    print('Bases covered: %s' % pct(len(counts), referenceLength))
    print('Min coverage depth: %d' %
          (0 if len(counts) < referenceLength else min(counts)))
    if counts:
        # Don't use Python3 default= option on max. Trying to keep Python 2
        # compatibility.
        print('Max coverage depth: %d' % max(counts))
    else:
        print('Max coverage depth: 0')
    print('Mean coverage depth: %.3f' % (sum(counts) / referenceLength))