-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathegautils.py
34 lines (27 loc) · 1.11 KB
/
egautils.py
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
import string
import logging
logger = logging.getLogger()
def obj_id(e):
def filter_alphan(t, additional):
return ''.join(filter(lambda x: x.lower() in string.ascii_lowercase or x in additional, t))
try:
idblock = e.get('@idblock', dict())
tags = sorted(list(set([idblock[k] for k in ['alias', 'refname', 'accession'] if k in idblock])))
return 'unknown' if not tags else filter_alphan('.'.join(tags), '.-_1234567890')
except Exception as e:
logger.info('#__could_not_exact_id__:{0}\n'.format(e ))
return '__cannot_understand_id_block__'
def strategy2schema(s):
def found(x, alist):
if x in alist: return True
else:
return x.lower() in [e.lower() for e in alist]
if found(s, ["DNase-Hypersensitivity", "ATAC-seq", "NOME-Seq"]): return "chromatin_accessibility"
elif found(s, ["Bisulfite-Seq"]): return "bisulfite-seq"
elif found(s, ["MeDIP-Seq"]): return "medip-seq"
elif found(s, ["MRE-Seq"]): return "mre-seq"
elif found(s, ["RNA-Seq", "miRNA-Seq"]): return "rna-seq"
elif found(s, ["WGS"]): return "wgs"
elif s[0:4].lower() in ['chip', 'hist']: return 'chip-seq'
else:
return s.lower()