Entering edit mode
6.9 years ago
horsedog
▴
60
Hi, a stupid question from a python beginner I'd like to rename the query of my fasta file, here is my sequence :
>WP_015529149.1
MSMTGIILAAVVVGGTGLFIGVFLGIAGKKFAVKVDEREEAILGVLPGNNCGGCGYAGCSGLAAAIVKGEAEVSGCPVGG
APVAAKIGDIMGVAAGTQERQTAFVKCAGTCEKAILDYDYTGIQDCTMASMMQNGGAKGCNSGCLGFGSCVAACPFDAIH
VVDGIAVVDKEACKACGKCIAACPKHLIELIPYEQKTFVRCNSNAKGKVQLTICQAGCIGCRLCEKNCEAGAITVTNFLA
HIDADKCTECGVCVEKCPRKIITLR
>WP_055172573.1
MSMTGIILAAVVVGGTGLFIGVFLGIAGKKFAVKVDEREEAILGVLPGNNCGGCGYAGCSGLAAAIVKGEAEVSGCPVGG
APVAAKIGEIMGVAAGTQERQTAFVKCAGTCEKAILDYDYTGIQDCTMASMMQNGGAKGCNSGCLGFGSCVAACPFDAIH
VVDGIAVVDKEACKACGKCIAACPKHLIELIPYEQKTFVRCNSNAKGKIQLTICQAGCIGCRICEKNCEAGAITVTNFLA
HIDADKCTECGVCVEKCPRKIITLR
I would like to add string "_ABCDE" to the line with ">"
to get" >WP_015529149.1_ABCDE" and" >WP_055172573.1_ABCDE",
if I use python how to achieve this?
Looking good, although for biiiiig files you shouldn't use
.readlines()
because you are reading everything in memory, while you can just iterate over the file: