Пример #1
0
def test_properties(pubchem_cassette):
	results = get_properties("tris-(1,10-phenanthroline)ruthenium", ["IsomericSMILES", "InChIKey"], "name")
	assert len(results) > 0
	for result in results:
		assert "CID" in result
		assert "IsomericSMILES" in result
		assert "InChIKey" in result
Пример #2
0
def test_properties_dataframe(pubchem_cassette):
    df = get_properties("1,2,3,4", ["IsomericSMILES", "XLogP", "InChIKey"],
                        "cid",
                        as_dataframe=True)
    assert df.ndim == 2
    assert df.index.names == ["CID"]
    assert len(df.index) == 4
    assert df.columns.values.tolist() == [
        "IsomericSMILES", "InChIKey", "XLogP"
    ]
Пример #3
0
def test_underscore_properties(pubchem_cassette):
	"""
	Properties can also be specified as underscore-separated words, rather than CamelCase.
	"""

	results = get_properties("tris-(1,10-phenanthroline)ruthenium", ["IsomericSMILES", "MolecularWeight"], "name")
	assert len(results) > 0
	for result in results:
		assert "CID" in result
		assert "IsomericSMILES" in result
		assert "MolecularWeight" in result
Пример #4
0
def test_comma_string_properties(pubchem_cassette):
	"""
	Properties can also be specified as a comma-separated string, rather than a list.
	"""

	results = get_properties(
			"tris-(1,10-phenanthroline)ruthenium",
			"IsomericSMILES,InChIKey,MolecularWeight",
			"name",
			)
	assert len(results) > 0
	for result in results:
		assert "CID" in result
		assert "IsomericSMILES" in result
		assert "MolecularWeight" in result
		assert "InChIKey" in result
Пример #5
0
    def from_tuple(cls, compound: Tuple[str, Optional[str]]) -> "PCDLCompound":
        """
		Construct a :class:`~.PCDLCompound` from a tuple of ``(name, cas)``.

		:param compound:
		"""

        pubchem_id: Optional[str]

        try:
            name = get_common_name(compound[0])
            pubchem_id = get_compound_id(compound[0])
        except NotFoundError:
            name = compound[0]
            pubchem_id = None

        cas = compound[1]

        try:
            properties = get_properties(name, "IUPACName, MolecularFormula")[0]
            iupac_name = properties["IUPACName"]
            formula = properties["MolecularFormula"]
            exact_mass = formula.monoisotopic_mass
        except NotFoundError:
            # print(compound[0])
            iupac_name = name
            formula = None
            exact_mass = None

        return cls(
            name=name,
            iupac_name=iupac_name,
            cas=cas,
            formula=formula,
            exact_mass=exact_mass,
            pubchem_id=pubchem_id,
        )