sustainable-processes / pura

Clean chemical data quickly
MIT License
10 stars 3 forks source link

CAS service is breaking #8

Closed marcosfelt closed 2 years ago

marcosfelt commented 2 years ago

I’ll check if we have access to ChemSpider. I’ve tried to use CAS, but unfortunately get an error (below). I am logged in in a browser and cookies are unchanged. Probably I’m doing something wrong.

Batch:   0%|                                                                                                                                          | 0/1 [00:00<?, ?it/s]

Traceback (most recent call last):                                                                                                                    | 0/1 [00:00<?, ?it/s]

  File "/home/robbert/Documents/Python/pura/pura_test_v1.py", line 7, in <module>

    smiles = resolve_identifiers(

  File "/home/robbert/Documents/Python/pura/pura/resolvers.py", line 434, in resolve_identifiers

    return resolver.resolve(

  File "/home/robbert/Documents/Python/pura/pura/resolvers.py", line 222, in resolve

    return loop.run_until_complete(

  File "/home/robbert/anaconda3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete

    return future.result()

  File "/home/robbert/Documents/Python/pura/pura/resolvers.py", line 274, in _resolve

    resolved_identifiers.extend([await f for f in batch_bar])

  File "/home/robbert/Documents/Python/pura/pura/resolvers.py", line 274, in <listcomp>

    resolved_identifiers.extend([await f for f in batch_bar])

  File "/home/robbert/anaconda3/lib/python3.9/asyncio/tasks.py", line 611, in _wait_for_one

    return f.result()  # May raise f.exception().

  File "/home/robbert/Documents/Python/pura/pura/resolvers.py", line 326, in _resolve_one_compound

    raise e

  File "/home/robbert/Documents/Python/pura/pura/resolvers.py", line 296, in _resolve_one_compound

    resolved_identifiers = await service.resolve_compound(

  File "/home/robbert/Documents/Python/pura/pura/services/cas.py", line 38, in resolve_compound

    raise ValueError(

ValueError: CompoundIdent
marcosfelt commented 2 years ago

@rvanputt I just checked CAS. The issue is that I only implemented going from CAS numbers to SMILES, so you would need to do the following

smiles = resolve_identifiers(
    names=["67-56-1"],
    input_identifer_type=CompoundIdentifierType.CAS_NUMBER,
    output_identifier_type=CompoundIdentifierType.SMILES,
    services=[CAS()],
    agreement=1,
)