I have a file that has this contents
1 5 9 14 15
00000
10000
00010
11010
00010
I want to parse the file so that the following is output
UUUUUUUUUUUUUU
YUUUUUUUUUUUUU
UUUUUUUUUUUUYY
YUUUYUUUUUUUYU
UUUUUUUUUUUUYU
This means the first row provides a position. If there is a 0, it becomes U. If it is a 1 it becomes Y. Between the first two columns there are 4 unmapped cols which means that for these four cols all rows are U - and 0
I tried the following in python
#!/usr/bin/env python2
import sys
with open(sys.argv[1]) as f:
f.readline()
for line in f:
new = ''
for char in line.rstrip():
if char == '0':
new += 'UU'
elif char == '1':
new +='YU'
print new.rstrip()[:-1]
The problem is that this script only works if the positions are 2 apart but they can also be larger - how can I extend the script?
there is some poroblem when i run the code from, Delimity - get an error
dropbox.com/s/cf8rbv20bgyvssq/conv_inp?dl=0 these are the real da
Traceback (most recent call last):
File "./con.py", line 8, in <module>
for v in xrange(max(positions) + 1):
OverflowError: long int too large to convert to int
00010isUUUUUUUUUUUUYY? It should beUUUUUUUUUUUUYU!