コード例 #1
0
lines = file.readlines()
print("\n".join(lines[:10] + ["..."]))

########################################################################
# In many cases you are not interested in a specific structure, but you
# want a set of structures that fits your desired criteria.
# For this purpose the *RCSB* search API can be used.
# At first you have to create :class:`Query` object for the property you
# want to filter.
# The :func:`search()` method takes the :class:`Query` and returns a
# list of PDB IDs, which itself can be used as input for
# :func:`fetch()`.
# Likewise, :func:`count()` is used to count the number of matching
# PDB IDs.

query = rcsb.BasicQuery("HCN1")
pdb_ids = rcsb.search(query)
print(pdb_ids)
print(rcsb.count(query))
files = rcsb.fetch(pdb_ids, "mmtf", gettempdir())

########################################################################
# This was a simple search for the occurrence of the search term in any
# field.
# You can also search for a value in a specific field with a
# :class:`FieldQuery`.
# A complete list of the available fields and its supported operators
# is documented
# `on this page <https://search.rcsb.org/search-attributes.html>`_.

# Query for 'lacA' gene
コード例 #2
0
def test_search_empty():
    query = rcsb.BasicQuery("This will not match any ID")
    assert rcsb.search(query) == []
    assert rcsb.count(query) == 0
コード例 #3
0
def test_search_basic():
    query = rcsb.BasicQuery("tc5b")
    assert rcsb.search(query) == ["1L2Y"]
    assert rcsb.count(query) == 1
コード例 #4
0
def test_search_return_type(return_type, expected):
    query = rcsb.BasicQuery("tc5b")
    assert rcsb.search(query, return_type) == expected
    assert rcsb.count(query, return_type) == len(expected)