python13

作者: rong酱 | 来源:发表于2021-08-09 23:54 被阅读0次
# -*- coding: utf-8 -*-
#!/usr/bin/env python

import os
import sys

inputtxt = sys.argv[1] # input motify table
output = sys.argv[2] # output
indir = sys.argv[3]  # analysis input dir 

dictr = {}
with open(inputtxt,"r") as inputliness:
    inputlines = inputliness.readlines()
    for inputline in inputlines:
        inputlin = inputline.strip().split(" ")
        con1 = inputlin[0].strip().split("-")
        time_num = str(con1[-2])+"_"+str(con1[-1])
        rename = {'hs+LPS':'L','i-s':'i','hs':'h'}
        samplename = str(rename[inputlin[1]])+"_"+str(time_num)
        pathline = inputlin[2].strip().split("\t")
        rpath = str(indir) + str(pathline[-1])
        if samplename not in dictr.keys(): 
            dictr[samplename] = []
            dictr[samplename].append(rpath)
        else:
             dictr[samplename].append(rpath)

outcon = open(output,"w")
for keys,values in dictr.items(): # 需要进一步优化
    if len(values) == 2:
        outcon.write(str(keys)+"\tph\t"+values[0]+"\t"+values[1]+"\n")
    elif len(values) == 4:
        outcon.write(str(keys)+"\tph\t"+values[0]+"\t"+values[1]+"\n"+str(keys)+"\tphred33\t"+values[2]+"\t"+values[3]+"\n")

引以为戒,足够主动
脚本越写越短,有点哀伤

相关文章

  • python13

    引以为戒,足够主动脚本越写越短,有点哀伤

  • 初入Python13/100

    新的在线工具https://c.runoob.com/compile/6?from=groupmessage 昨天...

网友评论

      本文标题:python13

      本文链接:https://www.haomeiwen.com/subject/oxatbltx.html