INNER CODE UNIT · Python

generate_modified_kegg_fasta

BortonWrightonLabs/DRAM · bin/format_kegg_database.py:112

def generate_modified_kegg_fasta(kegg_fasta, gene_ko_link_loc=None):
    """
    Takes kegg fasta file and gene ko link file, adds kos not already in headers to headers
    Whish I knew about this, oh well I may split this out.
    """
    genes_ko_dict = defaultdict(list)
    if gene_ko_link_loc is not None:
        if gene_ko_link_loc.endswith(".gz"):
            gene_ko_link_fh = gzip.open(gene_ko_link_loc, "rt")
        else:
            gene_ko_link_fh = open(gene_ko_link_loc)
        for line in gene_ko_link_fh:
            gene, ko = line.strip().split()
            genes_ko_dict[gene].append(remove_prefix(ko, "ko:"))
    for seq in read_sequence(kegg_fasta, format="fasta"):
        new_description = seq.metadata["description"]
        for ko in genes_ko_dict[seq.metadata["id"]]:
            if ko not in new_description:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…