Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Piotr Gawron
Big bed generator
Commits
692e453a
Commit
692e453a
authored
Apr 26, 2019
by
Piotr Gawron
Browse files
transformation to bed implemented
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
692e453a
.idea/
venv/
*.bed
*.txt.gz
generate.py
0 → 100644
View file @
692e453a
import
gzip
import
ntpath
import
sys
def
transform
(
input_line
):
chromosome
=
input_line
[
2
]
chromosome_start
=
input_line
[
4
]
chromosome_end
=
input_line
[
5
]
name
=
input_line
[
12
]
score
=
input_line
[
11
]
strand
=
input_line
[
3
]
thick_start
=
input_line
[
6
]
thick_end
=
input_line
[
7
]
item_rgb
=
"255,0,0"
block_count
=
input_line
[
8
]
block_starts
=
[]
block_sizes
=
[]
block_starts_tmp
=
input_line
[
9
].
split
(
","
)
block_ends_tmp
=
input_line
[
10
].
split
(
","
)
for
i
in
range
(
0
,
int
(
block_count
)):
block_starts
.
append
(
block_starts_tmp
[
i
])
block_sizes
.
append
(
str
(
int
(
block_ends_tmp
[
i
])
-
int
(
block_starts_tmp
[
i
])))
output
=
[
chromosome
,
chromosome_start
,
chromosome_end
,
name
,
score
,
strand
,
thick_start
,
thick_end
,
item_rgb
,
block_count
,
","
.
join
(
block_sizes
),
","
.
join
(
block_starts
)]
return
output
inputFile
=
sys
.
argv
[
1
]
outputFile
=
ntpath
.
basename
(
inputFile
).
replace
(
".txt.gz"
,
""
)
+
".bed"
output
=
open
(
outputFile
,
"w"
)
with
gzip
.
open
(
inputFile
,
'rt'
)
as
hIN
:
for
line
in
hIN
:
F
=
line
.
rstrip
(
'
\n
'
).
split
(
'
\t
'
)
output_line
=
transform
(
F
)
print
(
"
\t
"
.
join
(
output_line
),
file
=
output
)
output
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment