我有两个文件。第一个文件看起来像这样:
'1' 'PS' 'at5g38660' 'Symbols: APE1 | APE1' T
'1.1' 'PS.lightreaction' '' ''
'1.1.1' 'PS.lightreaction.photosystem II' '' ''
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' 'at1g15820' 'Symbols: LHCB6, ' T
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' 'at1g29910' 'Symbols: CAB3' T
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' 'at1g29920' 'Symbols: CAB2' T
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' 'at1g29930' 'Symbols: CAB1' T
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' 'at1g76570' 'chlorophyll A-B' T
'1.1.1.2' 'PS.lightreaction.photosystem II.PSII' 'at1g03600' 'photosystem II' T
'1.1.1.2' 'PS.lightreaction.photosystem II.PSII' 'at1g05385' 'photosystem II 11 kDa' T
'1.1.1.2' 'PS.lightreaction.photosystem II.PSII' 'at1g06680' 'Symbols: PSBP-1SII-P' T
第二个文件:
at5g38660 2356766_1
at1g15820 3043768_9
at1g29930 2325825_1
at1g76570 2921847_3
at1g03600 2368346_5
at1g05385 2321872_2
预期输出:
'1' 'PS' '2356766_1' 'Symbols: APE1 | APE1' T
'1.1' 'PS.lightreaction' '' ''
'1.1.1' 'PS.lightreaction.photosystem II' '' ''
'1.1.1.1 'PS.lightreaction.photosystem II.LHC-II' '3043768_9' 'Symbols: LHCB6, ' T
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' '' ''
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' '' ''
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' '2325825_1' 'Symbols: CAB1' T
'1.1.1.1' 'PS.lightreaction.photosystem II.LHC-II' '2921847_3' 'chlorophyll A-B' T
'1.1.1.2' 'PS.lightreaction.photosystem II.PSII' '2368346_5' 'photosystem II' T
'1.1.1.2' 'PS.lightreaction.photosystem II.PSII' '2321872_2' 'photosystem II 11 kDa' T
'1.1.1.2' 'PS.lightreaction.photosystem II.PSII' '' ''
在这里,我希望将第一个文件的“at5g38660”替换为 2356766_1.. 等等。
如果匹配,则第一个文件中的所有列都保持不变,除了第三个(它被第二个文件中的值替换)。
如果没有匹配,那么我希望将第一个文件的第一列和第二列以及第三列、第四列和第五列打印为 blanl。(显示在预期输出中)
编码累:
import sys
ara_red_file = open (sys.argv[1]).readlines()
ara_map_file = open (sys.argv[2]).readlines()
for line in ara_red__file:
split_line = line.split('\t')
ara_id1 = split_line[0]
redbean_id = split_line[1]
for lines in ara_map_file:
split_line = lines.split('\t')
bincode = split_line[0]
name = split_line[1]
ara_id2 = split_line[2]
description = split_line[3]
code_type = split_line[4]
if ara_id2 == ara_id1:
print bincode+'\t'+name+'\t'+"'"+redbean_id+"'"+'\t'+description +'\t'+code_type
elif ara_id2 != ara_id1:
print bincode+'\t'+name+'\t'+ "''" +'\t'+ "''"
这里我面临的问题是我没有得到预期的输出.. 它不检查 lat if 条件并打印最后一个 elif 条件打印。