From aaea0bcf7a4af5ad3358594d5e71e622381eaa2e Mon Sep 17 00:00:00 2001 From: Acribbs Date: Mon, 1 Apr 2024 15:58:10 +0100 Subject: [PATCH] removed transfac script as its better placed in a pipeline --- cgat/tools/transfac2transfac.py | 130 ------------------------------ doc/scripts/transfac2transfac.rst | 5 -- 2 files changed, 135 deletions(-) delete mode 100644 cgat/tools/transfac2transfac.py delete mode 100644 doc/scripts/transfac2transfac.rst diff --git a/cgat/tools/transfac2transfac.py b/cgat/tools/transfac2transfac.py deleted file mode 100644 index e7859526..00000000 --- a/cgat/tools/transfac2transfac.py +++ /dev/null @@ -1,130 +0,0 @@ -''' -transfac2transfac.py - filter transfac motif files -==================================================== - -:Tags: Python - -Purpose -------- - -Filter a transfac motif file. - -Usage ------ - -Example:: - - python cgat_script_template.py - -Type:: - - python cgat_script_template.py --help - -for command line help. - -Command line options --------------------- - -''' - - -import sys -import re -import cgatcore.experiment as E - - -def main(argv=None): - """script main. - - parses command line options in sys.argv, unless *argv* is given. - """ - - if argv is None: - argv = sys.argv - - # setup command line parser - parser = E.ArgumentParser(description=__doc__) - - parser.add_argument("--version", action='version', version="1.0") - - parser.add_argument( - "-f", "--filter-prefix", dest="filter_prefix", default=None, - help="ID prefix to filter on, eg. V for vertebrates") - - parser.add_argument( - "-p", "--pattern-identifier", dest="filter_pattern", default=None, - help="ID pattern to filter (filter is case insensitive) eg. pax6. " - "Multiple patterns should be specified as a comma separated list") - - (args) = E.start(parser) - - if args.filter_pattern: - patterns = [x.strip() for x in args.filter_pattern.split(",")] - E.info("Supplied patterns %s" % ", ".join(patterns)) - else: - patterns = False - - filtered_motifs = [] - n = 0 - - inmotif, tid, filter_emit, pattern_emit = False, False, False, False - - for line in args.stdin: - - # pick up motif start and ends. - if line.startswith("AC") and inmotif is False: - # print "in align" - inmotif = True - motif = line - continue - elif line.startswith("ID") and inmotif is True: - # print line - tid = line.split(" ")[1] - motif += line - continue - - elif line.startswith("//") and inmotif is True: - - motif += line - - if tid is False: - raise ValueError("matrix ID not determined") - - if args.filter_prefix: - if tid.startswith(args.filter_prefix): - filter_emit = True - else: - filter_emit = True - - if patterns is not False: - for pat in patterns: - match = re.search(pat, tid, re.IGNORECASE) - if match is not None: - pattern_emit = True - break - else: - pattern_emit = True - - if filter_emit is True and pattern_emit is True: - filtered_motifs.append(motif) - n += 1 - - inmotif, tid, filter_emit, pattern_emit = ( - False, False, False, False) - continue - - elif inmotif is True: - motif += line - - elif inmotif is False: - continue - - else: - raise ValueError("unknown parsing state") - - args.stdout.write("".join(filtered_motifs)) - - E.stop() - -if __name__ == "__main__": - sys.exit(main(sys.argv)) diff --git a/doc/scripts/transfac2transfac.rst b/doc/scripts/transfac2transfac.rst deleted file mode 100644 index 33e0cf72..00000000 --- a/doc/scripts/transfac2transfac.rst +++ /dev/null @@ -1,5 +0,0 @@ - -.. automodule:: cgat.tools.transfac2transfac - -.. program-output:: cgat transfac2transfac -? -