-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-viral-index-access.py
executable file
·87 lines (70 loc) · 2.88 KB
/
sample-viral-index-access.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
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
#!/usr/bin/env python3
"""
python/sample-viral-index-access.py - See DESC constant below
Author: Christiam Camacho ([email protected])
Created: Wed Nov 6 10:59:55 2019
"""
import os
from viral_index.client import ViralIndex
def main():
""" Entry point into this program. """
if 'GOOGLE_APPLICATION_CREDENTIALS' not in os.environ:
print("Please set the GOOGLE_APPLICATION_CREDENTIALS environment variable", file=sys.stderr)
return 1
viral_client = ViralIndex()
cdd_id = 165276
print('For CDD ID ' + str(cdd_id) + ' here are the SRA runs where it is found')
runs = viral_client.get_SRAs_where_CDD_is_found(cdd_id)
if runs is not None:
for r in runs:
print(r)
## print("For CDD ID {}, here are the potential hosts that can be infected by viruses that contain that domain".format(cdd_id))
## hosts = viral_client.get_hosts_for_virus_domain(cdd_id)
## if hosts is not None:
## for h in hosts:
## print(h)
##
pig_taxid = 9823
print("List of viruses that can infect my favorite taxid (Sus scrofa pig): " + str(pig_taxid))
viruses = viral_client.get_viruses_for_host_taxonomy(pig_taxid)
if viruses is not None:
for virus in viruses:
print(virus)
HCMV_taxid = 10359
print("List of hosts that can be infected by my favourite virus (Human cytomegalovirus): " + str(HCMV_taxid))
hosts_virus = viral_client.get_host_from_virus_taxonomy(HCMV_taxid)
if hosts_virus is not None:
for host in hosts_virus:
print(host)
# Combining data
cdd_id = 164925
print("For CDD ID " + str(cdd_id) + " these are the potential hosts that viruses containing that domain can infect")
virus_taxids = viral_client.get_potential_hosts_for_virus_domain(cdd_id)
if virus_taxids is not None:
for vtaxid in virus_taxids:
hosts = viral_client.get_host_from_virus_taxonomy(vtaxid)
if len(hosts) != 0:
print(hosts)
evidence = "\'NCBI\'"
print("List all virus:host interactions based on level of evidence: " + str(evidence))
evidence_interaction = viral_client.get_virus_host_interactions_from_confidence_level(evidence)
if evidence_interaction is not None:
for evi_int in evidence_interaction:
#print(evi_int)
print("List it's too long!")
#interacting with spacerdb
spacer_seqs=viral_client.get_spacer_seqs(1915496)
print([s for s in spacer_seqs])
spacer_seq='CACGAGTGCGAAGCATCCAATCCATATGACTACAT'
#print(str(spacer_seq))
spacer_tax_ids=viral_client.get_taxid_from_spacer_seq(str(spacer_seq))
print([t for t in spacer_tax_ids])
return 0
if __name__ == "__main__":
import sys, traceback
try:
sys.exit(main())
except Exception as e:
print(e, file=sys.stderr)
traceback.print_exc(file=sys.stderr)
sys.exit(1)