本文整理汇总了Python中khmer.GraphLabels.consume_seqfile_and_tag_with_labels方法的典型用法代码示例。如果您正苦于以下问题:Python GraphLabels.consume_seqfile_and_tag_with_labels方法的具体用法?Python GraphLabels.consume_seqfile_and_tag_with_labels怎么用?Python GraphLabels.consume_seqfile_and_tag_with_labels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类khmer.GraphLabels
的用法示例。
在下文中一共展示了GraphLabels.consume_seqfile_and_tag_with_labels方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_n_labels
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_n_labels():
lh = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lh.consume_seqfile_and_tag_with_labels(filename)
print(lh.n_labels())
assert lh.n_labels() == 4
示例2: test_save_load_corrupted
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_save_load_corrupted():
lb_pre = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb_pre.consume_seqfile_and_tag_with_labels(filename)
# save labels to a file
savepath = utils.get_temp_filename('saved.labels')
lb_pre.save_labels_and_tags(savepath)
# trash the old GraphLabels
del lb_pre
lb = GraphLabels(20, 1e7, 4)
# produce all possible truncated versions of this file
data = open(savepath, 'rb').read()
for i in range(len(data)):
truncated = utils.get_temp_filename('trunc.labels')
fp = open(truncated, 'wb')
fp.write(data[:i])
fp.close()
try:
lb.load_labels_and_tags(truncated)
assert 0, "this should not succeed -- truncated file len %d" % (i,)
except OSError as err:
print('expected failure for', i, ': ', str(err))
示例3: test_sweep_label_neighborhood
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_sweep_label_neighborhood():
lb = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('single-read.fq')
lb.consume_seqfile_and_tag_with_labels(filename)
labels = lb.sweep_label_neighborhood('CAGGCGCCCACCACCGTGCCCTCCAACCTGATGGT')
assert len(labels) == 1
assert labels.pop() == 0
示例4: test_get_tag_labels
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_get_tag_labels():
lb = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('single-read.fq')
lb.consume_seqfile_and_tag_with_labels(filename)
tag = 173473779682
labels = lb.get_tag_labels(tag)
assert len(labels) == 1
assert labels.pop() == 0
示例5: test_consume_seqfile_and_tag_with_labels
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_consume_seqfile_and_tag_with_labels(Graphtype):
infile = utils.get_test_data('valid-read-testing.fq')
# read this in consume_and_tag
graph = Graphtype(15, *params_1m)
x = GraphLabels(graph)
x.consume_seqfile_and_tag_with_labels(infile)
assert x.n_labels == 9
示例6: test_label_tag_correctness_save_load
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_label_tag_correctness_save_load():
lb_pre = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb_pre.consume_seqfile_and_tag_with_labels(filename)
# save labels to a file
savepath = utils.get_temp_filename('saved.labels')
lb_pre.save_labels_and_tags(savepath)
# trash the old GraphLabels
del lb_pre
# create new, load labels & tags
lb = GraphLabels(20, 1e7, 4)
lb.load_labels_and_tags(savepath)
# read A
labels = lb.sweep_label_neighborhood(
'ATCGTGTAAGCTATCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAGGCTCTGCCTAGAG'
'CTAGGCTAGGTGTGCTCTGCCTAGAGCTAGGCTAGGTGT')
print(lb.sweep_tag_neighborhood(
'TTCGTGTAAGCTATCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAGGCTCTGCCTAGAG'
'CTAGGCTAGGTGTGCTCTGCTAGAGCTAGGCTAGGTGT'))
print(labels)
print(len('ATCGTGTAAGCTATCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAG') - 19)
assert len(labels) == 2
assert 0 in labels
assert 1 in labels
# read B
labels = lb.sweep_label_neighborhood(
'GCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAGCTCTGCCTAGAGCTAGGCTAGGTGTTGGGGATAG'
'ATAGATAGATGACCTAGAGCTAGGCTAGGTGTTGGGGATAGATAGATAGATGA')
print(labels)
assert len(labels) == 3
assert 0 in labels
assert 1 in labels
assert 2 in labels
# read C
labels = lb.sweep_label_neighborhood(
'TGGGATAGATAGATAGATGACCTAGAGCTAGGCTAGGTGTTGGGGATAGATAGATAGATGACCTAGAG'
'CTAGGCTAGGTGTTGGGGATAGATAGATAGATGAGTTGGGGATAGATAGATAGATGAGTGTAGATCCA'
'ACAACACATACA')
print(labels)
assert len(labels) == 2
assert 1 in labels
assert 2 in labels
# read D
labels = lb.sweep_label_neighborhood(
'TATATATATAGCTAGCTAGCTAACTAGCTAGCATCGATCGATCGATC')
print(labels)
assert len(labels) == 1
assert 3 in labels
示例7: test_get_all_labels
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_get_all_labels():
lb = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb.consume_seqfile_and_tag_with_labels(filename)
labels = lb.get_all_labels()
expected = [0, 1, 2, 3]
for e_label in expected:
assert e_label in labels
for a_label in labels:
assert a_label in expected
示例8: test_save_fail_readonly
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_save_fail_readonly():
lb_pre = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb_pre.consume_seqfile_and_tag_with_labels(filename)
# save labels to a file
savepath = utils.get_temp_filename('saved.labels')
fp = open(savepath, 'w')
fp.close()
os.chmod(savepath, 0x444)
try:
lb_pre.save_labels_and_tags(savepath)
assert 0, "this should fail: read-only file"
except OSError as err:
print(str(err))
示例9: test_label_tag_correctness
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_label_tag_correctness():
lb = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb.consume_seqfile_and_tag_with_labels(filename)
# read A
labels = lb.sweep_label_neighborhood(
'ATCGTGTAAGCTATCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAGGCTCTGCCTAGAG'
'CTAGGCTAGGTGTGCTCTGCCTAGAGCTAGGCTAGGTGT')
print(lb.sweep_tag_neighborhood(
'TTCGTGTAAGCTATCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAGGCTCTGCCTAGAG'
'CTAGGCTAGGTGTGCTCTGCTAGAGCTAGGCTAGGTGT'))
print(labels)
print(len('ATCGTGTAAGCTATCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAG') - 19)
assert len(labels) == 2
assert 0 in labels
assert 1 in labels
# read B
labels = lb.sweep_label_neighborhood(
'GCGTAATCGTAAGCTCTGCCTAGAGCTAGGCTAGCTCTGCCTAGAGCTAGGCTAGGTGTTGGGGATAG'
'ATAGATAGATGACCTAGAGCTAGGCTAGGTGTTGGGGATAGATAGATAGATGA')
print(labels)
assert len(labels) == 3
assert 0 in labels
assert 1 in labels
assert 2 in labels
# read C
labels = lb.sweep_label_neighborhood(
'TGGGATAGATAGATAGATGACCTAGAGCTAGGCTAGGTGTTGGGGATAGATAGATAGATGACCTAGAG'
'CTAGGCTAGGTGTTGGGGATAGATAGATAGATGAGTTGGGGATAGATAGATAGATGAGTGTAGATCCA'
'ACAACACATACA')
print(labels)
assert len(labels) == 2
assert 1 in labels
assert 2 in labels
# read D
labels = lb.sweep_label_neighborhood(
'TATATATATAGCTAGCTAGCTAACTAGCTAGCATCGATCGATCGATC')
print(labels)
assert len(labels) == 1
assert 3 in labels
示例10: test_get_labels_save_load_wrong_ksize
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_get_labels_save_load_wrong_ksize():
lb_pre = GraphLabels(19, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb_pre.consume_seqfile_and_tag_with_labels(filename)
# save labels to a file
savepath = utils.get_temp_filename('saved.labels')
lb_pre.save_labels_and_tags(savepath)
# trash the old GraphLabels
del lb_pre
# create new, load labels & tags
lb = GraphLabels(20, 1e7, 4)
try:
lb.load_labels_and_tags(savepath)
assert 0, "this should not succeed - different ksize"
except OSError as err:
print(str(err))
assert "Incorrect k-mer size 19" in str(err)
示例11: test_get_labels_save_load
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_get_labels_save_load():
lb_pre = GraphLabels(20, 1e7, 4)
filename = utils.get_test_data('test-labels.fa')
lb_pre.consume_seqfile_and_tag_with_labels(filename)
# save labels to a file
savepath = utils.get_temp_filename('saved.labels')
lb_pre.save_labels_and_tags(savepath)
# trash the old GraphLabels
del lb_pre
# create new, load labels & tags
lb = GraphLabels(20, 1e7, 4)
lb.load_labels_and_tags(savepath)
labels = lb.get_all_labels()
expected = [0, 1, 2, 3]
for e_label in expected:
assert e_label in labels
for a_label in labels:
assert a_label in expected
示例12: test_consume_seqfile_and_tag_with_labels
# 需要导入模块: from khmer import GraphLabels [as 别名]
# 或者: from khmer.GraphLabels import consume_seqfile_and_tag_with_labels [as 别名]
def test_consume_seqfile_and_tag_with_labels():
lb = GraphLabels(20, 1e7, 4)
read_1 = 'ACGTAACCGGTTAAACCCGGGTTTAAAACCCCGGGGTTTT'
filename = utils.get_test_data('test-transcript.fa')
total_reads, _ = lb.consume_seqfile_and_tag_with_labels(filename)
print("doing get")
assert lb.graph.get(read_1[:20])
assert total_reads == 3
print("doing n_labels")
print(lb.n_labels())
print("doing all labels")
print(lb.get_all_labels())
print("get tagset")
for tag in lb.graph.get_tagset():
print("forward hash")
print(tag, khmer.forward_hash(tag, 20))
for record in screed.open(filename):
print("Sweeping tags")
print(lb.sweep_tag_neighborhood(record.sequence, 40))
print("Sweeping labels...")
print(lb.sweep_label_neighborhood(record.sequence, 40))
assert lb.n_labels() == 3