Skip to content
Snippets Groups Projects
Commit e8d91b95 authored by Michael Baudis's avatar Michael Baudis
Browse files

cleanup

parent 217521f3
No related branches found
No related tags found
1 merge request!1Michael's edits
from pymongo import MongoClient
import re
# import argparse, sys
# import argparse, sys, json
client = MongoClient()
db = client.arraymap
......@@ -16,28 +16,23 @@ 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 = ''
if seg['SEGTYPE'] < 0:
alternate_bases = 'DEL'
elif seg['SEGTYPE'] > 0:
alternate_bases = 'DUP'
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']))
if tag in variants:
variants[tag]['CALLS'].append(call)
callno += 1
......@@ -65,3 +60,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=(',', ':'))
{
"10_46499590_47154881_DUP":{
"CALLS":[
{
"VALUE":"0.4956",
"biosample_id":"AM_BS__GSM253289",
"call_set_id":"GSM253289"
}
],
"_id":
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment