Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yoann DUFRESNE
linked reads molecule ordering
Commits
31dd7951
Commit
31dd7951
authored
May 16, 2020
by
Rayan Chikhi
Browse files
added script that renames ecoli molecule graph for evaluate.py
parent
05916aa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/main/ecoli_to_interval_renamer.py
0 → 100644
View file @
31dd7951
import
sys
if
len
(
sys
.
argv
)
<
3
:
print
(
"renames nodes of a simulated molecule graph into consecutive integers (for evaluate.py)"
)
exit
(
"usage: input output"
)
out
=
open
(
sys
.
argv
[
2
],
'w'
)
for
line
in
open
(
sys
.
argv
[
1
]):
# change all occurrences of
# xxxxNC_000913.3_100644_115643_0:0:0_0:0:0_14f1/1xxxx
# to:
# xxxx100644xxxx
while
"NC_000913"
in
line
:
s
=
line
.
split
(
"NC_000913"
)
before
=
s
[
0
]
#we'll keep that
cur
=
s
[
1
]
#we'll modify that
if
len
(
s
)
>
2
:
#we'll keep that too
after
=
"NC_000913"
+
'NC_000913'
.
join
(
s
[
2
:])
else
:
after
=
""
#print("before:",before+cur+after)
# now we modify 'cur' which hopefully corresponds to [NC_00913].3_100644_115643_0:0:0_0:0:0_14f1/1....[the next NC_00913]
s
=
cur
.
split
(
'_'
)
val
=
s
[
1
]
# this is the start coordinate of the molecule, save it
cur
=
'_'
.
join
(
s
[
2
:])
# restore the rest of cur
s
=
cur
.
split
(
'/'
)
rest
=
'/'
.
join
(
s
[
1
:])
# skip until the next '/' char
rest
=
rest
[
1
:]
cur
=
val
+
rest
#print("after:",before+cur+after)
line
=
before
+
cur
+
after
out
.
write
(
line
)
out
.
close
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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