view genericize_db.py @ 2:ef46866326ef draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit e75f095a55caa325cd97127114c9703e4557ad50
author galaxyp
date Tue, 16 Jul 2024 06:55:53 +0000
parents 14785481da2b
children
line wrap: on
line source

#!/usr/bin/env python3
#
# Prefixes sequence headers in the input FASTA file that are not formatted according to the UniProt, NCBI, or ENSEMBL formats with '>generic|' to avoid being misinterpreted by Philosopher.
#

import re
import sys

input_db_file = sys.argv[1]
output_db_file = sys.argv[2]


def sub_header(line):
    return re.sub(r'^>(?!sp\||tr\||db\||AP_|NP_|YP_|XP_|WP_|ENSP|UniRef|nxp|generic)', '>generic|', line)


with open(input_db_file) as in_file, open(output_db_file, 'w') as out_file:
    for line in in_file:
        out_file.write(sub_header(line))