本文整理匯總了Python中xplib.TableIO.format_string方法的典型用法代碼示例。如果您正苦於以下問題:Python TableIO.format_string方法的具體用法?Python TableIO.format_string怎麽用?Python TableIO.format_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xplib.TableIO
的用法示例。
在下文中一共展示了TableIO.format_string方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Main
# 需要導入模塊: from xplib import TableIO [as 別名]
# 或者: from xplib.TableIO import format_string [as 別名]
def Main():
'''
IO TEMPLATE
'''
global args,out
args=ParseArg()
if args.output=="stdout":
out=sys.stdout
else:
try:
out=open(args.output,"w")
except IOError:
print >>sys.stderr,"can't open file ",args.output,"to write. Using stdout instead"
out=sys.stdout
if args.input=="stdin":
fin=sys.stdin
else:
try:
x=args.input.split(".")
if x[-1]=="gz":
fin=gzip.open(args.input,"r")
else:
fin=open(args.input,"r")
except IOError:
print >>sys.stderr,"can't read file",args.input
fin=sys.stdin
'''
END OF IO TEMPLATE
'''
print >>out,"# This data was generated by program ",sys.argv[0]," (version: %s)"%VERSION,
print >>out,"in bam2x ( https://github.com/nimezhu/bam2x )"
print >>out,"# Date: ",time.asctime()
print >>out,"# The command line is :"
print >>out,"#\t"," ".join(sys.argv)
h1={}
h2={}
for i in TableIO.parse(fin):
h1[i[args.c1-1]]=i
for j in TableIO.parse(args.input2):
h2[j[args.c2-1]]=j
if h1.has_key(j[args.c2-1]):
print >>out,TableIO.format_string(h1[j[args.c2-1]])+"\t"+TableIO.format_string(j)