Example #1
0
 def test_settings(self):
     toml = NestedDotDict.read_toml(get_test_resource("settings.toml"))
     x = Settings.load(toml)
     assert x.taxon == 1111
     assert x.min_pchembl == 15
     assert x.min_confidence_score == 2
     assert x.min_phase == 0
     assert str(x.cache_path) == "~"
     assert x.n_retries == 100
     assert not x.fast_save
     assert x.timeout_sec == 0
Example #2
0
    def search_for(
        what: What,
        compounds: Union[Sequence[str], PurePath],
        config: Union[None, Mapping[str, Any], Path],
    ) -> Tup[pd.DataFrame, Sequence[Triple]]:
        """

        Args:
            what:
            compounds:
            config:

        Returns:

        """
        if isinstance(compounds, (PurePath, str)):
            compounds = Path(compounds).read_text(encoding="utf8").splitlines()
        compounds = [c.strip() for c in compounds if len(c.strip()) > 0]
        if config is None:
            settings = Settings.load(NestedDotDict({}))
        elif isinstance(config, PurePath):
            settings = Settings.load(NestedDotDict.read_toml(config))
        elif isinstance(config, NestedDotDict):
            settings = config
        else:
            settings = Settings.load(NestedDotDict(config))
        settings.set()
        compounds = list(compounds)
        api = ChemblApi.wrap(Chembl)
        taxonomy = TaxonomyCaches.load(settings.taxon)
        hits = what.clazz(api, settings, taxonomy).find_all(compounds)
        # collapse over and sort the triples
        triples = sorted(list({hit.to_triple() for hit in hits}))
        df = pd.DataFrame([
            pd.Series({f: getattr(h, f)
                       for f in what.clazz.hit_fields()}) for h in hits
        ])
        return df, triples
Example #3
0
 def __init__(self):
     path = os.environ.get("VALARDAGGER_CONFIG",
                           Path("/etc", "valardagger.toml"))
     self.config = NestedDotDict.read_toml(path)
     self.valar = valarpy.Valar()
     self.model = None
Example #4
0
 def test_empty(self):
     toml = NestedDotDict.read_toml(
         get_test_resource("settings-empty.toml"))
     x = Settings.load(toml)
     assert x.min_phase == 3
Example #5
0
 def from_toml_file(
         cls,
         path: PathLike,
         *,
         warn: Union[bool, Callable[[Response], Any]] = True) -> Notifier:
     return cls.from_dict(NestedDotDict.read_toml(path), warn=warn)