I have a fasta file like this:
and an annotation file like this:
And I want to replace the fasta files` heading by the annotation to produce:
Here is what I wrote with python trying to do this:
But it does not work, says "AttributeError: 'str' object has no attribute 'spilt'
"
... any better ideas to do this or found any way to fix the codes?
Thanks
>comp0_c0_seq1 len=204 path=[4976:0-203]
ATTGTACTTAATCTA.....
>comp0_c1_seq1 len=222 path=[8835:0-221]
GTACAATCACGGCACATT......
ATTGTACTTAATCTA.....
>comp0_c1_seq1 len=222 path=[8835:0-221]
GTACAATCACGGCACATT......
comp1558_c0_seq1 repressor protein
comp8142_c0_seq1 aspartate aminotransferase
comp8357_c0_seq1 l-xylulose reductase
comp8387_c0_seq1 succinyl- synthetase alpha
comp8570_c0_seq1 fatty acid synthase beta subunit dehydratase
comp8142_c0_seq1 aspartate aminotransferase
comp8357_c0_seq1 l-xylulose reductase
comp8387_c0_seq1 succinyl- synthetase alpha
comp8570_c0_seq1 fatty acid synthase beta subunit dehydratase
>comp0_c0_seq1 xxx protein
ATTGTACTTAATCTA.....
>comp0_c1_seq1 xxx reductase
GTACAATCACGGCACATT......
ATTGTACTTAATCTA.....
>comp0_c1_seq1 xxx reductase
GTACAATCACGGCACATT......
f = open("test")
ano = open("annotation.txt")
output = open("merged.fasta",'w')
for line in ano:
x = line.spilt('\t')
for line in f:
str = line.split(' ')
if x[0] == str[0]:
output.write(x)
else:
output.write(line)
ano = open("annotation.txt")
output = open("merged.fasta",'w')
for line in ano:
x = line.spilt('\t')
for line in f:
str = line.split(' ')
if x[0] == str[0]:
output.write(x)
else:
output.write(line)
"
... any better ideas to do this or found any way to fix the codes?
Thanks
Comment