本文整理汇总了Python中pyfaidx.Faidx类的典型用法代码示例。如果您正苦于以下问题:Python Faidx类的具体用法?Python Faidx怎么用?Python Faidx使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Faidx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fetch_border
def test_fetch_border(self):
""" Fetch past the end of a gene entry """
faidx = Faidx('data/genes.fasta')
expect = 'TC'
result = faidx.fetch('gi|557361099|gb|KF435150.1|',
480, 500)
assert str(result) == expect
示例2: test_fetch_border_padded
def test_fetch_border_padded(self):
""" Fetch past the end of a gene entry """
faidx = Faidx('data/genes.fasta.gz', default_seq='N')
expect = 'TCNNNNNNNNNNNNNNNNNNN'
result = faidx.fetch('gi|557361099|gb|KF435150.1|',
480, 500)
print(result)
assert str(result) == expect
示例3: test_reindex_on_modification
def test_reindex_on_modification(self):
""" This test ensures that the index is regenerated when the FASTA
modification time is newer than the index modification time.
mdshw5/pyfaidx#50 """
faidx = Faidx('data/genes.fasta')
index_mtime = getmtime(faidx.indexname)
faidx.close()
os.utime('data/genes.fasta', (index_mtime + 10, ) * 2)
time.sleep(2)
faidx = Faidx('data/genes.fasta')
assert getmtime(faidx.indexname) > index_mtime
示例4: test_fetch_whole_entry
def test_fetch_whole_entry(self):
faidx = Faidx('data/genes.fasta.gz')
expect = ('ATGACATCATTTTCCACCTCTGCTCAGTGTTCAACATCTGA'
'CAGTGCTTGCAGGATCTCTCCTGGACAAATCAATCAGGTACGACCA'
'AAACTGCCGCTTTTGAAGATTTTGCATGCAGCAGGTGCGCAAGG'
'TGAAATGTTCACTGTTAAAGAGGTCATGCACTATTTAGGTCAGTACAT'
'AATGGTGAAGCAACTTTATGATCAGCAGGAGCAGCATATGGTATATTG'
'TGGTGGAGATCTTTTGGGAGAACTACTGGGACGTCAGAGCTTCTCCGTG'
'AAAGACCCAAGCCCTCTCTATGATATGCTAAGAAAGAATCTTGTCACTTT'
'AGCCACTGCTACTACAGCAAAGTGCAGAGGAAAGTTCCACTTCCAGAAAAA'
'GAACTACAGAAGACGATATCCCCACACTGCCTACCTCAGAGCATAAATGCA'
'TACATTCTAGAGAAGGTGATTGAAGTGGGAAAAAATGATGACCTGGAGGACTC')
result = faidx.fetch('gi|557361099|gb|KF435150.1|',
1, 481)
assert str(result) == expect
示例5: test_fetch_whole_entry
def test_fetch_whole_entry(self):
faidx = Faidx("data/genes.fasta")
expect = (
"ATGACATCATTTTCCACCTCTGCTCAGTGTTCAACATCTGA"
"CAGTGCTTGCAGGATCTCTCCTGGACAAATCAATCAGGTACGACCA"
"AAACTGCCGCTTTTGAAGATTTTGCATGCAGCAGGTGCGCAAGG"
"TGAAATGTTCACTGTTAAAGAGGTCATGCACTATTTAGGTCAGTACAT"
"AATGGTGAAGCAACTTTATGATCAGCAGGAGCAGCATATGGTATATTG"
"TGGTGGAGATCTTTTGGGAGAACTACTGGGACGTCAGAGCTTCTCCGTG"
"AAAGACCCAAGCCCTCTCTATGATATGCTAAGAAAGAATCTTGTCACTTT"
"AGCCACTGCTACTACAGCAAAGTGCAGAGGAAAGTTCCACTTCCAGAAAAA"
"GAACTACAGAAGACGATATCCCCACACTGCCTACCTCAGAGCATAAATGCA"
"TACATTCTAGAGAAGGTGATTGAAGTGGGAAAAAATGATGACCTGGAGGACTC"
)
result = faidx.fetch("gi|557361099|gb|KF435150.1|", 1, 482)
assert str(result) == expect
示例6: __init__
class TestFeatureKeyFunction:
def __init__(self):
self.fasta = os.path.join(path, 'data/genes.fasta')
self.faidx = Faidx(self.fasta, key_function=get_gene_name)
self.genes = Fasta(self.fasta, key_function=get_gene_name)
def test_keys(self):
expect = ['BARD1', 'FGFR2', 'KF435149.1', 'MDM4', 'NM_000465.3', 'NM_001282543.1', 'NM_001282545.1', 'NM_001282548.1', 'NM_001282549.1', 'NR_104212.1', 'NR_104215.1', 'XM_005249642.1', 'XM_005249643.1', 'XM_005249644.1', 'XM_005249645.1', 'XM_005265507.1', 'XM_005265508.1', 'XR_241079.1', 'XR_241080.1', 'XR_241081.1']
result = sorted(self.genes.keys())
assert result == expect
def test_key_function_by_dictionary_get_key(self):
expect = 'TTGAAGATTTTGCATGCAGCAGGTGCGCAAGGTGAAATGTTCACTGTTAAA'
result = self.genes['MDM4'][100-1:150]
assert str(result) == expect
def test_key_function_by_fetch(self):
expect = 'TTGAAGATTTTGCATGCAGCAGGTGCGCAAGGTGAAATGTTCACTGTTAAA'
result = self.faidx.fetch('MDM4',
100, 150)
assert str(result) == expect
@raises(ValueError)
def test_duplicated_keys(self):
genes = Fasta(self.fasta, key_function=get_duplicated_gene_name)
示例7: __init__
class TestFeatureBoundsCheck:
def __init__(self):
self.fasta = os.path.join(path, 'data/genes.fasta')
self.faidx = Faidx(self.fasta, default_seq='N')
def test_fetch_border_padded(self):
""" Fetch past the end of a gene entry """
expect = 'TCNNNNNNNNNNNNNNNNNNN'
result = self.faidx.fetch('KF435150.1',
480, 500)
assert str(result) == expect
示例8: __init__
class TestFeatureBoundsCheck:
def __init__(self):
self.fasta = os.path.join(path, 'data/genes.fasta')
self.faidx = Faidx(self.fasta)
self.faidx_strict = Faidx(self.fasta, strict_bounds=True)
def test_fetch_whole_entry(self):
expect = ('ATGACATCATTTTCCACCTCTGCTCAGTGTTCAACATCTGA'
'CAGTGCTTGCAGGATCTCTCCTGGACAAATCAATCAGGTACGACCA'
'AAACTGCCGCTTTTGAAGATTTTGCATGCAGCAGGTGCGCAAGG'
'TGAAATGTTCACTGTTAAAGAGGTCATGCACTATTTAGGTCAGTACAT'
'AATGGTGAAGCAACTTTATGATCAGCAGGAGCAGCATATGGTATATTG'
'TGGTGGAGATCTTTTGGGAGAACTACTGGGACGTCAGAGCTTCTCCGTG'
'AAAGACCCAAGCCCTCTCTATGATATGCTAAGAAAGAATCTTGTCACTTT'
'AGCCACTGCTACTACAGCAAAGTGCAGAGGAAAGTTCCACTTCCAGAAAAA'
'GAACTACAGAAGACGATATCCCCACACTGCCTACCTCAGAGCATAAATGCA'
'TACATTCTAGAGAAGGTGATTGAAGTGGGAAAAAATGATGACCTGGAGGACTC')
result = self.faidx.fetch('KF435150.1',
1, 482)
assert str(result) == expect
def test_fetch_middle(self):
expect = 'TTGAAGATTTTGCATGCAGCAGGTGCGCAAGGTGAAATGTTCACTGTTAAA'
result = self.faidx.fetch('KF435150.1',
100, 150)
assert str(result) == expect
def test_fetch_end(self):
expect = 'TC'
result = self.faidx.fetch('KF435150.1',
480, 482)
assert str(result) == expect
def test_fetch_border(self):
""" Fetch past the end of a gene entry """
expect = 'TC'
result = self.faidx.fetch('KF435150.1',
480, 500)
assert str(result) == expect
def test_rev(self):
expect = 'GA'
result = self.faidx.fetch('KF435150.1',
480, 482)
assert str(-result) == expect, result
@raises(FetchError)
def test_fetch_past_bounds(self):
""" Fetch past the end of a gene entry """
expect = 'TC'
result = self.faidx_strict.fetch('KF435150.1',
480, 5000)
示例9: test_fetch_end
def test_fetch_end(self):
faidx = Faidx('data/genes.fasta')
expect = 'TC'
result = faidx.fetch('gi|557361099|gb|KF435150.1|',
480, 481)
assert str(result) == expect
示例10: test_fetch_keyerror
def test_fetch_keyerror(self):
""" Fetch a key that does not exist """
faidx = Faidx("data/genes.fasta", strict_bounds=True)
result = faidx.fetch("gi|joe|gb|KF435150.1|", 1, 10)
示例11: test_fetch_past_bounds
def test_fetch_past_bounds(self):
""" Fetch past the end of a gene entry """
faidx = Faidx("data/genes.fasta", strict_bounds=True)
result = faidx.fetch("gi|557361099|gb|KF435150.1|", 480, 5000)
示例12: test_fetch_reversed_coordinates
def test_fetch_reversed_coordinates(self):
""" Fetch starting with a negative coordinate """
faidx = Faidx("data/genes.fasta", strict_bounds=True)
result = faidx.fetch("gi|557361099|gb|KF435150.1|", 50, 10)
示例13: test_fetch_border
def test_fetch_border(self):
""" Fetch past the end of a gene entry """
faidx = Faidx("data/genes.fasta")
expect = "TC"
result = faidx.fetch("gi|557361099|gb|KF435150.1|", 480, 500)
assert str(result) == expect
示例14: test_rev
def test_rev(self):
faidx = Faidx("data/genes.fasta")
expect = "GA"
result = faidx.fetch("gi|557361099|gb|KF435150.1|", 480, 482)
assert str(-result) == expect, result
示例15: test_key_function_by_fetch
def test_key_function_by_fetch(self):
faidx = Faidx('data/genes.fasta', key_function=get_gene_name)
expect = 'TTGAAGATTTTGCATGCAGCAGGTGCGCAAGGTGAAATGTTCACTGTTAAA'
result = faidx.fetch('MDM4',
100, 150)
assert str(result) == expect