本文整理汇总了Python中skbio.alignment.StockholmAlignment类的典型用法代码示例。如果您正苦于以下问题:Python StockholmAlignment类的具体用法?Python StockholmAlignment怎么用?Python StockholmAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StockholmAlignment类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_file
def test_to_file(self):
st = StockholmAlignment(self.seqs, gc=self.GC, gf=self.GF, gs=self.GS,
gr=self.GR)
with tempfile.NamedTemporaryFile('r+') as temp_file:
st.to_file(temp_file)
temp_file.flush()
temp_file.seek(0)
obs = temp_file.read()
exp = ('# STOCKHOLM 1.0\n'
'#=GF AC RF00360\n'
'#=GF BM cmbuild -F CM SEED\n'
'#=GF BM cmsearch -Z 274931 -E 1000000\n'
'#=GF SQ 9\n'
'#=GF RN [1]\n'
'#=GF RM 11469857\n'
'#=GF RT TITLE1\n'
'#=GF RA Auth1;\n'
'#=GF RL J Mol Biol\n'
'#=GF RN [2]\n'
'#=GF RM 12007400\n'
'#=GF RT TITLE2\n'
'#=GF RA Auth2;\n'
'#=GF RL Cell\n'
'#=GS seq1 AC 111\n'
'#=GS seq2 AC 222\n'
'seq1 ACC-G-GGTA\n'
'#=GR seq1 SS 1110101111\n'
'seq2 TCC-G-GGCA\n'
'#=GR seq2 SS 0110101110\n'
'#=GC SS_cons (((....)))\n//')
self.assertEqual(obs, exp)
示例2: test_from_file_GS
def test_from_file_GS(self):
sto = StringIO("# STOCKHOLM 1.0\n#=GS seq2 AC 222\n#=GS seq1 AC 111\n"
"seq1 ACC-G-GGTA\n"
"seq2 TCC-G-GGCA\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, self.GS, {}, {})
self.assertEqual(obs_sto, exp_sto)
示例3: test_from_file_GC
def test_from_file_GC(self):
sto = StringIO("# STOCKHOLM 1.0\n"
"seq1 ACC-G-GGTA\nseq2 TCC-G-GGCA\n"
"#=GC SS_cons (((....)))\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, {}, {}, self.GC)
self.assertEqual(obs_sto, exp_sto)
示例4: test_from_file_alignment
def test_from_file_alignment(self):
"""make sure can parse basic sto file with interleaved alignment"""
sto = StringIO(
"# STOCKHOLM 1.0\n" "seq1 ACC-G\n" "seq2 TCC-G\n\n" "seq1 -GGTA\n" "seq2 -GGCA\n//"
)
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs)
self.assertEqual(obs_sto, exp_sto)
示例5: test_from_file_GR
def test_from_file_GR(self):
sto = StringIO("# STOCKHOLM 1.0\nseq1 ACC-G\n"
"#=GR seq1 SS 11101\nseq2 TCC-G\n"
"#=GR seq2 SS 01101\n\nseq1 -GGTA\n"
"#=GR seq1 SS 01111\nseq2 -GGCA\n"
"#=GR seq2 SS 01110\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, {}, self.GR, {})
self.assertEqual(obs_sto, exp_sto)
示例6: test_from_file_GF
def test_from_file_GF(self):
# remove rn line to make sure auto-added
self.GF.pop("RN")
sto = StringIO("# STOCKHOLM 1.0\n#=GF RN [1]\n#=GF RM 11469857\n"
"#=GF RT TITLE1\n#=GF RA Auth1;\n#=GF RL J Mol Biol\n"
"#=GF RN [2]\n#=GF RM 12007400\n#=GF RT TITLE2\n"
"#=GF RA Auth2;\n#=GF RL Cell\n#=GF AC RF00360\n"
"#=GF BM cmbuild -F CM SEED\n"
"#=GF BM cmsearch -Z 274931 -E 1000000\n#=GF SQ 9\n"
"seq1 ACC-G-GGTA\nseq2 TCC-G-GGCA\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, self.GF, {}, {}, {})
self.assertEqual(obs_sto, exp_sto)
示例7: test_from_file_multi
def test_from_file_multi(self):
sto = StringIO("# STOCKHOLM 1.0\n#=GS seq2 AC 222\n#=GS seq1 AC 111\n"
"seq1 ACC-G-GGTA\n"
"seq2 TCC-G-GGCA\n//\n"
"# STOCKHOLM 1.0\nseq1 ACC-G-GGTA\n"
"#=GR seq1 SS 1110101111\nseq2 TCC-G-GGCA\n"
"#=GR seq2 SS 0110101110\n//")
obs_sto = StockholmAlignment.from_file(sto, DNA)
count = 0
for obs in obs_sto:
if count == 0:
exp_sto = StockholmAlignment(self.seqs, {}, self.GS, {}, {})
self.assertEqual(obs, exp_sto)
elif count == 1:
exp_sto = StockholmAlignment(self.seqs, {}, {}, self.GR, {})
self.assertEqual(obs, exp_sto)
else:
raise AssertionError("More than 2 sto alignments parsed!")
count += 1
示例8: setUp
def setUp(self):
"""Setup for stockholm tests."""
self.seqs = [DNASequence("ACC-G-GGTA", id="seq1"), DNASequence("TCC-G-GGCA", id="seq2")]
self.GF = OrderedDict(
[
("AC", "RF00360"),
("BM", ["cmbuild -F CM SEED", "cmsearch -Z 274931 -E 1000000"]),
("SQ", "9"),
("RT", ["TITLE1", "TITLE2"]),
("RN", ["[1]", "[2]"]),
("RA", ["Auth1;", "Auth2;"]),
("RL", ["J Mol Biol", "Cell"]),
("RM", ["11469857", "12007400"]),
("RN", ["[1]", "[2]"]),
]
)
self.GS = {"AC": OrderedDict([("seq1", "111"), ("seq2", "222")])}
self.GR = {"SS": OrderedDict([("seq1", "1110101111"), ("seq2", "0110101110")])}
self.GC = {"SS_cons": "(((....)))"}
self.st = StockholmAlignment(self.seqs, gc=self.GC, gf=self.GF, gs=self.GS, gr=self.GR)
示例9: setUp
def setUp(self):
self.seqs = [DNA("ACC-G-GGTA", metadata={'id': "seq1"}),
DNA("TCC-G-GGCA", metadata={'id': "seq2"})]
self.GF = OrderedDict([
("AC", "RF00360"),
("BM", ["cmbuild -F CM SEED",
"cmsearch -Z 274931 -E 1000000"]),
("SQ", "9"),
("RT", ["TITLE1", "TITLE2"]),
("RN", ["[1]", "[2]"]),
("RA", ["Auth1;", "Auth2;"]),
("RL", ["J Mol Biol", "Cell"]),
("RM", ["11469857", "12007400"]),
('RN', ['[1]', '[2]'])
])
self.GS = {"AC": OrderedDict([("seq1", "111"), ("seq2", "222")])}
self.GR = {"SS": OrderedDict([("seq1", "1110101111"),
("seq2", "0110101110")])}
self.GC = {"SS_cons": "(((....)))"}
self.st = StockholmAlignment(self.seqs, gc=self.GC, gf=self.GF,
gs=self.GS, gr=self.GR)
示例10: StockholmAlignmentTests
class StockholmAlignmentTests(TestCase):
def setUp(self):
self.seqs = [DNA("ACC-G-GGTA", id="seq1"),
DNA("TCC-G-GGCA", id="seq2")]
self.GF = OrderedDict([
("AC", "RF00360"),
("BM", ["cmbuild -F CM SEED",
"cmsearch -Z 274931 -E 1000000"]),
("SQ", "9"),
("RT", ["TITLE1", "TITLE2"]),
("RN", ["[1]", "[2]"]),
("RA", ["Auth1;", "Auth2;"]),
("RL", ["J Mol Biol", "Cell"]),
("RM", ["11469857", "12007400"]),
('RN', ['[1]', '[2]'])
])
self.GS = {"AC": OrderedDict([("seq1", "111"), ("seq2", "222")])}
self.GR = {"SS": OrderedDict([("seq1", "1110101111"),
("seq2", "0110101110")])}
self.GC = {"SS_cons": "(((....)))"}
self.st = StockholmAlignment(self.seqs, gc=self.GC, gf=self.GF,
gs=self.GS, gr=self.GR)
def test_retrieve_metadata(self):
self.assertEqual(self.st.gc, self.GC)
self.assertEqual(self.st.gf, self.GF)
self.assertEqual(self.st.gs, self.GS)
self.assertEqual(self.st.gr, self.GR)
def test_from_file_alignment(self):
# test that a basic stockholm file with interleaved alignment can be
# parsed
sto = StringIO("# STOCKHOLM 1.0\n"
"seq1 ACC-G\n"
"seq2 TCC-G\n\n"
"seq1 -GGTA\n"
"seq2 -GGCA\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs)
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GF(self):
# remove rn line to make sure auto-added
self.GF.pop("RN")
sto = StringIO("# STOCKHOLM 1.0\n#=GF RN [1]\n#=GF RM 11469857\n"
"#=GF RT TITLE1\n#=GF RA Auth1;\n#=GF RL J Mol Biol\n"
"#=GF RN [2]\n#=GF RM 12007400\n#=GF RT TITLE2\n"
"#=GF RA Auth2;\n#=GF RL Cell\n#=GF AC RF00360\n"
"#=GF BM cmbuild -F CM SEED\n"
"#=GF BM cmsearch -Z 274931 -E 1000000\n#=GF SQ 9\n"
"seq1 ACC-G-GGTA\nseq2 TCC-G-GGCA\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, self.GF, {}, {}, {})
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GC(self):
sto = StringIO("# STOCKHOLM 1.0\n"
"seq1 ACC-G-GGTA\nseq2 TCC-G-GGCA\n"
"#=GC SS_cons (((....)))\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, {}, {}, self.GC)
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GS(self):
sto = StringIO("# STOCKHOLM 1.0\n#=GS seq2 AC 222\n#=GS seq1 AC 111\n"
"seq1 ACC-G-GGTA\n"
"seq2 TCC-G-GGCA\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, self.GS, {}, {})
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GR(self):
sto = StringIO("# STOCKHOLM 1.0\nseq1 ACC-G\n"
"#=GR seq1 SS 11101\nseq2 TCC-G\n"
"#=GR seq2 SS 01101\n\nseq1 -GGTA\n"
"#=GR seq1 SS 01111\nseq2 -GGCA\n"
"#=GR seq2 SS 01110\n//")
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, {}, self.GR, {})
self.assertEqual(obs_sto, exp_sto)
def test_from_file_multi(self):
sto = StringIO("# STOCKHOLM 1.0\n#=GS seq2 AC 222\n#=GS seq1 AC 111\n"
"seq1 ACC-G-GGTA\n"
"seq2 TCC-G-GGCA\n//\n"
"# STOCKHOLM 1.0\nseq1 ACC-G-GGTA\n"
"#=GR seq1 SS 1110101111\nseq2 TCC-G-GGCA\n"
"#=GR seq2 SS 0110101110\n//")
obs_sto = StockholmAlignment.from_file(sto, DNA)
count = 0
for obs in obs_sto:
if count == 0:
exp_sto = StockholmAlignment(self.seqs, {}, self.GS, {}, {})
self.assertEqual(obs, exp_sto)
elif count == 1:
exp_sto = StockholmAlignment(self.seqs, {}, {}, self.GR, {})
self.assertEqual(obs, exp_sto)
else:
raise AssertionError("More than 2 sto alignments parsed!")
count += 1
#.........这里部分代码省略.........
示例11: StockholmAlignmentTests
class StockholmAlignmentTests(TestCase):
"""Tests for stockholmAlignment object"""
def setUp(self):
"""Setup for stockholm tests."""
self.seqs = [DNASequence("ACC-G-GGTA", id="seq1"), DNASequence("TCC-G-GGCA", id="seq2")]
self.GF = OrderedDict(
[
("AC", "RF00360"),
("BM", ["cmbuild -F CM SEED", "cmsearch -Z 274931 -E 1000000"]),
("SQ", "9"),
("RT", ["TITLE1", "TITLE2"]),
("RN", ["[1]", "[2]"]),
("RA", ["Auth1;", "Auth2;"]),
("RL", ["J Mol Biol", "Cell"]),
("RM", ["11469857", "12007400"]),
("RN", ["[1]", "[2]"]),
]
)
self.GS = {"AC": OrderedDict([("seq1", "111"), ("seq2", "222")])}
self.GR = {"SS": OrderedDict([("seq1", "1110101111"), ("seq2", "0110101110")])}
self.GC = {"SS_cons": "(((....)))"}
self.st = StockholmAlignment(self.seqs, gc=self.GC, gf=self.GF, gs=self.GS, gr=self.GR)
def test_retrieve_metadata(self):
self.assertEqual(self.st.gc, self.GC)
self.assertEqual(self.st.gf, self.GF)
self.assertEqual(self.st.gs, self.GS)
self.assertEqual(self.st.gr, self.GR)
def test_from_file_alignment(self):
"""make sure can parse basic sto file with interleaved alignment"""
sto = StringIO(
"# STOCKHOLM 1.0\n" "seq1 ACC-G\n" "seq2 TCC-G\n\n" "seq1 -GGTA\n" "seq2 -GGCA\n//"
)
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs)
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GF(self):
"""Make sure GF lines are parsed correctly"""
# remove rn line to make sure auto-added
self.GF.pop("RN")
sto = StringIO(
"# STOCKHOLM 1.0\n#=GF RN [1]\n#=GF RM 11469857\n"
"#=GF RT TITLE1\n#=GF RA Auth1;\n#=GF RL J Mol Biol\n"
"#=GF RN [2]\n#=GF RM 12007400\n#=GF RT TITLE2\n"
"#=GF RA Auth2;\n#=GF RL Cell\n#=GF AC RF00360\n"
"#=GF BM cmbuild -F CM SEED\n"
"#=GF BM cmsearch -Z 274931 -E 1000000\n#=GF SQ 9\n"
"seq1 ACC-G-GGTA\nseq2 TCC-G-GGCA\n//"
)
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, self.GF, {}, {}, {})
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GC(self):
"""Make sure GC lines are parsed correctly"""
sto = StringIO(
"# STOCKHOLM 1.0\n" "seq1 ACC-G-GGTA\nseq2 TCC-G-GGCA\n" "#=GC SS_cons (((....)))\n//"
)
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, {}, {}, self.GC)
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GS(self):
"""Make sure GS lines are parsed correctly"""
sto = StringIO(
"# STOCKHOLM 1.0\n#=GS seq2 AC 222\n#=GS seq1 AC 111\n"
"seq1 ACC-G-GGTA\n"
"seq2 TCC-G-GGCA\n//"
)
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, self.GS, {}, {})
self.assertEqual(obs_sto, exp_sto)
def test_from_file_GR(self):
"""Make sure GR lines are parsed correctly"""
sto = StringIO(
"# STOCKHOLM 1.0\nseq1 ACC-G\n"
"#=GR seq1 SS 11101\nseq2 TCC-G\n"
"#=GR seq2 SS 01101\n\nseq1 -GGTA\n"
"#=GR seq1 SS 01111\nseq2 -GGCA\n"
"#=GR seq2 SS 01110\n//"
)
obs_sto = next(StockholmAlignment.from_file(sto, DNA))
exp_sto = StockholmAlignment(self.seqs, {}, {}, self.GR, {})
self.assertEqual(obs_sto, exp_sto)
def test_from_file_multi(self):
"""Make sure yield works correctly with multi-alignment sto files"""
sto = StringIO(
"# STOCKHOLM 1.0\n#=GS seq2 AC 222\n#=GS seq1 AC 111\n"
"seq1 ACC-G-GGTA\n"
"seq2 TCC-G-GGCA\n//\n"
"# STOCKHOLM 1.0\nseq1 ACC-G-GGTA\n"
"#=GR seq1 SS 1110101111\nseq2 TCC-G-GGCA\n"
"#=GR seq2 SS 0110101110\n//"
)
#.........这里部分代码省略.........