-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathparseGeneMap2.py
More file actions
91 lines (68 loc) · 2.27 KB
/
Copy pathparseGeneMap2.py
File metadata and controls
91 lines (68 loc) · 2.27 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is a simple script to parse the genemap2.txt file that
# can be downloaded from https://omim.org/
#
# The file can downloaded from https://omim.org/downloads
# (registration required).
#
# Imports
import sys
import re
# Read from stdin
for line in sys.stdin:
# Skip comments
if line.startswith('#'):
continue
# Strip trailing new line
line = line.strip('\n')
# Get the values
valueList = line.split('\t')
# Get the fields
chromosome = valueList[0]
genomicPositionStart = valueList[1]
genomicPositionEnd = valueList[2]
cytoLocation = valueList[3]
computedCytoLocation = valueList[4]
mimNumber = valueList[5]
geneSymbols = valueList[6]
geneName = valueList[7]
approvedGeneSymbol = valueList[8]
entrezGeneID = valueList[9]
ensemblGeneID = valueList[10]
comments = valueList[11]
phenotypeString = valueList[12]
mouse = valueList[13]
# Skip empty phenotypes
if not phenotypeString:
continue
# Parse the phenotypes
for phenotype in phenotypeString.split(';'):
# Clean the phenotype
phenotype = phenotype.strip()
# Long phenotype
matcher = re.match(r'^(.*),\s(\d{6})\s\((\d)\)(|, (.*))$', phenotype)
if matcher:
# Get the fields
phenotype = matcher.group(1)
phenotypeMimNumber = matcher.group(2)
phenotypeMappingKey = matcher.group(3)
inheritances = matcher.group(5)
# Get the inheritances, may or may not be there
if inheritances:
for inheritance in inheritances.split(','):
inheritance = inheritance.strip()
# Short phenotype
else:
# Short phenotype
matcher = re.match(r'^(.*)\((\d)\)(|, (.*))$', phenotype)
if matcher:
# Get the fields
phenotype = matcher.group(1)
phenotypeMappingKey = matcher.group(2)
inheritances = matcher.group(3)
# Get the inheritances, may or may not be there
if inheritances:
for inheritance in inheritances.split(','):
inheritance = inheritance.strip()