annotate get_flanks.py @ 3:4cd116158aef draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
author devteam
date Wed, 11 Nov 2015 12:48:31 -0500
parents a72f0decd7b3
children 077f404ae1bb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
1 #!/usr/bin/env python
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
2 #Done by: Guru
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
3
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
4 """
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
5 Get Flanking regions.
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
6
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
7 usage: %prog input out_file size direction region
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
8 -l, --cols=N,N,N,N: Columns for chrom, start, end, strand in file
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
9 -o, --off=N: Offset
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
10 """
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
11
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
12 import sys
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
13 from bx.cookbook import doc_optparse
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
14 from galaxy.tools.util.galaxyops import parse_cols_arg
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
15
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
16
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
17 def stop_err( msg ):
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
18 sys.stderr.write( msg )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
19 sys.exit()
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
20
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
21
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
22 def main():
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
23 try:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
24 if int( sys.argv[3] ) < 0:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
25 raise Exception
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
26 except:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
27 stop_err( "Length of flanking region(s) must be a non-negative integer." )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
28
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
29 # Parsing Command Line here
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
30 options, args = doc_optparse.parse( __doc__ )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
31 try:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
32 chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg( options.cols )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
33 inp_file, out_file, size, direction, region = args
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
34 if strand_col_1 <= 0:
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
35 strand = "+" # if strand is not defined, default it to +
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
36 except:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
37 stop_err( "Metadata issue, correct the metadata attributes by clicking on the pencil icon in the history item." )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
38 try:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
39 offset = int(options.off)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
40 size = int(size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
41 except:
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
42 stop_err( "Invalid offset or length entered. Try again by entering valid integer values." )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
43
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
44 fo = open(out_file, 'w')
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
45
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
46 skipped_lines = 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
47 first_invalid_line = 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
48 invalid_line = None
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
49 elems = []
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
50 j = 0
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
51 for i, line in enumerate( file( inp_file ) ):
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
52 line = line.strip()
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
53 if line and (not line.startswith( '#' )) and line != '':
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
54 j += 1
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
55 try:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
56 elems = line.split('\t')
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
57 #if the start and/or end columns are not numbers, skip that line.
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
58 assert int(elems[start_col_1])
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
59 assert int(elems[end_col_1])
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
60 if strand_col_1 != -1:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
61 strand = elems[strand_col_1]
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
62 #if the stand value is not + or -, skip that line.
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
63 assert strand in ['+', '-']
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
64 if direction == 'Upstream':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
65 if strand == '+':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
66 if region == 'end':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
67 elems[end_col_1] = str(int(elems[end_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
68 elems[start_col_1] = str( int(elems[end_col_1]) - size )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
69 else:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
70 elems[end_col_1] = str(int(elems[start_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
71 elems[start_col_1] = str( int(elems[end_col_1]) - size )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
72 elif strand == '-':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
73 if region == 'end':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
74 elems[start_col_1] = str(int(elems[start_col_1]) - offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
75 elems[end_col_1] = str(int(elems[start_col_1]) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
76 else:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
77 elems[start_col_1] = str(int(elems[end_col_1]) - offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
78 elems[end_col_1] = str(int(elems[start_col_1]) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
79 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
80 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
81
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
82 elif direction == 'Downstream':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
83 if strand == '-':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
84 if region == 'start':
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
85 elems[end_col_1] = str(int(elems[end_col_1]) - offset)
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
86 elems[start_col_1] = str( int(elems[end_col_1]) - size )
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
87 else:
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
88 elems[end_col_1] = str(int(elems[start_col_1]) - offset)
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
89 elems[start_col_1] = str( int(elems[end_col_1]) - size )
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
90 elif strand == '+':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
91 if region == 'start':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
92 elems[start_col_1] = str(int(elems[start_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
93 elems[end_col_1] = str(int(elems[start_col_1]) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
94 else:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
95 elems[start_col_1] = str(int(elems[end_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
96 elems[end_col_1] = str(int(elems[start_col_1]) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
97 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
98 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
99
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
100 elif direction == 'Both':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
101 if strand == '-':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
102 if region == 'start':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
103 start = str(int(elems[end_col_1]) - offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
104 end1 = str(int(start) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
105 end2 = str(int(start) - size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
106 elems[start_col_1] = start
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
107 elems[end_col_1] = end1
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
108 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
109 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
110 elems[start_col_1] = end2
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
111 elems[end_col_1] = start
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
112 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
113 fo.write( "%s\n" % '\t'.join( elems ) )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
114 elif region == 'end':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
115 start = str(int(elems[start_col_1]) - offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
116 end1 = str(int(start) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
117 end2 = str(int(start) - size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
118 elems[start_col_1] = start
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
119 elems[end_col_1] = end1
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
120 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
121 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
122 elems[start_col_1] = end2
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
123 elems[end_col_1] = start
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
124 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
125 fo.write( "%s\n" % '\t'.join( elems ) )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
126 else:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
127 start1 = str(int(elems[end_col_1]) - offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
128 end1 = str(int(start1) + size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
129 start2 = str(int(elems[start_col_1]) - offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
130 end2 = str(int(start2) - size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
131 elems[start_col_1] = start1
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
132 elems[end_col_1] = end1
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
133 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
134 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
135 elems[start_col_1] = end2
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
136 elems[end_col_1] = start2
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
137 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
138 fo.write( "%s\n" % '\t'.join( elems ) )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
139 elif strand == '+':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
140 if region == 'start':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
141 start = str(int(elems[start_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
142 end1 = str(int(start) - size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
143 end2 = str(int(start) + size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
144 elems[start_col_1] = end1
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
145 elems[end_col_1] = start
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
146 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
147 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
148 elems[start_col_1] = start
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
149 elems[end_col_1] = end2
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
150 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
151 fo.write( "%s\n" % '\t'.join( elems ) )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
152 elif region == 'end':
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
153 start = str(int(elems[end_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
154 end1 = str(int(start) - size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
155 end2 = str(int(start) + size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
156 elems[start_col_1] = end1
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
157 elems[end_col_1] = start
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
158 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
159 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
160 elems[start_col_1] = start
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
161 elems[end_col_1] = end2
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
162 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
163 fo.write( "%s\n" % '\t'.join( elems ) )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
164 else:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
165 start1 = str(int(elems[start_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
166 end1 = str(int(start1) - size)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
167 start2 = str(int(elems[end_col_1]) + offset)
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
168 end2 = str(int(start2) + size)
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
169 elems[start_col_1] = end1
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
170 elems[end_col_1] = start1
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
171 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
172 fo.write( "%s\n" % '\t'.join( elems ) )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
173 elems[start_col_1] = start2
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
174 elems[end_col_1] = end2
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
175 assert int(elems[start_col_1]) > 0 and int(elems[end_col_1]) > 0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
176 fo.write( "%s\n" % '\t'.join( elems ) )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
177 except:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
178 skipped_lines += 1
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
179 if not invalid_line:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
180 first_invalid_line = i + 1
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
181 invalid_line = line
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
182 fo.close()
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
183
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
184 if skipped_lines == j:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
185 stop_err( "Data issue: click the pencil icon in the history item to correct the metadata attributes." )
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
186 if skipped_lines > 0:
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
187 print 'Skipped %d invalid lines starting with #%dL "%s"' % ( skipped_lines, first_invalid_line, invalid_line )
3
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
188 print 'Location: %s, Region: %s, Flank-length: %d, Offset: %d ' % ( direction, region, size, offset )
4cd116158aef planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/get_flanks commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
189
0
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
190 if __name__ == "__main__":
a72f0decd7b3 Imported from capsule None
devteam
parents:
diff changeset
191 main()