本文整理汇总了Python中nexus.NexusReader.write_to_file方法的典型用法代码示例。如果您正苦于以下问题:Python NexusReader.write_to_file方法的具体用法?Python NexusReader.write_to_file怎么用?Python NexusReader.write_to_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nexus.NexusReader
的用法示例。
在下文中一共展示了NexusReader.write_to_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_to_file
# 需要导入模块: from nexus import NexusReader [as 别名]
# 或者: from nexus.NexusReader import write_to_file [as 别名]
def test_write_to_file(self):
tmp = NamedTemporaryFile(delete=False, suffix=".nex")
tmp.close()
nex = NexusReader(os.path.join(EXAMPLE_DIR, 'example.nex'))
nex.write_to_file(tmp.name)
assert os.path.isfile(tmp.name)
n2 = NexusReader(tmp.name)
assert n2.data.matrix == nex.data.matrix
assert sorted(n2.data.taxa) == sorted(nex.data.taxa)
os.unlink(tmp.name) # cleanup
示例2: len
# 需要导入模块: from nexus import NexusReader [as 别名]
# 或者: from nexus.NexusReader import write_to_file [as 别名]
sys.exit("No trees found in found %s!" % nexusname)
if options.quiet is False:
print "%d trees found with %d translated taxa" % (nexus.trees.ntrees, len(nexus.trees.translators))
# Delete trees
if options.deltree:
nexus = run_deltree(options.deltree, nexus, options.quiet)
# Resample trees
if options.resample:
nexus = run_resample(options.resample, nexus, options.quiet)
# Randomly sample trees
if options.random:
nexus = run_random(options.random, nexus, options.quiet)
# remove comments
if options.removecomments:
nexus = run_removecomments(nexus, options.quiet)
# detranslate
if options.detranslate:
nexus = run_detranslate(nexus, options.quiet)
if newnexus is not None:
nexus.write_to_file(newnexus)
if options.quiet is False:
print "New nexus with %d trees written to %s" % (nexus.trees.ntrees, newnexus)
else:
print nexus.write()
示例3: hash
# 需要导入模块: from nexus import NexusReader [as 别名]
# 或者: from nexus.NexusReader import write_to_file [as 别名]
def hash(salt, taxon):
return hashlib.md5("%s-%s" % (salt, taxon)).hexdigest()
if __name__ == '__main__':
from optparse import OptionParser
parser = OptionParser(usage="usage: %prog fudge.nex output.nex")
options, nexuslist = parser.parse_args()
try:
nexusname = args[0]
except IndexError:
print(__doc__)
print("Author: %s\n" % __author__)
parser.print_help()
sys.exit()
try:
newnexus = args[1]
except IndexError:
newnexus = None
nexus = NexusReader(nexusname)
nexus = anonymise(nexus)
if newnexus is not None:
nexus.write_to_file(newnexus)
print("New nexus written to %s" % newnexus)
else:
print(nexus.write_to_file(hash('filename', filename)))