Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arraymapVariant-callsMapping
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bo Gao
arraymapVariant-callsMapping
Merge requests
!1
Michael's edits
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Michael's edits
michael-edits
into
master
Overview
0
Commits
3
Pipelines
0
Changes
2
Merged
Michael's edits
Michael Baudis
requested to merge
michael-edits
into
master
Oct 26, 2016
Overview
0
Commits
3
Pipelines
0
Changes
2
Adding type checks etc.
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
b83f5576
3 commits,
Oct 26, 2016
2 files
+
42
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
generate.py
+
32
−
13
View file @ b83f5576
Edit in single-file editor
Open in Web IDE
Show full file
from
pymongo
import
MongoClient
import
re
# import argparse, sys
# import argparse, sys
, json
client
=
MongoClient
()
db
=
client
.
arraymap
@@ -16,34 +16,50 @@ for sample in samples.find({}, {'UID': 1, 'BIOSAMPLEID': 1, 'SEGMENTS_HG18': 1})
if
(
'
SEGMENTS_HG18
'
in
sample
)
and
(
sample
[
'
SEGMENTS_HG18
'
]
is
not
None
)
and
(
len
(
sample
[
'
SEGMENTS_HG18
'
])
>
1
):
callset_id
=
sample
[
'
UID
'
]
biosample_id
=
sample
[
'
BIOSAMPLEID
'
]
# check if BIOSAMPLEID has string & use this as 'biosample_id';
# if not, create biosample_id as 'AM_BS__' + callset_id
matchObj
=
re
.
search
(
'
^\w+.$
'
,
sample
[
'
BIOSAMPLEID
'
])
if
not
matchObj
:
biosample_id
=
'
AM_BS__
'
+
callset_id
for
seg
in
sample
[
'
SEGMENTS_HG18
'
]:
alternate_bases
=
''
start
=
int
()
end
=
int
()
varvalue
=
float
()
if
seg
[
'
SEGTYPE
'
]
<
0
:
alternate_bases
=
'
DEL
'
elif
seg
[
'
SEGTYPE
'
]
>
0
:
alternate_bases
=
'
DUP
'
try
:
start
=
int
(
float
(
seg
[
'
SEGSTART
'
]))
except
TypeError
:
print
'
TypeError:
'
+
str
(
callset_id
)
+
'
- SEGSTART
'
continue
try
:
end
=
int
(
float
(
seg
[
'
SEGSTOP
'
]))
except
TypeError
:
print
'
TypeError:
'
+
str
(
callset_id
)
+
'
- SEGSTOP
'
continue
tag
=
str
(
seg
[
'
CHRO
'
])
+
'
_
'
+
str
(
seg
[
'
SEGSTART
'
])
+
'
_
'
+
str
(
seg
[
'
SEGSTOP
'
])
+
'
_
'
+
alternate_bases
# seg_type = int(seg['SEGTYPE'])
# start = int(seg['SEGSTART'])
# end = int(seg['SEGSTOP'])
# value = seg['SEGVALUE']
# chrom = int(seg['CHRO'])
# arraymap_id = sample['_id']
# call = {'type': seg_type, 'start': start, 'end': end, 'value': value,
# 'arraymap_id': arraymap_id, 'callset_id': callset_id}
call
=
{
'
call_set_id
'
:
sample
[
'
UID
'
],
'
biosample_id
'
:
biosample_id
,
'
VALUE
'
:
seg
[
'
SEGVALUE
'
]}
#print(str(sample['_id']))
call
=
{
'
call_set_id
'
:
str
(
sample
[
'
UID
'
]),
'
biosample_id
'
:
str
(
biosample_id
)}
try
:
varvalue
=
float
(
seg
[
'
SEGVALUE
'
])
except
ValueError
:
print
'
ValueError:
'
+
str
(
callset_id
)
+
'
- VALUE
'
else
:
call
[
'
VALUE
'
]
=
float
(
seg
[
'
SEGVALUE
'
])
if
tag
in
variants
:
variants
[
tag
][
'
CALLS
'
].
append
(
call
)
callno
+=
1
else
:
variants
[
tag
]
=
{
'
id
'
:
varid
,
'
start
'
:
seg
[
'
SEGSTART
'
],
'
end
'
:
seg
[
'
SEGSTOP
'
],
'
reference_name
'
:
seg
[
'
CHRO
'
],
'
alternate_bases
'
:
alternate_bases
,
'
CALLS
'
:[
call
]}
variants
[
tag
]
=
{
'
id
'
:
str
(
varid
),
'
start
'
:
start
,
'
end
'
:
end
,
'
reference_name
'
:
str
(
seg
[
'
CHRO
'
]),
'
alternate_bases
'
:
str
(
alternate_bases
),
'
CALLS
'
:[
call
]}
varid
+=
1
callno
+=
1
@@ -65,3 +81,6 @@ for k,v in variants.items():
insert_id
=
db_variants
.
insert
(
v
)
print
str
(
callno
)
+
'
calls were found for
'
+
str
(
varid
)
+
'
variants
'
# with open('variants.json', 'w') as outfile:
# json.dump(variants, outfile, indent=4, sort_keys=True, separators=(',', ':'))
Loading