forked from juzishengwu/decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflip.py
More file actions
31 lines (27 loc) · 836 Bytes
/
flip.py
File metadata and controls
31 lines (27 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#coding=utf-8
#http://www.snpedia.com/index.php/Orientation
#https://customercare.23andme.com/hc/en-us/articles/202907660-Which-DNA-strand-does-23andMe-report-for-SNP-genotypes
import os,sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'decoder.settings'
import django
django.setup()
from baike.models import *
def flip(s):
orientatio_map = {'A': 'T',
'T': 'A',
'G': 'C',
'C': 'G'}
r = []
for i in s:
try:
r.append(orientatio_map[i.upper()])
except KeyError:
return s
return ''.join(r)
for g in Genotype.objects.all():
if g.snp.orientation == 'plus':
g.allele_flipped = g.allele
g.save()
if g.snp.orientation == 'minus':
g.allele_flipped = flip(g.allele)
g.save()