# HG changeset patch
# User devteam
# Date 1447264111 18000
# Node ID 4cd116158aef236b383e8f38aa0459b56d766e3b
# Parent 4b14d0e3a837320eb934c6ee0e3c25bd74023203
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
diff -r 4b14d0e3a837 -r 4cd116158aef get_flanks.py
--- a/get_flanks.py Mon Apr 14 09:18:30 2014 -0400
+++ b/get_flanks.py Wed Nov 11 12:48:31 2015 -0500
@@ -9,15 +9,17 @@
-o, --off=N: Offset
"""
-import sys, re, os
+import sys
from bx.cookbook import doc_optparse
-from galaxy.tools.util.galaxyops import *
+from galaxy.tools.util.galaxyops import parse_cols_arg
+
def stop_err( msg ):
sys.stderr.write( msg )
sys.exit()
-def main():
+
+def main():
try:
if int( sys.argv[3] ) < 0:
raise Exception
@@ -30,26 +32,26 @@
chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg( options.cols )
inp_file, out_file, size, direction, region = args
if strand_col_1 <= 0:
- strand = "+" #if strand is not defined, default it to +
+ strand = "+" # if strand is not defined, default it to +
except:
stop_err( "Metadata issue, correct the metadata attributes by clicking on the pencil icon in the history item." )
try:
offset = int(options.off)
size = int(size)
- except:
+ except:
stop_err( "Invalid offset or length entered. Try again by entering valid integer values." )
- fo = open(out_file,'w')
-
+ fo = open(out_file, 'w')
+
skipped_lines = 0
first_invalid_line = 0
invalid_line = None
elems = []
- j=0
+ j = 0
for i, line in enumerate( file( inp_file ) ):
line = line.strip()
if line and (not line.startswith( '#' )) and line != '':
- j+=1
+ j += 1
try:
elems = line.split('\t')
#if the start and/or end columns are not numbers, skip that line.
@@ -76,15 +78,15 @@
elems[end_col_1] = str(int(elems[start_col_1]) + size)
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
-
+
elif direction == 'Downstream':
if strand == '-':
if region == 'start':
- elems[end_col_1] = str(int(elems[end_col_1]) - offset)
- elems[start_col_1] = str( int(elems[end_col_1]) - size )
+ elems[end_col_1] = str(int(elems[end_col_1]) - offset)
+ elems[start_col_1] = str( int(elems[end_col_1]) - size )
else:
- elems[end_col_1] = str(int(elems[start_col_1]) - offset)
- elems[start_col_1] = str( int(elems[end_col_1]) - size )
+ elems[end_col_1] = str(int(elems[start_col_1]) - offset)
+ elems[start_col_1] = str( int(elems[end_col_1]) - size )
elif strand == '+':
if region == 'start':
elems[start_col_1] = str(int(elems[start_col_1]) + offset)
@@ -94,31 +96,31 @@
elems[end_col_1] = str(int(elems[start_col_1]) + size)
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
-
+
elif direction == 'Both':
if strand == '-':
if region == 'start':
start = str(int(elems[end_col_1]) - offset)
end1 = str(int(start) + size)
end2 = str(int(start) - size)
- elems[start_col_1]=start
- elems[end_col_1]=end1
+ elems[start_col_1] = start
+ elems[end_col_1] = end1
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
- elems[start_col_1]=end2
- elems[end_col_1]=start
+ elems[start_col_1] = end2
+ elems[end_col_1] = start
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
elif region == 'end':
start = str(int(elems[start_col_1]) - offset)
end1 = str(int(start) + size)
end2 = str(int(start) - size)
- elems[start_col_1]=start
- elems[end_col_1]=end1
+ elems[start_col_1] = start
+ elems[end_col_1] = end1
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
- elems[start_col_1]=end2
- elems[end_col_1]=start
+ elems[start_col_1] = end2
+ elems[end_col_1] = start
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
else:
@@ -126,12 +128,12 @@
end1 = str(int(start1) + size)
start2 = str(int(elems[start_col_1]) - offset)
end2 = str(int(start2) - size)
- elems[start_col_1]=start1
- elems[end_col_1]=end1
+ elems[start_col_1] = start1
+ elems[end_col_1] = end1
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
- elems[start_col_1]=end2
- elems[end_col_1]=start2
+ elems[start_col_1] = end2
+ elems[end_col_1] = start2
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
elif strand == '+':
@@ -139,24 +141,24 @@
start = str(int(elems[start_col_1]) + offset)
end1 = str(int(start) - size)
end2 = str(int(start) + size)
- elems[start_col_1]=end1
- elems[end_col_1]=start
+ elems[start_col_1] = end1
+ elems[end_col_1] = start
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
- elems[start_col_1]=start
- elems[end_col_1]=end2
+ elems[start_col_1] = start
+ elems[end_col_1] = end2
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
elif region == 'end':
start = str(int(elems[end_col_1]) + offset)
end1 = str(int(start) - size)
end2 = str(int(start) + size)
- elems[start_col_1]=end1
- elems[end_col_1]=start
+ elems[start_col_1] = end1
+ elems[end_col_1] = start
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
- elems[start_col_1]=start
- elems[end_col_1]=end2
+ elems[start_col_1] = start
+ elems[end_col_1] = end2
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
else:
@@ -164,12 +166,12 @@
end1 = str(int(start1) - size)
start2 = str(int(elems[end_col_1]) + offset)
end2 = str(int(start2) + size)
- elems[start_col_1]=end1
- elems[end_col_1]=start1
+ elems[start_col_1] = end1
+ elems[end_col_1] = start1
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
- elems[start_col_1]=start2
- elems[end_col_1]=end2
+ elems[start_col_1] = start2
+ elems[end_col_1] = end2
assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
fo.write( "%s\n" % '\t'.join( elems ) )
except:
@@ -183,7 +185,7 @@
stop_err( "Data issue: click the pencil icon in the history item to correct the metadata attributes." )
if skipped_lines > 0:
print 'Skipped %d invalid lines starting with #%dL "%s"' % ( skipped_lines, first_invalid_line, invalid_line )
- print 'Location: %s, Region: %s, Flank-length: %d, Offset: %d ' %( direction, region, size, offset )
-
+ print 'Location: %s, Region: %s, Flank-length: %d, Offset: %d ' % ( direction, region, size, offset )
+
if __name__ == "__main__":
main()
diff -r 4b14d0e3a837 -r 4cd116158aef get_flanks.xml
--- a/get_flanks.xml Mon Apr 14 09:18:30 2014 -0400
+++ b/get_flanks.xml Wed Nov 11 12:48:31 2015 -0500
@@ -17,8 +17,8 @@
-
-
+
+
diff -r 4b14d0e3a837 -r 4cd116158aef tool_dependencies.xml
--- a/tool_dependencies.xml Mon Apr 14 09:18:30 2014 -0400
+++ b/tool_dependencies.xml Wed Nov 11 12:48:31 2015 -0500
@@ -1,9 +1,9 @@
-
+
-
+