How to get different outputs (fasta) files with unix or python

3

I have a fasta file that has several gene sequences, such as:

>gene1 C.irapeanum 5.8S rRNA gene
CGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGATGAGACCGTGGAATAAACGATCGAGTG
>gene2 C.irapeanum 5.8S rRNA gene
AATTTCAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGATGAGACCGTGGAATAAACGATCGAGTG
AATCCGGAGGACCGGTGTACTCAGCTCACCGGGGGCATTGCTCCCGTGGTGACCCTGATTTGTTGTTGGG
>gene3 C.irapeanum 5.8S rRNA gene
CGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTGATGAGACCGTGGAATAAACGATCGAGTG
>gene4
TTTTTTTTCCCTTTGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

I also have several files called ids.txt with the ids genes separated on each line.

For example I have the file named id1.txt:

gene1
gene2

And many others such as id2.txt:

gene4

I want to run a script that generates separate fasta files depending on my id file and how to input my large file with the sequences (only one file). For example for id2.txt, generate an id2.fasta file:

>gene4
TTTTTTTTCCCTTTGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

And so on ... I do not know how to do this, I tried to do with python, but I'm very beginner and I only managed to do one file at a time, but I have 500 different files for the ids ...

Any suggestions? Thank you

    
asked by anonymous 02.02.2017 / 17:32

1 answer

4

File Organization

First, let's define the organization of our files and the content in each one.

                                    
02.02.2017 / 18:35