https://github.com/fjruizruano/ngs-protocols
Raw File
Tip revision: 39a091d1fa569a7fc717ac73c4b3de07f0a1204d authored by fjruizruano on 03 August 2023, 11:48:27 UTC
adding gfa2fas.py and extract_gfa.py
Tip revision: 39a091d
join_multiple_lists.py
#!/usr/bin/python

import sys

files = sys.argv[1:]

di = {}
elements = []
names = []

for file in files:
    name = file.split(".")
    names.append(name[0])
    di[file] = {}
    data = open(file).readlines()
    for line in data[1:]:
        info = line.split()
        di[file][info[0]] = info[1]
        elements.append(info[0])

di_all = {}

for el in elements:
    di_all[el] = []
    for file in files:
        if el in di[file]:
            di_all[el].append(di[file][el])
        else:
            di_all[el].append("0")

w = open("toico.txt","w")
header = ["sequencepopeyeposition"] + names
header = "\t".join(header)
w.write(header+"\n")

for el in di_all:
    w.write("%s\t%s\n" % (el, "\t".join(di_all[el])))

w.close()
back to top