本文整理汇总了Python中dark.titles.TitlesAlignments.toDict方法的典型用法代码示例。如果您正苦于以下问题:Python TitlesAlignments.toDict方法的具体用法?Python TitlesAlignments.toDict怎么用?Python TitlesAlignments.toDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dark.titles.TitlesAlignments
的用法示例。
在下文中一共展示了TitlesAlignments.toDict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TitlesAlignments
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import toDict [as 别名]
titlesAlignments = TitlesAlignments(readsAlignments).filter(
minMatchingReads=args.minMatchingReads,
minMedianScore=args.minMedianScore,
withScoreBetterThan=args.withScoreBetterThan,
minNewReads=args.minNewReads, maxTitles=args.maxTitles,
sortOn=args.sortOn, minCoverage=args.minCoverage)
nTitles = len(titlesAlignments)
print('Found %d interesting title%s.' %
(nTitles, '' if nTitles == 1 else 's'), file=sys.stderr)
# If we've been asked to save the matched title information in JSON,
# write it out.
if args.titlesJSONFile:
with open(args.titlesJSONFile, 'w') as fp:
dump(titlesAlignments.toDict(), fp, sort_keys=True, indent=2,
separators=(',', ': '))
if nTitles:
# Use flush=True on the print of the titles so the output is
# definitely written out. This is because in some cases the
# following aligment panel generation takes a long time and exceeds
# its CPU or memory limit on an HPCS system. Also, it can be good
# to see the matching title details while waiting for the panel
# plots to be generated.
print(titlesAlignments.tabSeparatedSummary(sortOn=args.sortOn),
flush=True)
if args.earlyExit:
sys.exit(0)
示例2: testToDict
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import toDict [as 别名]
def testToDict(self):
"""
The toDict method must return the expected value.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'C' * 70))
reads.add(Read('id2', 'G' * 70))
reads.add(Read('id3', 'T' * 70))
readsAlignments = BlastReadsAlignments(
reads, 'file.json', scoreClass=LowerIsBetterScore)
titlesAlignments = TitlesAlignments(readsAlignments)
self.assertEqual(
{
'scoreClass': 'LowerIsBetterScore',
'titles': {
'gi|887699|gb|DQ37780 Cowpox virus 15': {
'subjectLength': 30000,
'subjectTitle': 'gi|887699|gb|DQ37780 Cowpox virus 15',
'titleAlignments': [
{
'hsps': [
{
'identicalCount': None,
'positiveCount': None,
'readEnd': 68,
'readEndInSubject': 1405,
'readFrame': 1,
'readMatchedSequence': (
'TACCCTGCGGCCCGCTACGGCTGG-TCTCCA'),
'readStart': 27,
'readStartInSubject': 1334,
'score': 1e-06,
'subjectEnd': 1400,
'subjectFrame': 1,
'subjectMatchedSequence': (
'TACCC--CGGCCCGCG-CGGCCGGCTCTCCA'),
'subjectStart': 1361}],
'read': {
'id': 'id2',
'quality': None,
'sequence': 'G' * 70,
}
},
{
'hsps': [
{
'identicalCount': None,
'positiveCount': None,
'readEnd': 68,
'readEndInSubject': 1405,
'readFrame': 1,
'readMatchedSequence': (
'TACCCTGCGGCCCGCTACGGCTGG-TCTCCA'),
'readStart': 27,
'readStartInSubject': 1334,
'score': 1e-05,
'subjectEnd': 1400,
'subjectFrame': 1,
'subjectMatchedSequence': (
'TACCC--CGGCCCGCG-CGGCCGGCTCTCCA'),
'subjectStart': 1361}],
'read': {
'id': 'id3',
'quality': None,
'sequence': 'T' * 70,
},
},
],
},
'gi|887699|gb|DQ37780 Monkeypox virus 456': {
'subjectLength': 35000,
'subjectTitle': (
'gi|887699|gb|DQ37780 Monkeypox virus 456'),
'titleAlignments': [
{
'hsps': [
{
'identicalCount': None,
'positiveCount': None,
'readEnd': 68,
'readEndInSubject': 11405,
'readFrame': 1,
'readMatchedSequence': (
'TACCCTGCGGCCCGCTACGGCTGG-TCTCCA'),
'readStart': 27,
'readStartInSubject': 11334,
'score': 1e-08,
'subjectEnd': 11400,
'subjectFrame': 1,
'subjectMatchedSequence': (
'TACCC--CGGCCCGCG-CGGCCGGCTCTCCA'),
'subjectStart': 11361}],
'read': {
#.........这里部分代码省略.........