view genericize_db.py @ 3:da9ebef968bd draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/fragpipe commit b1b03bb7cd31c1ec806b286d6c9444428b358e15
author galaxyp
date Thu, 12 Sep 2024 08:06:44 +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))