# HG changeset patch # User peterjc # Date 1494941810 14400 # Node ID b9dc7c967ee6beb0b2a2e867e62aea3d65494a01 # Parent 530c8d6fedd890bdfd9d599f232397b6c54055dd v0.0.16 Python 3 compatible print function diff -r 530c8d6fedd8 -r b9dc7c967ee6 tools/seq_primer_clip/README.rst --- a/tools/seq_primer_clip/README.rst Wed May 10 13:09:52 2017 -0400 +++ b/tools/seq_primer_clip/README.rst Tue May 16 09:36:50 2017 -0400 @@ -73,6 +73,7 @@ - Explicit dependency on ``galaxy_sequence_utils``. v0.0.15 - Use ```` (internal change only). - Single quote command line arguments (internal change only) +v0.0.16 - Python 3 compatible print function. ======= ====================================================================== diff -r 530c8d6fedd8 -r b9dc7c967ee6 tools/seq_primer_clip/seq_primer_clip.py --- a/tools/seq_primer_clip/seq_primer_clip.py Wed May 10 13:09:52 2017 -0400 +++ b/tools/seq_primer_clip/seq_primer_clip.py Tue May 16 09:36:50 2017 -0400 @@ -33,13 +33,13 @@ import re import sys +if "-v" in sys.argv or "--version" in sys.argv: + print("v0.0.16") + sys.exit(0) + from galaxy_utils.sequence.fasta import fastaReader, fastaWriter from galaxy_utils.sequence.fastq import fastqReader, fastqWriter -if "-v" in sys.argv or "--version" in sys.argv: - print "v0.0.12" - sys.exit(0) - try: from Bio.Seq import reverse_complement from Bio.SeqIO.SffIO import SffIterator, SffWriter @@ -130,10 +130,12 @@ def make_reg_ex(seq): + """Make regular expression for ambiguous DNA.""" return "".join(ambiguous_dna_re[letter] for letter in seq) def make_reg_ex_mm(seq, mm): + """Make regular expression for mis-matches.""" if mm > 2: raise NotImplementedError("At most 2 mismatches allowed!") seq = seq.upper() @@ -166,7 +168,10 @@ def load_primers_as_re(primer_fasta, mm, rc=False): - # Read primer file and record all specified sequences + """Load primers as regular expressions. + + Read primer file and record all specified sequences. + """ primers = set() in_handle = open(primer_fasta, "rU") reader = fastaReader(in_handle) @@ -189,7 +194,7 @@ # Read primer file and record all specified sequences count, primer = load_primers_as_re(primer_fasta, mm, rc) -print "%i primer sequences" % count +print("%i primer sequences" % count) short_neg = 0 short_clipped = 0 @@ -350,8 +355,8 @@ in_handle.close() out_handle.close() -print "Kept %i clipped reads," % clipped -print "discarded %i short." % short_clipped +print("Kept %i clipped reads," % clipped) +print("discarded %i short." % short_clipped) if keep_negatives: - print "Kept %i non-matching reads," % negs - print "discarded %i short." % short_neg + print("Kept %i non-matching reads," % negs) + print("discarded %i short." % short_neg) diff -r 530c8d6fedd8 -r b9dc7c967ee6 tools/seq_primer_clip/seq_primer_clip.xml --- a/tools/seq_primer_clip/seq_primer_clip.xml Wed May 10 13:09:52 2017 -0400 +++ b/tools/seq_primer_clip/seq_primer_clip.xml Tue May 16 09:36:50 2017 -0400 @@ -1,4 +1,4 @@ - + Trim off 5' or 3' primers galaxy_sequence_utils