Stianpr20 / MaXrd

Symmetry data and utilities related to crystallography and X-ray scattering
MIT License
24 stars 3 forks source link

Suggestion: ImportCrystalData could take ExternalIdentifier objects #10

Closed jasondbiggs closed 1 year ago

jasondbiggs commented 1 year ago

These types can be resolved to CIF files


ExternalIdentifier["CrystallographyOpenDatabaseID", id : (_Integer | _String)] :> StringTemplate["http://www.crystallography.net/cod/`1`.cif"][id]

ExternalIdentifier["PDBStructureID", id: (_Integer | _String)]   :>  StringTemplate["https://files.rcsb.org/download/`1`.cif.gz"][id]

This would allow you to call ImportCrystalData when all you have is a database ID - download the CIF file to a temp directory, import the data as usual, the delete the file.

Just a bit of syntactic sugar to save the user from downloading the file themselves.

Stianpr20 commented 1 year ago

That is a neat suggestion, thank you! I have overloaded ImportCrystalData with a new definition for an ExternalIdentifier argument in the commit d9ca0554137b6f836d68767f5e06d1f7f2365c1e.

Usage example:

demoExtID = ExternalIdentifier["CrystallographyOpenDatabaseID", "9011577"];
ImportCrystalData @ demoExtID

Note that you could also use an URL directly:

ImportCrystalData["http://www.crystallography.net/cod/9011577.cif"]

I have not implemented "PDBStructureID" since the package does not support macromolecular CIFs.