diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index f9b37e4..ed7ad00 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 0.5.2
+current_version = 0.5.3
commit = True
tag = False
diff --git a/CITATION.cff b/CITATION.cff
index 63dba64..7af0537 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -20,4 +20,4 @@ url: 'https://atomrdf.pyscal.org'
license: "MIT"
repository-code: https://github.com/pyscal/atomRDF
type: software
-version: 0.5.2
+version: 0.5.3
diff --git a/atomrdf/graph.py b/atomrdf/graph.py
index f69a47e..1490b63 100644
--- a/atomrdf/graph.py
+++ b/atomrdf/graph.py
@@ -136,7 +136,13 @@ def add_structure(self, structure):
def _is_valid(self, input_list):
valid = False
+ flat_list = []
for x in input_list:
+ if isinstance(x,list):
+ flat_list.extend(x)
+ else:
+ flat_list.append(x)
+ for x in flat_list:
if x is not None:
valid = True
break
diff --git a/atomrdf/structure.py b/atomrdf/structure.py
index e0015d3..1a767b5 100644
--- a/atomrdf/structure.py
+++ b/atomrdf/structure.py
@@ -11,6 +11,7 @@
import json
import shutil
import tarfile
+import warnings
import pyscal3.structure_creator as pcs
from pyscal3.grain_boundary import GrainBoundary
@@ -136,6 +137,45 @@ def _read_structure(filename,
basis_box=None,
basis_positions=None,
):
+ """
+ Read in structure from file or ase object
+
+ Parameters
+ ----------
+ filename: string
+ name of file
+
+ format: optional, string
+ format of the file
+
+ graph: optional
+ if provided, the structure will be added to the graph
+
+ names: bool, optional
+ if True, human readable names instead of random ids will be created.
+
+ species: list, optional
+ if provided lammps types will be matched to species. For example, if types 1 and 2 exist
+ in the input file, and species = ['Li', 'Al'] is given, type 1 will be matched to 'Li' and
+ type 2 will be matched to 'Al'
+
+ lattice: str, optional
+ currently supported lattices are {simple_cubic, bcc, fcc, hcp, dhcp, diamond, a15, l12, b2}
+ if provided, information such as the unit cell, basis positions, space groups, etc are automatically added
+
+ lattice_constant: float, optional
+ specify the lattice constant of the system
+
+ basis_box: 3x3 list, optional
+ specify the basis unit cell. Not required if lattice is provided
+
+ basis_positions: nX3 list, optional
+ specify the relative positions of atoms in the unit cell. Not required if lattice is provided
+
+ Returns
+ -------
+ Structure
+ """
datadict = {}
if lattice is not None:
if lattice in structure_dict.keys():
@@ -149,7 +189,7 @@ def _read_structure(filename,
datadict['positions'] = basis_positions
s = System(filename, format=format, species=species,
- graph=graph, names=names)
+ graph=graph, names=names, warn_read_in=False)
s.lattice_properties = datadict
s.to_graph()
return s
@@ -191,8 +231,12 @@ def __init__(self, filename = None,
species = None,
source=None,
graph=None,
- names=False):
+ names=False,
+ warn_read_in=True):
+ if (filename is not None) and warn_read_in:
+ warnings.warn('To provide additional information, use the System.read.file method')
+
super().__init__(filename = filename,
format = format,
compressed = compressed,
diff --git a/examples/07_read_in.ipynb b/examples/07_read_in.ipynb
new file mode 100644
index 0000000..d821208
--- /dev/null
+++ b/examples/07_read_in.ipynb
@@ -0,0 +1,1295 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "d3ff083a-cdf1-468a-9b2b-8279abcd5966",
+ "metadata": {},
+ "source": [
+ "# Reading in structures"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "8bef733f-c0b5-4c92-88fa-6d12114172f9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from atomrdf import System, KnowledgeGraph"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "50c53e9a-1029-49e6-9cb0-2b8171475c6a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "kg = KnowledgeGraph()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "58b32ff8-2255-4969-98a3-1ce683258aa5",
+ "metadata": {},
+ "source": [
+ "Read in a structure file, `System.read.ase` can also be used for ASE objects"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "0beed8c2-ede7-4b7b-b98a-d0d8b236565f",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "struct = System.read.file('conf.dump', graph=kg)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "13b457c1-2051-451d-8d98-6ee436959cf1",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.visualise(hide_types=True, layout='dot')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0b8fdca8-e857-4cb5-97f0-106aeb139a27",
+ "metadata": {},
+ "source": [
+ "Providing extra information"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "5d6c808a-07e7-4eca-8a46-9e2965046269",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "kg = KnowledgeGraph()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "88c44dbf-da7e-411f-9147-6011130825d9",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "\u001b[0;31mSignature:\u001b[0m\n",
+ "\u001b[0mSystem\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mfilename\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'lammps-dump'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mgraph\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mnames\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mspecies\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mlattice\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mlattice_constant\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mbasis_box\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mbasis_positions\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mDocstring:\u001b[0m\n",
+ "Read in structure from file or ase object\n",
+ "\n",
+ "Parameters\n",
+ "----------\n",
+ "filename: string\n",
+ " name of file\n",
+ "\n",
+ "format: optional, string\n",
+ " format of the file\n",
+ "\n",
+ "graph: optional\n",
+ " if provided, the structure will be added to the graph\n",
+ "\n",
+ "names: bool, optional\n",
+ " if True, human readable names instead of random ids will be created.\n",
+ "\n",
+ "species: list, optional\n",
+ " if provided lammps types will be matched to species. For example, if types 1 and 2 exist\n",
+ " in the input file, and species = ['Li', 'Al'] is given, type 1 will be matched to 'Li' and\n",
+ " type 2 will be matched to 'Al'\n",
+ "\n",
+ "lattice: str, optional\n",
+ " currently supported lattices are {simple_cubic, bcc, fcc, hcp, dhcp, diamond, a15, l12, b2}\n",
+ " if provided, information such as the unit cell, basis positions, space groups, etc are automatically added\n",
+ "\n",
+ "lattice_constant: float, optional\n",
+ " specify the lattice constant of the system\n",
+ "\n",
+ "basis_box: 3x3 list, optional\n",
+ " specify the basis unit cell. Not required if lattice is provided\n",
+ "\n",
+ "basis_positions: nX3 list, optional\n",
+ " specify the relative positions of atoms in the unit cell. Not required if lattice is provided\n",
+ "\n",
+ "Returns\n",
+ "-------\n",
+ "Structure\n",
+ "\u001b[0;31mFile:\u001b[0m ~/miniconda3/envs/workflow-rdf-v0.2/lib/python3.11/site-packages/atomrdf/structure.py\n",
+ "\u001b[0;31mType:\u001b[0m function"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "System.read.file?"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "dbd6907a-3180-4cc8-9576-46ce4ca8959b",
+ "metadata": {},
+ "source": [
+ "The file is a bcc structure, with lattice constant of 2.861"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "5b9355f0-7066-4239-8570-7b6dd59cb985",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "struct = System.read.file('conf.dump', graph=kg, lattice='bcc', lattice_constant=2.861)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "8e106f28-2320-4b76-8c30-06c7317e4bcd",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.visualise(hide_types=True, layout='dot')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "96c4a15b-0ee6-422b-8d40-b8900cf9b4d5",
+ "metadata": {},
+ "source": [
+ "Infomation such as space group symbols and numbers, lattice angles, and so on are automatically added"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.8"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/examples/conf.dump b/examples/conf.dump
new file mode 100644
index 0000000..37ab323
--- /dev/null
+++ b/examples/conf.dump
@@ -0,0 +1,11 @@
+ITEM: TIMESTEP
+0
+ITEM: NUMBER OF ATOMS
+2
+ITEM: BOX BOUNDS pp pp pp
+0.0 2.87
+0.0 2.87
+0.0 2.87
+ITEM: ATOMS x y z type id
+0.0 0.0 0.0 1 1
+1.435 1.435 1.435 1 2
diff --git a/setup.py b/setup.py
index 612ef77..26e132e 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@
setup(
name='atomrdf',
- version='0.5.2',
+ version='0.5.3',
author='Abril Azocar Guzman, Sarath Menon',
author_email='sarath.menon@pyscal.org',
description='Ontology based structural manipulation and quering',