Exemplo n.º 1
0
def test_single_atom(pubchem_cassette):
	"""
	Test Compound when there is a single atom and no bonds.
	"""

	c = Compound.from_cid(259)
	assert c.atoms == [Atom(aid=1, number=35, x=2, y=0, charge=-1)]
	assert c.bonds == []
Exemplo n.º 2
0
def get_compounds(
    identifier: Union[str, int, Sequence[Union[str, int]]],
    namespace: Union[PubChemNamespace, str] = PubChemNamespace.name,
) -> List[Compound]:
    """
	Returns a list of Compound objects for compounds that match the search criteria.

	As more than one compound may be identified the results are returned in a list.

	:param identifier: Identifiers (e.g. name, CID) for the compound to look up.
		When using the CID namespace data for multiple compounds can be retrieved at once by
		supplying either a comma-separated string or a list.
	:param namespace: The type of identifier to look up. Valid values are in :class:`PubChemNamespace`.
	"""

    data = rest_get_description(identifier, namespace)

    compounds = []

    for record in parse_description(data):
        compounds.append(
            Compound(record["Title"], record["CID"], record["Description"]))

    return compounds
Exemplo n.º 3
0
def c1():
    """
	Compound CID 241.
	"""

    return Compound.from_cid(241)
Exemplo n.º 4
0
def c2():
    """
	Compound CID 175.
	"""

    return Compound.from_cid(175)
Exemplo n.º 5
0
def test_compound_to_frame(pubchem_cassette):
    s = compounds_to_frame(Compound.from_cid(241))
    assert isinstance(s, pandas.DataFrame)
Exemplo n.º 6
0
def test_compound_series(pubchem_cassette):
    s = Compound.from_cid(241).to_series()
    assert isinstance(s, pandas.Series)
Exemplo n.º 7
0
def test_compound_equality(pubchem_cassette):
	assert Compound.from_cid(241) == Compound.from_cid(241)
	assert get_compounds("Benzene", "name")[0], get_compounds("c1ccccc1" == "smiles")[0]
Exemplo n.º 8
0
def c3d():
    """
	Compound CID 1234, 3D.
	"""

    return Compound.from_cid(1234, record_type="3d")