示例#1
0
    def testGapAndMatch(self):
        """
        Two sequences containing matches and gaps must compare as
        expected.
        """
        read1 = AARead('id1', 'GALHN-')
        read2 = AARead('id2', 'GALHNA')
        match = compareAaReads(read1, read2)

        self.assertEqual(
            '''\
Matches: 5/6 (83.33%)
Mismatches: 1/6 (16.67%)
  Not involving gaps (i.e., conflicts): 0
  Involving a gap in one sequence: 1/6 (16.67%)
  Involving a gap in both sequences: 0
  Id: id1
    Length: 6
    Gaps: 1/6 (16.67%)
    Gap locations (1-based): 6
  Id: id2
    Length: 6
    Gaps: 0''',
            matchToString(match, read1, read2)
        )
示例#2
0
identicalLengths = len1 == len2

# Sanity check.
if args.align:
    assert identicalLengths

match = compareAaReads(read1, read2, offsets=offsets)

x = 'Post-alignment, sequence' if args.align else 'Sequence'
if identicalLengths:
    print('%s lengths are identical: %s' % (x, len1))
else:
    print('%s lengths: %d, %d (difference %d)' % (x, len1, len2,
                                                  abs(len1 - len2)))

print(matchToString(match, read1, read2, offsets=offsets))

if args.showDiffs:
    # Print all sites where the sequences differ.
    width = int(log10(max(len1, len2))) + 1
    headerPrinted = False
    for site, (a, b) in enumerate(zip(read1.sequence, read2.sequence),
                                  start=1):
        if a != b:
            if not headerPrinted:
                print('Differences (site, %s, %s):' % (read1.id, read2.id))
                headerPrinted = True
            print('  %*d %s %s' % (width, site, a, b))

    if not headerPrinted:
        print('No sequence differences found.')
示例#3
0
identicalLengths = len1 == len2

# Sanity check.
if args.align:
    assert identicalLengths

match = compareAaReads(read1, read2, offsets=offsets)

x = 'Post-alignment, sequence' if args.align else 'Sequence'
if identicalLengths:
    print('%s lengths are identical: %s' % (x, len1))
else:
    print('%s lengths: %d, %d (difference %d)' %
          (x, len1, len2, abs(len1 - len2)))

print(matchToString(match, read1, read2, offsets=offsets))

if args.showDiffs:
    # Print all sites where the sequences differ.
    width = int(log10(max(len1, len2))) + 1
    headerPrinted = False
    for site, (a, b) in enumerate(zip(read1.sequence, read2.sequence),
                                  start=1):
        if a != b:
            if not headerPrinted:
                print('Differences (site, %s, %s):' % (read1.id, read2.id))
                headerPrinted = True
            print('  %*d %s %s' % (width, site, a, b))

    if not headerPrinted:
        print('No sequence differences found.')