# HG changeset patch # User peterjc # Date 1616071700 0 # Node ID c2c77e786cfca537100c8b66b48f4119e3108e38 # Parent 4e8ccac06848a084c583f2cb7aaa9fcce59c4ded "make_nr v0.0.2" diff -r 4e8ccac06848 -r c2c77e786cfc test-data/empty.fasta diff -r 4e8ccac06848 -r c2c77e786cfc tools/make_nr/README.rst --- a/tools/make_nr/README.rst Thu Aug 20 20:16:45 2020 +0000 +++ b/tools/make_nr/README.rst Thu Mar 18 12:48:20 2021 +0000 @@ -83,7 +83,9 @@ ======= ====================================================================== Version Changes ------- ---------------------------------------------------------------------- -v0.0.0 - Initial version +v0.0.2 - Fixed bug writing files when there were no duplicates +v0.0.1 - Added option to sort merged IDs, and support for gzipped files +v0.0.0 - Initial version (not published to main Galaxy Tool Shed) ======= ====================================================================== diff -r 4e8ccac06848 -r c2c77e786cfc tools/make_nr/make_nr.py --- a/tools/make_nr/make_nr.py Thu Aug 20 20:16:45 2020 +0000 +++ b/tools/make_nr/make_nr.py Thu Mar 18 12:48:20 2021 +0000 @@ -12,13 +12,14 @@ import gzip import os +import shutil import sys from optparse import OptionParser if "-v" in sys.argv or "--version" in sys.argv: - print("v0.0.1") + print("v0.0.2") sys.exit(0) @@ -139,9 +140,20 @@ "leaving %i representative records\n" % (unique, len(duplicates), len(representatives)) ) + elif len(input_fasta) == 1: + # Single file, no need to even edit titles + shutil.copy(os.path.abspath(input_fasta[0]), output_fasta) + sys.stderr.write("No perfect duplicates in file, %i unique entries\n" % unique) else: - os.symlink(os.path.abspath(input_fasta), output_fasta) - sys.stderr.write("No perfect duplicates in file, %i unique entries\n" % unique) + with open(output_fasta, "w") as handle: + for f in input_fasta: + with gzip_open(f) as in_handle: + for title, seq in SimpleFastaParser(in_handle): + handle.write(">%s\n%s\n" % (title, seq)) + sys.stderr.write( + "No perfect duplicates in %i files, %i unique entries\n" + % (len(input_fasta), unique) + ) make_nr(args, options.output, options.sep, options.alphasort) diff -r 4e8ccac06848 -r c2c77e786cfc tools/make_nr/make_nr.xml --- a/tools/make_nr/make_nr.xml Thu Aug 20 20:16:45 2020 +0000 +++ b/tools/make_nr/make_nr.xml Thu Mar 18 12:48:20 2021 +0000 @@ -1,4 +1,4 @@ - + by combining duplicated sequences biopython @@ -51,6 +51,14 @@ + + + + + + + + **What it does**