|
1
|
|
|
"""Read GAF file and allow ND Evidence codes.""" |
|
2
|
|
|
|
|
3
|
|
|
__copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang. All rights reserved." |
|
4
|
|
|
__author__ = "DV Klopfenstein" |
|
5
|
|
|
|
|
6
|
|
|
import sys |
|
7
|
|
|
from goatools.associations import read_gaf |
|
8
|
|
|
from goatools.base import dnld_gaf |
|
9
|
|
|
|
|
10
|
|
|
def test_gaf_read(log=sys.stdout): |
|
11
|
|
|
"""Return GO associations from a GAF file. Download if necessary.""" |
|
12
|
|
|
# On 2017/04/10, there were 3 GO IDs with ND Evidence Codes: |
|
13
|
|
|
# |
|
14
|
|
|
# $ cut -f5,7 goa_human.gaf | grep ND | sort | uniq -c |
|
15
|
|
|
# 739 GO:0003674 ND |
|
16
|
|
|
# 484 GO:0005575 ND |
|
17
|
|
|
# 639 GO:0008150 ND |
|
18
|
|
|
|
|
19
|
|
|
# Example species_ids: goa_human mgi fb |
|
20
|
|
|
fin_gaf = dnld_gaf('goa_human', loading_bar=None) |
|
21
|
|
|
|
|
22
|
|
|
# Example 1: Read GAF |
|
23
|
|
|
go2ids = read_gaf(fin_gaf, go2geneids=True) |
|
24
|
|
|
num_gos_dflt = len(go2ids) |
|
25
|
|
|
log.write("Read {N} GOs with all default values\n\n".format(N=num_gos_dflt)) |
|
26
|
|
|
|
|
27
|
|
|
# Example 2: Read GAF using defaults (No NOT Qualifiers and no ND Evidence Codes) |
|
28
|
|
|
go2ids = read_gaf(fin_gaf, go2geneids=True, keep_ND=False, keep_NOT=False) |
|
29
|
|
|
log.write("Read {N} GOs; keepif is default in goatools.associations.read_gaf\n\n".format( |
|
30
|
|
|
N=len(go2ids))) |
|
31
|
|
|
|
|
32
|
|
|
# Example 3: Read GAF allowing GOs with ND Evidence Codes |
|
33
|
|
|
go2ids = read_gaf(fin_gaf, go2geneids=True, keep_ND=True) |
|
34
|
|
|
log.write("Read {N} GOs; Allow ND Evidence codes\n\n".format(N=len(go2ids))) |
|
35
|
|
|
|
|
36
|
|
|
# Example 4: Read GAF allowing all GOs, even those with NOT Qualifiers or ND Evidence Codes |
|
37
|
|
|
go2ids = read_gaf(fin_gaf, go2geneids=True, keep_ND=True, keep_NOT=True) |
|
38
|
|
|
log.write("Read {N} GOs; Allow ND Evidence codes and NOT Qualifiers\n\n".format(N=len(go2ids))) |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
if __name__ == '__main__': |
|
42
|
|
|
test_gaf_read() |
|
43
|
|
|
|
|
44
|
|
|
# Copyright (C) 2016-2018, DV Klopfenstein, H Tang. All rights reserved. |
|
45
|
|
|
|