Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
biopython/Tests/common_BioSQL_online.py at data2code · data2code/biopython · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
data2code
/
biopython
Public
forked from
biopython/biopython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
data2code
Breadcrumbs
biopython
/
Tests
/
common_BioSQL_online.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
130 lines (104 loc) · 4.41 KB
data2code
Breadcrumbs
biopython
/
Tests
/
common_BioSQL_online.py
Copy path
Top
File metadata and controls
Code
Blame
130 lines (104 loc) · 4.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Test storing biopython objects in a BioSQL relational db."""
import
os
import
platform
import
tempfile
import
time
import
unittest
# Hide annoying warnings from things like bonds in GenBank features,
# or PostgreSQL schema rules. TODO - test these warnings are raised!
import
warnings
from
io
import
StringIO
import
requires_internet
from
common_BioSQL
import
check_config
from
common_BioSQL
import
create_database
from
common_BioSQL
import
destroy_database
from
Bio
import
BiopythonWarning
from
Bio
import
Entrez
# local stuff
from
Bio
import
MissingExternalDependencyError
from
Bio
import
SeqIO
from
Bio
.
Seq
import
MutableSeq
from
Bio
.
Seq
import
Seq
from
Bio
.
SeqFeature
import
SeqFeature
from
Bio
.
SeqRecord
import
SeqRecord
from
BioSQL
import
BioSeq
from
BioSQL
import
BioSeqDatabase
if
__name__
==
"__main__"
:
raise
RuntimeError
(
"Call this via test_BioSQL_*online.py not directly"
)
# Sharing these with test_BioSQL_XXX_online.py files which import this file:
# DBDRIVER, DBTYPE, DBHOST, DBUSER, DBPASSWD, TESTDB, DBSCHEMA, SQL_FILE, SYSTEM
SYSTEM
=
platform
.
system
()
def
share_config
(
dbdriver
,
dbtype
,
dbhost
,
dbuser
,
dbpasswd
,
testdb
):
"""Make sure we can access the DB settings from this file."""
global
DBDRIVER
,
DBTYPE
,
DBHOST
,
DBUSER
,
DBPASSWD
,
TESTDB
,
DBSCHEMA
global
SYSTEM
,
SQL_FILE
DBDRIVER
=
dbdriver
DBTYPE
=
dbtype
DBHOST
=
dbhost
DBUSER
=
dbuser
DBPASSWD
=
dbpasswd
TESTDB
=
testdb
class
TaxonomyTest
(
unittest
.
TestCase
):
"""Test proper insertion and retrieval of taxonomy data."""
def
setUp
(
self
):
global
DBDRIVER
,
DBTYPE
,
DBHOST
,
DBUSER
,
DBPASSWD
,
TESTDB
,
DBSCHEMA
global
SYSTEM
,
SQL_FILE
Entrez
.
email
=
"biopython@biopython.org"
# create TESTDB
TESTDB
=
create_database
()
# load the database
db_name
=
"biosql-test"
self
.
server
=
BioSeqDatabase
.
open_database
(
driver
=
DBDRIVER
,
user
=
DBUSER
,
passwd
=
DBPASSWD
,
host
=
DBHOST
,
db
=
TESTDB
)
# remove the database if it already exists
try
:
self
.
server
[
db_name
]
self
.
server
.
remove_database
(
db_name
)
except
KeyError
:
pass
self
.
db
=
self
.
server
.
new_database
(
db_name
)
# get the GenBank file we are going to put into it
self
.
iterator
=
SeqIO
.
parse
(
"GenBank/cor6_6.gb"
,
"gb"
)
def
tearDown
(
self
):
self
.
server
.
close
()
destroy_database
()
del
self
.
db
del
self
.
server
def
test_taxon_left_right_values
(
self
):
self
.
db
.
load
(
self
.
iterator
,
True
)
sql
=
"""SELECT DISTINCT include.ncbi_taxon_id FROM taxon
INNER JOIN taxon AS include ON
(include.left_value BETWEEN taxon.left_value
AND taxon.right_value)
WHERE taxon.taxon_id IN
(SELECT taxon_id FROM taxon_name
WHERE name = 'Brassicales')
AND include.right_value - include.left_value = 1"""
rows
=
self
.
db
.
adaptor
.
execute_and_fetchall
(
sql
)
self
.
assertEqual
(
4
,
len
(
rows
))
values
=
[
row
[
0
]
for
row
in
rows
]
self
.
assertCountEqual
([
3704
,
3711
,
3708
,
3702
],
values
)
def
test_load_database_with_tax_lookup
(
self
):
"""Load SeqRecord objects and fetch the taxonomy information from NCBI."""
handle
=
Entrez
.
efetch
(
db
=
"taxonomy"
,
id
=
3702
,
retmode
=
"XML"
)
taxon_record
=
Entrez
.
read
(
handle
)
entrez_tax
=
[]
for
t
in
taxon_record
[
0
][
"LineageEx"
]:
entrez_tax
.
append
(
t
[
"ScientificName"
])
entrez_tax
.
append
(
taxon_record
[
0
][
"ScientificName"
])
self
.
db
.
load
(
self
.
iterator
,
True
)
# do some simple tests to make sure we actually loaded the right
# thing. More advanced tests in a different module.
items
=
list
(
self
.
db
.
values
())
self
.
assertEqual
(
len
(
items
),
6
)
self
.
assertEqual
(
len
(
self
.
db
),
6
)
test_record
=
self
.
db
.
lookup
(
accession
=
"X55053"
)
# make sure that the ncbi taxonomy id is correct
self
.
assertEqual
(
test_record
.
annotations
[
"ncbi_taxid"
],
3702
)
# make sure that the taxonomic lineage is the same as reported
# using the Entrez module
self
.
assertEqual
(
test_record
.
annotations
[
"taxonomy"
],
entrez_tax
)
You can’t perform that action at this time.