Metadata-Version: 2.4
Name: ciffetch
Version: 0.1.0
Summary: A PyQt dialog for searching COD and fetching CIF files
Home-page: https://github.com/fgjorup/ciffetch
Author: Frederik H Gjørup
Author-email: fgjorup@chem.au.dk
License: GPL-3.0-only
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyQt6>=6.8.1
Requires-Dist: requests>=2.25.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# ciffetch

`ciffetch` is a PyQt6 dialog for searching the [Crystallography Open Database
(COD)](https://www.crystallography.net/cod/) and retrieving crystal structure
data as CIF files. It can be run as a standalone application or embedded in
another PyQt application.

Search using chemical formula or required elements, space group, lattice
parameter ranges, text, journal, and publication year. Matching entries appear
in a sortable results table; double-click an entry to choose where to save its
CIF file.

## Requirements

- Python 3
- PyQt6
- requests

Install the dependencies with:

```bash
python -m pip install PyQt6 requests
```

## Run the application

```bash
python ciffetch.py
```

Enter search criteria in the dialog and run the search. Double-click a result
to fetch its CIF file and save it to a chosen location.

## Use from a PyQt application

Create a `QApplication`, instantiate `CifFetchDialog`, and call
`fetch_cifs()`. The `sigFileFetched` signal provides the saved file path and
CIF text when a file has been fetched:

```python
import sys

from PyQt6.QtWidgets import QApplication
from ciffetch import CifFetchDialog

app = QApplication(sys.argv)
dialog = CifFetchDialog()
dialog.sigFileFetched.connect(
    lambda path, cif_content: print(f"Saved {path} ({len(cif_content)} characters)")
)
dialog.fetch_cifs()
sys.exit(app.exec())
```

For single-file selection, call `dialog.fetch_single_cif()` instead.
`CifFetchDialog` also emits the standard `accepted()` signal after a file is
fetched in single-file mode. The `get_latest_saved_file()` method returns the
most recently saved file path.

## Acknowledgment and data

This application is made possible by the people behind the
[Crystallography Open Database](https://www.crystallography.net/cod/). COD data
and the database are dedicated to the public domain under CC0. Users of COD
data should acknowledge the original authors of the structural data and cite
the relevant source information provided with each entry.

## License

The `ciffetch` software is licensed under the
[GNU General Public License, version 3](LICENSE). This software license is
separate from the license and attribution requirements for data retrieved from
COD.
