Hi, first post here.
So I'm trying take the CDS out of various species' orthologous sequences. I'm running on a Linux server, and am mainly aiming to use BioPython or Linux programs for this. 

I've run OrthoFinder on 28 species of seaweed, which gave out roughly 10,000 orthogroup sequences fasta files, each of which is a a multi-fasta file. I've concatenated each of them into one huge multifasta file, and now I want to extract the fasta files according to their species into a new multifasta file (so 10k files -> 1 file -> 28 files, one per species).

How do I do this? I'm still fairly new to BioPython, so I'm still wrapping my head around things. I know I'll definitely need SeqIO, not sure what other libraries I'll need. I already have a text file with all the species listed, one per line.

Thanks heaps for any help.
Lachlan
Here is a Python code that reads one FASTA file and creates multiple FASTA files for each species separately.

    from Bio import SeqIO

    d = {}
    fh = open('OG0000036.fa')
    for seq_record in SeqIO.parse(fh, 'fasta'):
        species_name = seq_record.id.split('-')[-1]
        if species_name not in d:
            d[species_name] = open(f"{species_name}.fa", 'w')
        d[species_name].write(seq_record.format("fasta"))
    fh.close()

**OUTPUT:**

FASTA files:

    Ahnfeltiopsis_flabelliformis.fa
    Betaphycus_philippinensis.fa
    Ceramium_kondoi.fa
    Chondrus_crispus.fa
    Chroodactylon_ornatum.fa
    Dumontia_simplex.fa
    Eucheuma_denticulatum.fa
    Glaucosphaera_vacuolata.fa
    Gloiopeltis_furcata.fa
    Gracilaria_blodgettii.fa
    Gracilaria_lemaneiformis.fa
    Gracilaria_sp..fa
    Grateloupia_catenata.fa
    Grateloupia_filicina.fa
    Grateloupia_livida.fa
    Grateloupia_turuturu.fa
    Heterosiphonia_pulchra.fa
    Kappaphycus_alvarezii.fa
    Mazzaella_japonica.fa
    Neosiphonia_japonica.fa
    Porphyridium_cruentum.fa
    Porphyridium_purpureum.fa
    Pyropia_yezoensis.fa
    Rhodochaete_parvula.fa

For example, `Grateloupia_filicina.fa` has three sequences:

    >scaffold-ZJOJ-2006011-Grateloupia_filicina
    MVVVFGLTGNDFALVVADMTSARSIMCFKHDEDKIERIDERKVLATAGEHSNRIEFSEYI
    QKNLALMKLQTGLELSNHGTANFIRNEVAKALRTRGAYNTNSIMAGFDETGPAQKVNFTA
    HGYASYFSLSVMDSKWRQDMTLEEGKKLVQECIDQLKSRFLINQPKFMMKIVTDQGITE
    >scaffold-ZJOJ-2006903-Grateloupia_filicina
    MDTLLGIAGEGFVVLAADAQVARSILLYKNDMDKIAHLSENKALACAGPQSDCVSFTEYI
    SKNMALYELNNDVKLSTKAAASFIRGELAKALRKGPFQTQILMGGVDKRAAAEAEGKDDA
    SLFWLDYLGTLQKVPYGAHGYGAAFTLSVMDREYVKGLSLDEALAIIDNCIKELHTRFLI
    AQKNFVIKVVTAEGIK
    >scaffold-ZJOJ-2055484-Grateloupia_filicina
    MESIIALEGDGYVLIAADVASARSVVVMKDDMDKIRPLDSHKLFAAAGIPGDVSKFTEHV
    QKDVRLYNMRSGITMSTAAAANYTRGELARFLRRSPFQCNVLIGGYDAPPYGHGPSLYSC
    DYLGTLTKLKFAAEGYAQYFVLSTLDRYWKKNLSIEDGVEVIKKCVAEVQKRLVINQPRF
    AIKIVDKNGVRVID

