本文整理汇总了Python中jcvi.formats.base.DictFile.update方法的典型用法代码示例。如果您正苦于以下问题:Python DictFile.update方法的具体用法?Python DictFile.update怎么用?Python DictFile.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jcvi.formats.base.DictFile
的用法示例。
在下文中一共展示了DictFile.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fillrbh
# 需要导入模块: from jcvi.formats.base import DictFile [as 别名]
# 或者: from jcvi.formats.base.DictFile import update [as 别名]
def fillrbh(args):
from jcvi.formats.base import DictFile
p = OptionParser(fillrbh.__doc__)
opts, args = p.parse_args(args)
if len(args) != 3:
sys.exit(not p.print_help())
blocksfile, rbhfile, orthofile = args
# Generate mapping both ways
adict = DictFile(rbhfile)
bdict = DictFile(rbhfile, keypos=1, valuepos=0)
adict.update(bdict)
fp = open(blocksfile)
fw = open(orthofile, "w")
nrecruited = 0
for row in fp:
a, b = row.split()
if b == '.':
if a in adict:
b = adict[a]
nrecruited += 1
b += "'"
print("\t".join((a, b)), file=fw)
logging.debug("Recruited {0} pairs from RBH.".format(nrecruited))
fp.close()
fw.close()
示例2: make_ortholog
# 需要导入模块: from jcvi.formats.base import DictFile [as 别名]
# 或者: from jcvi.formats.base.DictFile import update [as 别名]
def make_ortholog(blocksfile, rbhfile, orthofile):
from jcvi.formats.base import DictFile
# Generate mapping both ways
adict = DictFile(rbhfile)
bdict = DictFile(rbhfile, keypos=1, valuepos=0)
adict.update(bdict)
fp = open(blocksfile)
fw = open(orthofile, "w")
nrecruited = 0
for row in fp:
a, b = row.split()
if b == '.':
if a in adict:
b = adict[a]
nrecruited += 1
b += "'"
print >> fw, "\t".join((a, b))
logging.debug("Recruited {0} pairs from RBH.".format(nrecruited))
fp.close()
fw.close()
示例3: merge
# 需要导入模块: from jcvi.formats.base import DictFile [as 别名]
# 或者: from jcvi.formats.base.DictFile import update [as 别名]
def merge(args):
"""
%prog merge protein-quartets registry LOST
Merge protein quartets table with dna quartets registry. This is specific
to the napus project.
"""
from jcvi.formats.base import DictFile
p = OptionParser(merge.__doc__)
opts, args = p.parse_args(args)
if len(args) != 3:
sys.exit(not p.print_help())
quartets, registry, lost = args
qq = DictFile(registry, keypos=1, valuepos=3)
lost = DictFile(lost, keypos=1, valuepos=0, delimiter='|')
qq.update(lost)
fp = open(quartets)
cases = {
"AN,CN": 4,
"BO,AN,CN": 8,
"BO,CN": 2,
"BR,AN": 1,
"BR,AN,CN": 6,
"BR,BO": 3,
"BR,BO,AN": 5,
"BR,BO,AN,CN": 9,
"BR,BO,CN": 7,
}
ip = {
"syntenic_model": "Syntenic_model_excluded_by_OMG",
"complete": "Predictable",
"partial": "Truncated",
"pseudogene": "Pseudogene",
"random": "Match_random",
"real_ns": "Transposed",
"gmap_fail": "GMAP_fail",
"AN LOST": "AN_LOST",
"CN LOST": "CN_LOST",
"BR LOST": "BR_LOST",
"BO LOST": "BO_LOST",
"outside": "Outside_synteny_blocks",
"[NF]": "Not_found",
}
for row in fp:
atoms = row.strip().split("\t")
genes = atoms[:4]
tag = atoms[4]
a, b, c, d = [qq.get(x, ".").rsplit("-", 1)[-1] for x in genes]
qqs = [c, d, a, b]
for i, q in enumerate(qqs):
if atoms[i] != '.':
qqs[i] = "syntenic_model"
# Make comment
comment = "Case{0}".format(cases[tag])
dots = sum([1 for x in genes if x == '.'])
if dots == 1:
idx = genes.index(".")
status = qqs[idx]
status = ip[status]
comment += "-" + status
print row.strip() + "\t" + "\t".join(qqs + [comment])