# HG changeset patch # User devteam # Date 1610710736 0 # Node ID 9c1c0b947e4605e89cf6975bb8a1a10627674ab4 # Parent ef11139d45455be04940269f13763296b5c596fc "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/pileup_interval commit 8b2095c59ecc2e94c58a42e2e04dbcecdc823dbf" diff -r ef11139d4545 -r 9c1c0b947e46 pileup_interval.py --- a/pileup_interval.py Tue Jul 21 15:40:07 2015 -0400 +++ b/pileup_interval.py Fri Jan 15 11:38:56 2021 +0000 @@ -14,23 +14,17 @@ -r, --base_column=r: Reference base column -C, --cvrg_column=C: Coverage column """ - -from galaxy import eggs -import pkg_resources; pkg_resources.require( "bx-python" ) -from bx.cookbook import doc_optparse import sys -def stop_err( msg ): - sys.stderr.write( msg ) - sys.exit() +from bx.cookbook import doc_optparse + def __main__(): - strout = '' - #Parse Command Line - options, args = doc_optparse.parse( __doc__ ) + # Parse Command Line + options, args = doc_optparse.parse(__doc__) coverage = int(options.coverage) - fin = file(options.input, 'r') - fout = file(options.output, 'w') + fin = open(options.input, 'r') + fout = open(options.output, 'w') inLine = fin.readline() if options.format == 'six': seqIndex = 0 @@ -59,20 +53,20 @@ lineParts = inLine.split('\t') try: seq, loc, base, cov = lineParts[seqIndex], int(lineParts[locIndex]), lineParts[baseIndex], int(lineParts[covIndex]) - except IndexError, ei: + except IndexError as ei: if options.format == 'ten': - stop_err( 'It appears that you have selected 10 columns while your file has 6. Make sure that the number of columns you specify matches the number in your file.\n' + str( ei ) ) + sys.exit('It appears that you have selected 10 columns while your file has 6. Make sure that the number of columns you specify matches the number in your file.\n' + str(ei)) else: - stop_err( 'There appears to be something wrong with your column index values.\n' + str( ei ) ) - except ValueError, ev: + sys.exit('There appears to be something wrong with your column index values.\n' + str(ei)) + except ValueError as ev: if options.format == 'six': - stop_err( 'It appears that you have selected 6 columns while your file has 10. Make sure that the number of columns you specify matches the number in your file.\n' + str( ev ) ) + sys.exit('It appears that you have selected 6 columns while your file has 10. Make sure that the number of columns you specify matches the number in your file.\n' + str(ev)) else: - stop_err( 'There appears to be something wrong with your column index values.\n' + str( ev ) ) + sys.exit('There appears to be something wrong with your column index values.\n' + str(ev)) # strout += str(startLoc) + '\n' # strout += str(bases) + '\n' # strout += '%s\t%s\t%s\t%s\n' % (seq, loc, base, cov) - if loc == lastLoc+1 or lastLoc == -1: + if loc == lastLoc + 1 or lastLoc == -1: if cov >= coverage: if seq == lastSeq or lastSeq == '': if startLoc == -1: @@ -81,19 +75,19 @@ bases.append(base) else: if len(bases) > 0: - fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc-1, lastLoc, ''.join(bases))) + fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc - 1, lastLoc, ''.join(bases))) startLoc = loc locs = [loc] bases = [base] else: if len(bases) > 0: - fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc-1, lastLoc, ''.join(bases))) + fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc - 1, lastLoc, ''.join(bases))) startLoc = -1 locs = [] bases = [] else: if len(bases) > 0: - fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc-1, lastLoc, ''.join(bases))) + fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc - 1, lastLoc, ''.join(bases))) if cov >= coverage: startLoc = loc locs = [loc] @@ -106,12 +100,13 @@ lastLoc = loc inLine = fin.readline() if len(bases) > 0: - fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc-1, lastLoc, ''.join(bases))) + fout.write('%s\t%s\t%s\t%s\n' % (lastSeq, startLoc - 1, lastLoc, ''.join(bases))) fout.close() fin.close() - # import sys # strout += file(fout.name,'r').read() # sys.stderr.write(strout) -if __name__ == "__main__" : __main__() + +if __name__ == "__main__": + __main__() diff -r ef11139d4545 -r 9c1c0b947e46 pileup_interval.xml --- a/pileup_interval.xml Tue Jul 21 15:40:07 2015 -0400 +++ b/pileup_interval.xml Fri Jan 15 11:38:56 2021 +0000 @@ -1,7 +1,10 @@ - + + + bx-python + condenses pileup format into ranges of bases - - pileup_interval.py + +python '$__tool_directory__/pileup_interval.py' --input=$input --output=$output --coverage=$coverage