Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mosaicatcher Update
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Weber
Mosaicatcher Update
Commits
2e2364f1
Commit
2e2364f1
authored
6 years ago
by
Tobias Marschall
Browse files
Options
Downloads
Patches
Plain Diff
Create JSON files with count data to be browsed in GEAR/HALO
parent
1133fc7d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Snakefile
+15
-0
15 additions, 0 deletions
Snakefile
utils/counts_to_json.py
+65
-0
65 additions, 0 deletions
utils/counts_to_json.py
with
80 additions
and
0 deletions
Snakefile
+
15
−
0
View file @
2e2364f1
...
...
@@ -77,6 +77,10 @@ rule all:
bpdens = ["selected"],
method = METHODS,
plottype = ["byaf","bypos"]),
expand("halo/{sample}/{window}_{suffix}.json.gz",
sample = SAMPLES,
window = [100000],
suffix = ["fixed", "fixed_norm"])
################################################################################
...
...
@@ -299,6 +303,17 @@ rule plot_SV_consistency_barplot:
"utils/sv_consistency_barplot.snakemake.R"
rule generate_halo_json:
input:
counts = "counts/{sample}/{windows}.txt.gz",
output:
json = "halo/{sample}/{windows}.json.gz",
log:
"log/generate_halo_json/{sample}/{windows}.{windows}.log"
shell:
"(./utils/counts_to_json.py {input.counts} | gzip > {output.json}) 2> {log}"
################################################################################
# Read counting #
################################################################################
...
...
This diff is collapsed.
Click to expand it.
utils/counts_to_json.py
0 → 100755
+
65
−
0
View file @
2e2364f1
#!/usr/bin/env python
import
sys
from
argparse
import
ArgumentParser
import
gzip
import
json
from
collections
import
defaultdict
,
namedtuple
class
CountTable
:
def
__init__
(
self
,
filename
):
# maps (cell,chromosome) to a list of counts (start, end, w, c)
self
.
counts
=
defaultdict
(
list
)
for
i
,
line
in
enumerate
(
gzip
.
open
(
filename
)):
if
i
==
0
:
fieldnames
=
list
(
x
.
decode
()
+
'
_
'
for
x
in
line
.
split
())
Fields
=
namedtuple
(
'
Fields
'
,
fieldnames
)
else
:
f
=
list
(
x
.
decode
()
for
x
in
line
.
split
())
fields
=
Fields
(
*
f
)
self
.
counts
[(
fields
.
cell_
,
fields
.
chrom_
)].
append
(
(
int
(
fields
.
start_
),
int
(
fields
.
end_
),
float
(
fields
.
w_
),
float
(
fields
.
c_
))
)
def
write_json
(
self
):
cells
=
sorted
(
set
(
cell
for
(
cell
,
chromosome
)
in
self
.
counts
.
keys
()))
chromosomes
=
sorted
(
set
(
chromosome
for
(
cell
,
chromosome
)
in
self
.
counts
.
keys
()))
# list of dicts (one per cell) to be serialized as JSON
l
=
[]
for
cell
in
cells
:
d_cell
=
{}
d_cell
[
"
sample
"
]
=
cell
d_cell
[
"
coverages
"
]
=
[
{
"
chromosome
"
:
chromosome
,
"
positions
"
:
[
start
for
(
start
,
end
,
w
,
c
)
in
self
.
counts
[(
cell
,
chromosome
)]],
"
counts
"
:
[
{
"
label
"
:
"
Watson
"
,
"
values
"
:
[
w
for
(
start
,
end
,
w
,
c
)
in
self
.
counts
[(
cell
,
chromosome
)]]
},
{
"
label
"
:
"
Crick
"
,
"
values
"
:
[
c
for
(
start
,
end
,
w
,
c
)
in
self
.
counts
[(
cell
,
chromosome
)]]
},
]
}
for
chromosome
in
chromosomes
]
l
.
append
(
d_cell
)
json
.
dump
({
"
data
"
:
l
},
sys
.
stdout
)
def
main
():
parser
=
ArgumentParser
(
prog
=
'
counts_to_json.py
'
,
description
=
__doc__
)
parser
.
add_argument
(
'
counts
'
,
metavar
=
'
COUNT
'
,
help
=
'
Gzipped, tab-separated table with counts
'
)
args
=
parser
.
parse_args
()
print
(
'
Reading count table from
'
,
args
.
counts
,
file
=
sys
.
stderr
)
count_table
=
CountTable
(
args
.
counts
)
print
(
'
... done.
'
,
file
=
sys
.
stderr
)
count_table
.
write_json
()
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment