我有 2 个文件被调用big并small喜欢这些示例:
big:
chr1 transcript 2481359 2483515 - RP3-395M20.8
chr1 transcript 2487078 2492123 + TNFRSF14
chr1 transcript 2497849 2501297 + RP3-395M20.7
chr1 transcript 2512999 2515942 + RP3-395M20.9
chr1 transcript 2517930 2521041 + FAM213B
chr1 transcript 2522078 2524087 - MMEL1
small:
chr1 2487088 2492113 17
chr1 100757323 100757324 19
chr1 2487099 2492023 21
chr1 100758316 100758317 41
chr1 2514000 2515742 14
我试图5 columns在以下条件下从大文件创建一个新文件:
conditions :
1- if: the 1st column of small file == 1st column of big file
2- if: the 4th column of big file >= the 2nd column of small file >= the 3rd column of big file
3- if: the 4th column of big file >= the 3rd column of small file >= the 3rd column of big file
columns in output file:
1) 1st column of big file
2) 2nd column of big file
3) 3rd column of big file
4) the number of lines in small files that have the mentioned conditions (we should count)
5) 6th column of big file
这是上述示例的预期输出:
chr1 2487078 2492123 2 TNFRSF14
chr1 2512999 2515942 1 RP3-395M20.9
我在python. 它不会返回我想要的文件。我的代码中的每一行似乎都是合乎逻辑的。你能帮我修吗?
def correspond(big, small, outfile):
count = 0
big = open(big, "r")
small = open(small, "r")
big_list = []
small_list = []
for m in big:
big_list.append(m)
for n in small:
small_list.append(n)
final = []
慕妹3242003
神不在的星期二
相关分类