pyscal_rdf package#
Submodules#
pyscal_rdf.structure module#
StructureGraph is the central object in pyscal_rdf which combines all the functionality
of pyscal_rdf.graph.RDFGraph
along with easy structural creation routines.
- class pyscal_rdf.structure.StructureGraph(graph_file=None, store='Memory', store_file=None, identifier='http://default_graph')[source]#
Bases:
RDFGraph
- __init__(graph_file=None, store='Memory', store_file=None, identifier='http://default_graph')[source]#
- read_structure(filename, format='lammps-dump', add_to_graph=True, names=True)[source]#
Read an input file and return it as a System object.
- Parameters:
filename (string) – name of the input file
format (string) – format of the input file
add_to_graph (bool, optinal) – If False, the created structure will not be added to the graph
names (bool, optional) – If True, names will be used as IDs
- Returns:
System (pyscal System)
system will be populated with given atoms and simulation box
pyscal_rdf.graph module#
Graph module contains the basic RDFGraph object in pyscal_rdf. This object gets a structure as an input and annotates it with the CMSO ontology (PLDO and PODO too as needed). The annotated object is stored in triplets.
- class pyscal_rdf.graph.RDFGraph(graph_file=None, store='Memory', store_file=None, identifier='http://default_graph', ontology=None)[source]#
Bases:
object
- __init__(graph_file=None, store='Memory', store_file=None, identifier='http://default_graph', ontology=None)[source]#
- add_atoms(name=None)[source]#
Add Atoms including their species and positions
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_chemical_composition(name=None)[source]#
Add chemical composition
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_crystal_structure(name=None)[source]#
Add a CMSO Crystal Structure
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_gb(gb_dict, name=None)[source]#
Add GB details which will be annotated using PLDO
- Parameters:
gb_dict (dict) – dict containing details about the grain boundary
name – if provided, the name will be used instead of random identifier
- add_lattice_properties(name=None)[source]#
Add CMSO lattice properties such as Lattice Parameter, and its lengths and angles.
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_material(name=None)[source]#
Add a CMSO Material object
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_sample(name=None)[source]#
Add a CMSO Sample object
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_simulation_cell(name=None)[source]#
Add a CMSO SimulationCell
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_simulation_cell_properties(name=None)[source]#
Add a CMSO SimulationCell properties such as SimulationCellLength, and Vectors.
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_space_group(name=None)[source]#
Add a CMSO Space Group
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_structure_to_graph(structure, names=True, name_index=None, format=None)[source]#
Add a given
pyscal.core.System
to the Graph object- Parameters:
structure (
pyscal.core.System
) – input structurenames (bool) – if True, alphanumeric names will be used instead of random BNodes
- Return type:
None
- add_unit_cell(name=None)[source]#
Add a CMSO Unit Cell
- Parameters:
name – if provided, the name will be used instead of random identifier
- add_vacancy(concentration, number=None, name=None)[source]#
Add Vacancy details which will be annotated by PODO
- Parameters:
concentration (float) – vacancy concentration, value should be between 0-1
name – if provided, the name will be used instead of random identifier
- create_graph(names=False, name_index='1')[source]#
Create the RDF Graph from the data stored
- Parameters:
names (bool) – if True, alphanumeric names will be used instead of random BNodes
name_index (string) – Prefix to be added to identifiers, default 01
- Return type:
None
- get_sample(sample, no_atoms=False)[source]#
Get the Sample as an RDFGraph
- Parameters:
sample (string) – sample id
no_atoms (bool, optional) – if True, returns the number of atoms in the sample
- Returns:
sgraph – the RDFGraph of the queried sample
- Return type:
- get_system_from_sample(sample)[source]#
Get a pyscal
pyscal.core.System
from the selected sample- Parameters:
sample (string) – sample id
- Returns:
system – corresponding system
- Return type:
pyscal.core.System
- property n_samples#
Number of samples in the Graph
- process_structure(structure, format=None)[source]#
Convert a given
pyscal.core.System
to a data dictionary which can be used for annotation and storing the data in the RDF Graph.- Parameters:
structure (
pyscal.core.System
) – input structure- Return type:
None
- query(inquery)[source]#
Query the graph using SPARQL
- Parameters:
inquery (string) – SPARQL query to be executed
- Returns:
res – pandas dataframe results
- Return type:
pandas DataFrame
- property samples#
Returns a list of all Samples in the graph
- to_file(sample, filename=None, format='lammps-dump')[source]#
Save a given sample to a file
- Parameters:
sample – ID of the sample
filename (string) – name of output file
format (string, {"lammps-dump","lammps-data", "poscar"}) –
- Return type:
None
- visualise(backend='ipycytoscape', edge_color='#37474F', styledict=None, graph_attr={'rankdir': 'BT'}, layoutname='cola')[source]#
Vosualise the RDF tree of the Graph
- Parameters:
backend (string, {'ipycytoscape', 'graphviz'}) – Chooses the backend with which the graph will be plotted. ipycytoscape provides an interactive, but slow visualisation, whereas graphviz provides a non-interactive fast visualisation.
edge_color (string) – Edge color of the boxes
styledict (dict) – If provided, allows customisation of color and other properties.
graph_attr (dict) – further attributes that allow customisation of graphs
layoutname (string) – name of the layout for graph
Notes
styledict has the following options. Refer to graphviz and ipycytoscape documentation for more details BNode:
color: shape: style:
- URIRef:
color: shape: style:
- Literal:
color: shape: style:
- visualize(*args, **kwargs)[source]#
Vosualise the RDF tree of the Graph
- Parameters:
backend (string, {'ipycytoscape', 'graphviz'}) – Chooses the backend with which the graph will be plotted. ipycytoscape provides an interactive, but slow visualisation, whereas graphviz provides a non-interactive fast visualisation.
edge_color (string) – Edge color of the boxes
styledict (dict) – If provided, allows customisation of color and other properties.
graph_attr (dict) – further attributes that allow customisation of graphs
layoutname (string) – name of the layout for graph
Notes
styledict has the following options. Refer to graphviz and ipycytoscape documentation for more details BNode:
color: shape: style:
- URIRef:
color: shape: style:
- Literal:
color: shape: style:
pyscal_rdf.network module#
pyscal_rdf.properties module#
pyscal_rdf.queries module#
pyscal_rdf.rdfutils module#
pyscal_rdf.visualize module#
- pyscal_rdf.visualize.visualize_graph(g, backend='ipycytoscape', edge_color='#37474F', styledict={'BNode': {'color': '#ffe6ff', 'shape': 'box', 'style': 'filled'}, 'Literal': {'color': '#e6ffcc', 'shape': 'ellipse', 'style': 'filled'}, 'URIRef': {'color': '#ffffcc', 'shape': 'box', 'style': 'filled'}}, graph_attr={'rankdir': 'LR'}, layoutname='cola')[source]#