本文整理汇总了Python中Bio.PopGen.GenePop.read方法的典型用法代码示例。如果您正苦于以下问题:Python GenePop.read方法的具体用法?Python GenePop.read怎么用?Python GenePop.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.PopGen.GenePop
的用法示例。
在下文中一共展示了GenePop.read方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_features
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_remove_features(self):
"""Testing the ability to remove population/loci via class methods."""
for index in range(len(self.files)):
fname = self.files[index]
ftemp = tempfile.NamedTemporaryFile(mode="w+", delete=False)
ftemp.close()
rec = FileParser.read(fname)
rec.remove_loci_by_position([0], ftemp.name)
with open(ftemp.name, 'r') as ft:
ft.seek(0)
rec2 = GenePop.read(iter(ft))
self.assertEqual(rec.loci_list[1:], rec2.loci_list)
rec.remove_locus_by_position(0, ftemp.name)
with open(ftemp.name, 'r') as ft:
ft.seek(0)
rec3 = GenePop.read(iter(ft))
self.assertEqual(rec.loci_list[1:], rec3.loci_list)
rec.remove_locus_by_name(rec.loci_list[0], ftemp.name)
with open(ftemp.name, 'r') as ft:
ft.seek(0)
rec4 = GenePop.read(iter(ft))
self.assertEqual(rec.loci_list[1:], rec4.loci_list)
rec.remove_loci_by_name([rec.loci_list[0]], ftemp.name)
with open(ftemp.name, 'r') as ft:
ft.seek(0)
rec5 = GenePop.read(iter(ft))
self.assertEqual(rec.loci_list[1:], rec5.loci_list)
os.remove(ftemp.name)
rec._handle.close()
示例2: test_wrong_file_parser
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_wrong_file_parser(self):
"""Testing the ability to deal with wrongly formatted files."""
with open(os.path.join("PopGen", "README")) as f:
try:
rec = GenePop.read(f)
raise Exception("Should have raised exception")
except ValueError:
pass
示例3: test_convert
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_convert(self):
"""Basic conversion test.
"""
for i in range(len(self.handles)):
gp_rec = GenePop.read(self.handles[i])
fd_rec = convert_genepop_to_fdist(gp_rec)
assert(fd_rec.num_loci == 3)
assert(fd_rec.num_pops == 3)
示例4: test_wrong_file_parser
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_wrong_file_parser(self):
"""Testing the ability to deal with wrongly formatted files
"""
f = open(os.path.join("PopGen", "fdist1"))
try:
rec = GenePop.read(f)
raise Error("Should have raised exception")
except ValueError:
pass
f.close()
示例5: test_record_parser
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_record_parser(self):
"""Basic operation of the Record Parser.
"""
for index in range(len(self.handles)):
handle = self.handles[index]
rec = GenePop.read(handle)
assert isinstance(rec, GenePop.Record)
assert len(rec.loci_list) == self.num_loci[index]
assert rec.marker_len == self.marker_len[index]
assert len(rec.populations) == self.pops_indivs[index][0]
assert rec.pop_list == self.pop_names
for i in range(self.pops_indivs[index][0]):
assert len(rec.populations[i]) == \
self.pops_indivs[index][1][i]
示例6: test_utils
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_utils(self):
"""Basic operation of GenePop Utils."""
for index in range(len(self.handles)):
handle = self.handles[index]
rec = GenePop.read(handle)
initial_pops = len(rec.populations)
initial_loci = len(rec.loci_list)
first_loci = rec.loci_list[0]
rec.remove_population(0)
self.assertEqual(len(rec.populations), initial_pops - 1)
rec.remove_locus_by_name(first_loci)
self.assertEqual(len(rec.loci_list), initial_loci - 1)
self.assertNotEqual(rec.loci_list[0], first_loci)
rec.remove_locus_by_position(0)
self.assertEqual(len(rec.loci_list), initial_loci - 2)
示例7: test_utils
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_utils(self):
"""Basic operation of GenePop Utils.
"""
for index in range(len(self.handles)):
handle = self.handles[index]
rec = GenePop.read(handle)
initial_pops = len(rec.populations)
initial_loci = len(rec.loci_list)
first_loci = rec.loci_list[0]
rec.remove_population(0)
assert len(rec.populations) == initial_pops - 1
rec.remove_locus_by_name(first_loci)
assert len(rec.loci_list) == initial_loci - 1
assert rec.loci_list[0] != first_loci
rec.remove_locus_by_position(0)
assert len(rec.loci_list) == initial_loci - 2
示例8: test_record_parser
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def test_record_parser(self):
"""Basic operation of the Record Parser."""
for index in range(len(self.handles)):
handle = self.handles[index]
rec = GenePop.read(handle)
self.assertTrue(str(rec).startswith(
"Generated by createGenePop.py - (C) Tiago Antao\n"
"136255903\n"
"136257048\n"
"136257636\n"
"Pop\n"), "Did not expect this:\n%s" % rec)
self.assertIsInstance(rec, GenePop.Record)
self.assertEqual(len(rec.loci_list), self.num_loci[index])
self.assertEqual(rec.marker_len, self.marker_len[index])
self.assertEqual(len(rec.populations), self.pops_indivs[index][0])
self.assertEqual(rec.pop_list, self.pop_names)
for i in range(self.pops_indivs[index][0]):
self.assertEqual(len(rec.populations[i]),
self.pops_indivs[index][1][i])
示例9: get_basic_info
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def get_basic_info(self):
with open(self._fname) as f:
rec = GenePop.read(f)
return rec.pop_list, rec.loci_list
示例10: get_basic_info
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def get_basic_info(self):
"""Obtain the population list and loci list from the file."""
with open(self._fname) as f:
rec = GenePop.read(f)
return rec.pop_list, rec.loci_list
示例11: get_basic_info
# 需要导入模块: from Bio.PopGen import GenePop [as 别名]
# 或者: from Bio.PopGen.GenePop import read [as 别名]
def get_basic_info(self):
f=open(self._fname)
rec = GenePop.read(f)
f.close()
return rec.pop_list, rec.loci_list