### Install mofdb-client using pip Source: https://github.com/n8ta/mofdb-client/blob/master/README.md This command installs a specific version (0.10.0) of the mofdb-client package using pip. Ensure you have Python 3 installed. ```shell python3 -m pip install mofdb_client==0.10.0 ``` -------------------------------- ### Build and publish a new version of mofdb-client Source: https://github.com/n8ta/mofdb-client/blob/master/README.md These shell commands are used to build a distributable package of the mofdb-client and then upload it to a package repository (like PyPI). The first command builds the package, and the second uploads the built distribution files. ```shell python3 -m build -n python3 -m twine upload dist/* ``` -------------------------------- ### Fetch MOFs with Unit Conversion for Isotherms in Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Fetches MOFs and converts pressure and loading units for all isotherms to specified units (e.g., 'mmol/g' for loading, 'atm' for pressure). It then iterates through the MOFs and their isotherms, printing temperature, pressure units, loading units, and individual data points with their converted values. ```python from mofdb_client import fetch # Fetch MOFs with specific unit conversions for mof in fetch(vf_min=0.5, vf_max=0.99, loading_unit="mmol/g", pressure_unit="atm"): print(f"Mof: {mof.name}") for isotherm in mof.isotherms: print(f"Temperature: {isotherm.temperature} K") print(f"Pressure units: {isotherm.pressureUnits}") print(f"Loading units: {isotherm.adsorptionUnits}") for point in isotherm.isotherm_data: print(f"Pressure: {point.pressure} {isotherm.pressureUnits}, " f"Adsorption: {point.total_adsorption} {isotherm.adsorptionUnits}") ``` -------------------------------- ### Fetch and print MOF details using mofdb-client Source: https://github.com/n8ta/mofdb-client/blob/master/README.md This Python script demonstrates how to fetch MOF data from the mofdb using specified void fraction (vf) minimum and maximum values. It iterates through the results, printing the MOF's name, number of isotherms, elements, and the first line of its CIF file. ```python3 from mofdb_client import fetch for mof in fetch(vf_min=0.5, vf_max=0.99): print(f"Mof {mof.name} has {len(mof.isotherms)} isotherms and elements {[str(e) for e in mof.elements]}") print(f"This mof's cif file starts with: '{mof.cif.splitlines()[1]}'") ``` -------------------------------- ### Access Isotherm Data - Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Retrieve complete isotherm data including temperature, pressure, and adsorption measurements for a MOF. This includes details like category, DOI, pressure units, and access to individual data points. ```python from mofdb_client import fetch mof = next(fetch(vf_min=0.5, vf_max=0.6)) for isotherm in mof.isotherms: print(f"Isotherm ID: {isotherm.id}") print(f"Temperature: {isotherm.temperature} K") print(f"Category: {isotherm.category}") print(f"DOI: {isotherm.DOI}") print(f"Date: {isotherm.date}") print(f"Digitizer: {isotherm.digitizer}") print(f"Pressure Units: {isotherm.pressureUnits}") print(f"Adsorption Units: {isotherm.adsorptionUnits}") print(f"Composition Type: {isotherm.compositionType}") print(f"Adsorbent: {isotherm.adsorbent.name}") print(f"URL: {isotherm.isotherm_url}") # Access data points for point in isotherm.isotherm_data[:3]: # First 3 points print(f"P={point.pressure}, Loading={point.total_adsorption}") ``` -------------------------------- ### Download CO2 adsorption isotherm data from hMOF database Source: https://github.com/n8ta/mofdb-client/blob/master/README.md This Python script shows how to download CO2 adsorption isotherm data for MOFs from the 'hMOF' database. It filters MOFs by void fraction, then iterates through their isotherms to find CO2 adsorption data, printing details like MOF name, temperature, pressure units, adsorption units, and individual data points. ```python3 # This is an example of downloading CO2 adsorption isotherm data for MOFs from hMOF database from mofdb_client import fetch # Find mofs with void fraction less than 0.5 (for example), in 'hMOF' database for imof in fetch(vf_max=0.5, database='hMOF'): # loop over all available isotherms for imof for iiso in imof.isotherms: # only care about CO2 isotherm if iiso.adsorbates[0].formula == 'CO2': # print matched MOF name print(imof.name) # print CO2 adsorption isotherm temperature in Kelvin print(iiso.temperature) # print pressure units print(iiso.pressureUnits) # print adsorption data units print(iiso.adsorptionUnits) # loop over all adsorption data points in the matched CO2 isotherm # and print each adsorption data points in this isotherm for jdata in iiso.isotherm_data: print('adsorption data is {} at pressure {}'.format(jdata.total_adsorption, jdata.pressure)) ``` -------------------------------- ### Fetch MOFs from Specific Databases with Adsorbate Filters in Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Queries a specific MOF database (e.g., 'hMOF') and filters results by void fraction. It then iterates through the found MOFs, checking if they contain CO2 isotherms. If a CO2 isotherm is found, it prints details about the isotherm, including temperature, units, and adsorption data points. ```python from mofdb_client import fetch # Find CO2 isotherms in hMOF database for mof in fetch(vf_max=0.5, database='hMOF'): print(f"MOF: {mof.name} from database: {mof.database}") for isotherm in mof.isotherms: if isotherm.adsorbates[0].formula == 'CO2': print(f"CO2 Isotherm found!") print(f"Temperature: {isotherm.temperature} K") print(f"Pressure units: {isotherm.pressureUnits}") print(f"Adsorption units: {isotherm.adsorptionUnits}") for data_point in isotherm.isotherm_data: print(f"Adsorption: {data_point.total_adsorption} at " f"Pressure: {data_point.pressure}") ``` -------------------------------- ### Access TemperaturePoint Data - Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Access individual pressure-adsorption data points from an isotherm, including multicomponent information. This allows detailed inspection of species-specific adsorption values. ```python from mofdb_client import fetch mof = next(fetch(vf_min=0.5, limit=1)) isotherm = mof.isotherms[0] for point in isotherm.isotherm_data: print(f"Pressure: {point.pressure} {isotherm.pressureUnits}") print(f"Total Adsorption: {point.total_adsorption} {isotherm.adsorptionUnits}") # Access species-specific data for multicomponent isotherms for species in point.species_data: print(f" Species: {species.name}") print(f" InChIKey: {species.InChIKey}") print(f" Composition: {species.composition}") print(f" Adsorption: {species.adsorption}") ``` -------------------------------- ### Fetch MOFs with Multiple Structural Property Filters in Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Queries the MOF database using a combination of structural property filters, including minimum and maximum values for lattice parameters (LCD, PLD), surface area (m²/g and m²/cm³), and applies a limit to the number of results. It then prints key identifiers and properties for each matching MOF. ```python from mofdb_client import fetch # Query by multiple structural properties for mof in fetch( lcd_min=5.0, lcd_max=15.0, pld_min=3.0, sa_m2g_min=1000.0, sa_m2g_max=5000.0, limit=10 ): print(f"Name: {mof.name}") print(f"LCD: {mof.lcd} Å") print(f"PLD: {mof.pld} Å") print(f"Surface Area: {mof.surface_area_m2g} m²/g") print(f"Surface Area: {mof.surface_area_m2cm3} m²/cm³") print(f"MOFID: {mof.mofid}") print(f"MOFKEY: {mof.mofkey}") print(f"Database: {mof.database}") print(f"URL: {mof.url}") ``` -------------------------------- ### Fetch MOFs with Void Fraction Filters in Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Retrieves MOF data from the database, filtering by minimum and maximum void fraction. It iterates through the results, printing the MOF's name, number of isotherms, elements, a preview of its CIF data, void fraction, and surface area. This function is designed for efficient data retrieval from large datasets. ```python from mofdb_client import fetch # Filter MOFs by void fraction and iterate through results for mof in fetch(vf_min=0.5, vf_max=0.99): print(f"Mof {mof.name} has {len(mof.isotherms)} isotherms") print(f"Elements: {[str(e) for e in mof.elements]}") print(f"CIF preview: {mof.cif.splitlines()[1]}") print(f"Void fraction: {mof.void_fraction}") print(f"Surface area: {mof.surface_area_m2g} m²/g") ``` -------------------------------- ### Access Complete MOF Structure Data using Mof Object in Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Demonstrates how to retrieve a specific MOF by name and access its comprehensive structural properties using the Mof object. It prints details such as ID, name, void fraction, surface area, lattice parameters, elements, adsorbates, and allows access to the CIF file content and raw JSON representation. ```python from mofdb_client import fetch mof = next(fetch(name="UTEWUM_clean")) # Access structural properties print(f"ID: {mof.id}") print(f"Name: {mof.name}") print(f"Void Fraction: {mof.void_fraction}") print(f"Surface Area (m²/g): {mof.surface_area_m2g}") print(f"LCD: {mof.lcd}, PLD: {mof.pld}") # Access elements for element in mof.elements: print(f"Element: {element.symbol} ({element.name})") # Access adsorbates for adsorbate in mof.adsorbates: print(f"Adsorbate: {adsorbate.name}, Formula: {adsorbate.formula}") # Access CIF file print(f"CIF (first 100 chars): {mof.cif[:100]}") # Access raw JSON print(f"Batch number: {mof.json_repr['batch_number']}") ``` -------------------------------- ### Handle Invalid Units and Databases - Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Implement error handling for invalid unit or database names when fetching data. The client raises `InvalidUnit` or `InvalidDatabase` exceptions, providing feedback on valid options. ```python from mofdb_client import fetch, InvalidUnit, InvalidDatabase # Handle invalid pressure unit try: for mof in fetch(vf_min=0.5, pressure_unit="invalid_unit"): print(mof.name) except InvalidUnit as e: print(f"Error: {e}") # Output: 'invalid_unit' is not a valid unit for pressure. # Valid pressure units are: ['bar', 'Pa', 'kPa', 'MPa', 'atm', 'mmHg', 'torr'] # Handle invalid database try: for mof in fetch(database="invalid_db"): print(mof.name) except InvalidDatabase as e: print(f"Error: {e}") # Output: invalid_db is not a valid database name. # Valid names are: ['CoRE-MOF', 'hMOF', ...] ``` -------------------------------- ### Control Telemetry Reporting - Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Manage telemetry (error reporting to Sentry) for debugging purposes. Telemetry can be explicitly enabled or disabled via the `telemetry` parameter in the `fetch` function. ```python from mofdb_client import fetch # Disable telemetry (no crash reports sent) for mof in fetch(vf_min=0.5, telemetry=False): print(mof.name) # Enable telemetry (default behavior) for mof in fetch(vf_min=0.5, telemetry=True): print(mof.name) ``` -------------------------------- ### Limit Number of Results - Python Source: https://context7.com/n8ta/mofdb-client/llms.txt Control the number of MOFs returned by a query using the `limit` parameter. This is useful for processing subsets of the database or for testing. ```python from mofdb_client import fetch # Get only first 10 MOFs matching criteria count = 0 for mof in fetch(vf_min=0.5, limit=10): count += 1 print(f"{count}. {mof.name} - VF: {mof.void_fraction}") print(f"Total fetched: {count}") # Output: Total fetched: 10 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.