SBRG / pymodulon

Python package for analyzing and visualizing iModulons
MIT License
11 stars 13 forks source link

Allow users to enter multiple fasta files to make_prots_db #68

Closed sapoudel closed 3 years ago

sapoudel commented 3 years ago

Users should be able to make db from multiple fasta files. This is very useful if the organism has plasmids. example code below:

blast_dir = os.path.join('..','data','blastdb')if not os.path.exists(blast_dir):
    os.makedirs(blast_dir)
for org in orgs:
    fasta_file = os.path.join('..','data','cds',org+'.fna')
    records = SeqIO.parse(fasta_file,'fasta')
    result = []
    id_list = []
    for record in records:
        record.id = re.search(r'\[locus_tag=(.*?)\]',record.description).groups()[0]
        # Ignore duplicate sequences
        if record.id not in id_list:
            id_list.append(record.id)
            result.append(record)
    new_fasta_file = os.path.join(blast_dir,org+'.fna')
    SeqIO.write(result,new_fasta_file,'fasta')`