本文整理汇总了Python中dark.sam.PaddedSAM.queries方法的典型用法代码示例。如果您正苦于以下问题:Python PaddedSAM.queries方法的具体用法?Python PaddedSAM.queries怎么用?Python PaddedSAM.queries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dark.sam.PaddedSAM
的用法示例。
在下文中一共展示了PaddedSAM.queries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testQueryTooLong
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testQueryTooLong(self):
"""
If the query sequence is longer than the total of the lengths in the
CIGAR operations, a ValueError must be raised.
"""
# This test just returns. It used to be possible to reach the
# "Query ... not fully consumed when parsing CIGAR string."
# ValueError in sam.py, prior to the fix of
# https://github.com/acorg/dark-matter/issues/630 but it is not
# possible to get a CIGAR string that has a different total length
# from the sequence length through to our code in sam.py because
# pysam catches the error. I'm leaving this test here because it
# documents that the error checked for in sam.py cannot currently
# be reached and the test may become useful. For now it just returns.
return
data = '\n'.join([
'@SQ SN:ref1 LN:90',
'query1 0 ref1 1 60 4M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
error = ('^Query TCTAGG not fully consumed when parsing CIGAR '
'string\\.')
assertRaisesRegex(self, ValueError, error, list, ps.queries())
示例2: testHardClippingInCIGARButQueryNotHardClipped
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testHardClippingInCIGARButQueryNotHardClipped(self):
"""
As documented in https://github.com/acorg/dark-matter/issues/630 we
must deal correctly with a case in which the CIGAR string says a
query is hard-clipped but the query sequence in the SAM file
actually isn't. This can be due to a prior alignment with a soft clip,
in which case the full query sequence has to be given before the
secondary alignment with the hard clip.
"""
data = '\n'.join([
'@SQ SN:Chimp-D00220 LN:8',
'@SQ SN:D-AM494716 LN:8',
'@SQ SN:D-XXX LN:8',
'@SQ SN:Chimp-YYY LN:8',
'query1 0 Chimp-D00220 1 0 3S5M * 0 0 TTTTGGTT 12345678',
'query1 256 D-AM494716 1 0 3H5M * 0 0 * *',
'query1 256 D-XXX 1 0 5H3M * 0 0 * *',
'query1 0 Chimp-YYY 1 0 8M * 0 0 * *',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read1, read2, read3, read4) = list(ps.queries(addAlignment=True))
self.assertEqual(Read('query1', 'TGGTT---', '45678!!!'), read1)
self.assertEqual('TTTTGGTT', read1.alignment.query_sequence)
self.assertEqual(Read('query1/1', 'TGGTT---', '45678!!!'), read2)
self.assertEqual('TGGTT', read2.alignment.query_sequence)
self.assertEqual(Read('query1/2', 'GTT-----', '678!!!!!'), read3)
self.assertEqual('GTT', read3.alignment.query_sequence)
self.assertEqual(Read('query1/3', 'TTTTGGTT', '12345678'), read4)
self.assertEqual('TTTTGGTT', read4.alignment.query_sequence)
示例3: testAllMMatch
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testAllMMatch(self):
"""
A simple all-'M' match must result in the expected padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 2 60 6M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', '-TCTAGG---', '!ZZZZZZ!!!'), read)
示例4: testMixedMatch
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testMixedMatch(self):
"""
A match that is a mix of M, =, and X must result in the expected
padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 2 60 2=2X2M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', '-TCTAGG---', '!ZZZZZZ!!!'), read)
示例5: testQuerySoftClipProtrudesLeft
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testQuerySoftClipProtrudesLeft(self):
"""
A match with a soft-clipped region that extends to the left of the
reference must result in the expected padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 2 60 4S2M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', 'AGG-------', 'ZZZ!!!!!!!'), read)
示例6: testQuerySoftClipReachesRightEdge
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testQuerySoftClipReachesRightEdge(self):
"""
A match with a soft-clipped region that reaches to the right edge of
the reference must result in the expected padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 5 60 2M4S * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', '----TCTAGG', '!!!!ZZZZZZ'), read)
示例7: testQuerySoftClipProtrudesBothSides
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testQuerySoftClipProtrudesBothSides(self):
"""
A match with a soft-clipped region that extends to both the left and
right of the reference must result in the expected padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 4 60 5S5M5S * 0 0 TCTAGGCTGACTAAG ZZZZZZZZZZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', 'TAGGCTGACT', 'ZZZZZZZZZZ'), read)
示例8: testReferenceDeletion
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testReferenceDeletion(self):
"""
An deletion of reference bases must result in the expected padded
sequence (with Ns inserted for the deleted reference bases).
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 2 60 2M2D4M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', '-TCNNTAGG-', '!ZZ!!ZZZZ!'), read)
示例9: testMixedMatchSpecificReferenceButNoMatches
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testMixedMatchSpecificReferenceButNoMatches(self):
"""
A request for reads aligned against a reference that exists but that
has no matches must result in an empty list.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:15',
'@SQ SN:ref2 LN:15',
'query1 0 ref1 2 60 2=2X2M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename, referenceIds={'ref2'}))
self.assertEqual([], list(ps.queries()))
示例10: testDropSecondary
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testDropSecondary(self):
"""
Dropping matches flagged as secondary must give the expected result.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 2 60 2=2X2M * 0 0 TCTAGG ZZZZZZ',
'query2 256 ref1 2 60 2= * 0 0 TC ZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename, dropSecondary=True))
(read,) = list(ps.queries())
self.assertEqual(Read('query1', '-TCTAGG---', '!ZZZZZZ!!!'), read)
示例11: testRcNeeded
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testRcNeeded(self):
"""
A reverse-complemented match (flag = 16) when rcNeeded=True is passed
must result in the expected (reverse complemented) padded sequence
and reversed quality string.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 16 ref1 2 60 6M * 0 0 TCTAGG 123456',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(SAMFilter(filename))
(read,) = list(ps.queries(rcNeeded=True))
self.assertEqual(Read('query1', '-CCTAGA---', '!654321!!!'), read)
示例12: testReferenceSkipAlternateChar
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testReferenceSkipAlternateChar(self):
"""
An skip of reference bases must result in the expected padded
sequence (with gaps) when a queryInsertionChar is passed.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 2 60 2M2N4M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(filename)
(read,) = list(ps.queries(queryInsertionChar='X'))
self.assertEqual(Read('query1', '-TCXXTAGG-'), read)
ps.close()
示例13: testQuerySoftClipProtrudesRight
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testQuerySoftClipProtrudesRight(self):
"""
A match with a soft-clipped region that extends to the right of
the reference must result in the expected padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 0 ref1 6 60 2M4S * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(filename)
(read,) = list(ps.queries())
self.assertEqual(Read('query1', '-----TCTAG'), read)
ps.close()
示例14: testRcSuffix
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testRcSuffix(self):
"""
A reverse-complimented sequence should have the rcSuffix string added
to its id when an rcSuffix value is passed.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 16 ref1 2 60 6M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(filename)
(read,) = list(ps.queries(rcSuffix='-rc'))
self.assertEqual(Read('query1-rc', '-TCTAGG---'), read)
ps.close()
示例15: testRcNeeded
# 需要导入模块: from dark.sam import PaddedSAM [as 别名]
# 或者: from dark.sam.PaddedSAM import queries [as 别名]
def testRcNeeded(self):
"""
A reverse-complimented match (flag = 16) when rcNeeded=True is passed
must result in the expected (reverse complimented) padded sequence.
"""
data = '\n'.join([
'@SQ SN:ref1 LN:10',
'query1 16 ref1 2 60 6M * 0 0 TCTAGG ZZZZZZ',
]).replace(' ', '\t')
with dataFile(data) as filename:
ps = PaddedSAM(filename)
(read,) = list(ps.queries(rcNeeded=True))
self.assertEqual(Read('query1', '-CCTAGA---'), read)
ps.close()