examples   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 306
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 221
dl 0
loc 306
rs 10
c 0
b 0
f 0
1
import time
2
3
from pyensemblrest import EnsemblRest
4
5
# Setup a new EnsemblRest object
6
ensRest = EnsemblRest()
7
8
# Check the user agent
9
print(ensRest.get_user_agent())
10
11
# Archive
12
print(ensRest.getArchiveById(id="ENSG00000157764"))
13
print(ensRest.getArchiveByMultipleIds(id=["ENSG00000157764", "ENSG00000248378"]))
14
time.sleep(15)
15
16
# Comparative Genomics
17
print(ensRest.getCafeGeneTreeById(id="ENSGT00390000003602"))
18
print(ensRest.getCafeGeneTreeMemberBySymbol(species="human", symbol="BRCA2"))
19
print(ensRest.getCafeGeneTreeMemberById(species="human", id="ENSG00000167664"))
20
print(ensRest.getGeneTreeById(id="ENSGT00390000003602"))
21
print(ensRest.getGeneTreeMemberBySymbol(species="human", symbol="BRCA2"))
22
print(ensRest.getGeneTreeMemberById(species="human", id="ENSG00000167664"))
23
print(
24
    ensRest.getAlignmentByRegion(
25
        species="human",
26
        region="X:1000000..1000100:1",
27
        species_set_group="mammals",
28
    )
29
)
30
print(ensRest.getHomologyById(species="human", id="ENSG00000157764"))
31
print(ensRest.getHomologyBySymbol(species="human", symbol="BRCA2"))
32
time.sleep(15)
33
34
# Cross References
35
print(ensRest.getXrefsBySymbol(species="human", symbol="BRCA2"))
36
print(ensRest.getXrefsById(id="ENSG00000157764"))
37
print(ensRest.getXrefsByName(species="human", name="BRCA2"))
38
time.sleep(15)
39
40
# Information
41
print(ensRest.getInfoAnalysis(species="homo_sapiens"))
42
print(
43
    ensRest.getInfoAssembly(species="homo_sapiens", bands=1)
44
)  # bands is an optional parameter
45
print(ensRest.getInfoAssemblyRegion(species="homo_sapiens", region_name="X"))
46
ensRest.timeout = 300
47
print(ensRest.getInfoBiotypes(species="homo_sapiens"))  # this keeps timing out
48
ensRest.timeout = 60
49
print(ensRest.getInfoBiotypesByGroup(group="coding", object_type="gene"))
50
print(ensRest.getInfoBiotypesByName(name="protein_coding", object_type="gene"))
51
print(ensRest.getInfoComparaMethods())
52
print(ensRest.getInfoComparaSpeciesSets(methods="EPO"))
53
print(ensRest.getInfoComparas())
54
print(ensRest.getInfoData())
55
print(ensRest.getInfoEgVersion())
56
print(ensRest.getInfoExternalDbs(species="homo_sapiens"))
57
print(ensRest.getInfoDivisions())
58
print(ensRest.getInfoGenomesByName(name="arabidopsis_thaliana"))
59
print(ensRest.getInfoGenomesByAccession(accession="U00096"))
60
print(ensRest.getInfoGenomesByAssembly(assembly_id="GCA_902167145.1"))
61
print(ensRest.getInfoGenomesByDivision(division="EnsemblPlants"))
62
print(ensRest.getInfoGenomesByTaxonomy(taxon_name="Homo sapiens"))
63
print(ensRest.getInfoPing())
64
print(ensRest.getInfoRest())
65
print(ensRest.getInfoSoftware())
66
print(ensRest.getInfoSpecies())
67
print(ensRest.getInfoVariationBySpecies(species="homo_sapiens"))
68
print(ensRest.getInfoVariationConsequenceTypes())
69
print(
70
    ensRest.getInfoVariationPopulationIndividuals(
71
        species="human", population_name="1000GENOMES:phase_3:ASW"
72
    )
73
)
74
print(ensRest.getInfoVariationPopulations(species="homo_sapiens", filter="LD"))
75
time.sleep(15)
76
77
# Linkage Disequilibrium
78
print(
79
    ensRest.getLdId(
80
        species="homo_sapiens",
81
        id="rs56116432",
82
        population_name="1000GENOMES:phase_3:KHV",
83
        window_size=500,
84
        d_prime=1.0,
85
    )
86
)
87
print(ensRest.getLdPairwise(species="homo_sapiens", id1="rs6792369", id2="rs1042779"))
88
print(
89
    ensRest.getLdRegion(
90
        species="homo_sapiens",
91
        region="6:25837556..25843455",
92
        population_name="1000GENOMES:phase_3:KHV",
93
    )
94
)
95
time.sleep(15)
96
97
# Lookup
98
print(ensRest.getLookupById(id="ENSG00000157764"))
99
print(ensRest.getLookupByMultipleIds(ids=["ENSG00000157764", "ENSG00000248378"]))
100
print(ensRest.getLookupBySymbol(species="homo_sapiens", symbol="BRCA2", expand=1))
101
print(
102
    ensRest.getLookupByMultipleSymbols(
103
        species="homo_sapiens", symbols=["BRCA2", "BRAF"]
104
    )
105
)
106
time.sleep(15)
107
108
# Mapping
109
print(ensRest.getMapCdnaToRegion(id="ENST00000288602", region="100..300"))
110
print(ensRest.getMapCdsToRegion(id="ENST00000288602", region="1..1000"))
111
print(
112
    ensRest.getMapAssemblyOneToTwo(
113
        species="homo_sapiens",
114
        asm_one="GRCh37",
115
        region="X:1000000..1000100:1",
116
        asm_two="GRCh38",
117
    )
118
)
119
print(ensRest.getMapTranslationToRegion(id="ENSP00000288602", region="100..300"))
120
time.sleep(15)
121
122
# Ontologies and Taxonomy
123
print(ensRest.getAncestorsById(id="GO:0005667"))
124
print(ensRest.getAncestorsChartById(id="GO:0005667"))
125
print(ensRest.getDescendantsById(id="GO:0005667"))
126
print(ensRest.getOntologyById(id="GO:0005667"))
127
print(ensRest.getOntologyByName(name="transcription factor complex"))
128
print(ensRest.getTaxonomyClassificationById(id="9606"))
129
print(ensRest.getTaxonomyById(id="9606"))
130
print(ensRest.getTaxonomyByName(name="Homo%25"))
131
time.sleep(15)
132
133
# Overlap
134
print(ensRest.getOverlapById(id="ENSG00000157764", feature="gene"))
135
print(
136
    ensRest.getOverlapByRegion(
137
        species="homo_sapiens", region="X:1..1000:1", feature="gene"
138
    )
139
)
140
print(ensRest.getOverlapByTranslation(id="ENSP00000288602"))
141
time.sleep(15)
142
143
# Phenotype annotations
144
print(ensRest.getPhenotypeByAccession(species="homo_sapiens", accession="EFO:0003900"))
145
print(ensRest.getPhenotypeByGene(species="homo_sapiens", gene="ENSG00000157764"))
146
print(
147
    ensRest.getPhenotypeByRegion(species="homo_sapiens", region="9:22125500-22136000:1")
148
)
149
print(ensRest.getPhenotypeByTerm(species="homo_sapiens", term="coffee consumption"))
150
time.sleep(15)
151
152
# Regulation
153
print(
154
    ensRest.getRegulationBindingMatrix(
155
        species="homo_sapiens", binding_matrix="ENSPFM0001"
156
    )
157
)
158
time.sleep(15)
159
160
# Sequences
161
print(ensRest.getSequenceById(id="ENSG00000157764"))
162
print(ensRest.getSequenceByMultipleIds(ids=["ENSG00000157764", "ENSG00000248378"]))
163
print(
164
    ensRest.getSequenceByRegion(species="homo_sapiens", region="X:1000000..1000100:1")
165
)
166
print(
167
    ensRest.getSequenceByMultipleRegions(
168
        species="homo_sapiens",
169
        regions=["X:1000000..1000100:1", "ABBA01004489.1:1..100"],
170
    )
171
)
172
time.sleep(15)
173
174
# Transcript Haplotypes
175
print(ensRest.getTranscriptHaplotypes(species="homo_sapiens", id="ENST00000288602"))
176
time.sleep(15)
177
178
# VEP
179
print(
180
    ensRest.getVariantConsequencesByHGVSNotation(
181
        species="homo_sapiens", hgvs_notation="ENST00000366667:c.803C>T"
182
    )
183
)
184
print(
185
    ensRest.getVariantConsequencesByMultipleHGVSNotations(
186
        species="homo_sapiens",
187
        hgvs_notations=["ENST00000366667:c.803C>T", "9:g.22125504G>C"],
188
    )
189
)
190
print(ensRest.getVariantConsequencesById(species="homo_sapiens", id="rs56116432"))
191
print(
192
    ensRest.getVariantConsequencesByMultipleIds(
193
        species="homo_sapiens", ids=["rs56116432", "COSM476", "__VAR(sv_id)__"]
194
    )
195
)
196
print(
197
    ensRest.getVariantConsequencesByRegion(
198
        species="homo_sapiens", region="9:22125503-22125502:1", allele="C"
199
    )
200
)
201
print(
202
    ensRest.getVariantConsequencesByMultipleRegions(
203
        species="homo_sapiens",
204
        variants=[
205
            "21 26960070 rs116645811 G A . . .",
206
            "21 26965148 rs1135638 G A . . .",
207
        ],
208
    )
209
)
210
time.sleep(15)
211
212
# Variation
213
print(ensRest.getVariationRecoderById(species="homo_sapiens", id="rs56116432"))
214
print(
215
    ensRest.getVariationRecoderByMultipleIds(
216
        species="homo_sapiens", ids=["rs56116432", "rs1042779"]
217
    )
218
)
219
print(ensRest.getVariationById(species="homo_sapiens", id="rs56116432"))
220
print(ensRest.getVariationByPMCID(species="homo_sapiens", pmcid="PMC5002951"))
221
print(ensRest.getVariationByPMID(species="homo_sapiens", pmid="26318936"))
222
print(
223
    ensRest.getVariationByMultipleIds(
224
        species="homo_sapiens", ids=["rs56116432", "COSM476", "__VAR(sv_id)__"]
225
    )
226
)
227
time.sleep(15)
228
229
# Variation GA4GH
230
print(ensRest.getGA4GHBeacon())
231
print(
232
    ensRest.getGA4GHBeaconQuery(
233
        alternateBases="C",
234
        assemblyId="GRCh38",
235
        end="23125503",
236
        referenceBases="G",
237
        referenceName="9",
238
        start="22125503",
239
        variantType="DUP",
240
    )
241
)
242
print(
243
    ensRest.postGA4GHBeaconQuery(
244
        alternateBases="C",
245
        assemblyId="GRCh38",
246
        end="23125503",
247
        referenceBases="G",
248
        referenceName="9",
249
        start="22125503",
250
        variantType="DUP",
251
    )
252
)
253
print(ensRest.getGA4GHFeaturesById(id="ENST00000408937.7"))
254
ensRest.timeout = 180
255
print(
256
    ensRest.searchGA4GHFeatures(
257
        parentId="ENST00000408937.7",
258
        featureSetId="",
259
        featureTypes=["cds"],
260
        end=220023,
261
        referenceName="X",
262
        start=197859,
263
        pageSize=1,
264
    )
265
)  # this keeps timing out
266
ensRest.timeout = 60
267
print(ensRest.searchGA4GHCallset(variantSetId=1, pageSize=2))
268
print(ensRest.getGA4GHCallsetById(id="1"))
269
print(ensRest.searchGA4GHDatasets(pageSize=3))
270
print(ensRest.getGA4GHDatasetsById(id="6e340c4d1e333c7a676b1710d2e3953c"))
271
print(ensRest.searchGA4GHFeaturesets(datasetId="Ensembl"))
272
print(ensRest.getGA4GHFeaturesetsById(id="Ensembl"))
273
print(ensRest.getGA4GHVariantsById(id="1:rs1333049"))
274
print(
275
    ensRest.searchGA4GHVariantAnnotations(
276
        variantAnnotationSetId="Ensembl",
277
        referenceId="9489ae7581e14efcad134f02afafe26c",
278
        start=25221400,
279
        end=25221500,
280
        pageSize=1,
281
    )
282
)
283
print(
284
    ensRest.searchGA4GHVariants(
285
        variantSetId=1,
286
        referenceName=22,
287
        start=25455086,
288
        end=25455087,
289
        pageToken="",
290
        pageSize=1,
291
    )
292
)
293
print(
294
    ensRest.searchGA4GHVariantsets(
295
        datasetId="6e340c4d1e333c7a676b1710d2e3953c", pageToken="", pageSize=2
296
    )
297
)
298
print(ensRest.getGA4GHVariantsetsById(id=1))
299
print(ensRest.searchGA4GHReferences(referenceSetId="GRCh38", pageSize=10))
300
print(ensRest.getGA4GHReferencesById(id="9489ae7581e14efcad134f02afafe26c"))
301
print(ensRest.searchGA4GHReferencesets())
302
print(ensRest.getGA4GHReferencesetsById(id="GRCh38"))
303
print(ensRest.searchGA4GHVariantAnnotationsets(variantSetId="Ensembl"))
304
print(ensRest.getGA4GHVariantAnnotationsetsById(id="Ensembl"))
305
time.sleep(15)
306