Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
optical-mapping
bnx-info
Commits
a36f5534
Commit
a36f5534
authored
Mar 31, 2015
by
Haarst, Jan van
Browse files
Code cleanup.
parent
ef1027e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
scansize.py
View file @
a36f5534
...
...
@@ -13,19 +13,16 @@ import pandas as pd
import
numpy
as
np
import
matplotlib.pyplot
as
plt
debug
=
''
runsizes
=
dict
()
def
parse_bnx
(
file_path
,
size_dict
=
{}):
def
parse_bnx
(
runsizes
=
{}):
for
line
in
fileinput
.
input
():
if
line
.
startswith
(
'# Run '
):
if
debug
:
print
line
.
strip
()
line
=
line
.
split
(
'
\t
'
)
# The SourceFolder of this Run is the 2nd entry of the line
if
debug
:
SourceFolder
=
line
[
1
]
print
SourceFolder
SourceFolder
=
line
[
1
]
if
debug
:
print
SourceFolder
# The RunId of this Run is the last entry of the line
RunId
=
int
(
line
[
-
1
])
if
debug
:
print
RunId
...
...
@@ -34,9 +31,7 @@ def parse_bnx(file_path, size_dict = {}):
NumberofScans
=
int
(
line
[
7
])
for
Scan
in
range
(
1
,
NumberofScans
+
1
):
runsizes
[
RunId
][
Scan
]
=
0
size_dict
[
Scan
]
=
0
if
debug
:
print
runsizes
if
debug
:
print
size_dict
elif
line
.
startswith
(
'0
\t
'
):
line
=
line
.
split
(
'
\t
'
)
if
debug
:
print
line
...
...
@@ -48,24 +43,13 @@ def parse_bnx(file_path, size_dict = {}):
RunId
=
int
(
line
[
-
2
])
if
debug
:
print
ScanNumber
,
Length
runsizes
[
RunId
][
ScanNumber
]
+=
Length
size_dict
[
ScanNumber
]
+=
Length
if
debug
:
print
runsizes
if
debug
:
print
size_dict
return
size_dict
def
hist_plot
(
size_dict
,
values
=
[]):
for
n
in
size_dict
:
values
.
append
(
size_dict
[
n
])
plt
.
plot
(
values
)
plt
.
show
()
return
runsizes
if
__name__
==
'__main__'
:
parse_bnx
(
sys
.
argv
[
1
]
)
# print size_dict
runsizes
=
dict
(
)
runsizes
=
parse_bnx
()
print
json
.
dumps
(
runsizes
,
sort_keys
=
True
,
indent
=
4
,
separators
=
(
','
,
': '
))
labels
=
runsizes
.
keys
()
# 1,2,..
# hist_plot(size_dict)
"""
...
...
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