# HG changeset patch # User iuc # Date 1508779578 14400 # Node ID 3088e7e70888d09b70cb23683dccb34b3fa2124c # Parent 53db9cb721f18ccca982dc8b180413d39aee53cf planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/extract_genomic_dna commit 4a3c9f195ba5d899b1a1ce5e80281cdf230f456a diff -r 53db9cb721f1 -r 3088e7e70888 extract_genomic_dna.py --- a/extract_genomic_dna.py Mon Jul 03 07:19:41 2017 -0400 +++ b/extract_genomic_dna.py Mon Oct 23 13:26:18 2017 -0400 @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + import argparse import os @@ -81,7 +83,7 @@ start, end = egdu.convert_gff_coords_to_bed([start, end]) if includes_strand_col: strand = fields[strand_col] - except: + except Exception: warning = "Invalid chrom, start or end column values. " warnings.append(warning) if not invalid_lines: @@ -129,7 +131,7 @@ sequence += twobitfile[interval.chrom][interval.start:interval.end] else: sequence = twobitfile[chrom][start:end] - except: + except Exception: warning = "Unable to fetch the sequence from '%d' to '%d' for chrom '%s'. " % (start, end - start, chrom) warnings.append(warning) if not invalid_lines: @@ -156,8 +158,6 @@ if includes_strand_col and strand == "-": sequence = egdu.reverse_complement(sequence) if args.output_format == "fasta": - l = len(sequence) - c = 0 if input_is_gff: start, end = egdu.convert_bed_coords_to_gff([start, end]) if args.fasta_header_type == "bedtools_getfasta_default": @@ -175,8 +175,10 @@ out.write(">%s %s\n" % (meta_data, name)) else: out.write(">%s\n" % meta_data) - while c < l: - b = min(c + 50, l) + c = 0 + sequence_length = len(sequence) + while c < sequence_length: + b = min(c + 50, sequence_length) out.write("%s\n" % str(sequence[c:b])) c = b else: @@ -209,10 +211,10 @@ if warnings: warn_msg = "%d warnings, 1st is: " % len(warnings) warn_msg += warnings[0] - print warn_msg + print(warn_msg) if skipped_lines: # Error message includes up to the first 10 skipped lines. - print 'Skipped %d invalid lines, 1st is #%d, "%s"' % (skipped_lines, first_invalid_line, '\n'.join(invalid_lines[:10])) + print('Skipped %d invalid lines, 1st is #%d, "%s"' % (skipped_lines, first_invalid_line, '\n'.join(invalid_lines[:10]))) if args.reference_genome_source == "history": os.remove(seq_path) diff -r 53db9cb721f1 -r 3088e7e70888 extract_genomic_dna.xml --- a/extract_genomic_dna.xml Mon Jul 03 07:19:41 2017 -0400 +++ b/extract_genomic_dna.xml Mon Oct 23 13:26:18 2017 -0400 @@ -2,6 +2,7 @@ using coordinates from assembled/unassembled genomes bx-python + six ucsc-fatotwobit